From 5e9042e320d0a24d1691bcd6845936879238e812 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 25 Sep 2011 17:14:07 +0800 Subject: [PATCH] Kernel/arm7 - Fiddling with PCI etc - PCI is currently disabled because -pb boards don't implement it --- Kernel/Makefile | 17 ++++++++++---- Kernel/arch/arm7/debug.c | 2 +- Kernel/arch/arm7/pci.c | 18 +++++++++++++-- Kernel/arch/arm7/{start.s => start.S} | 33 +++++++++++++++++++++++---- Makefile.arm7.cfg | 2 +- 5 files changed, 59 insertions(+), 13 deletions(-) rename Kernel/arch/arm7/{start.s => start.S} (70%) diff --git a/Kernel/Makefile b/Kernel/Makefile index 3ae93776..14bae507 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -30,9 +30,12 @@ ifeq ($(DEBUG_BUILD),yes) endif ifeq ($(AS_SUFFIX),) - AS_SUFFIX = s + AS_SUFFIX = S endif +BUILDINFO_OBJ := $(OBJDIR)buildinfo.o$(OBJSUFFIX) +BUILDINFO_SRC := $(OBJDIR)buildinfo.c$(OBJSUFFIX) + OBJ := $(addprefix arch/$(ARCHDIR)/,$(A_OBJ)) OBJ += heap.o drvutil.o logging.o debug.o lib.o adt.o time.o OBJ += messages.o modules.o syscalls.o system.o threads.o @@ -58,13 +61,15 @@ DEPFILES := $(DEPFILES:%.o$(OBJSUFFIX)=%.dep$(OBJSUFFIX)) SRCFILES = $(OBJ:$(OBJDIR)%.o$(OBJSUFFIX)=%.c) SRCFILES := $(SRCFILES:$(OBJDIR)%.ao$(OBJSUFFIX)=%.$(AS_SUFFIX)) +OBJ += $(BUILDINFO_OBJ) + .PHONY: all clean install apidoc all: $(BIN) clean: # $(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt $(OBJ) $(DEPFILES) - @$(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt -r $(OBJDIR) $(OBJ) $(DEPFILES) + @$(RM) $(BIN) ../Acess2.$(ARCH).gz $(BIN).dsm ../Map.$(ARCH).txt LineCounts.$(ARCH).txt -r $(OBJDIR) $(OBJ) $(DEPFILES) $(BUILDINFO_SRC) install: $(BIN) cp $(BIN) $(BIN)_ @@ -107,8 +112,12 @@ include/syscalls.h include/syscalls.inc.asm: syscalls.lst Makefile GenSyscalls.p Makefile: ../Makefile.cfg arch/$(ARCHDIR)/Makefile -# HACK - Rebuild proc when the buildnum changes -#$(OBJDIR)drv/proc.o$(OBJSUFFIX): Makefile.BuildNum.$(ARCH) +.PHONY: $(BUILDINFO_SRC) +$(BUILDINFO_SRC): + @echo "const char * const gsGitHash = \""`git log -n 1 | head -n 1 | awk '{print $$1}'`"\";" > $@ + @echo "const int giBuildNumber = $(BUILD_NUM);" >> $@ +$(BUILDINFO_OBJ): $(BUILDINFO_SRC) + @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< # Dependency Files -include $(DEPFILES) diff --git a/Kernel/arch/arm7/debug.c b/Kernel/arch/arm7/debug.c index 12794983..d75048ed 100644 --- a/Kernel/arch/arm7/debug.c +++ b/Kernel/arch/arm7/debug.c @@ -10,7 +10,7 @@ // === CONSTANTS === //#define UART0_BASE 0x10009000 -#define UART0_BASE 0xF0000000 // Boot time mapped +#define UART0_BASE 0xF1000000 // Boot time mapped // === PROTOTYPES === void KernelPanic_SetMode(void); diff --git a/Kernel/arch/arm7/pci.c b/Kernel/arch/arm7/pci.c index 62b7deaf..0d25049f 100644 --- a/Kernel/arch/arm7/pci.c +++ b/Kernel/arch/arm7/pci.c @@ -3,6 +3,12 @@ */ #include +// Realview +//#define PCI_BASE 0x60000000 + +//#define PCI_BASE 0xF0400000 // VMM Mapping +#define PCI_BASE 0 + // === PROTOTYPES === #if 1 void PCI_CfgWriteDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset, Uint32 data); @@ -14,13 +20,21 @@ Uint8 PCI_CfgReadByte(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset); // === CODE === void PCI_CfgWriteDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset, Uint32 data) { - // TODO: Use PCI_ADDRESS constant + #if PCI_BASE + Uint32 address = PCI_BASE | ((Uint)bus<<16) | ((Uint)dev<<11) | ((Uint)func<<8) | (offset&0xFC); + *(Uint32*)(address) = data; + #else + #endif } Uint32 PCI_CfgReadDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset) { - // TODO: Locate PCI base and read/write data + #if PCI_BASE + Uint32 address = PCI_BASE | ((Uint)bus<<16) | ((Uint)dev<<11) | ((Uint)func<<8) | (offset&0xFC); + return *(Uint32*)address; + #else return 0xFFFFFFFF; + #endif } Uint16 PCI_CfgReadWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset) diff --git a/Kernel/arch/arm7/start.s b/Kernel/arch/arm7/start.S similarity index 70% rename from Kernel/arch/arm7/start.s rename to Kernel/arch/arm7/start.S index 606dbb73..d93033ea 100644 --- a/Kernel/arch/arm7/start.s +++ b/Kernel/arch/arm7/start.S @@ -1,4 +1,6 @@ KERNEL_BASE = 0x80000000 +PCI_PADDR = 0x60000000 @ Realview +UART0_PADDR = 0x10009000 @ Realview @ @ Exception defs taken from ARM DDI 0406B @ @@ -10,7 +12,7 @@ interrupt_vector_table: b . @ Prefetch abort b . @ Data abort b . @ Not Used - b . @ IRQ + b IRQHandler @ IRQ b . @ FIQ (Fast interrupt) .globl _start @@ -56,11 +58,33 @@ kernel_table0: .rept 0xF00 - 0x800 - 4 .long 0 .endr +#if PCI_PADDR + .long PCI_PADDR + 0*(1 << 20) + 2 @ Map PCI config space + .long PCI_PADDR + 1*(1 << 20) + 2 + .long PCI_PADDR + 2*(1 << 20) + 2 + .long PCI_PADDR + 3*(1 << 20) + 2 + .long PCI_PADDR + 4*(1 << 20) + 2 + .long PCI_PADDR + 5*(1 << 20) + 2 + .long PCI_PADDR + 6*(1 << 20) + 2 + .long PCI_PADDR + 7*(1 << 20) + 2 + .long PCI_PADDR + 8*(1 << 20) + 2 + .long PCI_PADDR + 9*(1 << 20) + 2 + .long PCI_PADDR + 10*(1 << 20) + 2 + .long PCI_PADDR + 11*(1 << 20) + 2 + .long PCI_PADDR + 12*(1 << 20) + 2 + .long PCI_PADDR + 13*(1 << 20) + 2 + .long PCI_PADDR + 14*(1 << 20) + 2 + .long PCI_PADDR + 15*(1 << 20) + 2 +#else + .rept 16 + .long 0 + .endr +#endif .long hwmap_table_0 + 0x000 - KERNEL_BASE + 1 .long hwmap_table_0 + 0x400 - KERNEL_BASE + 1 .long hwmap_table_0 + 0x800 - KERNEL_BASE + 1 .long hwmap_table_0 + 0xC00 - KERNEL_BASE + 1 - .rept 0xFF8 - 0xF00 - 4 + .rept 0xFF8 - 0xF00 - 16 - 4 .long 0 .endr @ Page fractals @@ -69,8 +93,7 @@ kernel_table0: .long kernel_table1_map + 0x800 - KERNEL_BASE + 1 .long kernel_table1_map + 0xC00 - KERNEL_BASE + 1 @ Top level fractals - @.long kernel_table0 - KERNEL_BASE + 2 @ Only need 16KiB, but this maps 1MiB - .long 0 @ removed for alignment constraints, using the KERNEL_BASE ident mapping instead + .long 0 @ removed for alignment constraints, using the KERNEL_BASE identity mapping instead .rept 0x1000 - 0xFF8 - 5 .long 0 .endr @@ -90,7 +113,7 @@ kernel_table1_map: @ Size = 4KiB @ Hardware mappings .globl hwmap_table_0 hwmap_table_0: - .long 0x10009000 + (1 << 4) + 3 @ UART0 + .long UART0_PADDR + (1 << 4) + 3 @ UART0 .rept 1024 - 1 .long 0 .endr diff --git a/Makefile.arm7.cfg b/Makefile.arm7.cfg index c1b454e4..992a88c3 100644 --- a/Makefile.arm7.cfg +++ b/Makefile.arm7.cfg @@ -1,6 +1,6 @@ CC = arm-elf-gcc -AS = arm-elf-as +AS = arm-elf-gcc -c LD = arm-elf-ld OBJDUMP = arm-elf-objdump DISASM = $(OBJDUMP) -d -S -- 2.20.1