Mercurial > hg > Members > taiki > elilo
changeset 12:61d2bea8cce5
faild ExitBootServices using create_boot_params
author | taiki |
---|---|
date | Tue, 11 Jun 2013 03:04:39 -0400 |
parents | 6eb39a8c991f |
children | 212d1e8ff02b |
files | bootparams.c elilo.c x86_64/ready_kernel.c x86_64/system.c |
diffstat | 4 files changed, 46 insertions(+), 60 deletions(-) [+] |
line wrap: on
line diff
--- a/bootparams.c Sun May 19 23:11:38 2013 -0400 +++ b/bootparams.c Tue Jun 11 03:04:39 2013 -0400 @@ -50,6 +50,7 @@ CHAR8 *cp; CHAR16 ch; + /* * Allocate runtime services memory to hold memory descriptor table and * command line arguments and fetch memory map: @@ -64,7 +65,6 @@ return NULL; } - /* * Allocate memory for boot parameters. * This CANNOT be EfiLoaderData or EfiLoaderCode as the kernel
--- a/elilo.c Sun May 19 23:11:38 2013 -0400 +++ b/elilo.c Tue Jun 11 03:04:39 2013 -0400 @@ -765,15 +765,45 @@ do_exit: unfixupargs(info); - //if (arglist) free(arglist); - /* free all resources assiocated with file accesses */ if (devices_initialized) close_devices(); - /* garbage collect all remaining allocations */ - free_all_memory(); + VOID *bp; + memdesc_t imem, mmem; + UINTN cookie; + CHAR16 cmdline[CMDLINE_MAXLEN]; + + cmdline[0] = 'E'; + cmdline[1] = 'L'; + cmdline[2] = 'I'; + cmdline[3] = 'L'; + cmdline[4] = 'O'; + cmdline[5] = '\0'; + + imem.start_addr = 0x100000; // initrd + imem.pgcnt = 40; + + Print(L"Execute create_boot_params\n"); + + if ((bp=create_boot_params(cmdline, &imem, &mmem, &cookie)) == 0) { + Print(L"create_boot_params is feild.\n"); + return status; + } + + Print(L"Execute ExitBootServices\n"); + + UINTN i=0; + while (i<3) { + status = uefi_call_wrapper(BS->ExitBootServices, 2, image, cookie); + if (EFI_ERROR(status)) { + Print(L"ERROR :Execute ExitBootServices %r\n", status); + } + } + if (EFI_ERROR(status)) { + Print(L"ERROR :Execute ExitBootServices %r\n", status); + return status; + } start_elilo_kernel(image); - return ret; }
--- a/x86_64/ready_kernel.c Sun May 19 23:11:38 2013 -0400 +++ b/x86_64/ready_kernel.c Tue Jun 11 03:04:39 2013 -0400 @@ -111,6 +111,12 @@ asm volatile("mov %%cr0,%0\n\t" : "=r" (cr0)); + UINT64 cs; + asm volatile("mov %%cs,%0\n\t" : "=r" (cs)); + Print(L"cs register : %ld\n",cs); + + while(1){} + cr0.pg = DISABLE; asm volatile("mov %0,%%cr0": : "r" (cr0)); @@ -249,62 +255,11 @@ }; -static VOID -fill_memory_map(struct e820entry *map, - UINTN *nr_map, - UINT64 start, - UINT64 size, - UINT64 type, - estatus_t *est) -{ - UINTN x = *nr_map; - if ((x > 0) && - (map[x-1].addr + map[x-1].size == start) && - (map[x-1].type == type)) { - est->estart = map[x-1].addr; - est->esize = map[x-1].size; - est->etype = map[x-1].type; - est->merge++; - return; - } - - if (x<MAP_MAX) { - map[x].addr = start; - map[x].size = size; - map[x].type = type; - (*nr_map)++; - est->merge=0; - return; - } - - if ((est->etype != type) || (est->estart + est->esize) != start) { - est->merge = 0; - est->estart = start; - est->esize = size; - est->etype = type; - } - - est->estart += est->esize; - est->esize += size; - est->merge++; - - return; -} - EFI_STATUS start_elilo_kernel(EFI_HANDLE image) { Print(L"Start original ELILO kernel.\n"); - UINTN map_size, cookie, size, version; - map_size = EFI_PAGE_SIZE * 2; - EFI_MEMORY_DESCRIPTOR *md; - - EFI_STATUS status = uefi_call_wrapper(BS->AllocatePool, 3, EfiLoaderData, map_size, &md); - if (EFI_ERROR(status)) { - Print(L"error 'allocate pool' %r \n", status); - } - /* cli: * ban to interrupt */ @@ -314,13 +269,13 @@ memcpy_for_ready(gdt_addr.base, init_gdt, sizeof_init_gdt); - // asm volatile ( "lgdt %0" : : "m" (gdt_addr) ); - //asm volatile ( "lidt %0" : : "m" (idt_addr) ); + asm volatile ( "lgdt %0" : : "m" (gdt_addr) ); + asm volatile ( "lidt %0" : : "m" (idt_addr) ); + init_pgtable_register(); Print(L"finish to initialize...\n"); - /* hlt: * assembler instruction. * stop cpu until next intrrupt.