diff --git a/src/kernel/include/service.h b/src/kernel/include/service.h index 041422b..5b094fd 100644 --- a/src/kernel/include/service.h +++ b/src/kernel/include/service.h @@ -8,6 +8,7 @@ typedef struct { PagingInfo pagingInfo; char *name; + uintptr_t nameHash; ListElement *providers; ListElement *events; } Service; @@ -35,5 +36,6 @@ extern Provider *findProvider(Service *, char *); extern Service *currentService; extern void scheduleProvider(Provider *provider, uintptr_t data1, - uintptr_t data2, Syscall *respondingTo); + uintptr_t data2, uintptr_t data3, + Syscall *respondingTo); #endif diff --git a/src/kernel/include/service.h b/src/kernel/include/service.h index 041422b..5b094fd 100644 --- a/src/kernel/include/service.h +++ b/src/kernel/include/service.h @@ -8,6 +8,7 @@ typedef struct { PagingInfo pagingInfo; char *name; + uintptr_t nameHash; ListElement *providers; ListElement *events; } Service; @@ -35,5 +36,6 @@ extern Provider *findProvider(Service *, char *); extern Service *currentService; extern void scheduleProvider(Provider *provider, uintptr_t data1, - uintptr_t data2, Syscall *respondingTo); + uintptr_t data2, uintptr_t data3, + Syscall *respondingTo); #endif diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 0c203a7..f8969b3 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -22,7 +22,7 @@ void onInterrupt(void *eip, void *esp, uint32_t intNo, void *cr3) { // an external interrupt was triggered foreach (interruptSubscriptions[intNo], Provider *, provider, - { scheduleProvider(provider, intNo, 0, NULL); }) + { scheduleProvider(provider, intNo, 0, 0, NULL); }) ; if (cr3 == PTR(0x500000)) { return; diff --git a/src/kernel/include/service.h b/src/kernel/include/service.h index 041422b..5b094fd 100644 --- a/src/kernel/include/service.h +++ b/src/kernel/include/service.h @@ -8,6 +8,7 @@ typedef struct { PagingInfo pagingInfo; char *name; + uintptr_t nameHash; ListElement *providers; ListElement *events; } Service; @@ -35,5 +36,6 @@ extern Provider *findProvider(Service *, char *); extern Service *currentService; extern void scheduleProvider(Provider *provider, uintptr_t data1, - uintptr_t data2, Syscall *respondingTo); + uintptr_t data2, uintptr_t data3, + Syscall *respondingTo); #endif diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 0c203a7..f8969b3 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -22,7 +22,7 @@ void onInterrupt(void *eip, void *esp, uint32_t intNo, void *cr3) { // an external interrupt was triggered foreach (interruptSubscriptions[intNo], Provider *, provider, - { scheduleProvider(provider, intNo, 0, NULL); }) + { scheduleProvider(provider, intNo, 0, 0, NULL); }) ; if (cr3 == PTR(0x500000)) { return; diff --git a/src/kernel/main.c b/src/kernel/main.c index d2dcdf4..4660129 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -25,7 +25,7 @@ Service *loadProgram(char *name, Syscall *respondingTo) { Service *service = readInitrdProgram(name); Provider *provider = findProvider(service, "main"); - scheduleProvider(provider, 0, 0, respondingTo); + scheduleProvider(provider, 0, 0, 0, respondingTo); return service; } diff --git a/src/kernel/include/service.h b/src/kernel/include/service.h index 041422b..5b094fd 100644 --- a/src/kernel/include/service.h +++ b/src/kernel/include/service.h @@ -8,6 +8,7 @@ typedef struct { PagingInfo pagingInfo; char *name; + uintptr_t nameHash; ListElement *providers; ListElement *events; } Service; @@ -35,5 +36,6 @@ extern Provider *findProvider(Service *, char *); extern Service *currentService; extern void scheduleProvider(Provider *provider, uintptr_t data1, - uintptr_t data2, Syscall *respondingTo); + uintptr_t data2, uintptr_t data3, + Syscall *respondingTo); #endif diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 0c203a7..f8969b3 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -22,7 +22,7 @@ void onInterrupt(void *eip, void *esp, uint32_t intNo, void *cr3) { // an external interrupt was triggered foreach (interruptSubscriptions[intNo], Provider *, provider, - { scheduleProvider(provider, intNo, 0, NULL); }) + { scheduleProvider(provider, intNo, 0, 0, NULL); }) ; if (cr3 == PTR(0x500000)) { return; diff --git a/src/kernel/main.c b/src/kernel/main.c index d2dcdf4..4660129 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -25,7 +25,7 @@ Service *loadProgram(char *name, Syscall *respondingTo) { Service *service = readInitrdProgram(name); Provider *provider = findProvider(service, "main"); - scheduleProvider(provider, 0, 0, respondingTo); + scheduleProvider(provider, 0, 0, 0, respondingTo); return service; } diff --git a/src/kernel/service/eventSyscalls.c b/src/kernel/service/eventSyscalls.c index bb116e7..50a7ed0 100644 --- a/src/kernel/service/eventSyscalls.c +++ b/src/kernel/service/eventSyscalls.c @@ -37,7 +37,7 @@ Service *service = call->service; Event *event = listGet(service->events, call->parameters[0]); foreach (event->subscriptions, Provider *, provider, - { scheduleProvider(provider, 0, 0, 0); }) + { scheduleProvider(provider, 0, 0, 0, 0); }) ; } diff --git a/src/kernel/include/service.h b/src/kernel/include/service.h index 041422b..5b094fd 100644 --- a/src/kernel/include/service.h +++ b/src/kernel/include/service.h @@ -8,6 +8,7 @@ typedef struct { PagingInfo pagingInfo; char *name; + uintptr_t nameHash; ListElement *providers; ListElement *events; } Service; @@ -35,5 +36,6 @@ extern Provider *findProvider(Service *, char *); extern Service *currentService; extern void scheduleProvider(Provider *provider, uintptr_t data1, - uintptr_t data2, Syscall *respondingTo); + uintptr_t data2, uintptr_t data3, + Syscall *respondingTo); #endif diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 0c203a7..f8969b3 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -22,7 +22,7 @@ void onInterrupt(void *eip, void *esp, uint32_t intNo, void *cr3) { // an external interrupt was triggered foreach (interruptSubscriptions[intNo], Provider *, provider, - { scheduleProvider(provider, intNo, 0, NULL); }) + { scheduleProvider(provider, intNo, 0, 0, NULL); }) ; if (cr3 == PTR(0x500000)) { return; diff --git a/src/kernel/main.c b/src/kernel/main.c index d2dcdf4..4660129 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -25,7 +25,7 @@ Service *loadProgram(char *name, Syscall *respondingTo) { Service *service = readInitrdProgram(name); Provider *provider = findProvider(service, "main"); - scheduleProvider(provider, 0, 0, respondingTo); + scheduleProvider(provider, 0, 0, 0, respondingTo); return service; } diff --git a/src/kernel/service/eventSyscalls.c b/src/kernel/service/eventSyscalls.c index bb116e7..50a7ed0 100644 --- a/src/kernel/service/eventSyscalls.c +++ b/src/kernel/service/eventSyscalls.c @@ -37,7 +37,7 @@ Service *service = call->service; Event *event = listGet(service->events, call->parameters[0]); foreach (event->subscriptions, Provider *, provider, - { scheduleProvider(provider, 0, 0, 0); }) + { scheduleProvider(provider, 0, 0, 0, 0); }) ; } diff --git a/src/kernel/service/service.c b/src/kernel/service/service.c index 98f1367..6016cb4 100644 --- a/src/kernel/service/service.c +++ b/src/kernel/service/service.c @@ -2,6 +2,7 @@ #include "elf.h" #include #include +#include #include extern void *functionsStart; @@ -30,6 +31,7 @@ memset(service, 0, sizeof(Service)); service->pagingInfo.pageDirectory = malloc(0x1000); service->name = serviceName; + service->nameHash = insertString(serviceName); void *current = &functionsStart; if (hlib) { service->pagingInfo.pageDirectory[0x3FC].pageTableID = @@ -89,7 +91,7 @@ } void scheduleProvider(Provider *provider, uintptr_t data1, uintptr_t data2, - Syscall *respondingTo) { + uintptr_t data3, Syscall *respondingTo) { Syscall *runCall = malloc(sizeof(Syscall)); runCall->function = 0; runCall->esp = malloc(0x1000); // todo: free this @@ -99,10 +101,11 @@ runCall->service = provider->service; runCall->resume = true; sharePage(&provider->service->pagingInfo, runCall->esp, runCall->esp); - runCall->esp += 0xFF0; + runCall->esp += 0x1000 - 0x20; *(void **)runCall->esp = provider->address; *(void **)(runCall->esp + 0x4) = &runEnd; *(uint32_t *)(runCall->esp + 0x8) = data1; *(uint32_t *)(runCall->esp + 0xC) = data2; + *(uint32_t *)(runCall->esp + 0x10) = data3; listAdd(&callsToProcess, runCall); } diff --git a/src/kernel/include/service.h b/src/kernel/include/service.h index 041422b..5b094fd 100644 --- a/src/kernel/include/service.h +++ b/src/kernel/include/service.h @@ -8,6 +8,7 @@ typedef struct { PagingInfo pagingInfo; char *name; + uintptr_t nameHash; ListElement *providers; ListElement *events; } Service; @@ -35,5 +36,6 @@ extern Provider *findProvider(Service *, char *); extern Service *currentService; extern void scheduleProvider(Provider *provider, uintptr_t data1, - uintptr_t data2, Syscall *respondingTo); + uintptr_t data2, uintptr_t data3, + Syscall *respondingTo); #endif diff --git a/src/kernel/interrupts/interrupts.c b/src/kernel/interrupts/interrupts.c index 0c203a7..f8969b3 100644 --- a/src/kernel/interrupts/interrupts.c +++ b/src/kernel/interrupts/interrupts.c @@ -22,7 +22,7 @@ void onInterrupt(void *eip, void *esp, uint32_t intNo, void *cr3) { // an external interrupt was triggered foreach (interruptSubscriptions[intNo], Provider *, provider, - { scheduleProvider(provider, intNo, 0, NULL); }) + { scheduleProvider(provider, intNo, 0, 0, NULL); }) ; if (cr3 == PTR(0x500000)) { return; diff --git a/src/kernel/main.c b/src/kernel/main.c index d2dcdf4..4660129 100644 --- a/src/kernel/main.c +++ b/src/kernel/main.c @@ -25,7 +25,7 @@ Service *loadProgram(char *name, Syscall *respondingTo) { Service *service = readInitrdProgram(name); Provider *provider = findProvider(service, "main"); - scheduleProvider(provider, 0, 0, respondingTo); + scheduleProvider(provider, 0, 0, 0, respondingTo); return service; } diff --git a/src/kernel/service/eventSyscalls.c b/src/kernel/service/eventSyscalls.c index bb116e7..50a7ed0 100644 --- a/src/kernel/service/eventSyscalls.c +++ b/src/kernel/service/eventSyscalls.c @@ -37,7 +37,7 @@ Service *service = call->service; Event *event = listGet(service->events, call->parameters[0]); foreach (event->subscriptions, Provider *, provider, - { scheduleProvider(provider, 0, 0, 0); }) + { scheduleProvider(provider, 0, 0, 0, 0); }) ; } diff --git a/src/kernel/service/service.c b/src/kernel/service/service.c index 98f1367..6016cb4 100644 --- a/src/kernel/service/service.c +++ b/src/kernel/service/service.c @@ -2,6 +2,7 @@ #include "elf.h" #include #include +#include #include extern void *functionsStart; @@ -30,6 +31,7 @@ memset(service, 0, sizeof(Service)); service->pagingInfo.pageDirectory = malloc(0x1000); service->name = serviceName; + service->nameHash = insertString(serviceName); void *current = &functionsStart; if (hlib) { service->pagingInfo.pageDirectory[0x3FC].pageTableID = @@ -89,7 +91,7 @@ } void scheduleProvider(Provider *provider, uintptr_t data1, uintptr_t data2, - Syscall *respondingTo) { + uintptr_t data3, Syscall *respondingTo) { Syscall *runCall = malloc(sizeof(Syscall)); runCall->function = 0; runCall->esp = malloc(0x1000); // todo: free this @@ -99,10 +101,11 @@ runCall->service = provider->service; runCall->resume = true; sharePage(&provider->service->pagingInfo, runCall->esp, runCall->esp); - runCall->esp += 0xFF0; + runCall->esp += 0x1000 - 0x20; *(void **)runCall->esp = provider->address; *(void **)(runCall->esp + 0x4) = &runEnd; *(uint32_t *)(runCall->esp + 0x8) = data1; *(uint32_t *)(runCall->esp + 0xC) = data2; + *(uint32_t *)(runCall->esp + 0x10) = data3; listAdd(&callsToProcess, runCall); } diff --git a/src/kernel/service/serviceSyscalls.c b/src/kernel/service/serviceSyscalls.c index cb3e7c8..d509a44 100644 --- a/src/kernel/service/serviceSyscalls.c +++ b/src/kernel/service/serviceSyscalls.c @@ -68,6 +68,7 @@ Service *providerService = listGet(services, call->parameters[0]); Provider *provider = listGet(providerService->providers, call->parameters[1]); - scheduleProvider(provider, call->parameters[2], call->parameters[3], call); + scheduleProvider(provider, call->parameters[2], call->parameters[3], + service->nameHash, call); call->avoidReschedule = true; }