SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
jmp.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0+ */
2
3#ifndef _JMP_H_
4#define _JMP_H_
5
6/*
7* The code reads the value from the ACTLR register,
8* sets the 6th bit of the register, and then writes the modified
9* value back to the ACTLR register using coprocessor
10* 15 (CP15) and its control register (CR).
11*/
12static inline void enable_kernel_smp(void) {
13 // Read ACTLR from coprocessor 15 (CP15), register c1
14 asm volatile("MRC p15, 0, r0, c1, c0, 1");
15 // Perform bitwise OR operation on register r0 with 0x040,
16 // setting bit 6 This is to set the 6th bit of the ACTLR register
17 asm volatile("ORR r0, r0, #0x040");
18 // Write the value in register r0 to coprocessor 15 (CP15),
19 // register c1 Writing back the modified value to the ACTLR register
20 asm volatile("MCR p15, 0, r0, c1, c0, 1");
21}
22
23static inline void syterkit_jmp(uint32_t addr) {
24 // Move the constant value 0 into register r2
25 asm volatile("mov r2, #0");
26
27 // Execute privileged instruction using coprocessor 15 (CP15),
28 // writing the value of register r2 to the Data ram latency
29 // control bit of the Cache Size Selection Register (CSSR)
30 // This sets the Data ram latency control bit of CSSR to 0
31 asm volatile("mcr p15, 0, r2, c7, c5, 6");
32
33 // Branch to the address stored in register r0,
34 // performing an unconditional jump to that location
35 asm volatile("bx r0");
36}
37
38static inline void jmp_to_fel() {
39 syterkit_jmp(0x20);
40}
41
42static inline void syterkit_jmp_kernel(uint32_t addr, uint32_t fdt) {
43 void (*kernel_entry)(int zero, int arch, unsigned int params);
44 kernel_entry = (void (*)(int, int, unsigned int)) addr;
45 kernel_entry(0, ~0, (unsigned int) fdt);
46}
47
48
49#endif// _JMP_H_
u32_t uint32_t
Definition stdint.h:13
static void jmp_to_fel()
Definition jmp.h:38
static void syterkit_jmp(uint32_t addr)
Definition jmp.h:23
static void enable_kernel_smp(void)
Definition jmp.h:12
static void syterkit_jmp_kernel(uint32_t addr, uint32_t fdt)
Definition jmp.h:42