Add support for strings (func serial_print) and newlines in serial
This commit is contained in:
parent
eb9ba8f632
commit
13618eeb27
|
@ -10,6 +10,9 @@ void kernel_main(void) {
|
||||||
printf("Hello from OrionOS!\n");
|
printf("Hello from OrionOS!\n");
|
||||||
printf("Testing serial\n");
|
printf("Testing serial\n");
|
||||||
init_serial();
|
init_serial();
|
||||||
write_serial('t');
|
serial_print("Test is success!\n");
|
||||||
|
serial_print("Newline test\n");
|
||||||
|
serial_print("No newline test ");
|
||||||
|
serial_print("No newline test");
|
||||||
printf("Test finished success!\n");
|
printf("Test finished success!\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define PORT 0x3f8 // COM1
|
#define PORT 0x3f8 // COM1
|
||||||
|
|
||||||
|
@ -44,8 +45,16 @@ void write_serial(char a) {
|
||||||
outb(PORT, a);
|
outb(PORT, a);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_printf() {
|
void serial_print(const char* str, ...) {
|
||||||
|
size_t len = strlen(str);
|
||||||
|
for (size_t i=0; i < len; i++) {
|
||||||
|
if (str[i] == '\n') {
|
||||||
|
write_serial('\r');
|
||||||
|
write_serial('\n');
|
||||||
|
} else {
|
||||||
|
write_serial(str[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void outb(uint16_t port, uint8_t val)
|
inline void outb(uint16_t port, uint8_t val)
|
||||||
|
|
Loading…
Reference in New Issue