1 /* Copyright 2019, Adrien Destugues, pulkomandy@pulkomandy.tk. 2 * Distributed under the terms of the MIT License. 3 */ 4 5 6 #include <arch/platform.h> 7 #include <boot/kernel_args.h> 8 #include <Htif.h> 9 #include <Plic.h> 10 #include <Clint.h> 11 #include <platform/sbi/sbi_syscalls.h> 12 13 #include <debug.h> 14 15 16 uint32 gPlatform; 17 18 void* gFDT = NULL; 19 20 HtifRegs *volatile gHtifRegs = (HtifRegs *volatile)0; 21 PlicRegs *volatile gPlicRegs; 22 ClintRegs *volatile gClintRegs; 23 24 25 status_t 26 arch_platform_init(struct kernel_args *args) 27 { 28 gPlatform = args->arch_args.machine_platform; 29 30 debug_early_boot_message("machine_platform: "); 31 switch (gPlatform) { 32 case kPlatformMNative: 33 debug_early_boot_message("Native mmode hooks\n"); 34 break; 35 case kPlatformSbi: 36 debug_early_boot_message("SBI\n"); 37 break; 38 default: 39 debug_early_boot_message("?\n"); 40 break; 41 } 42 43 gFDT = args->arch_args.fdt; 44 45 gHtifRegs = (HtifRegs *volatile)args->arch_args.htif.start; 46 gPlicRegs = (PlicRegs *volatile)args->arch_args.plic.start; 47 gClintRegs = (ClintRegs *volatile)args->arch_args.clint.start; 48 49 return B_OK; 50 } 51 52 53 status_t 54 arch_platform_init_post_vm(struct kernel_args *kernelArgs) 55 { 56 if (gPlatform == kPlatformSbi) { 57 sbiret res; 58 res = sbi_get_spec_version(); 59 dprintf("SBI spec version: %#lx\n", res.value); 60 res = sbi_get_impl_id(); 61 dprintf("SBI implementation ID: %#lx\n", res.value); 62 res = sbi_get_impl_version(); 63 dprintf("SBI implementation version: %#lx\n", res.value); 64 res = sbi_get_mvendorid(); 65 dprintf("SBI vendor ID: %#lx\n", res.value); 66 res = sbi_get_marchid(); 67 dprintf("SBI arch ID: %#lx\n", res.value); 68 } 69 return B_OK; 70 } 71 72 73 status_t 74 arch_platform_init_post_thread(struct kernel_args *kernelArgs) 75 { 76 return B_OK; 77 } 78