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
/*
*--------------------------------------------------------------------------
- * File Name: helloworld.c
+ * File Name: hello.c
*
* Author: Zhao Yanbai [zhaoyanbai@126.com]
* Tue Feb 23 22:44:40 2010
#include <unistd.h>
#include <stdio.h>
-int hw()
+int main()
{
printf("hello world\n");
//syscall3(SYSC_WRITE, 0, "fuck", 5);
+++ /dev/null
-/*
- *--------------------------------------------------------------------------
- * 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
+++ /dev/null
-/*
- *--------------------------------------------------------------------------
- * 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
void get_cmd()
{
+#if 0
int i;
i=0;
}
cmd[CMD_SIZE-1] = 0;
+#endif
}
-int shell()
+int main()
{
char buf[CMD_SIZE];
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
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);
}
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;
void ide_default_intr()
{
- printk("%s\n", __func__);
+ printd("%s\n", __func__);
u8_t status = inb(REG_STATUS(0));
drv.irq_cnt++;
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)));
}
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);
}
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
" by "
BUIDER;
+int main() { } // for libc
void setup_kernel()
{
detect_cpu();
- printk("%s\n", version);
-
setup_fs();
+
+ printk("%s\n", version);
}
*
*--------------------------------------------------------------------------
*/
+#if 0
#include <system.h>
#include <syscall.h>
#include <stdio.h>
return -1;
}
+#endif
--- /dev/null
+.extern main
+.global _start
+
+_start:
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+
+ call main
+
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+ nop
+1:
+ jmp 1b
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/