Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
b5dcebdb
Commit
b5dcebdb
authored
17 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
better lapic writes, suggested by cliff
parent
47212719
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
lapic.c
+26
-19
26 additions, 19 deletions
lapic.c
with
26 additions
and
19 deletions
lapic.c
+
26
−
19
View file @
b5dcebdb
...
...
@@ -37,6 +37,13 @@
volatile
uint
*
lapic
;
// Initialized in mp.c
static
void
lapicw
(
int
index
,
int
value
)
{
lapic
[
index
]
=
value
;
lapic
[
ID
];
// wait for write to finish, by reading
}
//PAGEBREAK!
void
lapic_init
(
int
c
)
...
...
@@ -45,43 +52,43 @@ lapic_init(int c)
return
;
// Enable local APIC; set spurious interrupt vector.
lapic
[
SVR
]
=
ENABLE
|
(
IRQ_OFFSET
+
IRQ_SPURIOUS
);
lapic
w
(
SVR
,
ENABLE
|
(
IRQ_OFFSET
+
IRQ_SPURIOUS
)
)
;
// The timer repeatedly counts down at bus frequency
// from lapic[TICR] and then issues an interrupt.
// If xv6 cared more about precise timekeeping,
// TICR would be calibrated using an external time source.
lapic
[
TDCR
]
=
X1
;
lapic
[
TIMER
]
=
PERIODIC
|
(
IRQ_OFFSET
+
IRQ_TIMER
);
lapic
[
TICR
]
=
10000000
;
lapic
w
(
TDCR
,
X1
)
;
lapic
w
(
TIMER
,
PERIODIC
|
(
IRQ_OFFSET
+
IRQ_TIMER
)
)
;
lapic
w
(
TICR
,
10000000
)
;
// Disable logical interrupt lines.
lapic
[
LINT0
]
=
MASKED
;
lapic
[
LINT1
]
=
MASKED
;
lapic
w
(
LINT0
,
MASKED
)
;
lapic
w
(
LINT1
,
MASKED
)
;
// Disable performance counter overflow interrupts
// on machines that provide that interrupt entry.
if
(((
lapic
[
VER
]
>>
16
)
&
0xFF
)
>=
4
)
lapic
[
PCINT
]
=
MASKED
;
lapic
w
(
PCINT
,
MASKED
)
;
// Map error interrupt to IRQ_ERROR.
lapic
[
ERROR
]
=
IRQ_OFFSET
+
IRQ_ERROR
;
lapic
w
(
ERROR
,
IRQ_OFFSET
+
IRQ_ERROR
)
;
// Clear error status register (requires back-to-back writes).
lapic
[
ESR
]
=
0
;
lapic
[
ESR
]
=
0
;
lapic
w
(
ESR
,
0
)
;
lapic
w
(
ESR
,
0
)
;
// Ack any outstanding interrupts.
lapic
[
EOI
]
=
0
;
lapic
w
(
EOI
,
0
)
;
// Send an Init Level De-Assert to synchronise arbitration ID's.
lapic
[
ICRHI
]
=
0
;
lapic
[
ICRLO
]
=
BCAST
|
INIT
|
LEVEL
;
lapic
w
(
ICRHI
,
0
)
;
lapic
w
(
ICRLO
,
BCAST
|
INIT
|
LEVEL
)
;
while
(
lapic
[
ICRLO
]
&
DELIVS
)
;
// Enable interrupts on the APIC (but not on the processor).
lapic
[
TPR
]
=
0
;
lapic
w
(
TPR
,
0
)
;
}
int
...
...
@@ -116,7 +123,7 @@ void
lapic_eoi
(
void
)
{
if
(
lapic
)
lapic
[
EOI
]
=
0
;
lapic
w
(
EOI
,
0
)
;
}
// Spin for a given number of microseconds.
...
...
@@ -139,16 +146,16 @@ lapic_startap(uchar apicid, uint addr)
volatile
int
j
=
0
;
// Send INIT interrupt to reset other CPU.
lapic
[
ICRHI
]
=
apicid
<<
24
;
lapic
[
ICRLO
]
=
INIT
|
LEVEL
;
lapic
w
(
ICRHI
,
apicid
<<
24
)
;
lapic
w
(
ICRLO
,
INIT
|
LEVEL
)
;
microdelay
(
10
);
// Send startup IPI (twice!) to enter bootstrap code.
// Regular hardware wants it twice, but Bochs complains.
// Too bad for Bochs.
for
(
i
=
0
;
i
<
2
;
i
++
){
lapic
[
ICRHI
]
=
apicid
<<
24
;
lapic
[
ICRLO
]
=
STARTUP
|
(
addr
>>
12
);
lapic
w
(
ICRHI
,
apicid
<<
24
)
;
lapic
w
(
ICRLO
,
STARTUP
|
(
addr
>>
12
)
)
;
for
(
j
=
0
;
j
<
10000
;
j
++
);
// 200us
}
}
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