aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/release.yml3
-rw-r--r--src/kernel/graphics/vesa.c23
-rw-r--r--src/kernel/io/io.c17
-rw-r--r--src/kernel/lib/lib.h8
-rw-r--r--src/kernel/lib/string.c22
-rw-r--r--src/kernel/system.c11
6 files changed, 46 insertions, 38 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b8d51ee..87e3ea4 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -3,9 +3,6 @@ name: Weekly project build and release
on:
schedule:
- cron: "0 2 * * 0"
- push:
- branches:
- - master
jobs:
build:
diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c
index 1cc508f..639ec2b 100644
--- a/src/kernel/graphics/vesa.c
+++ b/src/kernel/graphics/vesa.c
@@ -171,14 +171,16 @@ void set_optimal_resolution() {
vbe_set_mode(highest);
- vesa_draw_string(vga_buffer);
-
if (vbe_height > 1440) vesa_set_font(32);
else if (vbe_height > 720) vesa_set_font(24);
else vesa_set_font(16);
vesa_set_color(default_text_color);
vesa_clear();
+ vesa_set_color(vesa_blue);
+ vesa_draw_string(vga_buffer);
+ vesa_set_color(default_text_color);
+
info("Successfully switched to video mode!");
serial_write("Using mode: ");
@@ -335,21 +337,8 @@ void vesa_draw_string(const char *data) {
}
void vesa_draw_number(int n) {
- if (n == 0) vesa_draw_char('0');
- int acc = n;
- char c[32];
- int i = 0;
- while (acc > 0) {
- c[i] = '0' + acc % 10;
- acc /= 10;
- i++;
- }
- c[i] = 0;
- static char c2[32];
- c2[i--] = 0;
- int j = 0;
- while (i >= 0) c2[i--] = c[j++];
- vesa_draw_string(c2);
+ char string[16];
+ vesa_draw_string(itoa(n, string));
}
void vesa_set_color(uint32_t color) {
diff --git a/src/kernel/io/io.c b/src/kernel/io/io.c
index 974c391..acbe3dc 100644
--- a/src/kernel/io/io.c
+++ b/src/kernel/io/io.c
@@ -88,19 +88,6 @@ void serial_write_hex(int n) {
}
void serial_write_dec(int n) {
- if (n == 0) serial_put('0');
- int acc = n;
- char c[32];
- int i = 0;
- while (acc > 0) {
- c[i] = '0' + acc % 10;
- acc /= 10;
- i++;
- }
- c[i] = 0;
- static char c2[32];
- c2[i--] = 0;
- int j = 0;
- while (i >= 0) c2[i--] = c[j++];
- serial_write(c2);
+ char string[16];
+ serial_write(itoa(n, string));
}
diff --git a/src/kernel/lib/lib.h b/src/kernel/lib/lib.h
index 420dd5b..5cc3d1f 100644
--- a/src/kernel/lib/lib.h
+++ b/src/kernel/lib/lib.h
@@ -33,6 +33,14 @@ void strcat(char *dest, const char *src);
void strcpy(char *dest, const char *src);
/**
+ * Convert an integer to a char array (string)
+ * @param i The integer
+ * @param b The char array
+ * @return The char pointer
+ */
+char *itoa(int i, char b[]);
+
+/**
* Copy n data from src to dest
* @param dest The destination array pointer
* @param src The source array pointer of the data
diff --git a/src/kernel/lib/string.c b/src/kernel/lib/string.c
index c171439..12b4b06 100644
--- a/src/kernel/lib/string.c
+++ b/src/kernel/lib/string.c
@@ -10,7 +10,7 @@ size_t strlen(const char *str) {
size_t strcmp(const char *s1, const char *s2) {
size_t s_a = strlen(s1);
- for (size_t i = 0; i < s_a; i++)
+ for (size_t i = 0; i < s_a; i++)
if (s1[i] != s2[i])
return 1;
return 0;
@@ -30,3 +30,23 @@ void strcpy(char *dest, const char *src) {
for (size_t i = 0; i < s_orig; i++) dest[i] = src[i];
dest[s_orig] = 0;
}
+
+char *itoa(int i, char b[]) {
+ char const digit[] = "0123456789";
+ char *p = b;
+ if (i < 0) {
+ *p++ = '-';
+ i *= -1;
+ }
+ int shifter = i;
+ do {
+ ++p;
+ shifter = shifter / 10;
+ } while (shifter);
+ *p = '\0';
+ do {
+ *--p = digit[i % 10];
+ i = i / 10;
+ } while (i);
+ return b;
+} \ No newline at end of file
diff --git a/src/kernel/system.c b/src/kernel/system.c
index 3b3cf95..688b0b1 100644
--- a/src/kernel/system.c
+++ b/src/kernel/system.c
@@ -9,8 +9,15 @@ void vga_log(char *msg, int line) {
uint16_t *terminal_buffer = (uint16_t *) 0xB8000;
for (size_t i = 0; i < strlen(msg); i++)
terminal_buffer[line * 80 + i] = (uint16_t) msg[i] | (uint16_t) 0x700;
- strcpy(msg, "\n");
- memcpy(vga_buffer, msg, sizeof(msg));
+ char string[80];
+ char time[8];
+ strcpy(string, "[");
+ strcat(string, itoa((int) get_time(), time));
+ strcat(string, "] ");
+ strcat(string, "INFORMATION: ");
+ strcat(string, msg);
+ strcat(string, "\n");
+ strcat(vga_buffer, string);
}
void kernel_time() {