From d8f1f7bcd7faa25410cfc57035a94f9fabd7d562 Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Mon, 11 Nov 2019 14:40:08 +0100 Subject: describe CPSR using a struct with bitfields --- kernel.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'kernel.c') diff --git a/kernel.c b/kernel.c index 40b8a01..7a10b24 100644 --- a/kernel.c +++ b/kernel.c @@ -1,6 +1,6 @@ #include "uart.h" -#include "psr.h" #include "strings.h" +#include "psr.h" #include "translation_table_descriptors.h" #include "cp_regs.h" @@ -43,14 +43,13 @@ void kernel_main(uint32_t r0, uint32_t r1, uint32_t atags) uart_puts(paging); - uint32_t CPSR; // get content of current program status register to check the current // processor mode - asm("mrs %0, cpsr" : "=r" (CPSR) :: "memory"); - + PSR_t CPSR = read_CPSR(); + char *mode_name; - switch(read_processor_mode()) + switch(CPSR.fields.PSR_MODE_4_0) { case MODE_USER : mode_name = "User (PL0)\r\n"; break; case MODE_FIQ : mode_name = "FIQ (PL1)\r\n"; break; -- cgit v1.2.3