diff --git a/src/include/hlib.h b/src/include/hlib.h index 699c8d0..0f67432 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -70,5 +70,6 @@ extern void *listGet(ListElement *list, uint32_t position); extern bool listRemoveValue(ListElement **list, void *value); extern void *getPhysicalAddress(void *address); +extern void sleep(uint32_t millis); #endif diff --git a/src/include/hlib.h b/src/include/hlib.h index 699c8d0..0f67432 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -70,5 +70,6 @@ extern void *listGet(ListElement *list, uint32_t position); extern bool listRemoveValue(ListElement **list, void *value); extern void *getPhysicalAddress(void *address); +extern void sleep(uint32_t millis); #endif diff --git a/src/userland/hlib/main.c b/src/userland/hlib/main.c index d47964b..ac4f9a5 100644 --- a/src/userland/hlib/main.c +++ b/src/userland/hlib/main.c @@ -67,3 +67,19 @@ bool stackContains(uint32_t serviceId) { return syscall(SYS_STACK_CONTAINS, serviceId, 0, 0, 0); } + +#define REQUEST1(returnType, functionName, service, function) \ + returnType functionName(uint32_t data) { \ + static uint32_t serviceId = 0; \ + if (!serviceId) { \ + serviceId = getService(service); \ + serviceId = getService(service); \ + } \ + static uint32_t functionId = 0; \ + if (!functionId) { \ + functionId = getFunction(serviceId, function); \ + } \ + return (returnType)request(serviceId, functionId, data, 0); \ + } + +REQUEST1(void, sleep, "pit", "sleep") diff --git a/src/include/hlib.h b/src/include/hlib.h index 699c8d0..0f67432 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -70,5 +70,6 @@ extern void *listGet(ListElement *list, uint32_t position); extern bool listRemoveValue(ListElement **list, void *value); extern void *getPhysicalAddress(void *address); +extern void sleep(uint32_t millis); #endif diff --git a/src/userland/hlib/main.c b/src/userland/hlib/main.c index d47964b..ac4f9a5 100644 --- a/src/userland/hlib/main.c +++ b/src/userland/hlib/main.c @@ -67,3 +67,19 @@ bool stackContains(uint32_t serviceId) { return syscall(SYS_STACK_CONTAINS, serviceId, 0, 0, 0); } + +#define REQUEST1(returnType, functionName, service, function) \ + returnType functionName(uint32_t data) { \ + static uint32_t serviceId = 0; \ + if (!serviceId) { \ + serviceId = getService(service); \ + serviceId = getService(service); \ + } \ + static uint32_t functionId = 0; \ + if (!functionId) { \ + functionId = getFunction(serviceId, function); \ + } \ + return (returnType)request(serviceId, functionId, data, 0); \ + } + +REQUEST1(void, sleep, "pit", "sleep") diff --git a/src/userland/pit/main.c b/src/userland/pit/main.c index 4b37a0c..a5a188d 100644 --- a/src/userland/pit/main.c +++ b/src/userland/pit/main.c @@ -31,17 +31,12 @@ void interruptHandler() { systemTime++; - if (systemTime % 1000 == 0) { - printf("test\n"); - } if (listRemoveValue(&sleepNotifications, PTR(systemTime))) { - printf("sleep end %i with call %i\n", systemTime, - syscall(SYS_GET_EVENT, serviceId, systemTime, 0, 0)); fireEvent(syscall(SYS_GET_EVENT, serviceId, systemTime, 0, 0), 0); } } -void sleep(uint32_t millis) { +void doSleep(uint32_t millis) { uint32_t targetTime = systemTime + millis / 10; listAdd(&sleepNotifications, PTR(targetTime)); uint32_t event = syscall(SYS_GET_EVENT, serviceId, targetTime, 0, 0); @@ -56,7 +51,7 @@ if (!initialized) { initialized = true; serviceId = getServiceId(); - createFunction("sleep", (void *)sleep); + createFunction("sleep", (void *)doSleep); uint32_t service = getService("pic"); uint32_t event = getEvent(service, "irq0"); subscribeEvent(service, event, interruptHandler); @@ -69,7 +64,7 @@ printf("timer handler installed\n"); } else { printf("current uptime: %i.%is\n", systemTime / 100, systemTime % 100); - printf("waiting one second...\n"); - sleep(1000); + printf("waiting one second to demonstrate sleeping\n"); + doSleep(1000); } } diff --git a/src/include/hlib.h b/src/include/hlib.h index 699c8d0..0f67432 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -70,5 +70,6 @@ extern void *listGet(ListElement *list, uint32_t position); extern bool listRemoveValue(ListElement **list, void *value); extern void *getPhysicalAddress(void *address); +extern void sleep(uint32_t millis); #endif diff --git a/src/userland/hlib/main.c b/src/userland/hlib/main.c index d47964b..ac4f9a5 100644 --- a/src/userland/hlib/main.c +++ b/src/userland/hlib/main.c @@ -67,3 +67,19 @@ bool stackContains(uint32_t serviceId) { return syscall(SYS_STACK_CONTAINS, serviceId, 0, 0, 0); } + +#define REQUEST1(returnType, functionName, service, function) \ + returnType functionName(uint32_t data) { \ + static uint32_t serviceId = 0; \ + if (!serviceId) { \ + serviceId = getService(service); \ + serviceId = getService(service); \ + } \ + static uint32_t functionId = 0; \ + if (!functionId) { \ + functionId = getFunction(serviceId, function); \ + } \ + return (returnType)request(serviceId, functionId, data, 0); \ + } + +REQUEST1(void, sleep, "pit", "sleep") diff --git a/src/userland/pit/main.c b/src/userland/pit/main.c index 4b37a0c..a5a188d 100644 --- a/src/userland/pit/main.c +++ b/src/userland/pit/main.c @@ -31,17 +31,12 @@ void interruptHandler() { systemTime++; - if (systemTime % 1000 == 0) { - printf("test\n"); - } if (listRemoveValue(&sleepNotifications, PTR(systemTime))) { - printf("sleep end %i with call %i\n", systemTime, - syscall(SYS_GET_EVENT, serviceId, systemTime, 0, 0)); fireEvent(syscall(SYS_GET_EVENT, serviceId, systemTime, 0, 0), 0); } } -void sleep(uint32_t millis) { +void doSleep(uint32_t millis) { uint32_t targetTime = systemTime + millis / 10; listAdd(&sleepNotifications, PTR(targetTime)); uint32_t event = syscall(SYS_GET_EVENT, serviceId, targetTime, 0, 0); @@ -56,7 +51,7 @@ if (!initialized) { initialized = true; serviceId = getServiceId(); - createFunction("sleep", (void *)sleep); + createFunction("sleep", (void *)doSleep); uint32_t service = getService("pic"); uint32_t event = getEvent(service, "irq0"); subscribeEvent(service, event, interruptHandler); @@ -69,7 +64,7 @@ printf("timer handler installed\n"); } else { printf("current uptime: %i.%is\n", systemTime / 100, systemTime % 100); - printf("waiting one second...\n"); - sleep(1000); + printf("waiting one second to demonstrate sleeping\n"); + doSleep(1000); } } diff --git a/src/userland/usb/main.c b/src/userland/usb/main.c index 83868e0..b9e6d76 100644 --- a/src/userland/usb/main.c +++ b/src/userland/usb/main.c @@ -25,12 +25,6 @@ controller->doorbells[0] = 0; } -void waitForKeyPress() { - printf("press a key to continue...\n"); - uint32_t ioManager = getService("ioManager"); - await(ioManager, getEvent(ioManager, "keyPress")); -} - #define REQUEST(functionName, service, function) \ uint32_t functionName(uint32_t data1, uint32_t data2) { \ static uint32_t serviceId = 0; \ @@ -212,7 +206,7 @@ setupScratchpadBuffers(controller); controller->operational->command |= (1 << 0) | (1 << 2); - waitForKeyPress(); + sleep(100); if (controller->operational->status & (1 << 2)) return printf("critical XHCI problem\n");