2016-05-24 07:27:26 +00:00
|
|
|
/* Copyright 2016 secXsQuared
|
|
|
|
* Distributed under GPL license
|
|
|
|
* See COPYING under root for details
|
|
|
|
*/
|
|
|
|
|
2016-06-05 23:37:29 +00:00
|
|
|
#include "bit_ops.h"
|
2016-05-22 01:54:29 +00:00
|
|
|
#include "hal_print.h"
|
|
|
|
#include "hal_mem.h"
|
2016-06-01 05:00:29 +00:00
|
|
|
#include "hal_intr.h"
|
2016-07-09 03:01:33 +00:00
|
|
|
#include "hal_arch.h"
|
2016-05-22 01:54:29 +00:00
|
|
|
#include "std_lib.h"
|
2016-06-15 07:29:46 +00:00
|
|
|
#include "s_boot.h"
|
2015-04-21 00:19:06 +00:00
|
|
|
|
2016-07-09 03:01:33 +00:00
|
|
|
extern char kernel_start[];
|
|
|
|
extern char kernel_end[];
|
|
|
|
|
|
|
|
static void KAPI _hal_obtain_cpu_info(k_hal_boot_info_t *hal_info)
|
2015-04-21 00:19:06 +00:00
|
|
|
{
|
2016-06-13 04:11:38 +00:00
|
|
|
if(hal_info == NULL)
|
|
|
|
return;
|
|
|
|
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
|
|
|
|
hal_cpuid(&eax,&ebx,&ecx,&edx);
|
2016-06-15 07:29:46 +00:00
|
|
|
mem_cpy(&ebx, &hal_info->cpu_vd_str[0], sizeof(uint32_t));
|
|
|
|
mem_cpy(&edx, &hal_info->cpu_vd_str[4], sizeof(uint32_t));
|
|
|
|
mem_cpy(&ecx, &hal_info->cpu_vd_str[8], sizeof(uint32_t));
|
|
|
|
hal_info->cpu_vd_str[12] = 0;
|
2016-06-13 04:11:38 +00:00
|
|
|
}
|
2016-05-22 01:54:29 +00:00
|
|
|
|
2016-07-09 03:01:33 +00:00
|
|
|
void KAPI hal_main(void *m_info)
|
2016-06-13 04:11:38 +00:00
|
|
|
{
|
2016-06-23 04:50:29 +00:00
|
|
|
if (m_info == NULL || (uint64_t) m_info & bit_field_mask(0, 2))
|
|
|
|
return;
|
2016-06-05 23:37:29 +00:00
|
|
|
|
2016-07-09 03:01:33 +00:00
|
|
|
// init HAL infrastructures
|
|
|
|
hal_print_init();
|
|
|
|
hal_mem_init();
|
2016-06-05 23:37:29 +00:00
|
|
|
|
2016-06-14 06:33:31 +00:00
|
|
|
|
2016-07-09 03:01:33 +00:00
|
|
|
k_hal_boot_info_t* boot_info = halloc(sizeof(k_hal_boot_info_t));
|
2016-06-23 04:50:29 +00:00
|
|
|
|
2016-06-15 07:29:46 +00:00
|
|
|
// set up HAL def
|
|
|
|
boot_info->krnl_start = (uint64_t)kernel_start;
|
|
|
|
boot_info->krnl_end = (uint64_t)kernel_end;
|
|
|
|
|
|
|
|
// obtain cpu info
|
|
|
|
_hal_obtain_cpu_info(boot_info);
|
|
|
|
|
2016-06-13 04:11:38 +00:00
|
|
|
// init interrupt
|
|
|
|
if(hal_interrupt_init() != 0)
|
2016-06-05 23:37:29 +00:00
|
|
|
{
|
2016-07-09 03:01:33 +00:00
|
|
|
return;
|
2016-06-05 23:37:29 +00:00
|
|
|
}
|
2016-07-09 03:01:33 +00:00
|
|
|
// pass the control to the kernel
|
|
|
|
k_main(boot_info);
|
|
|
|
return;
|
2015-11-14 22:53:30 +00:00
|
|
|
}
|