From: Jacob Potter Date: Fri, 12 Sep 2008 21:22:56 +0000 (-0400) Subject: cleanup X-Git-Url: http://git.joshuawise.com/netwatch.git/commitdiff_plain/7e16b8e6b3c3aab2c91d9b54c8953201e111be50?ds=sidebyside;hp=-c cleanup --- 7e16b8e6b3c3aab2c91d9b54c8953201e111be50 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..64c574e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.bin +*.elf diff --git a/aseg/Makefile b/aseg/Makefile index 28a09de..079c3a5 100644 --- a/aseg/Makefile +++ b/aseg/Makefile @@ -1,6 +1,6 @@ CC=gcc CFLAGS=-I../include -nostdlib -nostdinc -fno-builtin -OBJS=counter.o ../pci/pci-smm.o ../lib/minilib.o ../lib/console.o +OBJS=counter.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o all: aseg.elf @@ -12,3 +12,6 @@ aseg.o: aseg.bin aseg.elf: aseg.lds aseg.o $(OBJS) ld -o aseg.elf -T aseg.lds $(OBJS) + +clean: + rm -f $(OBJS) aseg.elf aseg.bin aseg.o diff --git a/aseg/counter.c b/aseg/counter.c index 7fe4cef..2c82f08 100644 --- a/aseg/counter.c +++ b/aseg/counter.c @@ -1,5 +1,4 @@ #include -#include unsigned int counter = 0; unsigned long pcisave; diff --git a/elfload/.gitignore b/elfload/.gitignore new file mode 100644 index 0000000..955951e --- /dev/null +++ b/elfload/.gitignore @@ -0,0 +1 @@ +loader diff --git a/grubload/.gitignore b/grubload/.gitignore new file mode 100644 index 0000000..0647739 --- /dev/null +++ b/grubload/.gitignore @@ -0,0 +1 @@ +multiboot diff --git a/grubload/Makefile b/grubload/Makefile index 3cd15a7..e9fa1df 100644 --- a/grubload/Makefile +++ b/grubload/Makefile @@ -1,4 +1,4 @@ -OBJS=multiboot_c.o multiboot_asm.o realmode.o loader.o ../pci/pci-smm.o ../lib/minilib.o ../lib/console.o +OBJS=multiboot_c.o multiboot_asm.o realmode.o loader.o ../pci/pci-raw.o ../lib/minilib.o ../lib/console.o CC=gcc CFLAGS=-nostdlib -I../include -I. -fno-builtin -nostdinc @@ -12,3 +12,6 @@ realmode.bin: realmode.asm realmode.o: realmode.bin objcopy -I binary -B i386 -O elf32-i386 realmode.bin realmode.o + +clean: + rm -f $(OBJS) diff --git a/grubload/loader.c b/grubload/loader.c index 4ecba2a..ee9fc00 100644 --- a/grubload/loader.c +++ b/grubload/loader.c @@ -1,5 +1,4 @@ -#include "minilib.h" -#include "../include/elf.h" +#include static const unsigned char elf_ident[4] = { 0x7F, 'E', 'L', 'F' }; diff --git a/grubload/multiboot_c.c b/grubload/multiboot_c.c index ad421b4..572c3fd 100644 --- a/grubload/multiboot_c.c +++ b/grubload/multiboot_c.c @@ -24,11 +24,11 @@ struct mod_info void c_start(unsigned int magic, struct mb_info *wee) { - unsigned short *grubptr = 0x7CFE; + unsigned short *grubptr = (unsigned short *)0x7CFE; unsigned char smramc; int i; - void (*realmode)() = 0x4000; + void (*realmode)() = (void (*)()) 0x4000; puts("Magic is: "); puthex(magic); diff --git a/include/elf.h b/include/elf.h index 0d5abbd..7240b69 100644 --- a/include/elf.h +++ b/include/elf.h @@ -21,9 +21,7 @@ #ifndef _ELF_H #define _ELF_H 1 -#ifndef MINILIB #include -#endif /* Standard ELF types. */ diff --git a/include/stdint.h b/include/stdint.h new file mode 100644 index 0000000..dbe4222 --- /dev/null +++ b/include/stdint.h @@ -0,0 +1,27 @@ +#ifndef _STDINT_H +#define _STDINT_H + +#ifndef __i386__ +# ifndef __x86_64__ +# error this stdint.h expects either __i386__ or __x86_64__ to be defined +# endif +#endif + +typedef signed char int8_t; +typedef unsigned char uint8_t; + +typedef signed short int16_t; +typedef unsigned short uint16_t; + +typedef signed int int32_t; +typedef unsigned int uint32_t; + +#ifdef __x86_64__ +typedef signed long int64_t; +typedef unsigned long uint64_t; +#else +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#endif + +#endif diff --git a/pci/pci-linux.c b/pci/pci-linux.c index 11c2375..8880069 100644 --- a/pci/pci-linux.c +++ b/pci/pci-linux.c @@ -4,6 +4,8 @@ #include #include +#include "pci.h" + static int _open(int bus, int slot, int fn) { char fname[512]; diff --git a/pci/pci-smm.c b/pci/pci-raw.c similarity index 96% rename from pci/pci-smm.c rename to pci/pci-raw.c index 117a8b5..4747ffd 100644 --- a/pci/pci-smm.c +++ b/pci/pci-raw.c @@ -1,5 +1,6 @@ #include -#include +#include +#include "pci.h" static void __pci_config(int bus, int slot, int fn, int addr) { diff --git a/pci/pci.h b/pci/pci.h new file mode 100644 index 0000000..729f9c0 --- /dev/null +++ b/pci/pci.h @@ -0,0 +1,17 @@ +#ifndef PCI_H +#define PCI_H + +/* General PCI functions. This is implemented by pci-linux.c and pci-raw.c; the + * former uses Linux's /proc/bus/pci interface for access from userspace, while + * the latter accesses the PCI hardware directly. + */ + +void pci_write32(int bus, int slot, int fn, int addr, uint32_t data); +void pci_write16(int bus, int slot, int fn, int addr, uint16_t data); +void pci_write8(int bus, int slot, int fn, int addr, uint8_t data); + +uint32_t pci_read32(int bus, int slot, int fn, int addr); +uint16_t pci_read16(int bus, int slot, int fn, int addr); +uint8_t pci_read8(int bus, int slot, int fn, int addr); + +#endif