--- /dev/null
+*.o
+*.bin
+*.elf
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
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
#include <io.h>
-#include <minilib.h>
unsigned int counter = 0;
unsigned long pcisave;
-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
realmode.o: realmode.bin
objcopy -I binary -B i386 -O elf32-i386 realmode.bin realmode.o
+
+clean:
+ rm -f $(OBJS)
-#include "minilib.h"
-#include "../include/elf.h"
+#include <elf.h>
static const unsigned char elf_ident[4] = { 0x7F, 'E', 'L', 'F' };
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);
#ifndef _ELF_H
#define _ELF_H 1
-#ifndef MINILIB
#include <stdint.h>
-#endif
/* Standard ELF types. */
--- /dev/null
+#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
#include <stdio.h>
#include <inttypes.h>
+#include "pci.h"
+
static int _open(int bus, int slot, int fn)
{
char fname[512];
#include <io.h>
-#include <inttypes.h>
+#include <stdint.h>
+#include "pci.h"
static void __pci_config(int bus, int slot, int fn, int addr)
{
--- /dev/null
+#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