9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: ron minnich <rminnich@lanl.gov>
To: 9fans@cse.psu.edu
Subject: [9fans] loading plan 9 directly from linuxbios
Date: Tue, 28 Oct 2003 23:42:52 -0700	[thread overview]
Message-ID: <Pine.LNX.4.44.0310282334450.23763-100000@maxroach.lanl.gov> (raw)


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



             reply	other threads:[~2003-10-29  6:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-29  6:42 ron minnich [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44.0310282334450.23763-100000@maxroach.lanl.gov \
    --to=rminnich@lanl.gov \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).