diff --git a/src/userland/ioManager/main.c b/src/userland/ioManager/main.c index dc01370..81194e8 100644 --- a/src/userland/ioManager/main.c +++ b/src/userland/ioManager/main.c @@ -1,12 +1,18 @@ #include #include -uint32_t mainService, mainOut, globalService, globalOut; +uint32_t mainService, mainOut, globalService, globalOut, globalBulkOut; uint32_t focusService, focusServiceKeyHandler; uint32_t currentKeyConsumerService, currentKeyConsumerFunction; void writeString(char *string) { + if (globalBulkOut) { + uint32_t stringId = insertString(string); + request(globalService, globalBulkOut, stringId, 0); + discardString(stringId); + return; + } for (uint32_t i = 0; string[i]; i++) { request(globalService, globalOut, string[i], 0); } @@ -37,11 +43,6 @@ logMain(stringId); return; } - static bool lock = false; - while (lock) { - syscall(-1, 0, 0, 0, 0); - } - lock = true; char *buffer = malloc(getStringLength(stringId)); readString(stringId, buffer); @@ -58,6 +59,13 @@ for (uint32_t i = 0; i < callerNameLength; i++) { result[i + 2] = callerName[i]; } + + static bool lock = false; + while (lock) { + syscall(-1, 0, 0, 0, 0); + } + lock = true; + writeString(result); lock = false; @@ -132,6 +140,7 @@ mainOut = getFunction(mainService, "writeChar"); globalService = loadFromInitrd("parallel"); globalOut = getFunction(globalService, "writeChar"); + globalBulkOut = getFunction(globalService, "write_bulk"); loadFromInitrd("log"); createFunction("setForeground", (void *)setForeground); keyEvent = createEvent("keyPress"); diff --git a/src/userland/ioManager/main.c b/src/userland/ioManager/main.c index dc01370..81194e8 100644 --- a/src/userland/ioManager/main.c +++ b/src/userland/ioManager/main.c @@ -1,12 +1,18 @@ #include #include -uint32_t mainService, mainOut, globalService, globalOut; +uint32_t mainService, mainOut, globalService, globalOut, globalBulkOut; uint32_t focusService, focusServiceKeyHandler; uint32_t currentKeyConsumerService, currentKeyConsumerFunction; void writeString(char *string) { + if (globalBulkOut) { + uint32_t stringId = insertString(string); + request(globalService, globalBulkOut, stringId, 0); + discardString(stringId); + return; + } for (uint32_t i = 0; string[i]; i++) { request(globalService, globalOut, string[i], 0); } @@ -37,11 +43,6 @@ logMain(stringId); return; } - static bool lock = false; - while (lock) { - syscall(-1, 0, 0, 0, 0); - } - lock = true; char *buffer = malloc(getStringLength(stringId)); readString(stringId, buffer); @@ -58,6 +59,13 @@ for (uint32_t i = 0; i < callerNameLength; i++) { result[i + 2] = callerName[i]; } + + static bool lock = false; + while (lock) { + syscall(-1, 0, 0, 0, 0); + } + lock = true; + writeString(result); lock = false; @@ -132,6 +140,7 @@ mainOut = getFunction(mainService, "writeChar"); globalService = loadFromInitrd("parallel"); globalOut = getFunction(globalService, "writeChar"); + globalBulkOut = getFunction(globalService, "write_bulk"); loadFromInitrd("log"); createFunction("setForeground", (void *)setForeground); keyEvent = createEvent("keyPress"); diff --git a/src/userland/parallel/main.c b/src/userland/parallel/main.c index 3f03be1..3b4d7b7 100644 --- a/src/userland/parallel/main.c +++ b/src/userland/parallel/main.c @@ -18,9 +18,21 @@ } } +void writeBulk(uint32_t stringId) { + uint32_t length = getStringLength(stringId); + char *buffer = malloc(length); + readString(stringId, buffer); + for (uint32_t i = 0; i < length; i++) { + parallelOut(buffer[i], 0); + } +} + int32_t parallelIn(void *data, uint32_t dataLength) { // todo return 0; } -int32_t main() { createFunction("writeChar", (void *)parallelOut); } +int32_t main() { + createFunction("writeChar", (void *)parallelOut); + createFunction("write_bulk", (void *)writeBulk); +}