Skip to content

Commit

Permalink
multiboot: fill multiboot_header properly with parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Feb 15, 2022
1 parent 5334402 commit 76c7aed
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ ifeq ($(CONFIG_ACPICA),y)
COMMON_FLAGS += -DKTF_ACPICA
endif

AFLAGS := $(COMMON_FLAGS) -D__ASSEMBLY__ -nostdlib -nostdinc
AFLAGS := $(COMMON_FLAGS) -DASM_FILE -D__ASSEMBLY__ -nostdlib -nostdinc
CFLAGS := $(COMMON_FLAGS) -std=gnu99 -O2 -g -Wall -Wextra -ffreestanding -nostdlib -nostdinc
CFLAGS += -mno-red-zone -mno-mmx -mno-sse -mno-sse2
CFLAGS += -fno-stack-protector -fno-exceptions -fno-builtin -fomit-frame-pointer -fcf-protection="none"
Expand Down
31 changes: 27 additions & 4 deletions arch/x86/boot/boot.S
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright © 2020 Amazon.com, Inc. or its affiliates.
* Copyright © 2022 Open Source Security, Inc.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand All @@ -23,16 +24,38 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <asm-macros.h>
#include <multiboot.h>

SECTION(.multiboot, "a", 4)
#define MULTIBOOT_PAGE_ALIGN (1<<0)
#define MULTIBOOT_MEMORY_INFO (1<<1)
#define MULTIBOOT_HEADER_MAGIC (0x1BADB002)
#define MULTIBOOT_HEADER_FLAGS (MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO)
#define MULTIBOOT_HEADER_FLAGS (MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_VIDEO_MODE)
#define MULTIBOOT_CHECKSUM -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)

#define MULTIBOOT_VIDEO_MODE_GFX 0
#define MULTIBOOT_VIDEO_MODE_TEXT 1

#define MULTIBOOT_MODE_TYPE MULTIBOOT_VIDEO_MODE_TEXT

#define MULTIBOOT_HEADER_ADDR 0
#define MULTIBOOT_LOAD_ADDRESS 0
#define MULTIBOOT_LOAD_END_ADDRESS 0
#define MULTIBOOT_BSS_END_ADDRESS 0
#define MULTIBOOT_ENTRY_ADDRESS 0

#define MULTIBOOT_FB_WIDTH 1024
#define MULTIBOOT_FB_HEIGHT 768
#define MULTIBOOT_FB_BPP 32

.code32
multiboot_header:
.long MULTIBOOT_HEADER_MAGIC
.long MULTIBOOT_HEADER_FLAGS
.long MULTIBOOT_CHECKSUM
.long MULTIBOOT_HEADER_ADDR
.long MULTIBOOT_LOAD_ADDRESS
.long MULTIBOOT_LOAD_END_ADDRESS
.long MULTIBOOT_BSS_END_ADDRESS
.long MULTIBOOT_ENTRY_ADDRESS
.long MULTIBOOT_MODE_TYPE
.long MULTIBOOT_FB_WIDTH
.long MULTIBOOT_FB_HEIGHT
.long MULTIBOOT_FB_BPP
2 changes: 2 additions & 0 deletions include/multiboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ struct multiboot_apm_info {
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef __ASSEMBLY__
extern void display_multiboot_mmap(void);
extern void init_multiboot(multiboot_info_t *mbi, const char **cmdline);

Expand All @@ -295,5 +296,6 @@ extern void map_multiboot_areas(void);
extern unsigned mbi_get_avail_memory_ranges_num(void);
extern int mbi_get_avail_memory_range(unsigned index, addr_range_t *r);
extern int mbi_get_memory_range(paddr_t pa, addr_range_t *r);
#endif /* __ASSEMBLY__ */

#endif /* KTF_MULTIBOOT_H */

0 comments on commit 76c7aed

Please sign in to comment.