diff --git a/src/Makefile b/src/Makefile index 4988716..533f55f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -13,7 +13,7 @@ COPTIM=-O2 CLDSCR=-T kernel.ld CWARNS=-pedantic -Wall -Wextra -Werror CFLAGS=-nostdlib -ffreestanding -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -CINCLUDES=-I./kaleid +CINCLUDES=-isystem. CDEFINES= CC=$(CCNAME) $(COPTIM) $(CWARNS) $(CFLAGS) $(CDEFINES) $(CINCLUDES) diff --git a/src/kaleid/common/assert.h b/src/kaleid/common/assert.h index 8c18ad6..10b663d 100644 --- a/src/kaleid/common/assert.h +++ b/src/kaleid/common/assert.h @@ -11,7 +11,7 @@ #define _KALCOMM_ASSERT_H #ifndef _KALCOMM_COMMON_H -# error "don't include common/types.h without common/common.h" +# error "don't include kaleid/common/types.h without kaleid/common/common.h" #endif #ifdef _OSK_SOURCE diff --git a/src/kaleid/common/atomic.h b/src/kaleid/common/atomic.h index 56a4afb..569ecdb 100644 --- a/src/kaleid/common/atomic.h +++ b/src/kaleid/common/atomic.h @@ -11,7 +11,7 @@ #define _KALCOMM_ATOMIC_H #ifndef _KALCOMM_COMMON_H -# error "don't include common/types.h without common/common.h" +# error "don't include kaleid/common/types.h without kaleid/common/common.h" #endif // atomic_t defined in common/types.h diff --git a/src/kaleid/common/common.h b/src/kaleid/common/common.h index 52c3b44..5b4dc38 100644 --- a/src/kaleid/common/common.h +++ b/src/kaleid/common/common.h @@ -42,13 +42,13 @@ #endif #ifdef _KALEID_KERNEL -# include "kernel/config.h" +# include #endif -#include "common/types.h" -#include "common/atomic.h" -#include "common/status.h" -#include "common/assert.h" +#include +#include +#include +#include #endif diff --git a/src/kaleid/common/convert.h b/src/kaleid/common/convert.h index 737f016..915a071 100644 --- a/src/kaleid/common/convert.h +++ b/src/kaleid/common/convert.h @@ -11,7 +11,7 @@ #define _KALCOMM_CONVERT_H #ifndef _KALCOMM_COMMON_H -#include "common/common.h" +#include #endif #ifndef _OSK_SOURCE diff --git a/src/kaleid/common/lib/convert.c b/src/kaleid/common/lib/convert.c index 284f61f..49b8529 100644 --- a/src/kaleid/common/lib/convert.c +++ b/src/kaleid/common/lib/convert.c @@ -7,7 +7,7 @@ // Desc: Conversion utilities // //----------------------------------------------------------------------------// -#include "common/string.h" +#include // // Digits table for bases <=36 diff --git a/src/kaleid/common/lib/memory.c b/src/kaleid/common/lib/memory.c index 6ef23ce..7f7c05d 100644 --- a/src/kaleid/common/lib/memory.c +++ b/src/kaleid/common/lib/memory.c @@ -7,7 +7,7 @@ // Desc: mem*() functions // //----------------------------------------------------------------------------// -#include "common/memory.h" +#include // // Set "bytes"-many bytes starting from ptr to val diff --git a/src/kaleid/common/lib/sprintf.c b/src/kaleid/common/lib/sprintf.c index e26ded9..b1b86c6 100644 --- a/src/kaleid/common/lib/sprintf.c +++ b/src/kaleid/common/lib/sprintf.c @@ -7,7 +7,7 @@ // Desc: sprintf()-related functions // //----------------------------------------------------------------------------// -#include "common/string.h" +#include // // Format str according to fmt using ellipsed arguments diff --git a/src/kaleid/common/lib/status.c b/src/kaleid/common/lib/status.c index 5e8115c..254e1aa 100644 --- a/src/kaleid/common/lib/status.c +++ b/src/kaleid/common/lib/status.c @@ -7,7 +7,7 @@ // Desc: Implementation of describe_status() // //----------------------------------------------------------------------------// -#include "common/common.h" +#include static const char *descriptions[] = { [-SUCCESS] = "Success", diff --git a/src/kaleid/common/lib/string.c b/src/kaleid/common/lib/string.c index 464ff2e..b5178b9 100644 --- a/src/kaleid/common/lib/string.c +++ b/src/kaleid/common/lib/string.c @@ -7,7 +7,7 @@ // Desc: String-related functions // //----------------------------------------------------------------------------// -#include "common/string.h" +#include // TODO multibyte, assembly diff --git a/src/kaleid/common/memory.h b/src/kaleid/common/memory.h index 31f6a6b..a0f8366 100644 --- a/src/kaleid/common/memory.h +++ b/src/kaleid/common/memory.h @@ -11,7 +11,7 @@ #define _KALCOMM_MEMORY_H #ifndef _KALCOMM_COMMON_H -# include "common/common.h" +# include #endif #ifndef _OSK_SOURCE diff --git a/src/kaleid/common/status.h b/src/kaleid/common/status.h index 898c62a..7d674ff 100644 --- a/src/kaleid/common/status.h +++ b/src/kaleid/common/status.h @@ -11,7 +11,7 @@ #define _KALCOMM_STATUS_H #ifndef _KALCOMM_COMMON_H -# error "don't include common/types.h without common/common.h" +# error "don't include kaleid/common/types.h without kaleid/common/common.h" #endif #ifndef _OSK_SOURCE diff --git a/src/kaleid/common/string.h b/src/kaleid/common/string.h index 61056be..5440138 100644 --- a/src/kaleid/common/string.h +++ b/src/kaleid/common/string.h @@ -12,11 +12,11 @@ #define _KALCOMM_STRING_H #ifndef _KALCOMM_COMMON_H -# include "common/common.h" +# include #endif #ifndef _KALCOMM_CONVERT_H -# include "common/convert.h" +# include #endif #ifndef _OSK_SOURCE diff --git a/src/kaleid/common/sub/memory.c b/src/kaleid/common/sub/memory.c index aaecb6b..a12a9c6 100644 --- a/src/kaleid/common/sub/memory.c +++ b/src/kaleid/common/sub/memory.c @@ -10,7 +10,7 @@ // XXX to be improved before being brought back // to be tested with more alignment sizes -#include "common/memory.h" +#include // to be moved #define QWORD_SIZE 8 diff --git a/src/kaleid/common/types.h b/src/kaleid/common/types.h index bf74580..910ceac 100644 --- a/src/kaleid/common/types.h +++ b/src/kaleid/common/types.h @@ -12,7 +12,7 @@ #define _KALCOMM_TYPES_H #ifndef _KALCOMM_COMMON_H -# error "don't include common/types.h without common/common.h" +# error "don't include kaleid/common/types.h without kaleid/common/common.h" #endif typedef unsigned char uchar; diff --git a/src/kaleid/kernel/init.c b/src/kaleid/kernel/init.c index aa794fe..5483a22 100644 --- a/src/kaleid/kernel/init.c +++ b/src/kaleid/kernel/init.c @@ -7,18 +7,25 @@ // Desc: Kernel entry point // //----------------------------------------------------------------------------// -#include "kernel/init.h" -#include "kernel/ke/panic.h" -#include "kernel/io/terminal.h" +#include +#include +#include // // Entry point of kaleid-kernel.elf // -void kstart(void) +void DosStartKern(void) { + // we're not ready to deal with interrupts + DosDisableInterrupts(); + + // booting! DosSetKernState(KSTATE_INIT); + // kernel terminals DosInitTerms(); + + // we're out DosPanic("Goodbye World :("); } diff --git a/src/kaleid/kernel/init.h b/src/kaleid/kernel/init.h index bb80788..37e831c 100644 --- a/src/kaleid/kernel/init.h +++ b/src/kaleid/kernel/init.h @@ -10,10 +10,10 @@ #ifndef _KALKERN_INIT_H #define _KALKERN_INIT_H -#include "common/common.h" +#include // kernel entry point -void kstart(void); +void DosStartKern(void); #endif diff --git a/src/kaleid/kernel/io/ports.c b/src/kaleid/kernel/io/ports.c index fa824a0..4f5c8fe 100644 --- a/src/kaleid/kernel/io/ports.c +++ b/src/kaleid/kernel/io/ports.c @@ -7,7 +7,7 @@ // Desc: Ports I/O // //----------------------------------------------------------------------------// -#include "kernel/io/ports.h" +#include diff --git a/src/kaleid/kernel/io/ports.h b/src/kaleid/kernel/io/ports.h index 8df790d..a92ddb6 100644 --- a/src/kaleid/kernel/io/ports.h +++ b/src/kaleid/kernel/io/ports.h @@ -11,7 +11,7 @@ #define _KALKERN_IO_PORTS_H #ifndef _KALCOMM_COMMON_H -#include "common/common.h" +#include #endif #define DosWriteByteOnPort(port,val) asm volatile ("outb %1, %0" : : "dN" (port), "a" (value)) diff --git a/src/kaleid/kernel/io/terminal.c b/src/kaleid/kernel/io/terminal.c index e172daf..79da9b4 100644 --- a/src/kaleid/kernel/io/terminal.c +++ b/src/kaleid/kernel/io/terminal.c @@ -7,7 +7,7 @@ // Desc: Early terminal functions // //----------------------------------------------------------------------------// -#include "kernel/io/terminal.h" +#include // // VGA-related macros @@ -17,7 +17,7 @@ #define ComputeEntry(ch, cl) (((ushort)(ch)) | (ushort)(cl) << 8) // -// VGA output +// VGA output // static terminal_t _vga_term = { .kt_buffer = (ushort *)0xB8000, @@ -37,6 +37,13 @@ static terminal_t _vga_term = { // terminal_t *stdout; +#ifndef _NO_DEBUG +// +// Debugging terminal +// +terminal_t *stddbg; +#endif + // // Initialize standard output // @@ -46,6 +53,7 @@ void DosInitTerms(void) #ifndef _NO_DEBUG _vga_term.kt_init = TRUE; + stddbg = &_vga_term; #endif // to be switched to VESA diff --git a/src/kaleid/kernel/io/terminal.h b/src/kaleid/kernel/io/terminal.h index 229be43..63327fb 100644 --- a/src/kaleid/kernel/io/terminal.h +++ b/src/kaleid/kernel/io/terminal.h @@ -11,7 +11,7 @@ #define _KALKERN_IO_KTERM_H #ifndef _KALCOMM_COMMON_H -#include "common/common.h" +#include #endif // all available colors @@ -53,10 +53,12 @@ status_t DosChTermColor(terminal_t *, uchar); void DosPutOnTerm_Unlocked(terminal_t *, char); #endif -#define ktclear() kterm_clear(kt_stdout) -#define ktputch(c) kterm_putch(kt_stdout, (c)) -#define ktprint(s) kterm_print(kt_stdout, (s)) -#define ktchcol(c) kterm_change_color(kt_stdout, (c)) +#ifndef _NO_DEBUG +extern terminal_t *stddbg; +# define DebugLog(...) DosPutOnTerm(stddbg, __VA_ARGS__) +#else +# define DebugLog(...) +#endif #define DosLockTerm(kt) #define DosTryLockTerm(kt) diff --git a/src/kaleid/kernel/ke/panic.c b/src/kaleid/kernel/ke/panic.c index 38f8f9d..028729c 100644 --- a/src/kaleid/kernel/ke/panic.c +++ b/src/kaleid/kernel/ke/panic.c @@ -7,9 +7,9 @@ // Desc: How NOT to panic 101 // //----------------------------------------------------------------------------// -#include "kernel/ke/panic.h" -#include "kernel/ke/state.h" -#include "kernel/io/terminal.h" +#include +#include +#include // // Panic message diff --git a/src/kaleid/kernel/ke/panic.h b/src/kaleid/kernel/ke/panic.h index f73387a..4b7883a 100644 --- a/src/kaleid/kernel/ke/panic.h +++ b/src/kaleid/kernel/ke/panic.h @@ -10,7 +10,7 @@ #ifndef _KALKERN_KE_PANIC_H #define _KALKERN_KE_PANIC_H -#include "kernel/ke/state.h" +#include extern const char *__panicstr; noreturn void DosPanic(const char *); diff --git a/src/kaleid/kernel/ke/state.c b/src/kaleid/kernel/ke/state.c index e8a79fe..fae844d 100644 --- a/src/kaleid/kernel/ke/state.c +++ b/src/kaleid/kernel/ke/state.c @@ -7,7 +7,7 @@ // Desc: Current kernel state // //----------------------------------------------------------------------------// -#include "kernel/ke/state.h" +#include // // Current kernel state diff --git a/src/kaleid/kernel/ke/state.h b/src/kaleid/kernel/ke/state.h index ba6bf8d..7ca09a9 100644 --- a/src/kaleid/kernel/ke/state.h +++ b/src/kaleid/kernel/ke/state.h @@ -11,7 +11,7 @@ #define _KALKERN_KE_STATE_H #ifndef _KALCOMM_COMMON_H -#include "common/common.h" +#include #endif // XXX improve this diff --git a/src/kaleid/kernel/mm/malloc.c b/src/kaleid/kernel/mm/malloc.c index 5c62036..1ffa3c1 100644 --- a/src/kaleid/kernel/mm/malloc.c +++ b/src/kaleid/kernel/mm/malloc.c @@ -8,5 +8,5 @@ // Only exists to trigger Neox // //----------------------------------------------------------------------------// -#include "kernel/mm/malloc.h" +#include diff --git a/src/kaleid/kernel/mm/malloc.h b/src/kaleid/kernel/mm/malloc.h index 9d63aba..7d27929 100644 --- a/src/kaleid/kernel/mm/malloc.h +++ b/src/kaleid/kernel/mm/malloc.h @@ -11,7 +11,7 @@ #ifndef _KALKERN_MM_MALLOC_H #define _KALKERN_MM_MALLOC_H -#include "common/common.h" +#include #endif diff --git a/src/kaleid/linux/test-common.c b/src/kaleid/linux/test-common.c index edae890..b23e00a 100644 --- a/src/kaleid/linux/test-common.c +++ b/src/kaleid/linux/test-common.c @@ -11,9 +11,9 @@ #include #define KEEP_KALCOMM_TYPES_MINIMAL -#include "common/common.h" -#include "common/string.h" -#include "common/memory.h" +#include +#include +#include int main(int argc, char *argv[]) { diff --git a/src/kernel.ld b/src/kernel.ld index 86b66ea..d8fa35a 100644 --- a/src/kernel.ld +++ b/src/kernel.ld @@ -1,4 +1,4 @@ -ENTRY(kstart) +ENTRY(DosStartKern) SECTIONS { . = 0x4000; /* XXX 0x4000 is temporary */