Added build type detection, simplified legacy BIOS booting on x86_64
This commit is contained in:
parent
0236209e95
commit
1fc97f9c5f
18 changed files with 298 additions and 107 deletions
40
Makefile
40
Makefile
|
@ -17,8 +17,15 @@
|
|||
## SOFTWARE. ##
|
||||
###################################################################################
|
||||
|
||||
.DEFAULT_GOAL := all
|
||||
|
||||
##
|
||||
# Build configuration
|
||||
#
|
||||
|
||||
export ARCH ?= x86_64
|
||||
export PLATFORM ?= generic-pc
|
||||
export BUILD_TYPE ?= debug
|
||||
|
||||
export ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
|
@ -26,16 +33,45 @@ export BUILD_DIR ?= $(ROOT_DIR)/build
|
|||
export SYSROOT_DIR ?= $(ROOT_DIR)/sysroot
|
||||
export RELEASE_DIR ?= $(ROOT_DIR)/release
|
||||
|
||||
export GITREV := $(shell git rev-parse --short HEAD)
|
||||
|
||||
NOUEFI ?= y
|
||||
|
||||
##
|
||||
# Image generation and running
|
||||
#
|
||||
|
||||
LIVECD := $(RELEASE_DIR)/aurix-$(GITREV)-livecd_$(ARCH)-$(PLATFORM).iso
|
||||
LIVEHDD := $(RELEASE_DIR)/aurix-$(GITREV)-livehdd_$(ARCH)-$(PLATFORM).img
|
||||
LIVESD := $(RELEASE_DIR)/aurix-$(GITREV)-livesd_$(ARCH)-$(PLATFORM).img
|
||||
|
||||
QEMU_FLAGS := -m 2G -smp 4 -serial stdio
|
||||
|
||||
##
|
||||
# General info
|
||||
#
|
||||
|
||||
export CODENAME := "Matterhorn"
|
||||
export VERSION := "0.1"
|
||||
export GITREV := $(shell git rev-parse --short HEAD)
|
||||
|
||||
export DEFINES := AURIX_CODENAME=$(CODENAME) \
|
||||
AURIX_VERSION=$(VERSION) \
|
||||
AURIX_GITREV=$(GITREV) \
|
||||
BUILD_TYPE=$(BUILD_TYPE)
|
||||
|
||||
ifeq ($(BUILD_TYPE),debug)
|
||||
DEFINES += BUILD_DEBUG
|
||||
else
|
||||
DEFINES += BUILD_RELEASE
|
||||
endif
|
||||
|
||||
##
|
||||
# Recipes
|
||||
#
|
||||
|
||||
.PHONY: all
|
||||
all: boot kernel
|
||||
@:
|
||||
|
||||
.PHONY: boot
|
||||
boot:
|
||||
@printf ">>> Building bootloader...\n"
|
||||
|
|
|
@ -21,16 +21,19 @@
|
|||
|
||||
export INCLUDE_DIRS := $(BOOT_ROOT)/include
|
||||
|
||||
export DEFINES += __$(ARCH)__ \
|
||||
_AXBOOT
|
||||
|
||||
export BUILD_DIR ?= build
|
||||
export SYSROOT_DIR ?= sysroot
|
||||
|
||||
export ASFLAGS :=
|
||||
export CFLAGS := -D__$(ARCH) -D_AXBOOT -ffreestanding -fno-stack-protector -fno-stack-check -MMD -MP
|
||||
export ASFLAGS := $(foreach d, $(DEFINES), -D$d)
|
||||
export CFLAGS := $(foreach d, $(DEFINES), -D$d) -ffreestanding -fno-stack-protector -fno-stack-check -MMD -MP
|
||||
export LDFLAGS := -nostdlib
|
||||
|
||||
export BOOT_ROOT := $(ROOT_DIR)/boot
|
||||
|
||||
ifeq ($(DEBUG),yes)
|
||||
ifeq ($(BUILD_TYPE),debug)
|
||||
CFLAGS += -O0 -g3
|
||||
else
|
||||
CFLAGS += -O2
|
||||
|
|
0
boot/arch/aarch64/common/.gitkeep
Normal file
0
boot/arch/aarch64/common/.gitkeep
Normal file
|
@ -54,4 +54,4 @@ SECTIONS
|
|||
}
|
||||
}
|
||||
|
||||
/*__bss_size = (__bss_end - __bss_start) >> 3;*/
|
||||
__bss_size = (__bss_end - __bss_start) >> 3;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
[bits 16]
|
||||
[org 0x7c00]
|
||||
|
||||
_start:
|
||||
jmp 0x0000:AxBootEntry
|
||||
|
||||
times 8-($-$$) db 0
|
||||
|
@ -37,40 +38,12 @@ bi_Reserved times 40 db 0
|
|||
;; without UEFI on x86_64.
|
||||
;;
|
||||
|
||||
%include "boot.inc"
|
||||
%include "print.inc"
|
||||
%include "diskutils.inc"
|
||||
|
||||
%include "strings.inc"
|
||||
|
||||
AxBootEntry:
|
||||
;;
|
||||
;; Set 80x50 text mode and clear the screen
|
||||
;;
|
||||
mov ax, 0x03
|
||||
int 0x10
|
||||
xor bx, bx
|
||||
mov ax, 0x1112
|
||||
int 0x10
|
||||
mov ah, 0
|
||||
int 0x10
|
||||
|
||||
;;
|
||||
;; Display an error message and halt
|
||||
;;
|
||||
mov si, sErrorUnbootable
|
||||
call PrintString
|
||||
mov si, sPressToReboot
|
||||
call PrintString
|
||||
jmp AxBootHalt
|
||||
|
||||
PrintString:
|
||||
lodsb
|
||||
or al, al
|
||||
jz .done
|
||||
mov ah, 0x0e
|
||||
mov bx, 0x0007
|
||||
int 0x10
|
||||
jmp PrintString
|
||||
.done:
|
||||
ret
|
||||
|
||||
AxBootHalt:
|
||||
hlt
|
||||
jmp AxBootHalt
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
[bits 16]
|
||||
[org 0x7c00]
|
||||
|
||||
jmp 0x0000:AxBootEntry
|
||||
_start:
|
||||
jmp short AxBootEntry
|
||||
nop
|
||||
|
||||
;;
|
||||
;; BIOS bootloader on x86_64 is just a placeholder
|
||||
|
@ -29,40 +31,12 @@ jmp 0x0000:AxBootEntry
|
|||
;; without UEFI on x86_64.
|
||||
;;
|
||||
|
||||
%include "boot.inc"
|
||||
%include "print.inc"
|
||||
%include "diskutils.inc"
|
||||
|
||||
%include "strings.inc"
|
||||
|
||||
AxBootEntry:
|
||||
;;
|
||||
;; Set 80x50 text mode and clear the screen
|
||||
;;
|
||||
mov ax, 0x03
|
||||
int 0x10
|
||||
xor bx, bx
|
||||
mov ax, 0x1112
|
||||
int 0x10
|
||||
mov ah, 0
|
||||
int 0x10
|
||||
|
||||
;;
|
||||
;; Display an error message and halt
|
||||
;;
|
||||
mov si, sErrorUnbootable
|
||||
call PrintString
|
||||
mov si, sPressToReboot
|
||||
call PrintString
|
||||
jmp AxBootHalt
|
||||
|
||||
PrintString:
|
||||
lodsb
|
||||
or al, al
|
||||
jz .done
|
||||
mov ah, 0x0e
|
||||
mov bx, 0x0007
|
||||
int 0x10
|
||||
jmp PrintString
|
||||
.done:
|
||||
ret
|
||||
|
||||
AxBootHalt:
|
||||
hlt
|
||||
jmp AxBootHalt
|
||||
|
|
43
boot/arch/x86_64/stage1/boot.inc
Normal file
43
boot/arch/x86_64/stage1/boot.inc
Normal file
|
@ -0,0 +1,43 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Module Name: boot.inc ;;
|
||||
;; Project: AurixOS ;;
|
||||
;; ;;
|
||||
;; Copyright (c) 2024-2025 Jozef Nagy ;;
|
||||
;; ;;
|
||||
;; This source is subject to the MIT License. ;;
|
||||
;; See License.txt in the root of this repository. ;;
|
||||
;; All other rights reserved. ;;
|
||||
;; ;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;;
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;;
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;;
|
||||
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;;
|
||||
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;
|
||||
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ;;
|
||||
;; SOFTWARE. ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
AxBootEntry:
|
||||
;;
|
||||
;; Set 80x50 text mode and clear the screen
|
||||
;;
|
||||
mov ax, 0x03
|
||||
int 0x10
|
||||
xor bx, bx
|
||||
mov ax, 0x1112
|
||||
int 0x10
|
||||
mov ah, 0
|
||||
int 0x10
|
||||
|
||||
;; Legacy booting is not ready for release yet
|
||||
%ifdef BUILD_DEBUG
|
||||
;;
|
||||
;; Display an error message and halt
|
||||
;;
|
||||
mov si, sErrorUnbootable
|
||||
call PrintString
|
||||
mov si, sPressToReboot
|
||||
call PrintString
|
||||
jmp AxBootHalt
|
||||
%endif
|
||||
jmp AxBootHalt
|
42
boot/arch/x86_64/stage1/diskutils.inc
Normal file
42
boot/arch/x86_64/stage1/diskutils.inc
Normal file
|
@ -0,0 +1,42 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Module Name: diskutils.inc ;;
|
||||
;; Project: AurixOS ;;
|
||||
;; ;;
|
||||
;; Copyright (c) 2024-2025 Jozef Nagy ;;
|
||||
;; ;;
|
||||
;; This source is subject to the MIT License. ;;
|
||||
;; See License.txt in the root of this repository. ;;
|
||||
;; All other rights reserved. ;;
|
||||
;; ;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;;
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;;
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;;
|
||||
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;;
|
||||
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;
|
||||
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ;;
|
||||
;; SOFTWARE. ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; dh = number of sectors to read
|
||||
;; dl = drive number
|
||||
;;
|
||||
;; output: es:bx
|
||||
LoadDisk:
|
||||
push dx
|
||||
mov ah, 0x02
|
||||
mov al, dh
|
||||
mov ch, 0x00
|
||||
mov dh, 0x00
|
||||
mov cl, 0x02
|
||||
int 0x13
|
||||
jc .ReadError
|
||||
pop dx
|
||||
cmp dh, al
|
||||
jne .ReadError
|
||||
ret
|
||||
.ReadError:
|
||||
mov si, sDiskReadError
|
||||
call PrintString
|
||||
call AxBootHalt
|
||||
|
||||
sDiskReadError: db 'ERROR: Failed to read disk!', 0
|
31
boot/arch/x86_64/stage1/print.inc
Normal file
31
boot/arch/x86_64/stage1/print.inc
Normal file
|
@ -0,0 +1,31 @@
|
|||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Module Name: print.inc ;;
|
||||
;; Project: AurixOS ;;
|
||||
;; ;;
|
||||
;; Copyright (c) 2024-2025 Jozef Nagy ;;
|
||||
;; ;;
|
||||
;; This source is subject to the MIT License. ;;
|
||||
;; See License.txt in the root of this repository. ;;
|
||||
;; All other rights reserved. ;;
|
||||
;; ;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ;;
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ;;
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ;;
|
||||
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ;;
|
||||
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ;;
|
||||
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ;;
|
||||
;; SOFTWARE. ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; si = input string
|
||||
PrintString:
|
||||
lodsb
|
||||
or al, al
|
||||
cmp al, 0
|
||||
jz .done
|
||||
mov ah, 0x0e
|
||||
mov bx, 0x0007
|
||||
int 0x10
|
||||
jmp PrintString
|
||||
.done:
|
||||
ret
|
|
@ -17,8 +17,6 @@
|
|||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#include <config/config.h>
|
||||
#include <firmware/file.h>
|
||||
#include <lib/string.h>
|
||||
#include <print.h>
|
||||
#include <axboot.h>
|
||||
|
@ -35,12 +33,12 @@ char *config_paths[] = {
|
|||
|
||||
void config_init(void)
|
||||
{
|
||||
FILE *config_file;
|
||||
void *config_file;
|
||||
char *config_buffer;
|
||||
int filesize;
|
||||
|
||||
for (size_t i = 0; i < ARRAY_LENGTH(config_paths); i++) {
|
||||
config_file = fw_file_open(NULL, config_paths[i]);
|
||||
//config_file = fw_file_open(NULL, config_paths[i]);
|
||||
if (config_file != NULL) {
|
||||
break;
|
||||
}
|
||||
|
@ -52,18 +50,18 @@ void config_init(void)
|
|||
//console();
|
||||
}
|
||||
|
||||
filesize = fw_file_size(config_file);
|
||||
config_buffer = malloc(filesize);
|
||||
//filesize = fw_file_size(config_file);
|
||||
//config_buffer = malloc(filesize);
|
||||
if (config_buffer == NULL) {
|
||||
log("Entering console...\r\n\r\n");
|
||||
//console();
|
||||
}
|
||||
|
||||
fw_file_read(config_file, filesize, config_buffer);
|
||||
//fw_file_read(config_file, filesize, config_buffer);
|
||||
|
||||
// TODO: parse configuration file
|
||||
|
||||
free(config_buffer);
|
||||
//free(config_buffer);
|
||||
|
||||
/*
|
||||
if (config_errors != 0 || config_get_menu_root() == NULL) {
|
||||
|
@ -74,5 +72,5 @@ void config_init(void)
|
|||
}
|
||||
*/
|
||||
|
||||
fw_file_close(config_file);
|
||||
//fw_file_close(config_file);
|
||||
}
|
25
boot/common/menu/main_menu.c
Normal file
25
boot/common/menu/main_menu.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: main_menu.c */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#include <menu/bootmenu.h>
|
||||
|
||||
void main_menu(void)
|
||||
{
|
||||
while (1);
|
||||
}
|
|
@ -19,14 +19,13 @@
|
|||
|
||||
#define NANOPRINTF_IMPLEMENTATION
|
||||
#define NANOPRINTF_USE_FIELD_WIDTH_FORMAT_SPECIFIERS 1
|
||||
#define NANOPRINTF_USE_PRECISION_FORMAT_SPECIFIERS 1
|
||||
#define NANOPRINTF_USE_FLOAT_FORMAT_SPECIFIERS 1
|
||||
#define NANOPRINTF_USE_LARGE_FORMAT_SPECIFIERS 1
|
||||
#define NANOPRINTF_USE_PRECISION_FORMAT_SPECIFIERS 0
|
||||
#define NANOPRINTF_USE_FLOAT_FORMAT_SPECIFIERS 0
|
||||
#define NANOPRINTF_USE_LARGE_FORMAT_SPECIFIERS 0
|
||||
#define NANOPRINTF_USE_BINARY_FORMAT_SPECIFIERS 0
|
||||
#define NANOPRINTF_USE_WRITEBACK_FORMAT_SPECIFIERS 0
|
||||
#include <nanoprintf.h>
|
||||
|
||||
#include <debug/serial.h>
|
||||
#include <print.h>
|
||||
|
||||
#include <stddef.h>
|
||||
|
|
34
boot/include/lib/string.h
Normal file
34
boot/include/lib/string.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: string.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _LIB_STRING_H
|
||||
#define _LIB_STRING_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
size_t mbstowcs(wchar_t *dest, const char **src, size_t len);
|
||||
|
||||
size_t strlen(const char *str);
|
||||
char *strcpy(char *dest, const char *src);
|
||||
|
||||
void *memset(void *dest, int val, size_t len);
|
||||
void *memcpy(void *dest, void *src, size_t len);
|
||||
int memcmp(const void *a, const void *b, size_t len);
|
||||
|
||||
#endif /* _LIB_STRING_H */
|
25
boot/include/menu/bootmenu.h
Normal file
25
boot/include/menu/bootmenu.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*********************************************************************************/
|
||||
/* Module Name: bootmenu.h */
|
||||
/* Project: AurixOS */
|
||||
/* */
|
||||
/* Copyright (c) 2024-2025 Jozef Nagy */
|
||||
/* */
|
||||
/* This source is subject to the MIT License. */
|
||||
/* See License.txt in the root of this repository. */
|
||||
/* All other rights reserved. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR */
|
||||
/* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE */
|
||||
/* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER */
|
||||
/* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, */
|
||||
/* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE */
|
||||
/* SOFTWARE. */
|
||||
/*********************************************************************************/
|
||||
|
||||
#ifndef _MENU_BOOTMENU_H
|
||||
#define _MENU_BOOTMENU_H
|
||||
|
||||
void main_menu(void);
|
||||
|
||||
#endif /* _MENU_BOOTMENU_H */
|
|
@ -32,7 +32,6 @@ BOOT_CFLAGS := $(CFLAGS) \
|
|||
|
||||
BOOT_LDFLAGS := $(LDFLAGS)
|
||||
|
||||
$(shell find . -type d \( -name arch -o -name platform \) -prune -name '*.c')
|
||||
BOOT_ASFILES := $(shell find $(BOOT_ROOT)/arch/$(ARCH) -type d -name arch/$(ARCH)/uefi -prune -name '*.S')
|
||||
BOOT_CFILES := $(shell find $(BOOT_ROOT)/arch/$(ARCH) -type d -name arch/$(ARCH)/uefi -prune -name '*.c')
|
||||
|
||||
|
@ -56,9 +55,9 @@ install:
|
|||
$(STAGE1_HDD): $(BOOT_ROOT)/arch/$(ARCH)/stage1/boot-hdd.asm
|
||||
@mkdir -p $(@D)
|
||||
@printf " AS\tboot/arch/$(ARCH)/stage1/stage1-hdd.bin\n"
|
||||
@nasm -fbin -I$(BOOT_ROOT)/arch/$(ARCH)/stage1 $< -o $@
|
||||
@nasm -fbin -I$(BOOT_ROOT)/arch/$(ARCH)/stage1 $(ASFLAGS) $< -o $@
|
||||
|
||||
$(STAGE1_CD): $(BOOT_ROOT)/arch/$(ARCH)/stage1/boot-cd.asm
|
||||
@mkdir -p $(@D)
|
||||
@printf " AS\tboot/arch/$(ARCH)/stage1/stage1-cd.bin\n"
|
||||
@nasm -fbin -I$(BOOT_ROOT)/arch/$(ARCH)/stage1 $< -o $@
|
||||
@nasm -fbin -I$(BOOT_ROOT)/arch/$(ARCH)/stage1 $(ASFLAGS) $< -o $@
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
## SOFTWARE. ##
|
||||
###################################################################################
|
||||
|
||||
BOOTFILE := $(BUILD_DIR)/boot/raspi4/axboot.elf
|
||||
BOOTFILE := $(BUILD_DIR)/boot/raspi4/kernel8.img
|
||||
|
||||
INCLUDE_DIRS += $(BOOT_ROOT)/include \
|
||||
$(BOOT_ROOT)/include/arch/$(ARCH) \
|
||||
|
@ -26,14 +26,18 @@ INCLUDE_DIRS += $(BOOT_ROOT)/include \
|
|||
BOOT_AS := $(ARCH)-elf-gcc
|
||||
BOOT_CC := $(ARCH)-elf-gcc
|
||||
BOOT_LD := $(ARCH)-elf-ld
|
||||
BOOT_OBJCOPY := $(ARCH)-elf-objcopy
|
||||
|
||||
BOOT_ASFLAGS := $(ASFLAGS) \
|
||||
$(foreach d, $(INCLUDE_DIRS), -I$d)
|
||||
|
||||
BOOT_CFLAGS := $(CFLAGS) \
|
||||
$(foreach d, $(INCLUDE_DIRS), -I$d)
|
||||
$(foreach d, $(INCLUDE_DIRS), -I$d) \
|
||||
-mstrict-align \
|
||||
-nostartfiles
|
||||
|
||||
BOOT_LDFLAGS := $(LDFLAGS)
|
||||
BOOT_LDFLAGS := $(LDFLAGS) \
|
||||
-T$(BOOT_ROOT)/arch/$(ARCH)/linker.ld
|
||||
|
||||
COMMON_CFILES := $(shell find $(BOOT_ROOT)/common -name '*.c')
|
||||
COMMON_ARCH_CFILES := $(shell find $(BOOT_ROOT)/arch/$(ARCH)/common -name '*.c')
|
||||
|
@ -41,11 +45,11 @@ COMMON_ARCH_ASFILES := $(shell find $(BOOT_ROOT)/arch/$(ARCH)/common -name '*.S'
|
|||
PLATFORM_CFILES := $(shell find $(BOOT_ROOT)/platform/$(PLATFORM) -name '*.c')
|
||||
PLATFORM_ASFILES := $(shell find $(BOOT_ROOT)/platform/$(PLATFORM) -name '*.S')
|
||||
|
||||
BOOT_OBJ := $(COMMON_CFILES:$(BOOT_ROOT)/common/%.c=$(BUILD_DIR)/boot/raspi4/common/%.c.o) \
|
||||
$(COMMON_ARCH_CFILES:$(BOOT_ROOT)/arch/$(ARCH)/common/%.c=$(BUILD_DIR)/boot/raspi4/arch/%.c.o) \
|
||||
$(COMMON_ARCH_ASFILES:$(BOOT_ROOT)/arch/$(ARCH)/common/%.S=$(BUILD_DIR)/boot/raspi4/arch/%.S.o) \
|
||||
$(PLATFORM_CFILES:$(BOOT_ROOT)/platform/$(PLATFORM)/%.c=$(BUILD_DIR)/boot/raspi4/%.c.o) \
|
||||
$(PLATFORM_ASFILES:$(BOOT_ROOT)/platform/$(PLATFORM)/%.S=$(BUILD_DIR)/boot/raspi4/%.S.o)
|
||||
BOOT_OBJ := $(COMMON_CFILES:$(BOOT_ROOT)/common/%.c=$(BUILD_DIR)/boot/$(PLATFORM)/common/%.c.o) \
|
||||
$(COMMON_ARCH_CFILES:$(BOOT_ROOT)/arch/$(ARCH)/common/%.c=$(BUILD_DIR)/boot/$(PLATFORM)/arch/%.c.o) \
|
||||
$(COMMON_ARCH_ASFILES:$(BOOT_ROOT)/arch/$(ARCH)/common/%.S=$(BUILD_DIR)/boot/$(PLATFORM)/arch/%.S.o) \
|
||||
$(PLATFORM_CFILES:$(BOOT_ROOT)/platform/$(PLATFORM)/%.c=$(BUILD_DIR)/boot/$(PLATFORM)/%.c.o) \
|
||||
$(PLATFORM_ASFILES:$(BOOT_ROOT)/platform/$(PLATFORM)/%.S=$(BUILD_DIR)/boot/$(PLATFORM)/%.S.o)
|
||||
|
||||
.PHONY: all
|
||||
all: $(BOOTFILE)
|
||||
|
@ -54,13 +58,15 @@ all: $(BOOTFILE)
|
|||
.PHONY: install
|
||||
install: all
|
||||
@mkdir -p $(SYSROOT_DIR)
|
||||
@printf " INSTALL\t/kernel.elf\n"
|
||||
@cp $(BOOTFILE) $(SYSROOT_DIR)/kernel.elf
|
||||
@printf " INSTALL\t/kernel8.img\n"
|
||||
@cp $(BOOTFILE) $(SYSROOT_DIR)/kernel8.img
|
||||
|
||||
$(BOOTFILE): $(BOOT_OBJ)
|
||||
@mkdir -p $(@D)
|
||||
@printf " LD\t$(notdir $@)\n"
|
||||
@$(BOOT_LD) $(BOOT_LDFLAGS) $^ -o $@
|
||||
@printf " LD\taxboot.elf\n"
|
||||
@$(BOOT_LD) $(BOOT_LDFLAGS) $^ -o $(BUILD_DIR)/boot/raspi4/axboot.elf
|
||||
@printf " OCOPY\t$(notdir $@)\n"
|
||||
@$(BOOT_OBJCOPY) -O binary $(BUILD_DIR)/boot/raspi4/axboot.elf $@
|
||||
|
||||
-include $(wildcard $(BUILD_DIR)/boot/*.d)
|
||||
|
||||
|
@ -69,6 +75,11 @@ $(BUILD_DIR)/boot/raspi4/%.c.o: $(BOOT_ROOT)/platform/$(PLATFORM)/%.c
|
|||
@printf " CC\t$(subst $(ROOT_DIR)/,,$<)\n"
|
||||
@$(BOOT_CC) $(BOOT_CFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/boot/raspi4/%.S.o: $(BOOT_ROOT)/platform/$(PLATFORM)/%.S
|
||||
@mkdir -p $(@D)
|
||||
@printf " AS\t$(subst $(ROOT_DIR)/,,$<)\n"
|
||||
@$(BOOT_AS) $(BOOT_ASFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/boot/raspi4/common/%.c.o: $(BOOT_ROOT)/common/%.c
|
||||
@mkdir -p $(@D)
|
||||
@printf " CC\t$(subst $(ROOT_DIR)/,,$<)\n"
|
||||
|
|
|
@ -58,7 +58,7 @@ _start:
|
|||
cbnz w2, 3b
|
||||
|
||||
4:
|
||||
bl menu_main
|
||||
bl main_menu
|
||||
|
||||
//
|
||||
// crazy? i was crazy once.
|
|
@ -56,21 +56,19 @@ KERNEL_LDFLAGS := -Tarch/$(ARCH)/linker.ld \
|
|||
-static \
|
||||
-no-pie
|
||||
|
||||
ifeq ($(DEBUG),yes)
|
||||
KERNEL_CFLAGS += -g3
|
||||
ifeq ($(BUILD_TYPE),debug)
|
||||
KERNEL_CFLAGS += -O0 -g3
|
||||
else
|
||||
KERNEL_CFLAGS += -O2
|
||||
endif
|
||||
|
||||
KERNEL_CFILES := $(shell find . -type d \( -name arch -o -name platform \) -prune -name '*.c')
|
||||
KERNEL_ASFILES := $(shell find . -type d \( -name arch -o -name platform \) -prune -name '*.S')
|
||||
KERNEL_CFILES := $(shell find . -type d \( -name arch -o -name platform \) -prune -o -name '*.c' -print)
|
||||
KERNEL_ARCH_CFILES := $(shell find arch/$(ARCH) -name '*.c')
|
||||
KERNEL_ARCH_ASFILES := $(shell find arch/$(ARCH) -name '*.S')
|
||||
KERNEL_PLATFORM_CFILES := $(shell find platform/$(PLATFORM) -name '*.c')
|
||||
KERNEL_PLATFORM_ASFILES := $(shell find platform/$(PLATFORM) -name '*.S')
|
||||
|
||||
KERNEL_OBJ := $(KERNEL_CFILES:%.c=$(BUILD_DIR)/kernel/%.c.o) \
|
||||
$(KERNEL_ASFILES:%.S=$(BUILD_DIR)/kernel/%.S.o) \
|
||||
$(KERNEL_ARCH_CFILES:arch/$(ARCH)/%.c=$(BUILD_DIR)/kernel/arch/%.c.o) \
|
||||
$(KERNEL_ARCH_ASFILES:arch/$(ARCH)/%.S=$(BUILD_DIR)/kernel/arch/%.S.o) \
|
||||
$(KERNEL_PLATFORM_CFILES:platform/$(PLATFORM)/%.c=$(BUILD_DIR)/kernel/platform/%.c.o) \
|
||||
|
@ -84,7 +82,7 @@ $(KERNEL_FILE): $(KERNEL_OBJ)
|
|||
@mkdir -p $(@D)
|
||||
@printf " LD\t$(notdir $@)\n"
|
||||
@$(KERNEL_LD) $(KERNEL_LDFLAGS) $^ -o $@
|
||||
ifeq ($(DEBUG),yes)
|
||||
ifeq ($(BUILD_TYPE),debug)
|
||||
@printf " OBJCOPY axkrnl.sym\n"
|
||||
@$(KERNEL_OBJCOPY) --only-keep-debug $@ $(BUILD_DIR)/axkrnl.sym
|
||||
@$(KERNEL_OBJCOPY) --strip-debug --strip-unneeded $@
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue