added a main routine
This commit is contained in:
parent
ded713bb4e
commit
0cd3ab3fdb
5 changed files with 41 additions and 5 deletions
|
@ -30,7 +30,7 @@ LOAD_PROFILE(${ARCH} ${SYSTEM})
|
|||
ADD_EXECUTABLE(kernel ${PLATFORM_SRCS} ${ISA_SRCS} ${GENERIC_SRCS})
|
||||
SET(CMAKE_ASM-ATT_COMPILE_OBJECT
|
||||
"<CMAKE_C_COMPILER> -g -m32 -x assembler-with-cpp -I../../ -I../../libk/include/ -I../../kernel/src/include/ ${ISA_ASM_FLAGS} ${PLATFORM_ASM_FLAGS} -c -o <OBJECT> <SOURCE>")
|
||||
SET(CMAKE_C_FLAGS "-g -m32 -w -Werror -Wno-unused -Wno-unused-variable -std=c11 -ffreestanding -I../../ -I../../libk/include/ -I../../kernel/src/include/ ${ISA_C_FLAGS} ${PLATFORM_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS "-g -m32 -w -Werror -Wno-unused -Wno-unused-variable -ffreestanding -fno-rtti -fno-exceptions -std=gnu++17 -I../../ -I../../libk/include/ -I../../kernel/src/include/ ${ISA_CXX_FLAGS} ${PLATFORM_CXX_FLAGS}")
|
||||
SET(CMAKE_C_FLAGS "-g -m32 -w -Werror -Wno-unused -Wno-unused-variable -fno-use-cxa-atexit -std=c11 -ffreestanding -I../../ -I../../libk/include/ -I../../kernel/src/include/ ${ISA_C_FLAGS} ${PLATFORM_C_FLAGS}")
|
||||
SET(CMAKE_CXX_FLAGS "-g -m32 -w -Werror -Wno-unused -Wno-unused-variable -fno-use-cxa-atexit -ffreestanding -fno-rtti -fno-exceptions -std=gnu++17 -I../../ -I../../libk/include/ -I../../kernel/src/include/ ${ISA_CXX_FLAGS} ${PLATFORM_CXX_FLAGS}")
|
||||
SET_TARGET_PROPERTIES(kernel PROPERTIES LINK_FLAGS
|
||||
"-T ../../kernel/${PLATFORM_LAYOUT} -N ${ISA_LINKER_FLAGS} ${PLATFORM_LINKER_FLAGS} -nostdlib -nodefaultlibs -lgcc -Wl,--gc-sections")
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#include <tty.hpp>
|
||||
#include <base.hpp>
|
||||
#include "../../../hw/pc/cgaterm/cgaterm.hpp"
|
||||
CGATerm term;
|
||||
void main();
|
||||
extern "C" void start() {
|
||||
CGATerm x = CGATerm();
|
||||
x << "Hallo!\n";
|
||||
main();
|
||||
}
|
||||
void drivers_init() {
|
||||
setMainTTY(&term);
|
||||
--term;
|
||||
}
|
||||
|
|
5
kernel/src/include/base.hpp
Normal file
5
kernel/src/include/base.hpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
#pragma once
|
||||
#include <tty.hpp>
|
||||
#include <kobject.hpp>
|
||||
extern TTY *out;
|
||||
void setMainTTY(Kobject *obj);
|
14
kernel/src/main.cpp
Normal file
14
kernel/src/main.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <base.hpp>
|
||||
void drivers_init();
|
||||
extern "C" void(*start_ctors)();
|
||||
extern "C" void(*end_ctors)();
|
||||
extern "C" void(*start_dtors)();
|
||||
extern "C" void(*end_dtors)();
|
||||
void main() {
|
||||
for(auto ctor=&start_ctors;ctor<&end_ctors;ctor++)
|
||||
(**ctor)();
|
||||
drivers_init();
|
||||
*out << "Hallo!\n";
|
||||
for(auto dtor=&start_dtors;dtor!=&end_dtors;dtor++)
|
||||
(**dtor)();
|
||||
}
|
12
kernel/src/object_init.cpp
Normal file
12
kernel/src/object_init.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <base.hpp>
|
||||
TTY *out;
|
||||
bool tty_set = false;
|
||||
void setMainTTY(Kobject *obj) {
|
||||
if(obj->type == kobjectType::TTY) {
|
||||
++*obj;
|
||||
if(tty_set)
|
||||
--*out;
|
||||
out=(TTY*)obj;
|
||||
tty_set=true;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue