bond/hal/boot.c

44 lines
1.0 KiB
C
Raw Normal View History

2018-01-26 08:43:22 +00:00
#include "hal/print.h"
#include "hal/mem.h"
#include "hal/intr.h"
#include "hal/cpu.h"
#include "lib/sxtdlib.h"
#include "hal/boot.h"
#include "status.h"
2015-04-21 00:19:06 +00:00
2017-03-10 02:50:35 +00:00
static void KABI halp_obtain_cpu_info(boot_info_t *hal_info)
2015-04-21 00:19:06 +00:00
{
if(hal_info == NULL)
return;
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
hal_cpuid(&eax,&ebx,&ecx,&edx);
2017-02-01 03:26:08 +00:00
lb_mem_copy(&ebx, &hal_info->cpu_vd_str[0], sizeof(uint32_t));
lb_mem_copy(&edx, &hal_info->cpu_vd_str[4], sizeof(uint32_t));
lb_mem_copy(&ecx, &hal_info->cpu_vd_str[8], sizeof(uint32_t));
hal_info->cpu_vd_str[12] = 0;
}
status_t KABI hal_init(void *m_info)
{
2017-02-01 03:26:08 +00:00
if (m_info == NULL || (uint64_t) m_info & lb_bit_field_mask(0, 2))
return STATUS_FAIL;
2016-06-05 23:37:29 +00:00
// init HAL infrastructures
hal_print_init();
hal_mem_init();
2016-06-05 23:37:29 +00:00
2017-02-01 03:26:08 +00:00
boot_info_t* boot_info = halloc(sizeof(boot_info_t));
// obtain cpu info
2017-03-10 02:50:35 +00:00
halp_obtain_cpu_info(boot_info);
// init interrupt
if(hal_interrupt_init() != 0)
2016-06-05 23:37:29 +00:00
{
return STATUS_FAIL;
2016-06-05 23:37:29 +00:00
}
return STATUS_SUCCESS;
}