~pixelherodev/zyg

ref: 7dccbd7d9dc502f2cd859c4c7ebd84a0d8f3acd7 zyg/test/rk9/5.zig -rw-r--r-- 904 bytes
7dccbd7dNoam Preil merge 6 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const RK33 = struct{
	const panic = fn() noreturn{
		//TODO: add a hlt in here and reduce power
		while(true){}
	};
	const SpecialRegister = enum{
		const CPUACTLR_EL1 = "CPUACTLR_EL1";
		const set = fn(comptime reg: []const u8, val: u32) callconv(.Inline) void{
			// asm syntax rules:
			// $*N embeds COMPTIME string from argument N
			// $N references an argument which MUST be a LOCAL.
			asm("msr $2, $*1", reg, val);
		};
		// Expected error: returns void, u32 expected
		const get = fn(comptime reg: []const u8) callconv(.Inline) u32 {
			return asm("mrs $*1, $>2", reg, u32);
		};
	};
	const Erratum = struct{
		const E855873 = fn()void{
			var ACLTR = SpecialRegister.get(SpecialRegister.CPUACTLR_EL1);
			ACLTR = ACLTR | 1 << 44;
			SpecialRegister.set(SpecialRegister.CPUACTLR_EL1, ACLTR);
		};
	};
};

pub export const start = fn() noreturn{
	defer RK33.panic();
	RK33.Erratum.E855873();
};