added more files
This commit is contained in:
parent
e680da775a
commit
2d7c0a36fe
5 changed files with 115 additions and 4 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -10,8 +10,4 @@ iso/kernel
|
|||
*.firm
|
||||
html/
|
||||
latex/
|
||||
int.s
|
||||
regs.h
|
||||
out/
|
||||
*.mmap
|
||||
*.mh
|
||||
|
|
21
kernel/arch/arm/include/regs.h
Normal file
21
kernel/arch/arm/include/regs.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include <stdint.h>
|
||||
struct cpu_state {
|
||||
uint32_t cpsr;
|
||||
uint32_t sp;
|
||||
uint32_t lr;
|
||||
uint32_t returnAddr;
|
||||
uint32_t r0;
|
||||
uint32_t r1;
|
||||
uint32_t r2;
|
||||
uint32_t r3;
|
||||
uint32_t r4;
|
||||
uint32_t r5;
|
||||
uint32_t r6;
|
||||
uint32_t r7;
|
||||
uint32_t r8;
|
||||
uint32_t r9;
|
||||
uint32_t r10;
|
||||
uint32_t r11;
|
||||
uint32_t r12;
|
||||
uint32_t pc;
|
||||
};
|
89
kernel/arch/arm/int.s
Normal file
89
kernel/arch/arm/int.s
Normal file
|
@ -0,0 +1,89 @@
|
|||
.arm
|
||||
.fpu vfpv2
|
||||
.section .bss
|
||||
.space 4096
|
||||
exception_stack:
|
||||
.section .data
|
||||
.space 4
|
||||
oldsp:
|
||||
.section .text
|
||||
.global branch_macro
|
||||
branch_macro:
|
||||
ldr pc, [pc, #-4] //Load the next word into PC
|
||||
.macro interrupt_handler intid
|
||||
push {r0-r12,lr} //Push registers
|
||||
|
||||
//Get previous sp and lr
|
||||
mrs r1, cpsr //Current mode
|
||||
mrs r0, spsr //Previous mode
|
||||
orr r0, #0xC0 //Disable interrupts in the previous mode
|
||||
bic r0, #0x20 //enable ARM mode in there
|
||||
|
||||
//If the mode is user, switch to system mode
|
||||
and r2, r0, #0x1F
|
||||
cmp r2, #0x10
|
||||
bne 1f
|
||||
orr r0, #0x1F
|
||||
1:
|
||||
//Change mode
|
||||
msr cpsr, r0
|
||||
mov r2, sp
|
||||
mov r3, lr
|
||||
//Switch back
|
||||
msr cpsr, r1
|
||||
mrs r0, spsr
|
||||
|
||||
//Push those registers
|
||||
push {r0, r2, r3, lr}
|
||||
|
||||
//Set argument 1
|
||||
ldr r0, =\intid
|
||||
|
||||
//Jump to generic handler
|
||||
|
||||
bl intr_common_handler
|
||||
|
||||
//pop the special registers
|
||||
pop {r0, r3, r4, lr}
|
||||
msr spsr, r0
|
||||
tst r0, #0x20 //Is code ARM or thumb?
|
||||
beq 2f
|
||||
orr lr, lr, #1 //Enable thumb mode on return#
|
||||
2:
|
||||
str lr, [sp, #0x34] //Set correct lr
|
||||
|
||||
ldmfd sp!, {r0-r12, pc}^ //Return back to original mode
|
||||
.endm
|
||||
.global data_abort
|
||||
data_abort:
|
||||
interrupt_handler 0
|
||||
.global fast_irq
|
||||
fast_irq:
|
||||
interrupt_handler 1
|
||||
.global normal_irq
|
||||
normal_irq:
|
||||
interrupt_handler 2
|
||||
.global prefetch_abort
|
||||
prefetch_abort:
|
||||
interrupt_handler 3
|
||||
.global svc_call
|
||||
svc_call:
|
||||
interrupt_handler 4
|
||||
.global undefined_op
|
||||
undefined_op:
|
||||
interrupt_handler 5
|
||||
|
||||
.extern handleINT
|
||||
intr_common_handler:
|
||||
mov r1, sp
|
||||
push {lr}
|
||||
blx handleINT
|
||||
pop {lr}
|
||||
mov sp, r0
|
||||
bx lr
|
||||
.global panic
|
||||
.extern panic2
|
||||
panic:
|
||||
push {r0-r12,lr}
|
||||
mov r1, sp
|
||||
b panic
|
5
kernel/mmaps/3ds9.mh
Normal file
5
kernel/mmaps/3ds9.mh
Normal file
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
#include <stdint.h>
|
||||
uint8_t mmap[] = {
|
||||
0x4d, 0x4d, 0x41, 0x50, 0x0, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x4, 0x33, 0x44, 0x53, 0x39, 0x2, 0x1, 0x2, 0x3, 0x1, 0x1, 0x4, 0x1, 0x20, 0x5, 0x9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x6, 0x5, 0x9, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x10, 0x8, 0x7, 0x5, 0x9, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x18, 0x6, 0x5, 0x9, 0x0, 0x0, 0x0, 0x18, 0x0, 0x0, 0x60, 0x18, 0x6, 0x5, 0x9, 0x0, 0x0, 0xf0, 0x1f, 0x0, 0x0, 0xf8, 0x1f, 0x6, 0x5, 0x9, 0x0, 0x0, 0xf8, 0x1f, 0x0, 0x0, 0x0, 0x20, 0x6, 0x5, 0x9, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x28, 0x6, 0x5, 0x9, 0x0, 0x0, 0xf0, 0xff, 0x0, 0x40, 0xf0, 0xff, 0x6, 0x5, 0x9, 0x0, 0x0, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0, 0x5,
|
||||
};
|
BIN
kernel/mmaps/3ds9.mmap
Normal file
BIN
kernel/mmaps/3ds9.mmap
Normal file
Binary file not shown.
Loading…
Reference in a new issue