Mercurial > hg > Members > taiki > elilo
changeset 1:1b2326947b0d
add kernel source
author | taiki |
---|---|
date | Fri, 15 Feb 2013 04:22:42 +0900 |
parents | 7ac2a177e25d |
children | da946b5ff948 |
files | Makefile elilo.c x86_64/elilo_kernel.c x86_64/elilo_kernel.h x86_64/sysdeps.h |
diffstat | 5 files changed, 88 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Thu Feb 14 01:43:26 2013 +0900 +++ b/Makefile Fri Feb 15 04:22:42 2013 +0900 @@ -72,6 +72,7 @@ choosers/choosers.o \ devschemes/devschemes.o \ $(ARCH)/sysdeps.o \ + $(ARCH)/elilo_kernel.o \ $(FILESYSTEMS) TARGETS = elilo.efi
--- a/elilo.c Thu Feb 14 01:43:26 2013 +0900 +++ b/elilo.c Fri Feb 15 04:22:42 2013 +0900 @@ -45,6 +45,7 @@ #include "fileops.h" #include "loader.h" #include "config.h" /* for config_init() */ +#include "x86_64/elilo_kernel.h" /* embeded kernel */ #define ELILO_SHARED_CMDLINE_OPTS L"pPMC:aDhd:i:vVc:E" @@ -215,7 +216,6 @@ kdesc_t kd; memdesc_t imem, mmem; INTN r, retries=0; - kd.original_kernel_flag = ORG_KERNEL_FALSE; /* * First place where we potentially do system dependent @@ -304,9 +304,8 @@ if (mmem.start_addr) free(mmem.start_addr); if (bp) free_boot_params(bp); exit_error: - Print(L"Start original kernel.\n"); - kd.original_kernel_flag = ORG_KERNEL_TRUE; - start_kernel(kd.kentry, bp); + Print(L"Start original ELILO kernel.\n"); + start_elilo_kernel(); return ELILO_LOAD_ERROR; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/x86_64/elilo_kernel.c Fri Feb 15 04:22:42 2013 +0900 @@ -0,0 +1,76 @@ +#include <efi.h> +#include <efilib.h> + +#include "elilo.h" + +#define PAGETABLE_SIZE 1024 +#define PAGEDIRECTORY_SIZE 1024 + +extern UINT64 *pte; + +#define X86_CR4_PAE 0x00000020 +#define X86_CR4_PSE 0x00000010 + +VOID +MemCpy(UINT8 *t, UINT8 *f, UINTN n) +{ + if (t && f && n && (t<f)) { + while (n--) { + *t++ = *f++; + } + } else if (t && f && n && (t>f)) { + t +=n; + f +=n; + while (n--) { + *t-- = *f--; + } + } +} + +VOID +MemSet(UINT8 *p, UINTN *n, UINTN v) +{ + if (p && n) { + while (n--) { + *p++ = v; + } + } +} + +INTN +enable_cr4_pae() +{ + return 0; +} + +UINTN +insert_addr_to_cr3(UINT64 addr) +{ + asm volatile ("movq %0, %%rax \n\tmovq %%rax, %%cr3" :: "m"(addr) ); + //asm volatile ("movq %0, %%rax movq %rax, %cr3": :"a"(addr) :"%rax" ); + return 0; +} + +INTN +pgtable_init() +{ + UINTN size = PAGETABLE_SIZE * PAGEDIRECTORY_SIZE * sizeof(UINT64); + pte = (UINT64 *)alloc_pages(size, EfiLoaderData, AllocateAddress, pte); + if (pte != NULL) return -1; + Print(L"allocate page :%p", pte); + + return 0; +} + +EFI_STATUS +start_elilo_kernel() +{ + pgtable_init(); + UINT64 i=0; + asm volatile ("cli" : : ); + for (;i < 100000000; i++) + { + } + Print(L"finish internal kernel\n"); + return EFI_SUCCESS; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/x86_64/elilo_kernel.h Fri Feb 15 04:22:42 2013 +0900 @@ -0,0 +1,7 @@ +#ifndef ELILO_KERNEL +#define ELILO_KERNEL + +extern EFI_STATUS start_elilo_kernel(); + + +#endif /* ELILO_KERNEL */
--- a/x86_64/sysdeps.h Thu Feb 14 01:43:26 2013 +0900 +++ b/x86_64/sysdeps.h Fri Feb 15 04:22:42 2013 +0900 @@ -366,11 +366,11 @@ extern INTN x86_64_use_legacy_free_boot(); extern INTN x86_64_text_mode(); + /* * How to jump to kernel code */ - static inline void start_kernel(VOID *kentry, boot_params_t *bp) {