mirror of
https://github.com/LNH-team/pico-loader.git
synced 2026-06-02 09:16:49 +02:00
Initial commit
This commit is contained in:
32
arm9/source/arm9Clock.s
Normal file
32
arm9/source/arm9Clock.s
Normal file
@@ -0,0 +1,32 @@
|
||||
.section ".itcm", "ax"
|
||||
.arm
|
||||
|
||||
#define REG_SCFG_CLK 0x04004004
|
||||
#define SCFG_CLK_CPU_SPEED 1
|
||||
|
||||
.global scfg_setArm9Clock
|
||||
.type scfg_setArm9Clock, %function
|
||||
scfg_setArm9Clock:
|
||||
ldr r3,= REG_SCFG_CLK
|
||||
ldrh r2, [r3]
|
||||
and r1, r2, #SCFG_CLK_CPU_SPEED
|
||||
cmp r1, r0
|
||||
bxeq lr // requested speed already set
|
||||
|
||||
mrs r12, cpsr
|
||||
orr r1, r12, #0xC0 // disable irq and fiq
|
||||
msr cpsr, r1
|
||||
|
||||
bic r2, r2, #SCFG_CLK_CPU_SPEED
|
||||
orr r2, r2, r0
|
||||
|
||||
strh r2, [r3]
|
||||
|
||||
// allow the clock switch to stabilize
|
||||
mov r0, #8
|
||||
1:
|
||||
subs r0, r0, #1
|
||||
bne 1b
|
||||
|
||||
msr cpsr, r12
|
||||
bx lr
|
||||
Reference in New Issue
Block a user