]> Zhao Yanbai Git Server - kernel.git/commitdiff
update bin/Makefile
authorAceVest <zhaoyanbai@126.com>
Wed, 9 Jul 2014 15:13:50 +0000 (23:13 +0800)
committerAceVest <zhaoyanbai@126.com>
Wed, 9 Jul 2014 15:13:50 +0000 (23:13 +0800)
16 files changed:
bin/Makefile
bin/hello [new file with mode: 0755]
bin/hello.c [moved from bin/helloworld.c with 93% similarity]
bin/helloworld.S [deleted file]
bin/shell [new file with mode: 0755]
bin/shell.S [deleted file]
bin/shell.c
drivers/blk_rw.c
drivers/ide.c
fs/ext2.c
kernel/assert.c [moved from lib/assert.c with 100% similarity]
kernel/cpuid.c
kernel/setup.c
lib/keyboard.c
lib/libc.S [new file with mode: 0644]
scripts/copy.sh

index a64df42adf4fa18117fd9699326bce7449f2d383..848260c32ef7f30dfdc1cc89e410134fd493ed6a 100644 (file)
@@ -1,20 +1,24 @@
 CC = gcc
+LDFLAG = -e _start
 CFLAGS = -c -I../include -fno-builtin
-LDOBJS = ../lib/errno.c.o ../lib/fork.c.o ../lib/lib.c.o ../lib/open.c.o \
-       ../lib/stat.c.o ../lib/string.c.o ../lib/write.c.o ../lib/exec.c.o \
-       ../lib/vsprintf.c.o ../lib/read.c.o \
-       ../lib/keyboard.c.o ../lib/exit.c.o ../lib/syscall.c.o
-all:
-       gcc -c shell.S -o shell.S.c.o
-       gcc $(CFLAGS) shell.c -o shell.c.o
-       ld $(LDOBJS) shell.S.c.o shell.c.o -o sh
-       gcc -c helloworld.S -o helloworld.S.c.o
-       gcc $(CFLAGS) helloworld.c -o helloworld.c.o
-       ld $(LDOBJS) helloworld.S.c.o helloworld.c.o -o hw 
+LIBC_DIRS = ../lib
+LIBC_SRCS := $(foreach DIR, $(LIBC_DIRS), $(wildcard $(DIR)/*.[cS]))
+LIBC_OBJS := $(patsubst %,%.o,$(LIBC_SRCS))
+BINS := shell hello
+
+all:$(BINS)
+
+shell: shell.o
+       gcc $(CFLAGS) shell.c -o shell.o
+       ld ${LIBC_OBJS} shell.o -o shell
+hello: hello.o
+       gcc $(CFLAGS) hello.c -o hello.o
+       ld $(LIBC_OBJS) hello.o -o hello
+
 
 .PHONY:clean
 clean:
-       rm sh hw helloworld.c.o -f
+       rm $(BINS) *.o -f
 .PHONY:c
 c:
        make clean
diff --git a/bin/hello b/bin/hello
new file mode 100755 (executable)
index 0000000..9df53d8
Binary files /dev/null and b/bin/hello differ
similarity index 93%
rename from bin/helloworld.c
rename to bin/hello.c
index 8b4e9c85f036b0b0f57380db711a57e39e7a4512..917720f07aaaa9aca865e8c754ee16a8526c414b 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *--------------------------------------------------------------------------
- *   File Name: helloworld.c
+ *   File Name: hello.c
  * 
  *      Author: Zhao Yanbai [zhaoyanbai@126.com]
  *              Tue Feb 23 22:44:40 2010
@@ -12,7 +12,7 @@
 #include <unistd.h>
 #include <stdio.h>
 
-int hw()
+int main()
 {
     printf("hello world\n");
     //syscall3(SYSC_WRITE, 0, "fuck", 5);
diff --git a/bin/helloworld.S b/bin/helloworld.S
deleted file mode 100644 (file)
index 55c1ab8..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *--------------------------------------------------------------------------
- *   File Name: helloworld.S
- * 
- *      Author: Zhao Yanbai [zhaoyanbai@126.com]
- *              Tue Feb 23 20:15:27 2010
- * 
- * Description: none
- * 
- *--------------------------------------------------------------------------
- */
-#define ASM
-#include <syscall.h>
-.global    _start
-_start:
-    nop
-    nop
-    nop
-    #xchg %bx, %bx
-loop:
-    #jmp    loop
-    call    hw
-    
-    nop
-    nop
-    nop
-    nop
-    nop
-die:
-    jmp    die
diff --git a/bin/shell b/bin/shell
new file mode 100755 (executable)
index 0000000..2be5a31
Binary files /dev/null and b/bin/shell differ
diff --git a/bin/shell.S b/bin/shell.S
deleted file mode 100644 (file)
index 93330fc..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- *--------------------------------------------------------------------------
- *   File Name: shell.S
- * 
- *      Author: Zhao Yanbai [zhaoyanbai@126.com]
- *              Wed Feb 24 17:47:27 2010
- * 
- * Description: none
- * 
- *--------------------------------------------------------------------------
- */
-.global    _start
-_start:
-    nop
-    nop
-    nop
-loop:
-    #jmp    loop
-    call    shell
-    nop
-    nop
-    nop
-    nop
-    nop
-    nop
-    nop
-    nop
-die:
-    jmp    die
index 3883d962273dbf6d6b0c606194109b856d2d0d6f..4389260c2a77da38c1388883353350e4b3119bd0 100644 (file)
@@ -17,6 +17,7 @@ char cmd[CMD_SIZE];
 
 void get_cmd()
 {
+#if 0
     int i;
 
     i=0;
@@ -72,9 +73,10 @@ reinput:
     }
 
     cmd[CMD_SIZE-1] = 0;
+#endif
 }
 
-int shell()
+int main()
 {
     char buf[CMD_SIZE];
 
@@ -113,41 +115,3 @@ int shell()
 
     return 0;
 }
-
-#if 0
-int shell()
-{
-    pid_t pid;
-
-    pid = fork();
-
-    if(pid<0)
-    {
-        printf("shit happens in shell\n");
-        while(1);
-    }
-    else if(pid == 0)
-    {
-        execv("/bin/hw", NULL);
-    }
-    else
-    {
-
-        while(1)
-        {
-            int k;
-            char ch;
-            extern char ParseKbdInput(int k);
-            extern unsigned char read_kbd();
-            //asm("xchg %bx, %bx");
-            k = read_kbd();
-            ch = ParseKbdInput(k);
-            if(ch != -1)
-            printf("<%c>",ch);
-        }
-    }
-
-
-    return 0;
-}
-#endif
index 2b7865ff088e501dcf39c33cd753e8baf5baaeb9..1441f598b4f5ba635d2d146b0ef298bef99572cd 100644 (file)
@@ -27,7 +27,7 @@ void blk_rw(dev_t dev, u64_t offset, u32_t size, char *buf)
 
     u32_t scnt = size / SECT_SIZE;
 
-    printk("%s lba %u scnt %u\n", __func__, (u32_t)lba, scnt);
+    printd("%s lba %u scnt %u\n", __func__, (u32_t)lba, scnt);
 
     ide_do_read(lba, scnt, buf);
 }
