diff --git a/src/include/hlib.h b/src/include/hlib.h index 2533469..d77a938 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -4,8 +4,8 @@ #include #include -#define PTR(x) ((void *)(uintptr_t)x) -#define U32(x) ((uint32_t)(uintptr_t)x) +#define PTR(x) ((void *)(uintptr_t)(x)) +#define U32(x) ((uint32_t)(uintptr_t)(x)) #define NULL PTR(0) extern uint32_t installServiceProvider(char *name, diff --git a/src/include/hlib.h b/src/include/hlib.h index 2533469..d77a938 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -4,8 +4,8 @@ #include #include -#define PTR(x) ((void *)(uintptr_t)x) -#define U32(x) ((uint32_t)(uintptr_t)x) +#define PTR(x) ((void *)(uintptr_t)(x)) +#define U32(x) ((uint32_t)(uintptr_t)(x)) #define NULL PTR(0) extern uint32_t installServiceProvider(char *name, diff --git a/src/userland/log/main.c b/src/userland/log/main.c index ed1f9d4..9f3577f 100644 --- a/src/userland/log/main.c +++ b/src/userland/log/main.c @@ -1,9 +1,13 @@ #include #include -uint32_t outService, outProvider; +uint32_t services[10], functions[10], outputCount; -void writeParallel(uint8_t data) { request(outService, outProvider, data, 0); } +void writeChar(uint8_t data) { + for (uint8_t i = 0; i < outputCount; i++) { + request(services[i], functions[i], data, 0); + } +} char buffer[100]; @@ -11,15 +15,16 @@ readString(stringId, buffer); uint32_t length = strlen(buffer); for (uint32_t i = 0; i < length; i++) { - writeParallel(buffer[i]); + writeChar(buffer[i]); } - writeParallel('\r'); - writeParallel('\n'); + writeChar('\r'); + writeChar('\n'); } void registerOut(uintptr_t service, uintptr_t provider) { - outService = service; - outProvider = provider; + services[outputCount] = service; + functions[outputCount] = provider; + outputCount++; } int32_t main() { diff --git a/src/include/hlib.h b/src/include/hlib.h index 2533469..d77a938 100644 --- a/src/include/hlib.h +++ b/src/include/hlib.h @@ -4,8 +4,8 @@ #include #include -#define PTR(x) ((void *)(uintptr_t)x) -#define U32(x) ((uint32_t)(uintptr_t)x) +#define PTR(x) ((void *)(uintptr_t)(x)) +#define U32(x) ((uint32_t)(uintptr_t)(x)) #define NULL PTR(0) extern uint32_t installServiceProvider(char *name, diff --git a/src/userland/log/main.c b/src/userland/log/main.c index ed1f9d4..9f3577f 100644 --- a/src/userland/log/main.c +++ b/src/userland/log/main.c @@ -1,9 +1,13 @@ #include #include -uint32_t outService, outProvider; +uint32_t services[10], functions[10], outputCount; -void writeParallel(uint8_t data) { request(outService, outProvider, data, 0); } +void writeChar(uint8_t data) { + for (uint8_t i = 0; i < outputCount; i++) { + request(services[i], functions[i], data, 0); + } +} char buffer[100]; @@ -11,15 +15,16 @@ readString(stringId, buffer); uint32_t length = strlen(buffer); for (uint32_t i = 0; i < length; i++) { - writeParallel(buffer[i]); + writeChar(buffer[i]); } - writeParallel('\r'); - writeParallel('\n'); + writeChar('\r'); + writeChar('\n'); } void registerOut(uintptr_t service, uintptr_t provider) { - outService = service; - outProvider = provider; + services[outputCount] = service; + functions[outputCount] = provider; + outputCount++; } int32_t main() { diff --git a/src/userland/vga/main.c b/src/userland/vga/main.c index e64dc91..949916c 100644 --- a/src/userland/vga/main.c +++ b/src/userland/vga/main.c @@ -3,18 +3,33 @@ #include #include -char *string = "test"; uint16_t *videoSource; +uint32_t offset = 0; + +#define WIDTH 80 +#define HEIGHT 25 void writeChar(char character, char colorCode) { - *videoSource = ((uint16_t)colorCode << 8) | character; - videoSource++; + videoSource[offset] = ((uint16_t)colorCode << 8) | character; + offset++; +} + +void write(char c) { + switch (c) { + case '\r': + offset = (offset / WIDTH) * WIDTH; + return; + case '\n': + offset += WIDTH; + return; + } + writeChar(c, COLOR(white, black)); } int32_t main() { - videoSource = requestMemory(1, NULL, PTR(0xB8000)); - for (uint32_t i = 0; string[i]; i++) { - writeChar(string[i], COLOR(white, black)); - } + videoSource = requestMemory(2, NULL, PTR(0xB8000)); + uint32_t thisService = getServiceId(); + uint32_t functionId = installServiceProvider("writeVGA", (void *)write); + requestName("log", "registerOut", thisService, functionId); return 0; }