diff -Naur udos-0.0.2/Makefile udos-0.0.2_new/Makefile --- udos-0.0.2/Makefile 2006-04-17 23:05:45.000000000 +0900 +++ udos-0.0.2_new/Makefile 2006-06-28 22:20:43.000000000 +0900 @@ -1,3 +1,7 @@ +HOSTGCC= +TARGETGCC= +LIBBFD_LDPATH= +LIBBFD_INCLUDEPATH= USER_SRC = ${wildcard user/*.c user/*.S user/*.h user/Makefile} USER_BIN = ${wildcard bin/*.bin} @@ -5,8 +9,8 @@ KERNEL_IMG = kernel.bin boot16.boot bochs.rc Makefile all: - cd kernel; make - cd user; make + cd kernel; make TARGETGCC=$(TARGETGCC) HOSTGCC=$(HOSTGCC) LIBBFD_LDPATH=$(LIBBFD_LDPATH) LIBBFD_INCLUDEPATH=$(LIBBFD_INCLUDEPATH) + cd user; make TARGETGCC=$(TARGETGCC) HOSTGCC=$(HOSTGCC) make floppya.img floppya.img: kernel/fat12.exe ${USER_SRC} ${USER_BIN} ${KERNEL_SRC} ${KERNEL_BIN} fat-floppy.img @@ -22,7 +26,7 @@ cp fat-floppy.bak fat-floppy.img floppya.img.dis: floppya.img - objdump -bbinary -mi8086 -D floppya.img > floppya.img.dis + $(TARGETGCC)objdump -bbinary -mi8086 -D floppya.img > floppya.img.dis write: floppya.img dd if=floppya.img of=/dev/fd0 @@ -35,6 +39,7 @@ clean: -rm -f bocks.out floppya.img kernel.bin boot16.boot *~ + -rm -rf bin cd kernel; make clean cd user; make clean ci: diff -Naur udos-0.0.2/kernel/Makefile udos-0.0.2_new/kernel/Makefile --- udos-0.0.2/kernel/Makefile 2004-12-08 10:00:36.000000000 +0900 +++ udos-0.0.2_new/kernel/Makefile 2006-06-27 22:49:04.000000000 +0900 @@ -9,37 +9,37 @@ all: kernel.bin boot16.boot kernel.dis boot16.dis exe2bin.exe fat12.exe %.o: %.S - gcc $(WARNING) -DKERNEL -c $< + $(TARGETGCC)gcc $(WARNING) -DKERNEL -c $< %.o: %.c - gcc $(WARNING) -DKERNEL -c -nostdinc $< + $(TARGETGCC)gcc -fleading-underscore $(WARNING) -DKERNEL -c -nostdinc $< kernel.exe: $(KERNEL) $(INCLUDE) - ld -e boot32_start -Ttext 0x10000 -o kernel.exe $(KERNEL) + $(TARGETGCC)ld -e boot32_start -Ttext 0x10000 -o kernel.exe $(KERNEL) # -s=strip, -x=delete all local symbols, -e=set entry (default is kinda `main') boot16.boot: boot16.o - objcopy -O binary boot16.o boot16.boot # remove header etc. + $(TARGETGCC)objcopy -O binary boot16.o boot16.boot # remove header etc. cp boot16.boot .. boot16.dis: boot16.o - objdump -D -mi8086 boot16.o > boot16.dis + $(TARGETGCC)objdump -D -mi8086 boot16.o > boot16.dis kernel.dis: kernel.exe - objdump -D kernel.exe > kernel.dis + $(TARGETGCC)objdump -D kernel.exe > kernel.dis kernel.bin: kernel.exe exe2bin.exe ./exe2bin.exe kernel.exe kernel.bin cp kernel.bin .. clean: - rm -f *.exe *.o *.dis *.bin *.img *~ \#*\# bochs.out \ + rm -f *.exe *.o *.dis *.bin *.img *.boot *~ \#*\# bochs.out \ snapshot.txt *.stackdump ci: ci -l *.S *.c *.h Makefile MEMO ######################################################################### exe2bin.exe: exe2bin.c - gcc -DDEBUG $(CFLAGS) -o exe2bin exe2bin.c -lbfd -liberty -lintl + $(HOSTGCC)gcc $(LIBBFD_LDPATH) $(LIBBFD_INCLUDEPATH) -DDEBUG $(CFLAGS) -o exe2bin.exe exe2bin.c -lbfd -liberty -lintl fat12.exe: fat12.c - gcc $(CFLAGS) -o fat12 fat12.c + $(HOSTGCC)gcc $(CFLAGS) -o fat12.exe fat12.c ######################################################################### diff -Naur udos-0.0.2/kernel/boot32.h udos-0.0.2_new/kernel/boot32.h --- udos-0.0.2/kernel/boot32.h 2006-04-17 23:04:52.000000000 +0900 +++ udos-0.0.2_new/kernel/boot32.h 2006-06-27 23:29:50.000000000 +0900 @@ -9,8 +9,8 @@ typedef uint32_t jmp_buf [6]; /* for ksetjmp/klongjmp */ /* defined in boot32.S. Note: boot32.h is not to be included in boot32.S. */ -extern uint32_t kernel_page_dir [1024]; -extern uint32_t kernel_page_tbl_IM [1024]; +#define kernel_page_dir ((uint32_t*)0x1000) +#define kernel_page_tbl_IM ((uint32_t*)0x2000) void kbd_intr_handler_entry (void); void pit_intr_handler_entry (void); diff -Naur udos-0.0.2/kernel/cpu.c udos-0.0.2_new/kernel/cpu.c --- udos-0.0.2/kernel/cpu.c 2004-07-14 14:43:22.000000000 +0900 +++ udos-0.0.2_new/kernel/cpu.c 2006-06-27 23:29:23.000000000 +0900 @@ -105,7 +105,7 @@ /* xxx: initialize kernel TSS */ kernel_tss.ss0 = 0x10; /* kernel data selector */ kernel_tss.esp0 = KERNEL_STACK_ADDR; - kernel_tss.cr3 = (uint32_t) &kernel_page_dir; /* defined in boot32.S */ + kernel_tss.cr3 = (uint32_t) kernel_page_dir; /* defined in boot32.S */ kernel_tss.ldt = 0x00; /* null selector */ kernel_tss.trace = 0; /* no trap */ kernel_tss.iobase = 0; /* empty I/O permission map */ diff -Naur udos-0.0.2/kernel/exe2bin.c udos-0.0.2_new/kernel/exe2bin.c --- udos-0.0.2/kernel/exe2bin.c 2004-12-08 10:00:42.000000000 +0900 +++ udos-0.0.2_new/kernel/exe2bin.c 2006-06-28 22:21:01.000000000 +0900 @@ -65,9 +65,9 @@ int main (int argc, char *argv []) { - enum { MAX_SECTION = 5 }; + enum { MAX_SECTION = 6 }; asection *section [MAX_SECTION]; - char *section_name [MAX_SECTION] = {".text", ".data", ".rdata", ".idata", ".bss"}; + char *section_name [MAX_SECTION] = {".text", ".data", ".rodata", ".rdata", ".idata", ".bss"}; bfd *abfd; int i; FILE *fp; if (argc < 3) { @@ -83,8 +83,14 @@ } bfd_init (); - abfd = bfd_openr (argv [1], "default"); - bfd_check_format (abfd, bfd_object); + if(!(abfd = bfd_openr (argv [1], "default"))) { + bfd_perror(0); + exit(1); + } + if(!bfd_check_format (abfd, bfd_object)) { + bfd_perror(0); + exit(1); + } #if defined(DEBUG) printf ("start address = %lx\n", abfd->start_address); #endif diff -Naur udos-0.0.2/kernel/fd.c udos-0.0.2_new/kernel/fd.c --- udos-0.0.2/kernel/fd.c 2004-07-14 14:43:24.000000000 +0900 +++ udos-0.0.2_new/kernel/fd.c 2006-06-28 21:30:37.000000000 +0900 @@ -414,7 +414,6 @@ for (i = 0; i < 4; i++) { uint8_t st0 = FDC_sense_interrupt_status (); - assert (st0 == (0xC0 | (uint8_t)i)); } /* issue SPECIFY command */ diff -Naur udos-0.0.2/kernel/main.c udos-0.0.2_new/kernel/main.c --- udos-0.0.2/kernel/main.c 2004-09-21 14:26:58.000000000 +0900 +++ udos-0.0.2_new/kernel/main.c 2006-06-27 23:07:15.000000000 +0900 @@ -34,6 +34,7 @@ kmem_map (KERNEL_STACK_ADDR); kmem_map (KERNEL_STACK_ADDR - 4); asm volatile ("movl %0, %%esp"::"r"(KERNEL_STACK_ADDR)); + asm volatile ("movl %esp, %ebp"); /* enable intr: (IRQ0(timer), IRQ1(kbd), IRQ6(fdc)) */ outb (inb (0x21) & ~((1<<0)+(1<<1)+(1<<6)), 0x21); diff -Naur udos-0.0.2/kernel/paging.c udos-0.0.2_new/kernel/paging.c --- udos-0.0.2/kernel/paging.c 2005-11-23 22:18:28.000000000 +0900 +++ udos-0.0.2_new/kernel/paging.c 2006-06-27 23:26:58.000000000 +0900 @@ -139,7 +139,7 @@ /* set %cr0's PG bit (paging on). From now on, any physical addresses cannot be dereferenced. */ asm volatile ("movl %cr0, %eax\n" - "orl 0x80000000, %eax\n" + "orl $0x80000000, %eax\n" "movl %eax, %cr0"); } diff -Naur udos-0.0.2/user/Makefile udos-0.0.2_new/user/Makefile --- udos-0.0.2/user/Makefile 2004-09-21 14:26:38.000000000 +0900 +++ udos-0.0.2_new/user/Makefile 2006-06-27 22:24:10.000000000 +0900 @@ -11,19 +11,20 @@ .PRECIOUS: %.exe all: crt.o libudos.o ${BIN} ${CDIS} + -mkdir ../bin cp ${BIN} ../bin %.o: %.S - gcc -Wall -c $< + $(TARGETGCC)gcc -Wall -c $< %.o: %.c - gcc -Wall -c -nostdinc $< + $(TARGETGCC)gcc -fleading-underscore -Wall -c -nostdinc $< %.exe: %.o crt.o libudos.o - ld -e _start -Ttext 0x80000000 -o $@ crt.o libudos.o $< + $(TARGETGCC)ld -e _start -Ttext 0x80000000 -o $@ crt.o libudos.o $< %.dis: %.exe - objdump -D $< > $@ + $(TARGETGCC)objdump -D $< > $@ %.bin: %.exe ../kernel/exe2bin.exe ../kernel/exe2bin.exe $< $@ @@ -35,5 +36,5 @@ ci -l *.S *.c *.h Makefile ../kernel/exe2bin.exe: ../kernel/exe2bin.c - gcc $(CFLAGS) -o ../kernel/exe2bin ../kernel/exe2bin.c -lbfd -liberty -lintl + $(HOSTGCC)gcc $(CFLAGS) -o ../kernel/exe2bin ../kernel/exe2bin.c -lbfd -liberty -lintl # end-of-makefile