瀏覽代碼

test: makefile for test

simon 1 年之前
父節點
當前提交
3f93cf9f3f
共有 6 個文件被更改,包括 45 次插入4 次删除
  1. 1 1
      .gitignore
  2. 2 2
      build.sh
  3. 14 1
      kernel/interrupt.h
  4. 17 0
      test/makefile
  5. 6 0
      test/test1.c
  6. 5 0
      test/test2.c

+ 1 - 1
.gitignore

@@ -36,7 +36,7 @@
 CMakeCache.txt
 CMakeFiles
 CMakeScripts
-Makefile
+# Makefile
 cmake_install.cmake
 install_manifest.txt
 

+ 2 - 2
build.sh

@@ -83,5 +83,5 @@ else
     exit
 fi
 
-echo "Now starting bochs ..."
-bochs -f bochsrc -q
+# echo "Now starting bochs ..."
+# bochs -f bochsrc -q

+ 14 - 1
kernel/interrupt.h

@@ -11,6 +11,20 @@
 #define PIC_S_DATA 0xA1   // 从片的数据端口是 0xA1
 
 typedef void *intr_handler;
+void itd_init(void);
+
+/* 定义中断的两种状态:
+ * INTR_OFF值为 0,表示关中断
+ * INTR_ON值为 1,表示开中断 */
+enum intr_status
+{
+    INTR_OFF,
+    INTR_ON
+};
+enum intr_status intr_get_status(void);
+enum intr_status intr_set_status(enum intr_status);
+enum intr_status intr_enable(void);
+enum intr_status intr_disable(void);
 
 /* 中断门描述符结构体 */
 // Example type_attributes values that people are likely to use (assuming DPL is 0):
@@ -28,7 +42,6 @@ typedef struct
 
 static void make_idt_desc(gate_desc *p_gdesc, uint8_t attr, intr_handler function);
 static void itd_desc_init(void);
-void itd_init(void);
 
 static gate_desc idt[IDT_DESC_CNT]; // 中断描述符表,本质上就是个中断门描述符数组
 // 定义中断处理程序数组.在 kernel.S 中定义的intrXXentry只是中断处理程序的入口,最终调用的是ide_table中的处理程序

+ 17 - 0
test/makefile

@@ -0,0 +1,17 @@
+CC = gcc
+CFLAGS = -Wall -g
+
+# test2.o: test2.c
+# 	$(CC) $(CFLAGS) -c test2.c -o test2.o
+# test1.o: test1.c
+# 	$(CC) $(CFLAGS) -c test1.c -o test1.o
+%.o: %.c
+	$(CC) $(CFLAGS) -c $^ -o $@
+objfiles = test1.o test2.o
+test: $(objfiles)
+	$(CC) $(CFLAGS) $^ -o $@
+all: test
+	@echo "Build complete"
+.PHONY: clean
+clean:
+	rm -f test1.o test2.o test

+ 6 - 0
test/test1.c

@@ -0,0 +1,6 @@
+void my_print(char *);
+int main()
+{
+    my_print("Hello, world!\n");
+    return 0;
+}

+ 5 - 0
test/test2.c

@@ -0,0 +1,5 @@
+#include <stdio.h>
+void my_print(char *str)
+{
+    printf("%s\n", str);
+}