A_OBJ = start.ao main.o lib.o time.o pci.o debug.o
A_OBJ += mm_phys.o mm_virt.o proc.o
+
+main.c: Makefile.BuildNum.$(ARCH)
+
/**
+ * Acess2
+ * - By John Hodge (thePowersGang)
+ *
+ * arch/arm7/debug.c
+ * - ARM7 Debug output
+ * NOTE: Currently designed for the realview-pb-a8 emulated by Qemu
*/
#include <acess.h>
// === CONSTANTS ===
//#define UART0_BASE 0x10009000
-#define UART0_BASE 0xF0000000
+#define UART0_BASE 0xF0000000 // Boot time mapped
// === PROTOTYPES ===
void KernelPanic_SetMode(void);
return _dest;
}
+Uint64 DivMod64U(Uint64 Num, Uint64 Den, Uint64 *Rem)
+{
+ Uint64 ret;
+ if(Den == 0) return 0; // TODO: #div0
+ if(Num == 0) {
+ if(Rem) *Rem = 0;
+ return 0;
+ }
+ if(Den == 1) {
+ if(Rem) *Rem = 0;
+ return Num;
+ }
+ if(Den == 2) {
+ if(Rem) *Rem = Num & 1;
+ return Num >> 1;
+ }
+ if(Den == 16) {
+ if(Rem) *Rem = Num & 0xF;
+ return Num >> 4;
+ }
+ if(Den == 0x1000) {
+ if(Rem) *Rem = Num & 0xFFF;
+ return Num >> 12;
+ }
+
+ #if 0
+ {
+ // http://www.tofla.iconbar.com/tofla/arm/arm02/index.htm
+ Uint64 tmp = 1;
+ __asm__ __volatile__(
+ "1:"
+ "cmpl %2,%1"
+ "movls %2,%2,lsl#1"
+ "movls %3,%3,lsl#1"
+ "bls 1b"
+ "2:"
+ "cmpl %"
+ while(Num > Den) {
+ Den <<= 1;
+ tmp <<= 1;
+ }
+ Den >>= 1; tmp >>= 1;
+ while(
+ }
+ #else
+ for( ret = 0; Num > Den; ret ++, Num -= Den) ;
+ #endif
+ if(Rem) *Rem = Num;
+ return ret;
+}
+
// Unsigned Divide 64-bit Integer
Uint64 __udivdi3(Uint64 Num, Uint64 Den)
{
- if( Num == 0 ) return 0;
- if( Den == 0 ) return 5 / (Uint32)Den; // Force a #DIV0
- if( Den == 1 ) return Num;
- if( Den == 2 ) return Num >> 1;
+ return DivMod64U(Num, Den, NULL);
+// if( Den == 0 ) return 5 / (Uint32)Den; // Force a #DIV0
if( Den == 16 ) return Num >> 4;
if( Den == 256 ) return Num >> 8;
if( Den == 512 ) return Num >> 9;
// Unsigned Modulus 64-bit Integer
Uint64 __umoddi3(Uint64 Num, Uint64 Den)
{
- if( Num == 0 ) return 0;
if( Den == 0 ) return 5 / (Uint32)Den; // Force a #DIV0
+ if( Num < Den ) return Num;
if( Den == 1 ) return 0;
if( Den == 2 ) return Num & 1;
if( Den == 16 ) return Num & 3;
if( Den == 1024 ) return Num & 0x3FF;
if( Den == 2048 ) return Num & 0x7FF;
if( Den == 4096 ) return Num & 0xFFF;
- if( Num < Den ) return 0;
- if( Num <= 0xFFFFFFFF && Den <= 0xFFFFFFFF )
- return (Uint32)Num % (Uint32)Den;
+// if( Num <= 0xFFFFFFFF && Den <= 0xFFFFFFFF )
+// return (Uint32)Num % (Uint32)Den;
#if 0
if( Den <= 0xFFFFFFFF ) {
// === CODE ===
int kmain(void)
{
- LogF("Booting...\n");
+ LogF("Acess2 ARMv7 v"EXPAND_STR(KERNEL_VERSION)"\n", BUILD_NUM);
+ LogF(" Build %i\n", BUILD_NUM);
// Interrupts_Setup();
MM_SetupPhys();
//TODO:
+ LogF("End of kmain(), for(;;);\n");
for(;;);
}
char gStaticAllocPages[NUM_STATIC_ALLOC][PAGE_SIZE] __attribute__ ((section(".padata")));
tPAddr gaiStaticAllocPages[NUM_STATIC_ALLOC] = {
- (tPAddr)(&gStaticAllocPages[0] - KERNEL_BASE),
- (tPAddr)(&gStaticAllocPages[1] - KERNEL_BASE),
- (tPAddr)(&gStaticAllocPages[2] - KERNEL_BASE),
- (tPAddr)(&gStaticAllocPages[3] - KERNEL_BASE)
+ (tPAddr)(&gStaticAllocPages[0]) - KERNEL_BASE,
+ (tPAddr)(&gStaticAllocPages[1]) - KERNEL_BASE,
+ (tPAddr)(&gStaticAllocPages[2]) - KERNEL_BASE,
+ (tPAddr)(&gStaticAllocPages[3]) - KERNEL_BASE
};
extern char gKernelEnd[];
int AP;
} tMM_PageInfo;
+//#define FRACTAL(table1, addr) ((table1)[ (0xFF8/4*1024) + ((addr)>>20)])
+#define FRACTAL(table1, addr) ((table1)[ (0xFF8/4*1024) + ((addr)>>22)])
+#define TLBIALL() __asm__ __volatile__ ("mcr p15, 0, %0, c8, c7, 0" : : "r" (0))
+
// === PROTOTYPES ===
void MM_int_GetTables(tVAddr VAddr, Uint32 **Table0, Uint32 **Table1);
int MM_int_AllocateCoarse(tVAddr VAddr, int Domain);
desc[2] = desc[0] + 0x800;
desc[3] = desc[0] + 0xC00;
- table1[(VAddr>>20)*256] = paddr | 3;
+ Log("FRACTAL(%p, %p) = %p", table1, VAddr, &FRACTAL(table1, VAddr));
+ FRACTAL(table1, VAddr) = paddr | 3;
+
+ // TLBIALL
+ TLBIALL();
return 0;
}
KERNEL_BASE = 0x80000000
-
+@
+@ Exception defs taken from ARM DDI 0406B
+@
.section .init
interrupt_vector_table:
b _start @ Reset
- b . @ ?
- b SyscallHandler @ SWI instruction
- b .
- b .
- b .
- b .
- b .
+ b . @ #UD
+ b SyscallHandler @ SVC (SWI assume)
+ b . @ Prefetch abort
+ b . @ Data abort
+ b . @ Not Used
+ b . @ IRQ
+ b . @ FIQ (Fast interrupt)
.globl _start
_start:
.globl kernel_table0
kernel_table0:
- .long 0x00000002 @ Identity map the first 4 MiB
+ .long 0x00000002 @ Identity map the first 1 MiB
.rept 0x800 - 1
.long 0
.endr
.endr
.globl kernel_table1_map
-kernel_table1_map:
+kernel_table1_map: @ Size = 4KiB
.rept 0xF00/4
.long 0
.endr