index 1e4be5493a839853b94e36001b358aa191e4e3d5..3d2f6ccb0642dbd0a4a9ffd7b179446f3f503e5c 100644 (file)
@@ -80,7 +80,6 @@ void ide_printl()
 
 void ide_cmd_out(dev_t dev, u32 sect_cnt, u64 sect_nr, u32 cmd)
 {
-    printk("sect_cnt %u sect_nr %u \n", sect_cnt, (u32)sect_nr);
     drv.pio_cnt++;
     drv.read_mode = cmd;
 
@@ -230,7 +229,7 @@ void init_pci_controller(unsigned int classcode)
 
 void ide_default_intr()
 {
-    printk("%s\n", __func__);
+    printd("%s\n", __func__);
     u8_t status = inb(REG_STATUS(0));
 
     drv.irq_cnt++;
index ce08decfd5a36bf2a69c682b7e0651262a4e1daf..45cf95ad75c75507250fc4b37e8b9d67ab38c69c 100644 (file)
--- a/fs/ext2.c
+++ b/fs/ext2.c
@@ -26,8 +26,6 @@ void ext2_setup_fs()
     if(buf == 0)
         panic("out of memory");
 
-    printk("EXT2_BLOCK_SIZE %u\n", EXT2_BLOCK_SIZE);
-
     BLKRW(EXT2_SB_OFFSET, 1, buf);
 
     memcpy(EXT2_SB, buf, sizeof(*(EXT2_SB)));
@@ -39,11 +37,11 @@ void ext2_setup_fs()
     }
 
     printk("Ext2 File System Information:\n");
-    printk("inodes cnt %u blocks cnt %u free blocks %u free inodes %u\n",
+    printk(" inodes %u blocks %u free blocks %u free inodes %u\n",
         EXT2_SB->s_inodes_count, EXT2_SB->s_blocks_count, EXT2_SB->s_free_blocks_count, EXT2_SB->s_free_inodes_count);
-    printk("block size %u log block size %u first data block %u\n",
+    printk(" block size %u log block size %u first data block %u\n",
         EXT2_BLOCK_SIZE, EXT2_SB->s_log_block_size, EXT2_SB->s_first_data_block);
-    printk("blocks per group %u inodes per group %u\n", EXT2_SB->s_blocks_per_group, EXT2_SB->s_inodes_per_group);
+    printk(" blocks per group %u inodes per group %u\n", EXT2_SB->s_blocks_per_group, EXT2_SB->s_inodes_per_group);
 }
 
 
similarity index 100%
rename from lib/assert.c
rename to kernel/assert.c
index 383cb81c848c5221d6e2a740b1a37b67e5455eab..6d94a7948654adfa32b8398b0a69dfdb05e6d6ca 100644 (file)
@@ -71,7 +71,7 @@ void    detect_cpu()
     memcpy(pbs + 40 , &r.ecx, 4);
     memcpy(pbs + 44 , &r.edx, 4);
     pbs[48] = 0;
-    printk("Model Name: %s",pbs);
+    printk("%s",pbs);
 
      /**********************Get Number of Processors********************/
     int pn;//number of logical processors in one physical processor
index e0239e30e15384a191fc4f54fdf4dcaeba3cd3b3..afeef42a91252a488a277ce2f3039e4ecad10445 100644 (file)
@@ -54,6 +54,7 @@ const char *version =
     " by "
     BUIDER;
 
+int main() { } // for libc
 
 void setup_kernel()
 {
@@ -92,8 +93,8 @@ void setup_kernel()
 
     detect_cpu();
 
-    printk("%s\n", version);
-
     setup_fs();
+
+    printk("%s\n", version);
 }
 
index 0a3a896d5458850aa4396c7d53eb045439b69864..c9043aa6eba412a2a4a64343c5107f15103d4fcb 100644 (file)
@@ -13,6 +13,7 @@
  * 
  *--------------------------------------------------------------------------
  */
+#if 0
 #include <system.h>
 #include <syscall.h>
 #include <stdio.h>
@@ -227,3 +228,4 @@ End:
 
     return -1;
 }
+#endif
diff --git a/lib/libc.S b/lib/libc.S
new file mode 100644 (file)
index 0000000..0d3c9af
--- /dev/null
@@ -0,0 +1,22 @@
+.extern main
+.global _start
+
+_start:
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+
+    call main
+
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+    nop
+1:
+    jmp 1b
index efdd1dba160f3d47c714f54099f14b45cbdaf44d..44f2f07cf418a1af15db82ed397b1362827f1eaa 100755 (executable)
@@ -16,8 +16,8 @@ cp scripts/grub.cfg /mnt/boot/grub2/
 md5sum /mnt/boot/Kernel
 
 mkdir -p /mnt/bin/
-cp ./bin/hw /mnt/bin/
-cp ./bin/sh /mnt/bin/
+cp ./bin/shell /mnt/bin/
+cp ./bin/hello /mnt/bin/
 
 umount /mnt/