Compare commits
6 Commits
f79f04361a
...
51af007cd5
Author | SHA1 | Date | |
---|---|---|---|
51af007cd5 | |||
ae6d4ecabd | |||
2536c58607 | |||
b13f7e6755 | |||
c22bd248e3 | |||
5dadfeb8fd |
53
bochsrc.txt
53
bochsrc.txt
|
@ -1,53 +0,0 @@
|
|||
# configuration file generated by Bochs
|
||||
plugin_ctrl: unmapped=1, biosdev=1, speaker=1, extfpuirq=1, parallel=1, serial=1, iodebug=1
|
||||
config_interface: textconfig
|
||||
display_library: x
|
||||
memory: host=32, guest=32
|
||||
romimage: file="/usr/share/bochs/BIOS-bochs-latest", address=0x0, options=none
|
||||
vgaromimage: file="/usr/share/bochs/VGABIOS-lgpl-latest"
|
||||
boot: a
|
||||
floppy_bootsig_check: disabled=1
|
||||
floppya: 1_44=/dev/loop0, status=inserted
|
||||
# no floppyb
|
||||
ata0: enabled=0
|
||||
ata1: enabled=0
|
||||
ata2: enabled=0
|
||||
ata3: enabled=0
|
||||
optromimage1: file=none
|
||||
optromimage2: file=none
|
||||
optromimage3: file=none
|
||||
optromimage4: file=none
|
||||
optramimage1: file=none
|
||||
optramimage2: file=none
|
||||
optramimage3: file=none
|
||||
optramimage4: file=none
|
||||
pci: enabled=1, chipset=i440fx
|
||||
vga: extension=vbe, update_freq=5, realtime=1
|
||||
cpu: count=1:1:1, ips=1000000, quantum=16, model=bx_generic, reset_on_triple_fault=0, cpuid_limit_winnt=0, ignore_bad_msrs=1, mwait_is_nop=0
|
||||
cpuid: level=6, stepping=3, model=3, family=6, vendor_string="AuthenticAMD", brand_string="AMD Athlon(tm) processor"
|
||||
cpuid: mmx=1, apic=xapic, simd=sse2, sse4a=0, misaligned_sse=0, sep=1, movbe=0, adx=0
|
||||
cpuid: aes=0, sha=0, xsave=0, xsaveopt=0, avx_f16c=0, avx_fma=0, bmi=0, xop=0, fma4=0
|
||||
cpuid: tbm=0, x86_64=1, 1g_pages=0, pcid=0, fsgsbase=0, smep=0, smap=0, mwait=1
|
||||
print_timestamps: enabled=0
|
||||
debugger_log: ../red.debug
|
||||
magic_break: enabled=1
|
||||
port_e9_hack: enabled=0
|
||||
private_colormap: enabled=0
|
||||
clock: sync=none, time0=local, rtc_sync=0
|
||||
# no cmosimage
|
||||
# no loader
|
||||
log: ../red.log
|
||||
logprefix: %t%e%d
|
||||
debug: action=ignore
|
||||
info: action=report
|
||||
error: action=report
|
||||
panic: action=ask
|
||||
keyboard: type=mf, serial_delay=250, paste_delay=100000, user_shortcut=none
|
||||
mouse: type=ps2, enabled=0, toggle=ctrl+mbutton
|
||||
speaker: enabled=1, mode=system
|
||||
parport1: enabled=1, file=none
|
||||
parport2: enabled=0
|
||||
com1: enabled=1, mode=null
|
||||
com2: enabled=0
|
||||
com3: enabled=0
|
||||
com4: enabled=0
|
|
@ -6,6 +6,7 @@ kernel\utils.c
|
|||
kernel\graphics.c
|
||||
kernel\print.c
|
||||
kernel\interrupts.c
|
||||
kernel\ports.c
|
||||
kernel\memory.c
|
||||
kernel\memory\memmove.c
|
||||
kernel\memory\memcmp.c
|
||||
|
|
|
@ -618,6 +618,9 @@ static const char* ExceptionStrings[] = {
|
|||
/* = Sync Functions = */
|
||||
/* ============================================================= */
|
||||
|
||||
/* Required functions */
|
||||
size_t strlen(const char* string);
|
||||
|
||||
/* System Initialization */
|
||||
void PrepareSystem(FILELOADER_PARAMS* FLOP);
|
||||
|
||||
|
@ -639,10 +642,13 @@ uint32_t ReadPort(uint16_t Port, int Length);
|
|||
uint32_t WritePort(uint16_t Port, uint32_t Data, int Length);
|
||||
|
||||
/* Serial functions */
|
||||
void serial_write(const char chr);
|
||||
void serial_print(const char* data);
|
||||
void serial_printf(const char* format, ...);
|
||||
void init_serial();
|
||||
void serialWrite(const char chr);
|
||||
void serialPrint(const char* data);
|
||||
void serialPrintf(const char* format, ...);
|
||||
void serialInit();
|
||||
void inttoa(int input, char* output);
|
||||
void itoh(int input, char* output);
|
||||
void zeroString(char* string);
|
||||
|
||||
/* ==================== Registers ==================== */
|
||||
size_t ReadModelSpecificRegister(size_t MSR);
|
||||
|
@ -676,15 +682,15 @@ void SetLDT(uint16_t LDTData);
|
|||
uint16_t FetchTSR(void);
|
||||
void SetTSR(uint16_t TSRData);
|
||||
|
||||
void InstallGDT(void);
|
||||
void InstallIDT(void);
|
||||
void InstallPaging(void);
|
||||
void InstallGDT(void);
|
||||
void InstallIDT(void);
|
||||
void InstallPaging(void);
|
||||
|
||||
/* ==================== Branding ==================== */
|
||||
char* FetchBrandStr(uint32_t* Str);
|
||||
char* FetchManufacturer(char* ID);
|
||||
char* FetchBrandStr(uint32_t* Str);
|
||||
char* FetchManufacturer(char* ID);
|
||||
|
||||
void ScanCPUFeatures(size_t RAX, size_t RCX);
|
||||
void ScanCPUFeatures(size_t RAX, size_t RCX);
|
||||
|
||||
/* ==================== Interrupts ==================== */
|
||||
|
||||
|
|
|
@ -43,12 +43,12 @@ __attribute__((aligned(4096))) static size_t FirstPageTable[512] = {0};
|
|||
*/
|
||||
|
||||
//Play sound using built in speaker
|
||||
static void play_sound(uint32_t nFrequence) {
|
||||
static void playPCSpeaker(uint32_t frequency) {
|
||||
uint32_t Div;
|
||||
uint8_t tmp;
|
||||
|
||||
//Set the PIT to the desired frequency
|
||||
Div = 1193180 / nFrequence;
|
||||
Div = 1193180 / frequency;
|
||||
WritePort(0x0043, 0xb6, 1);
|
||||
WritePort(0x0042, (uint8_t) (Div), 1);
|
||||
WritePort(0x0042, (uint8_t) (Div >> 8), 1);
|
||||
|
@ -61,22 +61,22 @@ __attribute__((aligned(4096))) static size_t FirstPageTable[512] = {0};
|
|||
}
|
||||
|
||||
//make it shutup
|
||||
static void nosound() {
|
||||
static void stopPCSpeaker() {
|
||||
uint8_t tmp = ReadPort(0x0061, 1) & 0xFC;
|
||||
|
||||
WritePort(0x0061, tmp, 1);
|
||||
}
|
||||
|
||||
//Make a beep
|
||||
void beep() {
|
||||
play_sound(1000);
|
||||
timer_wait(10);
|
||||
nosound();
|
||||
void beepPCSpeaker() {
|
||||
playPCSpeaker(1000);
|
||||
awaitTicks(10);
|
||||
stopPCSpeaker();
|
||||
//set_PIT_2(old_frequency);
|
||||
}
|
||||
|
||||
|
||||
void timer_wait(int ticks){
|
||||
void awaitTicks(int ticks) {
|
||||
uint64_t FinalTick = time + ticks;
|
||||
|
||||
int i = 0;
|
||||
|
@ -94,9 +94,19 @@ void PrepareSystem(FILELOADER_PARAMS* FLOP) {
|
|||
|
||||
|
||||
SetupPrinting(FLOP->GPU_Info->GPUs[0]);
|
||||
ClearScreen(Print_Info.defaultGPU);
|
||||
printf("1");
|
||||
SetupPrinting(FLOP->GPU_Info->GPUs[1]);
|
||||
ClearScreen(Print_Info.defaultGPU);
|
||||
printf("2");
|
||||
/* All print functions are now available. */
|
||||
printf("ready!");
|
||||
|
||||
serialInit();
|
||||
serialPrintf("Kernel has been given control of the computer.\nStarting bootstrap init.\n");
|
||||
|
||||
FLOP->RTServices->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, L"");
|
||||
|
||||
InstallGDT();
|
||||
InstallIDT();
|
||||
|
||||
|
|
|
@ -18,9 +18,7 @@
|
|||
and other functions that are uniquely
|
||||
related to the above tasks. */
|
||||
|
||||
#include <kernel/utils.h>
|
||||
#include <kernel/descriptor_tables.h>
|
||||
#include <kernel/serial.h>
|
||||
#include <kernel.h>
|
||||
|
||||
/*
|
||||
* The GDT gate setting function.
|
||||
|
|
|
@ -37,8 +37,6 @@ void SetupPrinting(EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE GPU) {
|
|||
Print_Info.cursorPos = 0;
|
||||
|
||||
Print_Info.scrollMode = 0;
|
||||
|
||||
ClearScreen(GPU);
|
||||
}
|
||||
|
||||
void WriteScaledFormatString(EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE GPU,
|
||||
|
|
|
@ -52,8 +52,8 @@ void ISR_Common(INTERRUPT_FRAME* Frame, size_t Exception) {
|
|||
if(Exception < 32) {
|
||||
/* ExceptionStrings is an array of c-strings defined in kernel.h */
|
||||
|
||||
serial_print(ExceptionStrings[Exception]);
|
||||
serial_print(" Exception.\r\n");
|
||||
serialPrint(ExceptionStrings[Exception]);
|
||||
serialPrint(" Exception.\r\n");
|
||||
printf("%s exception!", ExceptionStrings[Exception]);
|
||||
panic();
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ void ISR_Common(INTERRUPT_FRAME* Frame, size_t Exception) {
|
|||
into what went wrong. In pure Curle style, though, we just ignore the error code. */
|
||||
void ISR_Error_Common(EXCEPTION_FRAME* Frame, size_t Exception) {
|
||||
if(Exception < 32) {
|
||||
serial_print(ExceptionStrings[Exception]);
|
||||
serial_printf(" Exception. Context given: %d\r\n", Frame->ErrorCode);
|
||||
serialPrint(ExceptionStrings[Exception]);
|
||||
serialPrintf(" Exception. Context given: %d\r\n", Frame->ErrorCode);
|
||||
printf("%s exception. Context: %x", ExceptionStrings[Exception], Frame->ErrorCode);
|
||||
panic();
|
||||
}
|
||||
|
|
|
@ -23,8 +23,6 @@ void gdb_end() {} /* GDB Debugging stump */
|
|||
static size_t time = 0;
|
||||
|
||||
int kernel_main(FILELOADER_PARAMS* FLOP) {
|
||||
init_serial();
|
||||
serial_printf("Kernel has been given control of the computer.\nStarting bootstrap init.\n");
|
||||
/* The kernel is started in 64-bit Long Mode by Syncboot. */
|
||||
|
||||
/* PrepareSystem just initializes all hardware features and gets the system ready to execute every function.
|
||||
|
|
110
kernel/serial.c
110
kernel/serial.c
|
@ -14,132 +14,118 @@
|
|||
|
||||
#include <kernel.h>
|
||||
|
||||
#define SERIAL_DATA_PORT(base) (base)
|
||||
#define SERIAL_FIFO_COMMAND_PORT(base) (base + 2)
|
||||
#define SERIAL_LINE_COMMAND_PORT(base) (base + 3)
|
||||
#define SERIAL_MODEM_COMMAND_PORT(base) (base + 4)
|
||||
#define SERIAL_LINE_STATUS_PORT(base) (base + 5)
|
||||
#define SERIAL_COM1_BASE 0x3F8
|
||||
#define SERIAL_DATA(base) (base)
|
||||
#define SERIAL_DLAB(base) (base + 1)
|
||||
#define SERIAL_FIFO(base) (base + 2)
|
||||
#define SERIAL_LINE(base) (base + 3)
|
||||
#define SERIAL_MODEM(base) (base + 4)
|
||||
#define SERIAL_LINE_STATUS(base) (base + 5)
|
||||
#define COM1 0x3F8
|
||||
|
||||
#define SERIAL_LINE_ENABLE_DLAB 0x80
|
||||
|
||||
/** serial_set_baud_rate:
|
||||
/** serialSetBaudrate:
|
||||
* Sets the speed that data is sent via the serial port.
|
||||
* The default speed is 115200 bits/s.
|
||||
* The argument given is the divisor of the number.
|
||||
* Hence, the new speed becomes (115200/divisor) bits/s.
|
||||
*
|
||||
* @param com The COM port to configure.
|
||||
* @param divisor The new divisor for the baud rate.
|
||||
*/
|
||||
|
||||
void serial_set_baud_rate(uint16_t com, uint16_t divisor) {
|
||||
WritePort(SERIAL_LINE_COMMAND_PORT(com),
|
||||
SERIAL_LINE_ENABLE_DLAB, 1);
|
||||
void serialSetBaudrate() {
|
||||
WritePort(SERIAL_LINE(COM1), 0x80, 1);
|
||||
|
||||
WritePort(SERIAL_DATA_PORT(com),
|
||||
(divisor >> 8) & 0x00FF, 1);
|
||||
WritePort(SERIAL_DATA(COM1), 0x03, 1);
|
||||
|
||||
WritePort(SERIAL_DATA_PORT(com),
|
||||
divisor & 0x00FF, 1);
|
||||
WritePort(SERIAL_DLAB(COM1), 0x00, 1);
|
||||
|
||||
}
|
||||
|
||||
/** serial_configure_line:
|
||||
/** serialConfigure:
|
||||
* Sets a specific data byteset in the Serial hardware.
|
||||
* Required for expected operation.
|
||||
*
|
||||
* @param com The COM port to configure.
|
||||
*/
|
||||
|
||||
void serial_configure_line(uint16_t com) {
|
||||
void serialConfigure() {
|
||||
/* Bit: | 7 | 6 | 5 4 3 | 2 | 1 0 |
|
||||
* Content: | d | b | parity | s | dl |
|
||||
* Value: | 0 | 0 | 0 0 0 | 0 | 1 1 | = 0x03
|
||||
*/
|
||||
|
||||
WritePort(SERIAL_LINE_COMMAND_PORT(com), 0x0B, 1);
|
||||
WritePort(SERIAL_LINE(COM1), 0x03, 1);
|
||||
}
|
||||
|
||||
/** serial_configure_buffers:
|
||||
/** serialConfigureBuffers:
|
||||
* Enables FIFO (First In First Out) on the Serial line.
|
||||
* It clears both the receive and transmit queues.
|
||||
* It uses a 14 byte wide queue.
|
||||
*
|
||||
* @param com The COM port to configure.
|
||||
*/
|
||||
|
||||
void serial_configure_buffers(uint16_t com) {
|
||||
void serialConfigureBuffers() {
|
||||
/* Bit: | 7 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
* Content: | 1v1 | bs | r | dma | clt | clr | e |
|
||||
* Value: | 1 1 | 0 | 0 | 0 | 1 | 1 | 1 | = 0xC7
|
||||
*/
|
||||
|
||||
WritePort(SERIAL_FIFO_COMMAND_PORT(com), 0xC7, 1);
|
||||
WritePort(SERIAL_FIFO(COM1), 0xC7, 1);
|
||||
}
|
||||
|
||||
/** serial_configure_modem
|
||||
* @param com The COM port to configure.
|
||||
/** serialConfigureModem:
|
||||
*/
|
||||
|
||||
void serial_configure_modem(uint16_t com) {
|
||||
void serialConfigureModem() {
|
||||
/* Bit: | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
||||
* Content: | r | r | af | lb | ao2 | ao1 | rts | dtr |
|
||||
* Value: | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | = 0x03
|
||||
*/
|
||||
|
||||
WritePort(SERIAL_MODEM_COMMAND_PORT(com), 0x3, 1);
|
||||
WritePort(SERIAL_MODEM(COM1), 0x03, 1);
|
||||
}
|
||||
|
||||
/** serial_check_tqueue:
|
||||
/** serialCheck:
|
||||
* Checks whether the Transmit FIFO Queue is empty on the given port.
|
||||
*
|
||||
* @param com The COM port to check.
|
||||
* @return 0 If the queue is not empty.
|
||||
* 1 If the queue is empty.
|
||||
*/
|
||||
|
||||
int serial_check_tqueue(uint16_t com) {
|
||||
return ReadPort(SERIAL_LINE_STATUS_PORT(com), 1) & 0x20;
|
||||
int serialCheck() {
|
||||
return ReadPort(SERIAL_LINE_STATUS(COM1), 1) & 0x20;
|
||||
}
|
||||
|
||||
/** serial_write:
|
||||
* Prints a single character to the serial port.
|
||||
* Does nothing fancy.
|
||||
* @param com The COM port to write to.
|
||||
* @param data The character to write.
|
||||
*/
|
||||
|
||||
void serial_write(const char chr) {
|
||||
uint16_t com = SERIAL_COM1_BASE;
|
||||
void serialWrite(const char chr) {
|
||||
//Hang until we have access to the COM port.
|
||||
while(serial_check_tqueue(com) == 0);
|
||||
WritePort(com, chr, 1);
|
||||
while(!serialCheck());
|
||||
WritePort(COM1, chr, 1);
|
||||
}
|
||||
|
||||
/** serial_print:
|
||||
/** serialPrint:
|
||||
* Prints a string to the serial port.
|
||||
* Does not support ANSI codes, or color.
|
||||
*
|
||||
* @param com The COM port to write to.
|
||||
* @param data The string to write.
|
||||
*/
|
||||
|
||||
void serial_print(const char* data) {
|
||||
void serialPrint(const char* data) {
|
||||
for(size_t i = 0; i < strlen(data); i++) {
|
||||
serial_write(data[i]);
|
||||
serialWrite(data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/** serial_printf:
|
||||
/** serialPrintf:
|
||||
* A printf-style function for the serial port.
|
||||
*
|
||||
* @param format The base string - used to substitute the succeding values.
|
||||
* @param ... The substitutions.
|
||||
*/
|
||||
|
||||
void serial_printf(const char* format, ...) {
|
||||
uint16_t com = SERIAL_COM1_BASE;
|
||||
void serialPrintf(const char* format, ...) {
|
||||
uint32_t storage; //To hold temporary variables
|
||||
char stringstore[10] = {0}; //To convert ints to strings.
|
||||
va_list list;
|
||||
|
@ -152,46 +138,46 @@ void serial_printf(const char* format, ...) {
|
|||
if(format[i+1] == 'd') {
|
||||
|
||||
storage = va_arg(list, int);
|
||||
int_to_ascii(storage, stringstore);
|
||||
serial_print(stringstore);
|
||||
empty_string(stringstore);
|
||||
inttoa(storage, stringstore);
|
||||
serialPrint(stringstore);
|
||||
zeroString(stringstore);
|
||||
i += 2;
|
||||
|
||||
} else if(format[i+1] == 'x') {
|
||||
|
||||
storage = va_arg(list, int);
|
||||
int_to_hex(storage, stringstore);
|
||||
serial_print(stringstore);
|
||||
empty_string(stringstore);
|
||||
itoh(storage, stringstore);
|
||||
serialPrint(stringstore);
|
||||
zeroString(stringstore);
|
||||
i += 2;
|
||||
|
||||
} else if(format[i+1] == 's') {
|
||||
|
||||
serial_print(va_arg(list, char*));
|
||||
serialPrint(va_arg(list, char*));
|
||||
i += 2;
|
||||
|
||||
} else {
|
||||
serial_print("ERROR: Attempting to parse unknown format string.");
|
||||
serialPrint("ERROR: Attempting to parse unknown format string.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
serial_write(format[i]);
|
||||
serialWrite(format[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
va_end(list); //Free the list
|
||||
}
|
||||
|
||||
void init_serial() {
|
||||
void serialInit() {
|
||||
// Disable interrupts
|
||||
WritePort(SERIAL_COM1_BASE + 1, 0x00, 1);
|
||||
WritePort(SERIAL_DLAB(COM1), 0x00, 1);
|
||||
|
||||
// Set baud rate divisor.
|
||||
serial_set_baud_rate(SERIAL_COM1_BASE, 3);
|
||||
// Set baud rate divisor to 3
|
||||
serialSetBaudrate();
|
||||
// 8 bits, no parity, one stop bit.
|
||||
serial_configure_line(SERIAL_COM1_BASE);
|
||||
serialConfigure();
|
||||
// Enable FIFO and clear buffers.
|
||||
serial_configure_buffers(SERIAL_COM1_BASE);
|
||||
serialConfigureBuffers();
|
||||
// Enable IRQs, RTS/DSR set.
|
||||
serial_configure_modem(SERIAL_COM1_BASE);
|
||||
serialConfigureModem();
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ int memcmp (const void *str1, const void *str2, size_t count) {
|
|||
* @param string: The string to be written into.
|
||||
*/
|
||||
|
||||
void int_to_ascii(int num, char* string) {
|
||||
void inttoa(int num, char* string) {
|
||||
size_t i = 0; //Counter.
|
||||
// TODO: Convert this to a for-loop?
|
||||
int32_t calc = 0;
|
||||
|
@ -157,8 +157,8 @@ char* itoc(size_t num) {
|
|||
* @param num: Number to convert
|
||||
* @param string: String pointer to put the converted number.
|
||||
*/
|
||||
void int_to_hex(int num, char* string) {
|
||||
empty_string(string);
|
||||
void itoh(int num, char* string) {
|
||||
zeroString(string);
|
||||
|
||||
uint8_t i = 8;
|
||||
uint8_t temp = 0;
|
||||
|
@ -182,7 +182,7 @@ void int_to_hex(int num, char* string) {
|
|||
* @param string: The string to empty.
|
||||
*/
|
||||
|
||||
void empty_string(char* string) {
|
||||
void zeroString(char* string) {
|
||||
size_t len = strlen(string);
|
||||
|
||||
for(size_t i = 0; i < len + 1; i++) {
|
||||
|
|
91
makefile
91
makefile
|
@ -1,91 +0,0 @@
|
|||
DEFAULT_HOST:=i686-elf
|
||||
HOST?=DEFAULT_HOST
|
||||
HOSTARCH:=i386
|
||||
CC:=$(PREFIX)/bin/$(DEFAULT_HOST)-gcc
|
||||
|
||||
CFLAGS?= -O0 -g -fno-pie -fno-stack-protector -Wl,--build-id=none
|
||||
CPPFLAGS?=
|
||||
LDFLAGS?=
|
||||
LIBS?=
|
||||
|
||||
DESTDIR?=
|
||||
PREFIX?=/usr/local
|
||||
EXEC_PREFIX?=$(PREFIX)
|
||||
BOOTDIR?=$(EXEC_PREFIX)/boot
|
||||
INCLUDEDIR?=$(PREFIX)/include
|
||||
|
||||
CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra -I"../include" -I"../../include"
|
||||
CPPFLAGS:=$(CPPFLAGS) -D__is_kernel -Iinclude
|
||||
LDFLAGS:=$(LDFLAGS)
|
||||
LIBS:=$(LIBS) -nostdlib -lgcc
|
||||
|
||||
ARCHDIR=arch/$(HOSTARCH)
|
||||
|
||||
include $(ARCHDIR)/make.config
|
||||
|
||||
CFLAGS:=$(CFLAGS) $(KERNEL_ARCH_CFLAGS)
|
||||
CPPFLAGS:=$(CPPFLAGS) $(KERNEL_ARCH_CPPFLAGS)
|
||||
LDFLAGS:=$(LDFLAGS) $(KERNEL_ARCH_LDFLAGS)
|
||||
LIBS:=$(LIBS) $(KERNEL_ARCH_LIBS)
|
||||
|
||||
KERNEL_OBJS= \
|
||||
$(KERNEL_ARCH_OBJS) \
|
||||
kernel/utils.o \
|
||||
kernel/serial.o \
|
||||
kernel/interrupts.o \
|
||||
kernel/descriptor_tables.o\
|
||||
kernel/kernel.o
|
||||
|
||||
OBJS=\
|
||||
$(KERNEL_OBJS)
|
||||
|
||||
LINK_LIST=\
|
||||
$(LDFLAGS) \
|
||||
$(KERNEL_OBJS) \
|
||||
$(LIBS) \
|
||||
|
||||
.PHONY: all clean install install-headers install-kernel
|
||||
.SUFFIXES: .o .c .s
|
||||
|
||||
all: red.kernel
|
||||
|
||||
red.kernel: $(OBJS) $(ARCHDIR)/linker.ld
|
||||
$(CC) -T $(ARCHDIR)/linker.ld -o $@ $(CFLAGS) $(LINK_LIST)
|
||||
|
||||
kernel/interrupts.o:
|
||||
$(CC) -MD -c kernel/interrupts.c -o $@ -std=gnu11 $(CFLAGS) -mno-red-zone -mgeneral-regs-only $(CPPFLAGS)
|
||||
|
||||
.c.o:
|
||||
$(CC) -MD -c $< -o $@ -std=gnu11 $(CFLAGS) $(CPPFLAGS)
|
||||
.s.o:
|
||||
nasm -f elf $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f red.kernel
|
||||
rm -f $(OBJS) *.o */*.o */*/*.o
|
||||
rm -f $(OBJS:.o=.d) *.d */*.d */*/*.d
|
||||
|
||||
install: install-headers install-kernel gen-iso
|
||||
|
||||
install-headers:
|
||||
mkdir -p $(DESTDIR)$(INCLUDEDIR)
|
||||
cp -R --preserve=timestamps include/. $(DESTDIR)$(INCLUDEDIR)/.
|
||||
|
||||
install-kernel: red.kernel
|
||||
mkdir -p $(DESTDIR)$(BOOTDIR)
|
||||
cp red.kernel $(DESTDIR)$(BOOTDIR)
|
||||
|
||||
gen-iso:
|
||||
rm -f red.iso
|
||||
cp red.kernel iso/boot/kernel.elf
|
||||
genisoimage -R \
|
||||
-b boot/grub/stage2_eltorito \
|
||||
-no-emul-boot \
|
||||
-A ProjectRED \
|
||||
-input-charset utf8 \
|
||||
-quiet \
|
||||
-boot-info-table \
|
||||
-o red.iso \
|
||||
iso
|
||||
|
||||
-include $(OBJS:.o=.d)
|
Loading…
Reference in New Issue
Block a user