debugging
authorJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 17 Aug 2024 14:56:16 +0000 (17:56 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Sat, 17 Aug 2024 14:56:16 +0000 (17:56 +0300)
kern/src/con.c
kern/src/config.h
kern/src/dbg.c
kern/src/dev.c
kern/src/intr.c
kern/src/libc/string.c
kern/src/ser.c

index 2c2965d..b9b91a4 100644 (file)
@@ -10,22 +10,15 @@ static struct file *devfile;
 void con_init(void)
 {
        if(!(devfile = dev_open(CONDEV, 0, O_RDWR))) {
-               //panic("can't open console device %d,%d\n", CONDEV, 0);
-       }
-}
-
-void con_printf(const char *fmt, ...)
-{
-       /* TODO */
-       while(*fmt) {
-               con_putchar(*fmt++);
+               panic("can't open console device %d,%d\n", CONDEV, 0);
        }
 }
 
 void con_putchar(int c)
 {
        if(devfile) {
-               devfile->dev->fop->write(devfile, &c, 1);
+               vid_putchar(c); /* XXX dbg */
+               //devfile->dev->fop->write(devfile, &c, 1);
        } else {
                vid_putchar(c);
        }
index d46832b..45bf49f 100644 (file)
@@ -4,6 +4,6 @@
 #define VERSTR         "v0.0"
 
 /* CONDEV: which device to use for the kernel console (DEV_VID or DEV_SER) */
-#define CONDEV         DEV_VID
+#define CONDEV         DEV_SER
 
 #endif /* CONFIG_H_ */
index 7daf689..5dcab9f 100644 (file)
@@ -20,7 +20,7 @@ void panic(const char *fmt, ...)
        vprintf(fmt, ap);
        va_end(ap);
 
-       printf("ax:%04x bx:%04x cx:%04x dx:%04x\n", regs.ax, regs.bx, regs.cx, regs.dx);
+       printf("\nax:%04x bx:%04x cx:%04x dx:%04x\n", regs.ax, regs.bx, regs.cx, regs.dx);
        printf("bp:%04x si:%04x di:%04x flags:%04x\n", regs.bp, regs.si, regs.di, regs.flags);
        printf("ss:sp %04x:%04x cs:ip %04x:%04x ds:%04x es:%04x\n", sregs.ss, regs.sp,
                        sregs.cs, regs.ip, sregs.ds, sregs.es);
index 0648a36..312b821 100644 (file)
@@ -1,4 +1,6 @@
+#include <stdio.h>
 #include "dev.h"
+#include "dbg.h"
 
 struct device devices[MAX_DEVICES];
 
@@ -14,8 +16,12 @@ struct file *dev_open(int major, int minor, unsigned int flags)
        if(!devices[major].fop) {
                return 0;
        }
+       printf("dev_open(%x, %x, %x)\n", major, minor, flags);
        if(devices[major].fop->open(&file, &fakenode, flags) < 0) {
+               panic("open failed");
                return 0;
        }
+       panic("WTF");
+
        return &file;
 }
index e682b30..a76a72f 100644 (file)
@@ -43,9 +43,6 @@ void intr_entry_irq5();
 void intr_entry_irq6();
 void intr_entry_irq7();
 
-extern int _kern_start_seg;
-#define KERN_CS        ((uint16_t)(&_kern_start_seg))
-
 
 void init_intr(void)
 {
@@ -55,7 +52,7 @@ void init_intr(void)
                intrfunc[i] = 0;
        }
 
-       set_intr_vect(0, KERN_CS, (uint16_t)intr_entry_div);
+       set_intr_vect(0, 0, (uint16_t)intr_entry_div);
 }
 
 void dispatch_intr(struct intr_frame frm)
index 8b5325a..36c1d53 100644 (file)
@@ -6,3 +6,14 @@ int strlen(const char *s)
        while(*end) end++;
        return end - s;
 }
+
+/*
+void *memset(void *s, int c, unsigned int n)
+{
+       unsigned char *ptr = s;
+       while(n-- > 0) {
+               *ptr++ = c;
+       }
+       return s;
+}
+*/
index db948e9..b30af46 100644 (file)
@@ -1,9 +1,11 @@
+#include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #include "ser.h"
 #include "file.h"
 #include "dev.h"
 #include "asmutil.h"
+#include "dbg.h"
 
 #define UART1_BASE     0x3f8
 #define UART2_BASE     0x2f8
@@ -25,7 +27,7 @@
 static void setuart(int portidx, int baud);
 static void serput(int portidx, int c);
 
-static int ser_open(struct file *file, struct inode *inode, unsigned int flags);
+int ser_open(struct file *file, struct inode *inode, unsigned int flags);
 static int ser_close(struct file *file);
 static int ser_read(struct file *file, void *buf, int sz);
 static int ser_write(struct file *file, void *buf, int sz);
@@ -82,10 +84,12 @@ static void serput(int portidx, int c)
        outp(iobase | UART_DATA, c);
 }
 
-static int ser_open(struct file *file, struct inode *inode, unsigned int flags)
+int ser_open(struct file *file, struct inode *inode, unsigned int flags)
 {
        int port = inode->dev_minor;
 
+       panic("ser_open");
+
        if(port < 0 || port >= 2) {
                return -ENXIO;
        }