9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] loading plan 9 directly from linuxbios
@ 2003-10-29  6:42 ron minnich
  2003-10-29  8:08 ` Charles Forsyth
  0 siblings, 1 reply; 11+ messages in thread
From: ron minnich @ 2003-10-29  6:42 UTC (permalink / raw)
  To: 9fans


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



^ permalink raw reply	[flat|nested] 11+ messages in thread
* RE: [9fans] loading plan 9 directly from linuxbios
@ 2003-10-29  7:42 Tiit Lankots
  2003-10-29 16:12 ` ron minnich
  0 siblings, 1 reply; 11+ messages in thread
From: Tiit Lankots @ 2003-10-29  7:42 UTC (permalink / raw)
  To: 9fans

>stage. here is my (doubtless incorrect) code. Can somebody 
>remind me what 
>the MSW is.

MSW is the low 16 bits of CR0. Writing 1 into it sets the PE bit
(i.e. switches to protected mode).

Tiit


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-10-29 23:17 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-29  6:42 [9fans] loading plan 9 directly from linuxbios ron minnich
2003-10-29  8:08 ` Charles Forsyth
2003-10-29  9:37   ` C H Forsyth
2003-10-29 16:16   ` ron minnich
2003-10-29 16:39     ` David Presotto
2003-10-29 16:46       ` ron minnich
2003-10-29 16:54         ` ron minnich
2003-10-29 20:58     ` C H Forsyth
2003-10-29 23:17       ` ron minnich
2003-10-29  7:42 Tiit Lankots
2003-10-29 16:12 ` ron minnich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).