]> Joshua Wise's Git repositories - netwatch.git/commitdiff
Working serial output in pagingland. Continues to run, too.
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Fri, 7 Nov 2008 20:54:37 +0000 (15:54 -0500)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Fri, 7 Nov 2008 20:54:37 +0000 (15:54 -0500)
aseg-paging/pagingstub.c
aseg-paging/smi.c
aseg-paging/vga-overlay.c
lib/serial.c

index 849c6dc3a01eb1d4c89de7ef6ec301a747162b3e..0a79385a31c0cdeaf1377752bae8b170956f441d 100644 (file)
@@ -105,28 +105,31 @@ void c_entry(void)
        unsigned char *bp;
 
        outb(0x80, 0x41);
-       char * pagedir = pt_setup(0xA0000, 0x1FF80000, 0x80000);
-       outb(0x80, 0x43);
-       set_cr3((int)pagedir);
-       outb(0x80, 0xA5);
-
-       /* Turn paging on */
+       if (!entry_initialized)
+               pt_setup(0xA0000, 0x1FF80000, 0x80000);
+               
+       /* Enable paging. */
+       outb(0x80, 0x42);
+       set_cr3(0x1FF80000);
        set_cr0(get_cr0() | CR0_PG);
-       serial_init();
-       serial_tx('A');
-       outb(0x80, 0xAA);
-
        
+       outb(0x80, 0x43);
        if (!entry_initialized) {
-               serial_tx('B');
-               outb(0x80, 0xAB);
+               extern void __firstrun_start();
+               
+               /* If needed, copy in data. */
                for (bp = (void *)0x200000; (void *)bp < (void *)&_bss; bp++)
                        *bp = *(bp + 0x100000);
                for (bp = (void *)&_bss; (void *)bp < (void *)&_bssend; bp++)
                        *bp = 0;
+               serial_init();
+               dolog("Paging enabled.");
+               __firstrun_start();     /* Now initialize BSS, etc. */
+               
+               entry_initialized = 1;
        }
 
-       outb(0x80, 0xAC);
-       ps_switch_stack(smi_entry, 0x2FF000);
+       outb(0x80, 0x44);
+       ps_switch_stack(smi_entry, 0x270000);
        outb(0x80, 0xFA);
 }
index 33536ebb1be5e48fb1d5668b2dc021fb3db8cff7..9bc124eba642396ba246ec8c3dcd063917e9cce1 100644 (file)
@@ -4,6 +4,7 @@
 #include <minilib.h>
 #include <smi.h>
 #include <pci-bother.h>
+#include <serial.h>
 #include "../net/net.h"
 #include "vga-overlay.h"
 
@@ -49,6 +50,9 @@ void smi_entry(void)
        strblit(statstr, 0, 0);
        outb(0x80, 0x4B);
        
+       serial_init();
+       dolog("wee!");
+       
        /*
        eth_poll();
        */
@@ -62,9 +66,9 @@ void smi_entry(void)
                outl(0x840, 0x0100);
        }
 
-/*
+
        smi_poll();
-       
+/*     
        pci_bother_all();
  */
        outl(0xCF8, pcisave);
@@ -85,6 +89,10 @@ void timer_handler(smi_event_t ev)
 
 
 void __firstrun_start() {
+       smram_state_t smram;
+       
+       smram = smram_save_state();
+       smram_tseg_set_state(SMRAM_TSEG_OPEN);
        smi_disable();
        outb(0x80, 0x41);
 
index df446bcd47eb2662cef5d4b689959075a1666c3e..2fe4dc6ed6663474466a0ae31af0131b8ab7269e 100644 (file)
@@ -89,6 +89,8 @@ void dolog(const char *s)
        prodptr = (prodptr + 1) % LOGLEN;
        while (*s)
                serial_tx(*(s++));
+       serial_tx('\r');
+       serial_tx('\n');
        if (flush_imm)
                outlog();
 }
@@ -96,6 +98,20 @@ void (*output)(const char *s) = dolog;
 
 void dologf(const char *fmt, ...)
 {
+       char *s;
+       va_list va;
+       
+       va_start(va, fmt);
+       vsnprintf(logents[prodptr], 40, fmt, va);
+       s = logents[prodptr];
+       while (*s)
+               serial_tx(*(s++));
+       serial_tx('\r');
+       serial_tx('\n');
+       va_end(va);
+       prodptr = (prodptr + 1) % LOGLEN;
+       if (flush_imm)
+               outlog();
 }
 void (*outputf)(const char *s, ...) = dologf;
 
index 0cbb495b2a0a2ea00d0a1259e6d134329f53c1a2..6043db247d3db6ad8b8c83be942bd8c415f978f4 100644 (file)
@@ -44,7 +44,9 @@ void serial_init()
 
 void serial_tx(unsigned char c)
 {
-       while (!(_inb(SER_LSR) & SER_LSR_THR_EMPTY))
+       int i = 100000;
+       
+       while (!(_inb(SER_LSR) & SER_LSR_THR_EMPTY) && (i--))
                ;
        _outb(SER_THR, c);
 }
This page took 0.038017 seconds and 4 git commands to generate.