]> Joshua Wise's Git repositories - netwatch.git/commitdiff
cleanup; add -Wkesden
authorJacob Potter <jdpotter@andrew.cmu.edu>
Fri, 19 Sep 2008 19:44:09 +0000 (15:44 -0400)
committerJacob Potter <jdpotter@andrew.cmu.edu>
Fri, 19 Sep 2008 19:44:09 +0000 (15:44 -0400)
aseg/Makefile
aseg/counter.c
aseg/firstrun.c
ich2/smram-ich2.c
include/minilib.h
include/raw/io.h
include/video_defines.h
lib/console.c
lib/minilib.c

index 5033a5545116a52d5e49cb04dce7f3e5ec07d1e0..1c2867d43c67275c20e3d73fcf76e41f145f29a8 100644 (file)
@@ -1,6 +1,6 @@
 CC=gcc
-CFLAGS=-I../include -I../include/raw -nostdlib -nostdinc -fno-builtin -D__RAW__
-OBJS=counter.o firstrun.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o
+CFLAGS=-I../include -I../include/raw -nostdlib -nostdinc -fno-builtin -D__RAW__ -Wall -Werror -pedantic -ansi -std=gnu99
+OBJS=counter.o firstrun.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o ../ich2/smram-ich2.o
 
 all: aseg.elf
 
index e4b5eae7279b67292ffa6e2f4dd0cf7379007411..ccfff7254d9b355430ec336b8c1e2e13364d64e7 100644 (file)
@@ -1,51 +1,72 @@
 #include <io.h>
+#include <smram.h>
+#include <video_defines.h>
+#include <minilib.h>
 
 unsigned int counter = 0;
 unsigned long pcisave;
 unsigned char vgasave;
-unsigned char thestr[512];
-unsigned char logents[4][41] = {0};
+char thestr[512];
+char logents[4][41] = {{0}};
 
-unsigned char vgaread(unsigned char idx)
+#define VRAM_BASE              0xA0000UL
+#define TEXT_CONSOLE_OFFSET    0x18000UL 
+
+#define TEXT_CONSOLE_BASE      (VRAM_BASE + TEXT_CONSOLE_OFFSET)
+
+#define COLOR                  0x1F
+
+unsigned char vga_read(unsigned char idx)
+{
+       outb(CRTC_IDX_REG, idx);
+       return inb(CRTC_DATA_REG);
+}
+
+char * vga_base()
 {
-       outb(0x3D4, idx);
-       inb(0x3D5);
+       return (char *) (
+               TEXT_CONSOLE_BASE
+               | (((unsigned int) vga_read(CRTC_START_ADDR_LSB_IDX)) << 9)
+               | (((unsigned int) vga_read(CRTC_START_ADDR_MSB_IDX)) << 1)
+       );
 }
 
-void strblit(char *src, int r, int c)
+void strblit(char *src, int row, int col)
 {
-       char *destp = (char*)(0xB8000UL | (((unsigned int)vgaread(0xC)) << 9) | (((unsigned int)vgaread(0xD)) << 1)) + r*80*2 + c*2;
-       unsigned char smramc;
+       char *destp = vga_base() + row * 80 * 2 + col * 2;
+       smram_state_t old_state = smram_save_state();
+
+       smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
        
-       smramc = pci_read8(0, 0, 0, 0x70);
-       pci_write8(0, 0, 0, 0x70, (smramc & 0xF3) | 0x08);
        while (*src)
        {
                *(destp++) = *(src++);
-               *(destp++) = 0x1F;
+               *(destp++) = COLOR;
        }
-       pci_write8(0, 0, 0, 0x70, smramc);
+
+       smram_restore_state(old_state);
 }
 
 void outlog()
 {
        int y, x;
-       unsigned char smramc;
-       unsigned char *basep = (char*)(0xB8000UL | (((unsigned int)vgaread(0xC)) << 9) | (((unsigned int)vgaread(0xD)) << 1));
-       
-       smramc = pci_read8(0, 0, 0, 0x70);
-       pci_write8(0, 0, 0, 0x70, (smramc & 0xF3) | 0x08);
+       char *basep = vga_base();
+
+       smram_state_t old_state = smram_save_state();
+
+       smram_aseg_set_state(SMRAM_ASEG_SMMCODE);
+
        for (y = 0; y < 4; y++)
                for (x = 40; x < 80; x++)
                {
                        basep[y*80*2+x*2] = ' ';
                        basep[y*80*2+x*2+1] = 0x1F;
                }
-       pci_write8(0, 0, 0, 0x70, smramc);
-       
+
+       smram_restore_state(old_state);
+
        for (y = 0; y < 4; y++)
                strblit(logents[y], y, 40);
-       
 }
 
 void dolog(char *s)
