run: all
$(QEMU) boot/x86/disk.img
+debug: all
+ $(QEMU) -s -S boot/x86/disk.img
+
boot/x86/mbr: boot/x86/mbr.s
boot/x86/vbr-fat32: boot/x86/vbr-fat32.s boot/x86/fat32/*.s
boot/x86/stage3/LOADER.BIN: boot/x86/stage3/*.s boot/x86/stage3/*.c boot/x86/fat32/*.s
-rm kernel/kernel.{bin,dbg,elf} ${KERNEL_OBJ}
cd boot/x86 && $(MAKE) clean
-.PHONY: default all clean run bootloader
+.PHONY: default all clean run debug bootloader
extern void kprintw(const uint16_t word);
extern void kprintd(const uint32_t dword);
extern void kprintq(const uint64_t qword);
+extern int kprintdec(uint32_t num);
#endif
temp = qword & 0xF;
kprintc(hex_chars[temp], VGA_COLOR_LIGHT_GRAY);
}
+
+int kprintdec(uint32_t num)
+{
+ char buffer[11];
+ int digits = 10;
+ /* TODO: make an actual memset function to use instead of this */
+ for (int i=0; i<11; i++) {
+ buffer[i] = 0;
+ }
+
+ /* put the numbers in the buffer */
+ for (int i=9; i>0 && num>0; i--) {
+ uint8_t currdigit = num%10;
+ buffer[i] = currdigit+'0';
+ num /= 10;
+ }
+
+ /* shift the array as much as needed */
+ while (*buffer == '\0') {
+ digits--;
+ for (int i=0; i<9; i++) {
+ buffer[i] = buffer[i+1];
+ }
+ }
+
+ /* zero out any leftovers */
+ if (digits < 10) {
+ for (int i=digits; i<10; i++) {
+ buffer[i] = '\0';
+ }
+ }
+
+ kprint(buffer, 0);
+ return digits;
+}