Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
68ae4cc1
Commit
68ae4cc1
authored
17 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
comment what +m means; omit needless __
parent
2aae7205
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
x86.h
+27
-25
27 additions, 25 deletions
x86.h
with
27 additions
and
25 deletions
x86.h
+
27
−
25
View file @
68ae4cc1
// Special assembly routines to access x86-specific
// hardware instructions.
static
__
inline
uchar
static
inline
uchar
inb
(
ushort
port
)
{
uchar
data
;
__
asm
__
volatile
(
"in %1,%0"
:
"=a"
(
data
)
:
"d"
(
port
));
asm
volatile
(
"in %1,%0"
:
"=a"
(
data
)
:
"d"
(
port
));
return
data
;
}
static
__
inline
void
static
inline
void
insl
(
int
port
,
void
*
addr
,
int
cnt
)
{
__
asm
__
volatile
(
"cld
\n\t
repne
\n\t
insl"
:
asm
volatile
(
"cld
\n\t
repne
\n\t
insl"
:
"=D"
(
addr
),
"=c"
(
cnt
)
:
"d"
(
port
),
"0"
(
addr
),
"1"
(
cnt
)
:
"memory"
,
"cc"
);
}
static
__
inline
void
static
inline
void
outb
(
ushort
port
,
uchar
data
)
{
__
asm
__
volatile
(
"out %0,%1"
:
:
"a"
(
data
),
"d"
(
port
));
asm
volatile
(
"out %0,%1"
:
:
"a"
(
data
),
"d"
(
port
));
}
static
__
inline
void
static
inline
void
outw
(
ushort
port
,
ushort
data
)
{
__
asm
__
volatile
(
"out %0,%1"
:
:
"a"
(
data
),
"d"
(
port
));
asm
volatile
(
"out %0,%1"
:
:
"a"
(
data
),
"d"
(
port
));
}
static
__
inline
void
static
inline
void
outsl
(
int
port
,
const
void
*
addr
,
int
cnt
)
{
__
asm
__
volatile
(
"cld
\n\t
repne
\n\t
outsl"
:
asm
volatile
(
"cld
\n\t
repne
\n\t
outsl"
:
"=S"
(
addr
),
"=c"
(
cnt
)
:
"d"
(
port
),
"0"
(
addr
),
"1"
(
cnt
)
:
"cc"
);
...
...
@@ -41,7 +41,7 @@ outsl(int port, const void *addr, int cnt)
struct
segdesc
;
static
__
inline
void
static
inline
void
lgdt
(
struct
segdesc
*
p
,
int
size
)
{
volatile
ushort
pd
[
3
];
...
...
@@ -55,7 +55,7 @@ lgdt(struct segdesc *p, int size)
struct
gatedesc
;
static
__
inline
void
static
inline
void
lidt
(
struct
gatedesc
*
p
,
int
size
)
{
volatile
ushort
pd
[
3
];
...
...
@@ -67,27 +67,27 @@ lidt(struct gatedesc *p, int size)
asm
volatile
(
"lidt (%0)"
:
:
"r"
(
pd
));
}
static
__
inline
void
static
inline
void
ltr
(
ushort
sel
)
{
__
asm
__
volatile
(
"ltr %0"
:
:
"r"
(
sel
));
asm
volatile
(
"ltr %0"
:
:
"r"
(
sel
));
}
static
__
inline
uint
static
inline
uint
read_eflags
(
void
)
{
uint
eflags
;
__
asm
__
volatile
(
"pushfl; popl %0"
:
"=r"
(
eflags
));
asm
volatile
(
"pushfl; popl %0"
:
"=r"
(
eflags
));
return
eflags
;
}
static
__
inline
void
static
inline
void
write_eflags
(
uint
eflags
)
{
__
asm
__
volatile
(
"pushl %0; popfl"
:
:
"r"
(
eflags
));
asm
volatile
(
"pushl %0; popfl"
:
:
"r"
(
eflags
));
}
static
__
inline
void
static
inline
void
cpuid
(
uint
info
,
uint
*
eaxp
,
uint
*
ebxp
,
uint
*
ecxp
,
uint
*
edxp
)
{
uint
eax
,
ebx
,
ecx
,
edx
;
...
...
@@ -104,27 +104,29 @@ cpuid(uint info, uint *eaxp, uint *ebxp, uint *ecxp, uint *edxp)
*
edxp
=
edx
;
}
static
__
inline
uint
static
inline
uint
cmpxchg
(
uint
oldval
,
uint
newval
,
volatile
uint
*
lock_addr
)
{
uint
result
;
__asm__
__volatile__
(
"lock; cmpxchgl %2, %0"
:
// The + in "+m" denotes a read-modify-write operand.
asm
volatile
(
"lock; cmpxchgl %2, %0"
:
"+m"
(
*
lock_addr
),
"=a"
(
result
)
:
"r"
(
newval
),
"1"
(
oldval
)
:
"cc"
);
return
result
;
}
static
__
inline
void
static
inline
void
cli
(
void
)
{
__
asm
__
volatile
(
"cli"
);
asm
volatile
(
"cli"
);
}
static
__
inline
void
static
inline
void
sti
(
void
)
{
__
asm
__
volatile
(
"sti"
);
asm
volatile
(
"sti"
);
}
// Layout of the trap frame on the stack upon entry to trap.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment