From bc55dc5d60469521269a41928d3d15809e2c8134 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 26 Sep 2011 21:23:32 +0800 Subject: [PATCH] Kernel/arm7 - Fiddling on process switching - Not implemented yet, but coming along --- Kernel/arch/arm7/Makefile | 2 +- Kernel/arch/arm7/main.c | 2 +- Kernel/arch/arm7/proc.S | 58 +++++++++++++++++++++++++++++++++++++++ Kernel/arch/arm7/proc.c | 5 ++++ Kernel/arch/arm7/start.S | 4 +++ 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 Kernel/arch/arm7/proc.S diff --git a/Kernel/arch/arm7/Makefile b/Kernel/arch/arm7/Makefile index 4d1aa049..21da1726 100644 --- a/Kernel/arch/arm7/Makefile +++ b/Kernel/arch/arm7/Makefile @@ -21,7 +21,7 @@ CPPFLAGS += -DMMU_PRESENT=$(MMU_PRESENT) -DPCI_ADDRESS=$(PCI_ADDRESS) LDFLAGS += `$(CC) --print-libgcc-file-name` A_OBJ = start.ao main.o lib.o time.o pci.o debug.o -A_OBJ += mm_phys.o mm_virt.o proc.o +A_OBJ += mm_phys.o mm_virt.o proc.o proc.ao main.c: Makefile.BuildNum.$(ARCH) diff --git a/Kernel/arch/arm7/main.c b/Kernel/arch/arm7/main.c index 2cbe8f28..b6186bbe 100644 --- a/Kernel/arch/arm7/main.c +++ b/Kernel/arch/arm7/main.c @@ -19,7 +19,7 @@ extern void System_Init(const char *Commandline); // === CODE === int kmain(void) { - LogF("Acess2 ARMv7 v"EXPAND_STR(KERNEL_VERSION)"\n", BUILD_NUM); + LogF("Acess2 ARMv7 v"EXPAND_STR(KERNEL_VERSION)"\n"); LogF(" Build %i\n", BUILD_NUM); // Interrupts_Setup(); diff --git a/Kernel/arch/arm7/proc.S b/Kernel/arch/arm7/proc.S new file mode 100644 index 00000000..7f9b88ef --- /dev/null +++ b/Kernel/arch/arm7/proc.S @@ -0,0 +1,58 @@ +/* + * Acess2 ARM + * - By John Hodge (thePowersGang) + * + * arch/arm7/proc.S + * - Process management assembly + */ + +#define PUSH_GPRS \ + str r0, [sp,#1*4];\ + str r1, [sp,#2*4];\ + str r2, [sp,#3*4];\ + str r3, [sp,#4*4];\ + str r4, [sp,#5*4];\ + str r5, [sp,#6*4];\ + str r6, [sp,#7*4];\ + str r7, [sp,#8*4];\ + str r8, [sp,#9*4];\ + str r9, [sp,#10*4];\ + str r10, [sp,#11*4];\ + str r11, [sp,#12*4];\ + str r12, [sp,#13*4];\ + str sp, [sp,#14*4];\ + str lr, [sp,#15*4];\ + sub sp, #16*4 + +#define POP_GPRS add sp, #16*4; \ + ldr r0, [sp,#1*4]; \ + ldr r1, [sp,#2*4]; \ + ldr r2, [sp,#3*4]; \ + ldr r3, [sp,#4*4]; \ + ldr r4, [sp,#5*4]; \ + ldr r5, [sp,#6*4]; \ + ldr r6, [sp,#7*4]; \ + ldr r7, [sp,#8*4]; \ + ldr r8, [sp,#9*4]; \ + ldr r9, [sp,#10*4]; \ + ldr r10, [sp,#11*4]; \ + ldr r11, [sp,#12*4]; \ + ldr r12, [sp,#13*4]; \ + ldr lr, [sp,#15*4]; + +.globl SwitchStacks +@ R0: New stack +@ R1: Pointer to where to save old stack +@ R2: New address space +SwitchStacks: + PUSH_GPRS + + str sp, [r1] + mov r0, sp + + @ Only update TTBR0 if the task has an explicit address space + tst r2, r2 + mcrne p15, 0, r2, c2, c0, 0 @ Set TTBR0 to r2 + + POP_GPRS + bx lr diff --git a/Kernel/arch/arm7/proc.c b/Kernel/arch/arm7/proc.c index e18d9772..28b0af03 100644 --- a/Kernel/arch/arm7/proc.c +++ b/Kernel/arch/arm7/proc.c @@ -55,6 +55,11 @@ void Proc_CallFaultHandler(tThread *Thread) } +void Proc_Reschedule(void) +{ + // TODO: Task switching! +} + void Proc_DumpThreadCPUState(tThread *Thread) { diff --git a/Kernel/arch/arm7/start.S b/Kernel/arch/arm7/start.S index d93033ea..718131c0 100644 --- a/Kernel/arch/arm7/start.S +++ b/Kernel/arch/arm7/start.S @@ -43,6 +43,10 @@ _ptr_kmain: SyscallHandler: b . + +IRQHandler: + b . + .section .padata .globl kernel_table0 -- 2.20.1