aboutsummaryrefslogtreecommitdiff
path: root/src/kern/main.c
blob: 4fddb0a6305cb57c6e224cebdc56f949c073ca93 (plain) (blame)
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
32
33
34
35
36
37
38
39
40
41
#include "arch.h"
#include "arch/arm/cortex-m4/mpu.h"
#include "arch/stm32l4xxx/peripherals/clock.h"
#include "arch/stm32l4xxx/peripherals/system.h"
#include "kern/init.h"
#include "kern/log.h"
#include "kern/mem.h"
#include "kern/mpu/mpu_manager.h"
#include "kern/panic.h"
#include "kern/priv.h"
#include "user/syscall.h"

void on_hard_fault()
{
  panic("Hard fault encountered!\n");
}

void on_systick() /* Overrides weak-symbol on_systick. */
{
  klogf("Systick\n");
}

void configure_mpu()
{
  configure_flash_region((void*)0x08000000, REGION_SIZE_256Kb, NOT_PRIVILEGED);
  configure_ram_region((void*)SRAM1_BASE, REGION_SIZE_64Kb, NOT_PRIVILEGED);
  configure_ram_region((void*)SRAM2_BASE, REGION_SIZE_16Kb, NOT_PRIVILEGED);
  configure_peripheral_region((void*)0x40000000, REGION_SIZE_512Mb, PRIVILEGED);
  mpu_set_enabled(1);
}

#ifdef ARCH_STM32L4

/* Main function. This gets executed from the interrupt vector defined above. */
int main()
{
  configure_mpu();
  jump_to_user_mode();
}

#endif