@@ -55,7 +76,7 @@ void dolog(char *s)
 }
 
 void pci_dump() {
-       unsigned char s[40];
+       char s[40];
        unsigned long cts;
        static int curdev = 0;  /* 0 if kbd, 1 if mouse */
                
@@ -99,7 +120,6 @@ void pci_dump() {
 
 void __start (void)
 {
-       unsigned char smramc;
        static int first = 1;
        
        pcisave = inl(0xCF8);
@@ -141,7 +161,7 @@ void __start (void)
        }
        if (inl(0x834) & ~(0x4160))
        {
-               unsigned char s[40];
+               char s[40];
                strcpy(s, "Unknown: xxxxxxxx");
                tohex(s + 9, inl(0x834) & ~(0x140));
                dolog(s);
index ace70c6c0703488adcd3fd632bf7efd0660f28d7..355fb9a8acc67867e5b8effe3c1da19e6b2f2ad9 100644 (file)
@@ -1,4 +1,5 @@
 #include <io.h>
+#include <pci.h>
 
 void __firstrun_start() {
 /*
index 36a191bd28a9a0a8542615222e7188c105326cdf..d274c852028c497e932e91d4aa2df572bcbae605 100644 (file)
@@ -94,7 +94,7 @@ smram_state_t smram_save_state()
 
 void smram_restore_state(smram_state_t state)
 {
-       return pci_write8(0, 0, 0, SMRAMC, state); 
+       pci_write8(0, 0, 0, SMRAMC, state); 
 }
 
 int smram_aseg_set_state (int open) {
index e0fc16bfd21ab6588f964d394d198fedb225a27e..747b2aa71dc4a4d5db7f608e4e6d6b3a656f418d 100644 (file)
@@ -1,33 +1,9 @@
-#ifndef __MINILIB_H
-#define __MINILIB_H
+#ifndef MINILIB_H
+#define MINILIB_H
 
-#define MINILIB 1
-
-#ifndef __int8_t_defined
-# define __int8_t_defined
-typedef signed char             int8_t;
-typedef short int               int16_t;
-typedef int                     int32_t;
-# if __WORDSIZE == 64
-typedef long int                int64_t;
-# else
-__extension__
-typedef long long int           int64_t;
-# endif
-#endif
-
-/* Unsigned.  */
-typedef unsigned char           uint8_t;
-typedef unsigned short int      uint16_t;
-#ifndef __uint32_t_defined
-typedef unsigned int            uint32_t;
-# define __uint32_t_defined
-#endif
-#if __WORDSIZE == 64
-typedef unsigned long int       uint64_t;
-#else
-__extension__
-typedef unsigned long long int  uint64_t;
-#endif
+void memmove(void *dest, void *src, int bytes);
+int strcmp(const char *a2, const char *a1);
+void strcpy(char *a2, const char *a1);
+void tohex(char *s, unsigned long l);
 
 #endif
index 5fd0b19e62f4a7c0094229797e0199069a041726..f04f44cde7caa64f83c56e3ad8fa471b9780ee99 100644 (file)
@@ -1,11 +1,11 @@
 #ifndef __IO_H
 #define __IO_H
 
-#define inb(port) ({ unsigned char val; asm volatile("inb %%dx, %0" : "=a" ((unsigned char)(val)) : "d" ((unsigned short)(port))); val; })
-#define inw(port) ({ unsigned short val; asm volatile("inw %%dx, %0" : "=a" ((unsigned short)(val)) : "d" ((unsigned short)(port))); val; })
-#define inl(port) ({ unsigned long val; asm volatile("inl %%dx, %0" : "=a" ((unsigned long)(val)) : "d" ((unsigned short)(port))); val; })
-#define outb(port, val) ({ asm volatile("outb %0, %%dx" : : "a" ((unsigned char)(val)) , "d" ((unsigned short)(port))); })
-#define outw(port, val) ({ asm volatile("outw %0, %%dx" : : "a" ((unsigned short)(val)) , "d" ((unsigned short)(port))); })
-#define outl(port, val) ({ asm volatile("outl %0, %%dx" : : "a" ((unsigned long)(val)) , "d" ((unsigned short)(port))); })
+#define inb(port) __extension__ ({ unsigned char val; asm volatile("inb %%dx, %0" : "=a" ((unsigned char)(val)) : "d" ((unsigned short)(port))); val; })
+#define inw(port) __extension__ ({ unsigned short val; asm volatile("inw %%dx, %0" : "=a" ((unsigned short)(val)) : "d" ((unsigned short)(port))); val; })
+#define inl(port) __extension__ ({ unsigned long val; asm volatile("inl %%dx, %0" : "=a" ((unsigned long)(val)) : "d" ((unsigned short)(port))); val; })
+#define outb(port, val) __extension__ ({ asm volatile("outb %0, %%dx" : : "a" ((unsigned char)(val)) , "d" ((unsigned short)(port))); })
+#define outw(port, val) __extension__ ({ asm volatile("outw %0, %%dx" : : "a" ((unsigned short)(val)) , "d" ((unsigned short)(port))); })
+#define outl(port, val) __extension__ ({ asm volatile("outl %0, %%dx" : : "a" ((unsigned long)(val)) , "d" ((unsigned short)(port))); })
 
 #endif
index ca202ef276f5d671e5110d35fbbc28ac7064a582..8c3b9feaa9675d5f6af3cc93e8b053aeb85756bf 100644 (file)
 #define BLINK      0x80 /* Annoying. */
 
 /* --- CRTC Register Manipulation --- */
+
 #define CRTC_IDX_REG 0x3d4
 #define CRTC_DATA_REG 0x3d5
-#define CRTC_CURSOR_LSB_IDX 15
-#define CRTC_CURSOR_MSB_IDX 14
+
+#define CRTC_START_ADDR_MSB_IDX        0xC
+#define CRTC_START_ADDR_LSB_IDX        0xD
+#define CRTC_CURSOR_MSB_IDX    0xE
+#define CRTC_CURSOR_LSB_IDX    0xF
 
 #endif
index 27880baabbafce3a3d0edb1bcee9d8e6a6c98c2a..66cfbaffcb47b57f29e09263ba9b34ffce45a2ae 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <console.h>
 #include "console-ext.h"
+#include <minilib.h>
 #include <io.h>
 
 #define POS_IS_VALID(row, col) ((row) >= 0 && (row) < CONSOLE_HEIGHT && (col) >= 0 && (col) < CONSOLE_WIDTH)
index f64f3b1d7bf96469a533af0b3bf8198d2a969ea0..232878b8478743c4a70d6574ef2785768d9e01e7 100644 (file)
@@ -1,26 +1,31 @@
 #include "console.h"
+#include <minilib.h>
 
-void memcpy(unsigned char *a2, unsigned char *a1, int bytes)
+void memcpy(void *dest, void *src, int bytes)
 {
+       char * cdest = dest;
+       char * csrc = src;
        while (bytes--)
-               *(a2++) = *(a1++);
+               *(cdest++) = *(csrc++);
 }
 
-void memmove(unsigned char *dest, unsigned char *src, int bytes)
+void memmove(void *dest, void *src, int bytes)
 {
-       if ((dest > src) && (dest <= (src + bytes)))
+       char * cdest = dest;
+       char * csrc = src;
+       if ((cdest > csrc) && (cdest <= (csrc + bytes)))
        {
                /* do it backwards! */
-               dest += bytes;
-               src += bytes;
+               cdest += bytes;
+               csrc += bytes;
                while (bytes--)
-                       *(--dest) = *(--src);
+                       *(--cdest) = *(--csrc);
        } else
                while (bytes--)
-                       *(dest++) = *(src++);
+                       *(cdest++) = *(csrc++);
 }
 
-int memcmp (unsigned char *a2, unsigned char *a1, int bytes) {
+int memcmp (const char *a2, const char *a1, int bytes) {
        while (bytes--)
        {
                if (*(a2++) != *(a1++))
@@ -29,7 +34,7 @@ int memcmp (unsigned char *a2, unsigned char *a1, int bytes) {
        return 0;
 }
 
-int strcmp (unsigned char *a2, unsigned char *a1) {
+int strcmp (const char *a2, const char *a1) {
        while (1) {
                if (*a2 != *a1) return 1;
                if (*a2 == 0) return 0;
@@ -46,7 +51,7 @@ int strlen(char *c)
        return l;
 }
 
-void strcpy(unsigned char *a2, unsigned char *a1)
+void strcpy(char *a2, const char *a1)
 {
        do {
                *(a2++) = *a1;
@@ -59,7 +64,7 @@ void puts(char *c)
 }
 
 static char hexarr[] = "0123456789ABCDEF";
-void tohex(unsigned char *s, unsigned long l)
+void tohex(char *s, unsigned long l)
 {
        int i;
        for (i = 0; i < 8; i++)
@@ -71,7 +76,7 @@ void tohex(unsigned char *s, unsigned long l)
 
 void puthex(unsigned long l)
 {
-       unsigned char d[9];
+       char d[9];
        d[8] = 0;
        tohex(d, l);
        puts(d);
This page took 0.040135 seconds and 4 git commands to generate.