From: AceVest Date: Wed, 9 Jul 2014 15:13:50 +0000 (+0800) Subject: update bin/Makefile X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=bc19108eae8d6280704ea757e2049eb838fa07a7;p=kernel.git update bin/Makefile --- diff --git a/bin/Makefile b/bin/Makefile index a64df42..848260c 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -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 index 0000000..9df53d8 Binary files /dev/null and b/bin/hello differ diff --git a/bin/helloworld.c b/bin/hello.c similarity index 93% rename from bin/helloworld.c rename to bin/hello.c index 8b4e9c8..917720f 100644 --- a/bin/helloworld.c +++ b/bin/hello.c @@ -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 #include -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 index 55c1ab8..0000000 --- a/bin/helloworld.S +++ /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 -.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 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 index 93330fc..0000000 --- a/bin/shell.S +++ /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 diff --git a/bin/shell.c b/bin/shell.c index 3883d96..4389260 100644 --- a/bin/shell.c +++ b/bin/shell.c @@ -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 diff --git a/drivers/blk_rw.c b/drivers/blk_rw.c index 2b7865f..1441f59 100644 --- a/drivers/blk_rw.c +++ b/drivers/blk_rw.c @@ -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); } diff --git a/drivers/ide.c b/drivers/ide.c index 1e4be54..3d2f6cc 100644 --- a/drivers/ide.c +++ b/drivers/ide.c @@ -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++; diff --git a/fs/ext2.c b/fs/ext2.c index ce08dec..45cf95a 100644 --- 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); } diff --git a/lib/assert.c b/kernel/assert.c similarity index 100% rename from lib/assert.c rename to kernel/assert.c diff --git a/kernel/cpuid.c b/kernel/cpuid.c index 383cb81..6d94a79 100644 --- a/kernel/cpuid.c +++ b/kernel/cpuid.c @@ -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 diff --git a/kernel/setup.c b/kernel/setup.c index e0239e3..afeef42 100644 --- a/kernel/setup.c +++ b/kernel/setup.c @@ -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); } diff --git a/lib/keyboard.c b/lib/keyboard.c index 0a3a896..c9043aa 100644 --- a/lib/keyboard.c +++ b/lib/keyboard.c @@ -13,6 +13,7 @@ * *-------------------------------------------------------------------------- */ +#if 0 #include #include #include @@ -227,3 +228,4 @@ End: return -1; } +#endif diff --git a/lib/libc.S b/lib/libc.S new file mode 100644 index 0000000..0d3c9af --- /dev/null +++ b/lib/libc.S @@ -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 diff --git a/scripts/copy.sh b/scripts/copy.sh index efdd1db..44f2f07 100755 --- a/scripts/copy.sh +++ b/scripts/copy.sh @@ -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/