Allow re-using the Multiboot constants
This commit is contained in:
parent
9b6b86802f
commit
790d3fb627
|
@ -51,7 +51,7 @@ _start:
|
|||
|
||||
/* detect multiboot */
|
||||
pop %eax
|
||||
cmp $MAGIC2, %eax
|
||||
cmp $BOOT_MULTIBOOT_HEADER_MAGIC, %eax
|
||||
jne 1f
|
||||
push %ebx
|
||||
call multiboot
|
||||
|
|
|
@ -50,7 +50,7 @@ _start:
|
|||
|
||||
/* detect multiboot */
|
||||
pop %eax
|
||||
cmp $MAGIC2, %eax
|
||||
cmp $BOOT_MULTIBOOT_LOADER_MAGIC, %eax
|
||||
jne 1f
|
||||
push %ebx
|
||||
call multiboot
|
||||
|
|
|
@ -4,20 +4,51 @@
|
|||
|
||||
|
||||
|
||||
#include "drivers/boot/multiboot/constants.h"
|
||||
|
||||
|
||||
/* variables */
|
||||
#define ALIGN (1 << 0) /* align the modules loaded on */
|
||||
/* page boundaries */
|
||||
#define MEMINFO (1 << 1) /* provide the memory map */
|
||||
#define FLAGS ALIGN | MEMINFO /* multiboot flags */
|
||||
#define MAGIC1 0x1badb002 /* magic number */
|
||||
#define MAGIC2 0x2badb002 /* magic number */
|
||||
#define CHECKSUM -(MAGIC1 + FLAGS) /* checksum for the above */
|
||||
#define FLAGS (BOOT_MULTIBOOT_HEADER_MODS_ALIGNED \
|
||||
| BOOT_MULTIBOOT_HEADER_WANT_MEMORY \
|
||||
| BOOT_MULTIBOOT_HEADER_HAS_VBE)
|
||||
#define MAGIC BOOT_MULTIBOOT_HEADER_MAGIC
|
||||
#define CHECKSUM -(MAGIC + FLAGS) /* checksum for the above */
|
||||
|
||||
|
||||
/* sections */
|
||||
/* multiboot */
|
||||
.section .multiboot
|
||||
.align 4
|
||||
.long MAGIC1
|
||||
|
||||
multiboot_header:
|
||||
.long MAGIC
|
||||
.long FLAGS
|
||||
.long CHECKSUM
|
||||
|
||||
#ifdef __ELF__
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
.long 0
|
||||
#else
|
||||
.long multiboot_header
|
||||
.long _multiboot_start
|
||||
.long _edata
|
||||
.long _end
|
||||
.long _start
|
||||
#endif
|
||||
|
||||
/* fail-safe video mode */
|
||||
.long 0
|
||||
.long 640
|
||||
.long 480
|
||||
.long 8
|
||||
|
||||
|
||||
.section .text
|
||||
/* multiboot_start */
|
||||
.global _multiboot_start
|
||||
.type _multiboot_start,@function
|
||||
_multiboot_start:
|
||||
jmp _start
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
# include <sys/types.h>
|
||||
# include <stdint.h>
|
||||
# include <elf.h>
|
||||
# include "multiboot/constants.h"
|
||||
|
||||
|
||||
/* types */
|
||||
|
@ -86,23 +87,6 @@ struct _ukBootMultibootMod
|
|||
};
|
||||
|
||||
|
||||
/* constants */
|
||||
# define BOOT_MULTIBOOT_HEADER_MAGIC 0x1badb002
|
||||
# define BOOT_MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001
|
||||
# define BOOT_MULTIBOOT_HEADER_WANT_MEMORY 0x00000002
|
||||
# define BOOT_MULTIBOOT_HEADER_HAS_VBE 0x00000004
|
||||
# define BOOT_MULTIBOOT_HEADER_HAS_MODS 0x00000008
|
||||
# define BOOT_MULTIBOOT_HEADER_HAS_ADDR 0x00010000
|
||||
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_MEMORY 0x00000001
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_CMDLINE 0x00000004
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_MODS 0x00000008
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_MMAP 0x00000040
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_DRIVES 0x00000080
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_VBE 0x00000800
|
||||
|
||||
/* prototypes */
|
||||
int multiboot_boot_kernel32(ukMultibootInfo * info, vaddr_t entrypoint);
|
||||
int multiboot_boot_kernel64(ukMultibootInfo * info, vaddr_t entrypoint);
|
||||
|
|
29
src/drivers/boot/multiboot/constants.h
Normal file
29
src/drivers/boot/multiboot/constants.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2018 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS uKernel */
|
||||
|
||||
|
||||
|
||||
#ifndef UKERNEL_DRIVERS_BOOT_MULTIBOOT_CONSTANTS_H
|
||||
# define UKERNEL_DRIVERS_BOOT_MULTIBOOT_CONSTANTS_H
|
||||
|
||||
|
||||
/* constants */
|
||||
# define BOOT_MULTIBOOT_HEADER_MAGIC 0x1badb002
|
||||
# define BOOT_MULTIBOOT_HEADER_MODS_ALIGNED 0x00000001
|
||||
# define BOOT_MULTIBOOT_HEADER_WANT_MEMORY 0x00000002
|
||||
# define BOOT_MULTIBOOT_HEADER_HAS_VBE 0x00000004
|
||||
# define BOOT_MULTIBOOT_HEADER_HAS_ADDR 0x00010000
|
||||
|
||||
# define BOOT_MULTIBOOT_LOADER_MAGIC 0x2badb002
|
||||
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_MEMORY 0x00000001
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_BOOT_DEVICE 0x00000002
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_CMDLINE 0x00000004
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_MODS 0x00000008
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_MMAP 0x00000040
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_DRIVES 0x00000080
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_LOADER_NAME 0x00000200
|
||||
# define BOOT_MULTIBOOT_INFO_HAS_VBE 0x00000800
|
||||
|
||||
#endif /* !UKERNEL_DRIVERS_BOOT_MULTIBOOT_CONSTANTS_H */
|
|
@ -1,4 +1,3 @@
|
|||
dist=Makefile,multiboot.h
|
||||
targets=multiboot.o
|
||||
cppflags_force=-nostdinc -isystem ../../../include -I../..
|
||||
as=$(CC)
|
||||
|
@ -6,7 +5,7 @@ asflags_force=$(CFLAGSF) $(CFLAGS) -c
|
|||
cflags_force=`../../../tools/platform.sh -V UKERNEL_CFLAGS -C "$$ARCH"`
|
||||
cflags=-W -Wall -g -O2
|
||||
ldflags_force=`../../../tools/platform.sh -V UKERNEL_LDFLAGS -C "$$ARCH"`
|
||||
dist=Makefile,bus.h,console.h
|
||||
dist=Makefile/multiboot/constants.h,multiboot.h
|
||||
|
||||
#targets
|
||||
[multiboot.o]
|
||||
|
|
|
@ -51,7 +51,7 @@ int multiboot(ukMultibootInfo * mi)
|
|||
printf("%u MB memory available\n",
|
||||
(mi->mem_upper - mi->mem_lower) / 1024);
|
||||
printf("Booted from %#x\n", mi->boot_device_drive);
|
||||
if(!(mi->flags & BOOT_MULTIBOOT_HEADER_HAS_MODS))
|
||||
if(!(mi->flags & BOOT_MULTIBOOT_INFO_HAS_MODS))
|
||||
{
|
||||
puts("No modules provided");
|
||||
return 2;
|
||||
|
|
|
@ -52,7 +52,7 @@ int multiboot(ukMultibootInfo * mi)
|
|||
|
||||
#ifdef notyet
|
||||
/* detect the video driver to use */
|
||||
if(mi->flags & BOOT_MULTIBOOT_HEADER_HAS_VBE)
|
||||
if(mi->flags & BOOT_MULTIBOOT_INFO_HAS_VBE)
|
||||
console = "vesa";
|
||||
#endif
|
||||
|
||||
|
@ -70,7 +70,7 @@ int multiboot(ukMultibootInfo * mi)
|
|||
printf("Booted from %#x\n", mi->boot_device_drive);
|
||||
|
||||
/* look for the kernel and modules */
|
||||
if(!(mi->flags & BOOT_MULTIBOOT_HEADER_HAS_MODS))
|
||||
if(!(mi->flags & BOOT_MULTIBOOT_INFO_HAS_MODS))
|
||||
{
|
||||
puts("No modules provided");
|
||||
return 2;
|
||||
|
|
Loading…
Reference in New Issue
Block a user