diff --git a/src/include/hlib.h b/src/include/hlib.h index c1e77c9..594c104 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -22,6 +22,7 @@ extern void log(char *); extern void subscribeInterrupt(uint32_t intNo, void *handler); extern uint32_t loadFromInitrd(char *name); +extern uint32_t loadFromInitrdUninitialized(char *name); extern uint32_t createEvent(char *name); extern uint32_t syscall(uint32_t function, uint32_t parameter0, uint32_t parameter1, uint32_t parameter2, diff --git a/src/include/hlib.h b/src/include/hlib.h index c1e77c9..594c104 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -22,6 +22,7 @@ extern void log(char *); extern void subscribeInterrupt(uint32_t intNo, void *handler); extern uint32_t loadFromInitrd(char *name); +extern uint32_t loadFromInitrdUninitialized(char *name); extern uint32_t createEvent(char *name); extern uint32_t syscall(uint32_t function, uint32_t parameter0, uint32_t parameter1, uint32_t parameter2, diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 5b094f7..a1c03fe 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -42,6 +42,9 @@ service->nameHash, getServiceId(service)); }) ; + if (currentSyscall->respondingTo) { + listAdd(&callsToProcess, currentSyscall->respondingTo); + } free(currentSyscall); } diff --git a/src/include/hlib.h b/src/include/hlib.h index c1e77c9..594c104 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -22,6 +22,7 @@ extern void log(char *); extern void subscribeInterrupt(uint32_t intNo, void *handler); extern uint32_t loadFromInitrd(char *name); +extern uint32_t loadFromInitrdUninitialized(char *name); extern uint32_t createEvent(char *name); extern uint32_t syscall(uint32_t function, uint32_t parameter0, uint32_t parameter1, uint32_t parameter2, diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 5b094f7..a1c03fe 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -42,6 +42,9 @@ service->nameHash, getServiceId(service)); }) ; + if (currentSyscall->respondingTo) { + listAdd(&callsToProcess, currentSyscall->respondingTo); + } free(currentSyscall); } diff --git a/src/kernel/main.c b/src/kernel/main.c index 2d69c20..ae6b0d1 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -22,10 +22,12 @@ return loadElf(elfData, name); } -Service *loadProgram(char *name, Syscall *respondingTo) { +Service *loadProgram(char *name, Syscall *respondingTo, bool initialize) { Service *service = readInitrdProgram(name); - ServiceFunction *provider = findFunction(service, "main"); - scheduleFunction(provider, respondingTo); + if (initialize) { + ServiceFunction *provider = findFunction(service, "main"); + scheduleFunction(provider, respondingTo); + } return service; } @@ -34,7 +36,7 @@ void *address = kernelMapPhysicalCount(multibootInfo, 4); initrd = findInitrd(address, &initrdSize); hlib = readInitrdProgram("hlib"); - loadProgram("loader", NULL); + loadProgram("loader", NULL, true); } void kernelMain(void *multibootInfo) { diff --git a/src/include/hlib.h b/src/include/hlib.h index c1e77c9..594c104 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -22,6 +22,7 @@ extern void log(char *); extern void subscribeInterrupt(uint32_t intNo, void *handler); extern uint32_t loadFromInitrd(char *name); +extern uint32_t loadFromInitrdUninitialized(char *name); extern uint32_t createEvent(char *name); extern uint32_t syscall(uint32_t function, uint32_t parameter0, uint32_t parameter1, uint32_t parameter2, diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 5b094f7..a1c03fe 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -42,6 +42,9 @@ service->nameHash, getServiceId(service)); }) ; + if (currentSyscall->respondingTo) { + listAdd(&callsToProcess, currentSyscall->respondingTo); + } free(currentSyscall); } diff --git a/src/kernel/main.c b/src/kernel/main.c index 2d69c20..ae6b0d1 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -22,10 +22,12 @@ return loadElf(elfData, name); } -Service *loadProgram(char *name, Syscall *respondingTo) { +Service *loadProgram(char *name, Syscall *respondingTo, bool initialize) { Service *service = readInitrdProgram(name); - ServiceFunction *provider = findFunction(service, "main"); - scheduleFunction(provider, respondingTo); + if (initialize) { + ServiceFunction *provider = findFunction(service, "main"); + scheduleFunction(provider, respondingTo); + } return service; } @@ -34,7 +36,7 @@ void *address = kernelMapPhysicalCount(multibootInfo, 4); initrd = findInitrd(address, &initrdSize); hlib = readInitrdProgram("hlib"); - loadProgram("loader", NULL); + loadProgram("loader", NULL, true); } void kernelMain(void *multibootInfo) { diff --git a/src/kernel/multiboot/initrdSyscall.c b/src/kernel/multiboot/initrdSyscall.c index c918ede..1164adc 100644 --- a/src/kernel/multiboot/initrdSyscall.c +++ b/src/kernel/multiboot/initrdSyscall.c @@ -2,12 +2,12 @@ #include #include -extern void loadProgram(char *name, Syscall *respondingTo); +extern void loadProgram(char *name, Syscall *respondingTo, bool initialize); void handleLoadFromInitrdSyscall(Syscall *call) { call->returnValue = listCount(services); char *name = retrieveString(call->parameters[0]); Service *service = call->service; - loadProgram(name, (void *)call); - call->avoidReschedule = true; + loadProgram(name, (void *)call, call->parameters[1]); + call->avoidReschedule = call->parameters[1]; } diff --git a/src/include/hlib.h b/src/include/hlib.h index c1e77c9..594c104 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -22,6 +22,7 @@ extern void log(char *); extern void subscribeInterrupt(uint32_t intNo, void *handler); extern uint32_t loadFromInitrd(char *name); +extern uint32_t loadFromInitrdUninitialized(char *name); extern uint32_t createEvent(char *name); extern uint32_t syscall(uint32_t function, uint32_t parameter0, uint32_t parameter1, uint32_t parameter2, diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 5b094f7..a1c03fe 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -42,6 +42,9 @@ service->nameHash, getServiceId(service)); }) ; + if (currentSyscall->respondingTo) { + listAdd(&callsToProcess, currentSyscall->respondingTo); + } free(currentSyscall); } diff --git a/src/kernel/main.c b/src/kernel/main.c index 2d69c20..ae6b0d1 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -22,10 +22,12 @@ return loadElf(elfData, name); } -Service *loadProgram(char *name, Syscall *respondingTo) { +Service *loadProgram(char *name, Syscall *respondingTo, bool initialize) { Service *service = readInitrdProgram(name); - ServiceFunction *provider = findFunction(service, "main"); - scheduleFunction(provider, respondingTo); + if (initialize) { + ServiceFunction *provider = findFunction(service, "main"); + scheduleFunction(provider, respondingTo); + } return service; } @@ -34,7 +36,7 @@ void *address = kernelMapPhysicalCount(multibootInfo, 4); initrd = findInitrd(address, &initrdSize); hlib = readInitrdProgram("hlib"); - loadProgram("loader", NULL); + loadProgram("loader", NULL, true); } void kernelMain(void *multibootInfo) { diff --git a/src/kernel/multiboot/initrdSyscall.c b/src/kernel/multiboot/initrdSyscall.c index c918ede..1164adc 100644 --- a/src/kernel/multiboot/initrdSyscall.c +++ b/src/kernel/multiboot/initrdSyscall.c @@ -2,12 +2,12 @@ #include #include -extern void loadProgram(char *name, Syscall *respondingTo); +extern void loadProgram(char *name, Syscall *respondingTo, bool initialize); void handleLoadFromInitrdSyscall(Syscall *call) { call->returnValue = listCount(services); char *name = retrieveString(call->parameters[0]); Service *service = call->service; - loadProgram(name, (void *)call); - call->avoidReschedule = true; + loadProgram(name, (void *)call, call->parameters[1]); + call->avoidReschedule = call->parameters[1]; } diff --git a/src/userland/hlib/main.c b/src/userland/hlib/main.c index c8082c6..8ec79a2 100644 --- a/src/userland/hlib/main.c +++ b/src/userland/hlib/main.c @@ -24,6 +24,11 @@ uint32_t loadFromInitrd(char *name) { uintptr_t id = insertString(name); + return syscall(SYS_LOAD_INITRD, id, 1, 0, 0); +} + +uint32_t loadFromInitrdUninitialized(char *name) { + uintptr_t id = insertString(name); return syscall(SYS_LOAD_INITRD, id, 0, 0, 0); } diff --git a/src/include/hlib.h b/src/include/hlib.h index c1e77c9..594c104 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -22,6 +22,7 @@ extern void log(char *); extern void subscribeInterrupt(uint32_t intNo, void *handler); extern uint32_t loadFromInitrd(char *name); +extern uint32_t loadFromInitrdUninitialized(char *name); extern uint32_t createEvent(char *name); extern uint32_t syscall(uint32_t function, uint32_t parameter0, uint32_t parameter1, uint32_t parameter2, diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 5b094f7..a1c03fe 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -42,6 +42,9 @@ service->nameHash, getServiceId(service)); }) ; + if (currentSyscall->respondingTo) { + listAdd(&callsToProcess, currentSyscall->respondingTo); + } free(currentSyscall); } diff --git a/src/kernel/main.c b/src/kernel/main.c index 2d69c20..ae6b0d1 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -22,10 +22,12 @@ return loadElf(elfData, name); } -Service *loadProgram(char *name, Syscall *respondingTo) { +Service *loadProgram(char *name, Syscall *respondingTo, bool initialize) { Service *service = readInitrdProgram(name); - ServiceFunction *provider = findFunction(service, "main"); - scheduleFunction(provider, respondingTo); + if (initialize) { + ServiceFunction *provider = findFunction(service, "main"); + scheduleFunction(provider, respondingTo); + } return service; } @@ -34,7 +36,7 @@ void *address = kernelMapPhysicalCount(multibootInfo, 4); initrd = findInitrd(address, &initrdSize); hlib = readInitrdProgram("hlib"); - loadProgram("loader", NULL); + loadProgram("loader", NULL, true); } void kernelMain(void *multibootInfo) { diff --git a/src/kernel/multiboot/initrdSyscall.c b/src/kernel/multiboot/initrdSyscall.c index c918ede..1164adc 100644 --- a/src/kernel/multiboot/initrdSyscall.c +++ b/src/kernel/multiboot/initrdSyscall.c @@ -2,12 +2,12 @@ #include #include -extern void loadProgram(char *name, Syscall *respondingTo); +extern void loadProgram(char *name, Syscall *respondingTo, bool initialize); void handleLoadFromInitrdSyscall(Syscall *call) { call->returnValue = listCount(services); char *name = retrieveString(call->parameters[0]); Service *service = call->service; - loadProgram(name, (void *)call); - call->avoidReschedule = true; + loadProgram(name, (void *)call, call->parameters[1]); + call->avoidReschedule = call->parameters[1]; } diff --git a/src/userland/hlib/main.c b/src/userland/hlib/main.c index c8082c6..8ec79a2 100644 --- a/src/userland/hlib/main.c +++ b/src/userland/hlib/main.c @@ -24,6 +24,11 @@ uint32_t loadFromInitrd(char *name) { uintptr_t id = insertString(name); + return syscall(SYS_LOAD_INITRD, id, 1, 0, 0); +} + +uint32_t loadFromInitrdUninitialized(char *name) { + uintptr_t id = insertString(name); return syscall(SYS_LOAD_INITRD, id, 0, 0, 0); } diff --git a/src/userland/ioManager/main.c b/src/userland/ioManager/main.c index f2e73ee..31caa0e 100644 --- a/src/userland/ioManager/main.c +++ b/src/userland/ioManager/main.c @@ -44,6 +44,8 @@ extern uint32_t logService, logFunction; +void setForeground(uint32_t service) { focusService = service; } + int32_t main() { logService = getServiceId(); logFunction = createFunction("", (void *)handleLog); @@ -54,4 +56,5 @@ loadFromInitrd("log"); loadFromInitrd("pic"); loadFromInitrd("keyboard"); + createFunction("setForeground", (void *)setForeground); } diff --git a/src/include/hlib.h b/src/include/hlib.h index c1e77c9..594c104 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -22,6 +22,7 @@ extern void log(char *); extern void subscribeInterrupt(uint32_t intNo, void *handler); extern uint32_t loadFromInitrd(char *name); +extern uint32_t loadFromInitrdUninitialized(char *name); extern uint32_t createEvent(char *name); extern uint32_t syscall(uint32_t function, uint32_t parameter0, uint32_t parameter1, uint32_t parameter2, diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 5b094f7..a1c03fe 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -42,6 +42,9 @@ service->nameHash, getServiceId(service)); }) ; + if (currentSyscall->respondingTo) { + listAdd(&callsToProcess, currentSyscall->respondingTo); + } free(currentSyscall); } diff --git a/src/kernel/main.c b/src/kernel/main.c index 2d69c20..ae6b0d1 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -22,10 +22,12 @@ return loadElf(elfData, name); } -Service *loadProgram(char *name, Syscall *respondingTo) { +Service *loadProgram(char *name, Syscall *respondingTo, bool initialize) { Service *service = readInitrdProgram(name); - ServiceFunction *provider = findFunction(service, "main"); - scheduleFunction(provider, respondingTo); + if (initialize) { + ServiceFunction *provider = findFunction(service, "main"); + scheduleFunction(provider, respondingTo); + } return service; } @@ -34,7 +36,7 @@ void *address = kernelMapPhysicalCount(multibootInfo, 4); initrd = findInitrd(address, &initrdSize); hlib = readInitrdProgram("hlib"); - loadProgram("loader", NULL); + loadProgram("loader", NULL, true); } void kernelMain(void *multibootInfo) { diff --git a/src/kernel/multiboot/initrdSyscall.c b/src/kernel/multiboot/initrdSyscall.c index c918ede..1164adc 100644 --- a/src/kernel/multiboot/initrdSyscall.c +++ b/src/kernel/multiboot/initrdSyscall.c @@ -2,12 +2,12 @@ #include #include -extern void loadProgram(char *name, Syscall *respondingTo); +extern void loadProgram(char *name, Syscall *respondingTo, bool initialize); void handleLoadFromInitrdSyscall(Syscall *call) { call->returnValue = listCount(services); char *name = retrieveString(call->parameters[0]); Service *service = call->service; - loadProgram(name, (void *)call); - call->avoidReschedule = true; + loadProgram(name, (void *)call, call->parameters[1]); + call->avoidReschedule = call->parameters[1]; } diff --git a/src/userland/hlib/main.c b/src/userland/hlib/main.c index c8082c6..8ec79a2 100644 --- a/src/userland/hlib/main.c +++ b/src/userland/hlib/main.c @@ -24,6 +24,11 @@ uint32_t loadFromInitrd(char *name) { uintptr_t id = insertString(name); + return syscall(SYS_LOAD_INITRD, id, 1, 0, 0); +} + +uint32_t loadFromInitrdUninitialized(char *name) { + uintptr_t id = insertString(name); return syscall(SYS_LOAD_INITRD, id, 0, 0, 0); } diff --git a/src/userland/ioManager/main.c b/src/userland/ioManager/main.c index f2e73ee..31caa0e 100644 --- a/src/userland/ioManager/main.c +++ b/src/userland/ioManager/main.c @@ -44,6 +44,8 @@ extern uint32_t logService, logFunction; +void setForeground(uint32_t service) { focusService = service; } + int32_t main() { logService = getServiceId(); logFunction = createFunction("", (void *)handleLog); @@ -54,4 +56,5 @@ loadFromInitrd("log"); loadFromInitrd("pic"); loadFromInitrd("keyboard"); + createFunction("setForeground", (void *)setForeground); } diff --git a/src/userland/loader/main.c b/src/userland/loader/main.c index 56210b4..483b25d 100644 --- a/src/userland/loader/main.c +++ b/src/userland/loader/main.c @@ -5,8 +5,10 @@ int32_t main() { loadFromInitrd("ioManager"); - printf("HONEY-OS by Lukas Eisenhauer"); + printf("HONEY-OS - made by Lukas Eisenhauer"); printf("finished loading all the essential modules"); loadFromInitrd("crashTest"); - return 0; + uint32_t id = loadFromInitrdUninitialized("shell"); + requestName("ioManager", "setForeground", id, 0); + requestName("shell", "main", 0, 0); } diff --git a/src/include/hlib.h b/src/include/hlib.h index c1e77c9..594c104 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -22,6 +22,7 @@ extern void log(char *); extern void subscribeInterrupt(uint32_t intNo, void *handler); extern uint32_t loadFromInitrd(char *name); +extern uint32_t loadFromInitrdUninitialized(char *name); extern uint32_t createEvent(char *name); extern uint32_t syscall(uint32_t function, uint32_t parameter0, uint32_t parameter1, uint32_t parameter2, diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 5b094f7..a1c03fe 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -42,6 +42,9 @@ service->nameHash, getServiceId(service)); }) ; + if (currentSyscall->respondingTo) { + listAdd(&callsToProcess, currentSyscall->respondingTo); + } free(currentSyscall); } diff --git a/src/kernel/main.c b/src/kernel/main.c index 2d69c20..ae6b0d1 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -22,10 +22,12 @@ return loadElf(elfData, name); } -Service *loadProgram(char *name, Syscall *respondingTo) { +Service *loadProgram(char *name, Syscall *respondingTo, bool initialize) { Service *service = readInitrdProgram(name); - ServiceFunction *provider = findFunction(service, "main"); - scheduleFunction(provider, respondingTo); + if (initialize) { + ServiceFunction *provider = findFunction(service, "main"); + scheduleFunction(provider, respondingTo); + } return service; } @@ -34,7 +36,7 @@ void *address = kernelMapPhysicalCount(multibootInfo, 4); initrd = findInitrd(address, &initrdSize); hlib = readInitrdProgram("hlib"); - loadProgram("loader", NULL); + loadProgram("loader", NULL, true); } void kernelMain(void *multibootInfo) { diff --git a/src/kernel/multiboot/initrdSyscall.c b/src/kernel/multiboot/initrdSyscall.c index c918ede..1164adc 100644 --- a/src/kernel/multiboot/initrdSyscall.c +++ b/src/kernel/multiboot/initrdSyscall.c @@ -2,12 +2,12 @@ #include #include -extern void loadProgram(char *name, Syscall *respondingTo); +extern void loadProgram(char *name, Syscall *respondingTo, bool initialize); void handleLoadFromInitrdSyscall(Syscall *call) { call->returnValue = listCount(services); char *name = retrieveString(call->parameters[0]); Service *service = call->service; - loadProgram(name, (void *)call); - call->avoidReschedule = true; + loadProgram(name, (void *)call, call->parameters[1]); + call->avoidReschedule = call->parameters[1]; } diff --git a/src/userland/hlib/main.c b/src/userland/hlib/main.c index c8082c6..8ec79a2 100644 --- a/src/userland/hlib/main.c +++ b/src/userland/hlib/main.c @@ -24,6 +24,11 @@ uint32_t loadFromInitrd(char *name) { uintptr_t id = insertString(name); + return syscall(SYS_LOAD_INITRD, id, 1, 0, 0); +} + +uint32_t loadFromInitrdUninitialized(char *name) { + uintptr_t id = insertString(name); return syscall(SYS_LOAD_INITRD, id, 0, 0, 0); } diff --git a/src/userland/ioManager/main.c b/src/userland/ioManager/main.c index f2e73ee..31caa0e 100644 --- a/src/userland/ioManager/main.c +++ b/src/userland/ioManager/main.c @@ -44,6 +44,8 @@ extern uint32_t logService, logFunction; +void setForeground(uint32_t service) { focusService = service; } + int32_t main() { logService = getServiceId(); logFunction = createFunction("", (void *)handleLog); @@ -54,4 +56,5 @@ loadFromInitrd("log"); loadFromInitrd("pic"); loadFromInitrd("keyboard"); + createFunction("setForeground", (void *)setForeground); } diff --git a/src/userland/loader/main.c b/src/userland/loader/main.c index 56210b4..483b25d 100644 --- a/src/userland/loader/main.c +++ b/src/userland/loader/main.c @@ -5,8 +5,10 @@ int32_t main() { loadFromInitrd("ioManager"); - printf("HONEY-OS by Lukas Eisenhauer"); + printf("HONEY-OS - made by Lukas Eisenhauer"); printf("finished loading all the essential modules"); loadFromInitrd("crashTest"); - return 0; + uint32_t id = loadFromInitrdUninitialized("shell"); + requestName("ioManager", "setForeground", id, 0); + requestName("shell", "main", 0, 0); } diff --git a/src/userland/shell/Makefile b/src/userland/shell/Makefile new file mode 100644 index 0000000..cc7b87e --- /dev/null +++ b/src/userland/shell/Makefile @@ -0,0 +1,29 @@ +CC = i686-elf-gcc +CCFLAGS = -m32 -mtune=generic -ffreestanding -nostdlib -c -I ../../include -I include -Wno-discarded-qualifiers -fms-extensions -Wno-shift-count-overflow -O0 +LD = i686-elf-ld +LD_FLAGS = -z max-page-size=0x1000 -T ../link.ld +AS = nasm +ASFlAGS = -felf32 + +BUILD_FOLDER = build + +SOURCE_FILES := $(shell find . -name '*.c' -or -name '*.asm' -or -name '*.s') +OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) + +../../../initrd/shell: $(OBJS) ../../../build/hlib.o + @echo "linking user program shell" + @$(LD) $(LD_FLAGS) -o $@ $(OBJS) + +$(BUILD_FOLDER)/%.asm.o: %.asm + @echo "asembling $<" + @mkdir -p $(dir $@) + @$(AS) $(ASFlAGS) $< -o $@ + +$(BUILD_FOLDER)/%.c.o: %.c + @echo "compiling $<" + @mkdir -p $(dir $@) + @$(CC) $(CCFLAGS) -r $< -o $@ + +clean: + @echo "clearing build folder" + @rm -r $(BUILD_FOLDER) diff --git a/src/include/hlib.h b/src/include/hlib.h index c1e77c9..594c104 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -22,6 +22,7 @@ extern void log(char *); extern void subscribeInterrupt(uint32_t intNo, void *handler); extern uint32_t loadFromInitrd(char *name); +extern uint32_t loadFromInitrdUninitialized(char *name); extern uint32_t createEvent(char *name); extern uint32_t syscall(uint32_t function, uint32_t parameter0, uint32_t parameter1, uint32_t parameter2, diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 5b094f7..a1c03fe 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -42,6 +42,9 @@ service->nameHash, getServiceId(service)); }) ; + if (currentSyscall->respondingTo) { + listAdd(&callsToProcess, currentSyscall->respondingTo); + } free(currentSyscall); } diff --git a/src/kernel/main.c b/src/kernel/main.c index 2d69c20..ae6b0d1 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -22,10 +22,12 @@ return loadElf(elfData, name); } -Service *loadProgram(char *name, Syscall *respondingTo) { +Service *loadProgram(char *name, Syscall *respondingTo, bool initialize) { Service *service = readInitrdProgram(name); - ServiceFunction *provider = findFunction(service, "main"); - scheduleFunction(provider, respondingTo); + if (initialize) { + ServiceFunction *provider = findFunction(service, "main"); + scheduleFunction(provider, respondingTo); + } return service; } @@ -34,7 +36,7 @@ void *address = kernelMapPhysicalCount(multibootInfo, 4); initrd = findInitrd(address, &initrdSize); hlib = readInitrdProgram("hlib"); - loadProgram("loader", NULL); + loadProgram("loader", NULL, true); } void kernelMain(void *multibootInfo) { diff --git a/src/kernel/multiboot/initrdSyscall.c b/src/kernel/multiboot/initrdSyscall.c index c918ede..1164adc 100644 --- a/src/kernel/multiboot/initrdSyscall.c +++ b/src/kernel/multiboot/initrdSyscall.c @@ -2,12 +2,12 @@ #include #include -extern void loadProgram(char *name, Syscall *respondingTo); +extern void loadProgram(char *name, Syscall *respondingTo, bool initialize); void handleLoadFromInitrdSyscall(Syscall *call) { call->returnValue = listCount(services); char *name = retrieveString(call->parameters[0]); Service *service = call->service; - loadProgram(name, (void *)call); - call->avoidReschedule = true; + loadProgram(name, (void *)call, call->parameters[1]); + call->avoidReschedule = call->parameters[1]; } diff --git a/src/userland/hlib/main.c b/src/userland/hlib/main.c index c8082c6..8ec79a2 100644 --- a/src/userland/hlib/main.c +++ b/src/userland/hlib/main.c @@ -24,6 +24,11 @@ uint32_t loadFromInitrd(char *name) { uintptr_t id = insertString(name); + return syscall(SYS_LOAD_INITRD, id, 1, 0, 0); +} + +uint32_t loadFromInitrdUninitialized(char *name) { + uintptr_t id = insertString(name); return syscall(SYS_LOAD_INITRD, id, 0, 0, 0); } diff --git a/src/userland/ioManager/main.c b/src/userland/ioManager/main.c index f2e73ee..31caa0e 100644 --- a/src/userland/ioManager/main.c +++ b/src/userland/ioManager/main.c @@ -44,6 +44,8 @@ extern uint32_t logService, logFunction; +void setForeground(uint32_t service) { focusService = service; } + int32_t main() { logService = getServiceId(); logFunction = createFunction("", (void *)handleLog); @@ -54,4 +56,5 @@ loadFromInitrd("log"); loadFromInitrd("pic"); loadFromInitrd("keyboard"); + createFunction("setForeground", (void *)setForeground); } diff --git a/src/userland/loader/main.c b/src/userland/loader/main.c index 56210b4..483b25d 100644 --- a/src/userland/loader/main.c +++ b/src/userland/loader/main.c @@ -5,8 +5,10 @@ int32_t main() { loadFromInitrd("ioManager"); - printf("HONEY-OS by Lukas Eisenhauer"); + printf("HONEY-OS - made by Lukas Eisenhauer"); printf("finished loading all the essential modules"); loadFromInitrd("crashTest"); - return 0; + uint32_t id = loadFromInitrdUninitialized("shell"); + requestName("ioManager", "setForeground", id, 0); + requestName("shell", "main", 0, 0); } diff --git a/src/userland/shell/Makefile b/src/userland/shell/Makefile new file mode 100644 index 0000000..cc7b87e --- /dev/null +++ b/src/userland/shell/Makefile @@ -0,0 +1,29 @@ +CC = i686-elf-gcc +CCFLAGS = -m32 -mtune=generic -ffreestanding -nostdlib -c -I ../../include -I include -Wno-discarded-qualifiers -fms-extensions -Wno-shift-count-overflow -O0 +LD = i686-elf-ld +LD_FLAGS = -z max-page-size=0x1000 -T ../link.ld +AS = nasm +ASFlAGS = -felf32 + +BUILD_FOLDER = build + +SOURCE_FILES := $(shell find . -name '*.c' -or -name '*.asm' -or -name '*.s') +OBJS := $(SOURCE_FILES:%=$(BUILD_FOLDER)/%.o) + +../../../initrd/shell: $(OBJS) ../../../build/hlib.o + @echo "linking user program shell" + @$(LD) $(LD_FLAGS) -o $@ $(OBJS) + +$(BUILD_FOLDER)/%.asm.o: %.asm + @echo "asembling $<" + @mkdir -p $(dir $@) + @$(AS) $(ASFlAGS) $< -o $@ + +$(BUILD_FOLDER)/%.c.o: %.c + @echo "compiling $<" + @mkdir -p $(dir $@) + @$(CC) $(CCFLAGS) -r $< -o $@ + +clean: + @echo "clearing build folder" + @rm -r $(BUILD_FOLDER) diff --git a/src/userland/shell/main.c b/src/userland/shell/main.c new file mode 100644 index 0000000..871a389 --- /dev/null +++ b/src/userland/shell/main.c @@ -0,0 +1,6 @@ +#define ALLOC_MAIN + +#include +#include + +int32_t main() { printf("HONEY-OS - made by Lukas Eisenhauer"); }