From mboxrd@z Thu Jan 1 00:00:00 1970 From: ron minnich To: 9fans@cse.psu.edu Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: [9fans] loading plan 9 directly from linuxbios Date: Tue, 28 Oct 2003 23:42:52 -0700 Topicbox-Message-UUID: 7a71f0f8-eacc-11e9-9e20-41e7f4b1d025 I'm working to get plan 9 to load directly from linuxbios. The first problem I've hit is that Plan 9 assumes that the gdt table is set up by 9load in a friendly fashion. Because linuxbios has to accomodate so many different OSes with directly conflicting GDT setups, it's not really practical to try to make linuxbios have a plan 9 friendly gdt. I'd like to have plan 9 just set up its own gdt correctly. I'm trying to get this to work but am still at the 'system wedges up' stage. here is my (doubtless incorrect) code. Can somebody remind me what the MSW is. Also what is a reasonable way to do this: $PADDR($tgdtptr(SB)) or is that impossible? TEXT _start0x00100020(SB),$0 CLI /* make sure interrupts are off */ /* for linuxbios. */ /* now set up the gdt so we have sane plan 9 style gdts. */ MOVL $tgdtptr(SB), AX ANDL $~KZERO, AX MOVL (AX), GDTR /* MOVL $tgdtptr(SB),GDTR /**/ MOVW $1, AX MOVW AX,MSW /* * clear prefetch queue (weird code to avoid optimizations) */ DELAY /* * set all segs */ MOVW $(1<<3),AX /**/ MOVW AX,DS MOVW AX,SS MOVW AX,ES MOVW AX,FS MOVW AX,GS /* JMP $(2<<3):$mode32bit(SB) /**/ BYTE $0xEA LONG $mode32bit-KZERO(SB) WORD $(2<<3) TEXT mode32bit(SB),$0 /* end linuxbios stuff */ MOVL $PADDR(CPU0PDB), DI /* clear 4 pages for the tables etc. */ XORL AX, AX MOVL $(4*BY2PG), CX SHRL $2, CX etc. etc. The GDT is this: /* for linuxbios mods. * /* * gdt to get us to 32-bit/segmented/unpaged mode */ TEXT tgdt(SB),$0 /* null descriptor */ LONG $0 LONG $0 /* data segment descriptor for 4 gigabytes (PL 0) */ LONG $(0xFFFF) LONG $(SEGG|SEGB|(0xF<<16)|SEGP|SEGPL(0)|SEGDATA|SEGW) /* exec segment descriptor for 4 gigabytes (PL 0) */ LONG $(0xFFFF) LONG $(SEGG|SEGD|(0xF<<16)|SEGP|SEGPL(0)|SEGEXEC|SEGR) /* * pointer to initial gdt */ TEXT tgdtptr(SB),$0 WORD $(3*8) LONG $tgdt-KZERO(SB) I suspect the tgdtptr is bogus ... probably an 0x8000xxxx address. Any hints welcome. ron