Reset code and vector handling from Linux

上级 7a34e712
......@@ -43,6 +43,8 @@ void initfutex(void);
void initcmdline(void);
void idleloop(void);
#define IO_RTC 0x70
static volatile int bstate;
void
......@@ -59,6 +61,34 @@ mpboot(void)
}
static void
warmreset(u32 addr)
{
volatile u16 *wrv;
// "The BSP must initialize CMOS shutdown code to 0AH
// and the warm reset vector (DWORD based at 40:67) to point at
// the AP startup code prior to the [universal startup algorithm]."
outb(IO_RTC, 0xF); // offset 0xF is shutdown code
outb(IO_RTC+1, 0x0A);
wrv = (u16*)(0x40<<4 | 0x67); // Warm reset vector
wrv[0] = 0;
wrv[1] = addr >> 4;
}
static void
rstrreset(void)
{
volatile u16 *wrv;
// Paranoid: set warm reset code and vector back to defaults
outb(IO_RTC, 0xF);
outb(IO_RTC+1, 0);
wrv = (u16*)(0x40<<4 | 0x67);
wrv[0] = 0;
wrv[1] = 0;
}
static void
bootothers(void)
{
extern u8 _bootother_start[];
......@@ -78,6 +108,8 @@ bootothers(void)
if(c == cpus+myid()) // We've started already.
continue;
warmreset(v2p(code));
// Tell bootother.S what stack to use and the address of apstart;
// it expects to find these two addresses stored just before
// its first instruction.
......@@ -92,6 +124,7 @@ bootothers(void)
// Wait for cpu to finish mpmain()
while(bstate == 0)
;
rstrreset();
}
}
......
......@@ -33,8 +33,6 @@
#define TCCR 0x839 // Timer Current Count
#define TDCR 0x83e // Timer Divide Configuration
#define IO_RTC 0x70
static u64 x2apichz;
static int
......@@ -65,16 +63,6 @@ void
x2apicstartap(hwid_t id, u32 addr)
{
int i;
volatile u16 *wrv;
// "The BSP must initialize CMOS shutdown code to 0AH
// and the warm reset vector (DWORD based at 40:67) to point at
// the AP startup code prior to the [universal startup algorithm]."
outb(IO_RTC, 0xF); // offset 0xF is shutdown code
outb(IO_RTC+1, 0x0A);
wrv = (u16*)(0x40<<4 | 0x67); // Warm reset vector
wrv[0] = 0;
wrv[1] = addr >> 4;
// Be paranoid about clearing APIC errors
writemsr(ESR, 0);
......
......@@ -187,16 +187,6 @@ void
xapicstartap(hwid hwid, u32 addr)
{
int i;
volatile u16 *wrv;
// "The BSP must initialize CMOS shutdown code to 0AH
// and the warm reset vector (DWORD based at 40:67) to point at
// the AP startup code prior to the [universal startup algorithm]."
outb(IO_RTC, 0xF); // offset 0xF is shutdown code
outb(IO_RTC+1, 0x0A);
wrv = (u16*)(0x40<<4 | 0x67); // Warm reset vector
wrv[0] = 0;
wrv[1] = addr >> 4;
// "Universal startup algorithm."
// Send INIT (level-triggered) interrupt to reset other CPU.
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论