From: Arun Thomas Date: Wed, 19 May 2010 13:24:15 +0000 (+0000) Subject: Buildsystem changes for GCC X-Git-Tag: v3.1.7~43 X-Git-Url: http://zhaoyanbai.com/repos/man.named-checkzone.html?a=commitdiff_plain;h=b0159ad168fe3adb2edcc30af5c7c15ab0dc1631;p=minix.git Buildsystem changes for GCC -Makefile updates -Update mkdep -Build fixes/warning cleanups for some programs -Restore leading underscores on global syms in kernel asm files -Increase ramdisk size --- diff --git a/boot/Makefile b/boot/Makefile index e40aadfb1..b4e100193 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -1,5 +1,9 @@ # Makefile for the boot monitor package. +# XXX: Can only be built with ACK currently +CC:=${CC:C/^gcc/cc/} +COMPILER_TYPE:=ack + PROGS= bootblock cdbootblock bootexec boot masterboot \ jumpboot installboot edparams diff --git a/commands/aal/Makefile b/commands/aal/Makefile index 26cf974be..957ce59ec 100644 --- a/commands/aal/Makefile +++ b/commands/aal/Makefile @@ -4,7 +4,7 @@ PROG= aal SRCS= archiver.c print.c rd.c rd_arhdr.c rd_unsig2.c sprint.c \ wr_arhdr.c wr_bytes.c wr_int2.c wr_long.c wr_ranlib.c \ format.c rd_bytes.c system.c write.c long2str.c -CPPFLAGS+= -I${.CURDIR} -wo -DAAL -DSTB -DNDEBUG -DDISTRIBUTION +CPPFLAGS+= -I${.CURDIR} -DAAL -DSTB -DNDEBUG -DDISTRIBUTION LINKS+= ${BINDIR}/aal ${BINDIR}/ar MAN= diff --git a/commands/aal/archiver.c b/commands/aal/archiver.c index b7e8da46b..9bd8cd3b4 100644 --- a/commands/aal/archiver.c +++ b/commands/aal/archiver.c @@ -793,4 +793,4 @@ enter_name(namep) } tnum++; } -#endif AAL +#endif /* AAL */ diff --git a/commands/aal/local.h b/commands/aal/local.h index 9f9811457..825cfbfd7 100644 --- a/commands/aal/local.h +++ b/commands/aal/local.h @@ -12,7 +12,7 @@ # define ACKM "minix" /* size of local machine, either 0 (for 16 bit address space), or 1 */ -# undef BIGMACHINE 1 +# undef BIGMACHINE /* operating system, SYS_5, V7, BSD4_1 or BSD4_2; Do NOT delete the comment in the next line! */ diff --git a/commands/aal/system.h b/commands/aal/system.h index 72e523e77..af36299dd 100644 --- a/commands/aal/system.h +++ b/commands/aal/system.h @@ -44,4 +44,4 @@ extern File _sys_ftab[]; /* system's idea of block */ #define BUFSIZ 1024 -#endif __SYSTEM_INCLUDED__ +#endif /* __SYSTEM_INCLUDED__ */ diff --git a/commands/autil/Makefile b/commands/autil/Makefile index d6bff2f34..241d7de25 100644 --- a/commands/autil/Makefile +++ b/commands/autil/Makefile @@ -3,7 +3,7 @@ PROGS= anm asize SRCS.anm= anm.c rd.c rd_arhdr.c rd_bytes.c rd_unsig2.c SRCS.asize= asize.c -CPPFLAGS+= -I${.CURDIR} -wo +CPPFLAGS+= -I${.CURDIR} MAN.anm= MAN.asize= diff --git a/commands/cawf/Makefile b/commands/cawf/Makefile index 3eaa64048..f8388b1c9 100644 --- a/commands/cawf/Makefile +++ b/commands/cawf/Makefile @@ -34,7 +34,7 @@ # #DEFS = -DUNIX -DMALLOCH DEFS= -DUNIX -DUSG -DSTDLIB -CPPFLAGS+= -i -f -wo ${DEFS} +CPPFLAGS+= ${DEFS} PROGS= bsfilt cawf SRCS.cawf= cawf.c device.c error.c expand.c expr.c getopt.c macsup.c nreq.c \ diff --git a/commands/dis88/Makefile b/commands/dis88/Makefile index 15a699b20..769ced239 100644 --- a/commands/dis88/Makefile +++ b/commands/dis88/Makefile @@ -26,7 +26,6 @@ PROG= dis88 SRCS= disrel.c dismain.c distabs.c dishand.c disfp.c -CPPFLAGS+= -wo MAN= .include diff --git a/commands/elle/Makefile b/commands/elle/Makefile index e7bd6c6e4..ea2849aa6 100644 --- a/commands/elle/Makefile +++ b/commands/elle/Makefile @@ -1,5 +1,9 @@ # Makefile for elle +# XXX: Can only be built with ACK currently +CC:=${CC:C/^gcc/cc/} +COMPILER_TYPE:=ack + PROGS= ellec elle SRCS.elle= eemain.c eecmds.c eesite.c eevini.c eedisp.c eeterm.c eeerr.c \ eeques.c eebuff.c eefile.c eefed.c eeedit.c eebit.c eef1.c \ diff --git a/commands/ftp101/Makefile b/commands/ftp101/Makefile index 5b07ec2a1..941f4ce48 100644 --- a/commands/ftp101/Makefile +++ b/commands/ftp101/Makefile @@ -6,6 +6,6 @@ PROG= ftp SRCS= ftp.c local.c file.c xfer.c other.c net.c crc.c -CPPFLAGS+= -DCRC_ONLY -m +CPPFLAGS+= -DCRC_ONLY .include diff --git a/commands/ftpd200/Makefile b/commands/ftpd200/Makefile index d0090c66a..10ac4153b 100644 --- a/commands/ftpd200/Makefile +++ b/commands/ftpd200/Makefile @@ -5,7 +5,6 @@ PROG= in.ftpd SRCS= ftpd.c access.c file.c net.c -CPPFLAGS+= -m MAN= ftpd.8 SCRIPTS= ftpdsh FILES= setup.anonftp diff --git a/commands/indent/Makefile b/commands/indent/Makefile index de64f5b37..2f1d70b19 100644 --- a/commands/indent/Makefile +++ b/commands/indent/Makefile @@ -2,7 +2,6 @@ PROG= indent SRCS= args.c comment.c lexi.c indent.c parse.c io.c -CPPFLAGS+= -wo -m MAN= .include diff --git a/commands/mined/Makefile b/commands/mined/Makefile index 7092ba20d..f0d68dd6a 100644 --- a/commands/mined/Makefile +++ b/commands/mined/Makefile @@ -2,7 +2,6 @@ PROG= mined SRCS= mined1.c mined2.c -CPPFLAGS+= -wo MAN= .include diff --git a/commands/mkdep/mkdep.sh b/commands/mkdep/mkdep.sh index ad2f1ee07..db8328065 100644 --- a/commands/mkdep/mkdep.sh +++ b/commands/mkdep/mkdep.sh @@ -47,7 +47,7 @@ case $# in s/.*"\(.*\)".*/\1/ s:^\./::' \ -e '/^$/d' \ - -e '/^$/d' \ + -e '/^$/d' \ -e "s:^:$o\: :" | \ sort -u done diff --git a/commands/patch/Makefile b/commands/patch/Makefile index 0d5758c2b..e7507c415 100644 --- a/commands/patch/Makefile +++ b/commands/patch/Makefile @@ -2,7 +2,7 @@ PROG= patch SRCS= patch.c pch.c inp.c util.c version.c -CPPFLAGS+= -DVOIDSIG -wo -DSMALL +CPPFLAGS+= -DVOIDSIG -DSMALL MAN= .include diff --git a/commands/swifi/extra.c b/commands/swifi/extra.c index b8233f69e..87e1e4a2d 100644 --- a/commands/swifi/extra.c +++ b/commands/swifi/extra.c @@ -30,7 +30,7 @@ size_t strncpy_from_user(char *addr, const char *user_name, size_t size) /* void lock_kernel(void) { assert(0); } */ /* void unlock_kernel(void) { assert(0); } */ -void __asm__(char *str) { assert(0); } +/* void __asm__(char *str) { assert(0); } */ extern void *__vmalloc(unsigned long size, int gfp_mask, pgprot_t prot) { assert(0); } diff --git a/commands/swifi/extra.h b/commands/swifi/extra.h index ddd4b241f..f00c410e0 100644 --- a/commands/swifi/extra.h +++ b/commands/swifi/extra.h @@ -39,7 +39,7 @@ size_t strncpy_from_user(char *addr, const char *user_name, size_t size); void lock_kernel(void); void unlock_kernel(void); -void __asm__(char *str); +/* void __asm__(char *str); */ #define for_each_task(t) for(t= task_list; t; t=t->next) extern struct task_struct *task_list; diff --git a/commands/swifi/fault_model.c b/commands/swifi/fault_model.c index 0576031bd..c6c7e7b05 100644 --- a/commands/swifi/fault_model.c +++ b/commands/swifi/fault_model.c @@ -61,7 +61,7 @@ #include "swifi.h" #include "extra.h" - +#include #define CRASH_INTERVAL 8192 #define FI_MASK 0xfff @@ -310,9 +310,13 @@ sys_inject_fault(char * module_name, addr1 = (unsigned long *) 0xf0212000; addr2 = (unsigned long *) 0xf0212010; PDEBUG(("%p=%lx, %p=%lx\n", addr1, *addr1, addr2, *addr2)); + /* __asm__ ("movl $0xf0212000, %eax\n\t" \ "movl $6, 0(%eax)\n\t" \ "movl $6, 4(%eax)\n\t"); + */ + /* Not implemented on MINIX */ + assert(0); addr1 = (unsigned long *) 0xf0212000; addr2 = (unsigned long *) 0xf0212010; PDEBUG(("after injecting fault\n")); @@ -323,9 +327,13 @@ sys_inject_fault(char * module_name, case DEBUGGER_FAULT: PDEBUG(("Debugger fault")); + /* __asm__ ("movl %cr4, %ecx\n\t" \ "movl $42, %ecx; .byte 0x0f, 0x32\n\t" \ "movl $377, %ecx; .byte 0x0f, 0x32\n\t"); + */ + /* Not implemented on MINIX */ + assert(0); result = 0; break; default: PDEBUG(("unknown fault type %ld\n", faultType)); break; diff --git a/commands/synctree/Makefile b/commands/synctree/Makefile index 1895460c6..3a67e1fee 100644 --- a/commands/synctree/Makefile +++ b/commands/synctree/Makefile @@ -1,5 +1,4 @@ PROG= synctree -CPPFLAGS+= -wo MAN= .include diff --git a/commands/yap/Makefile b/commands/yap/Makefile index 14b3148eb..20ee5e8d1 100644 --- a/commands/yap/Makefile +++ b/commands/yap/Makefile @@ -1,5 +1,9 @@ # yap Makefile +# XXX: Can only be built with ACK currently +CC:=${CC:C/^gcc/cc/} +COMPILER_TYPE:=ack + PROG= yap SRCS= assert.c commands.c display.c getcomm.c getline.c help.c \ keys.c machine.c main.c options.c output.c pattern.c \ diff --git a/commands/zmodem/Makefile b/commands/zmodem/Makefile index d92d1486c..92f6f6421 100644 --- a/commands/zmodem/Makefile +++ b/commands/zmodem/Makefile @@ -1,7 +1,7 @@ # Makefile for zmodem PROGS= rz sz -CPPFLAGS+= -DPOSIX -wo +CPPFLAGS+= -DPOSIX MAN.rz= MAN.sz= diff --git a/drivers/memory/ramdisk/Makefile b/drivers/memory/ramdisk/Makefile index 63d171278..0b2e7e2fd 100644 --- a/drivers/memory/ramdisk/Makefile +++ b/drivers/memory/ramdisk/Makefile @@ -4,6 +4,7 @@ PROGRAMS=at_wini bios_wini cdprobe dev2name floppy loadramdisk newroot \ pci sh service sysenv mfs EXTRA=system.conf passwd +CPPFLAGS+= -I${MINIXSRCDIR}/servers MAKEDEV=/usr/bin/MAKEDEV all: image.c diff --git a/drivers/memory/ramdisk/proto b/drivers/memory/ramdisk/proto index 9547833cd..fb2e197bc 100644 --- a/drivers/memory/ramdisk/proto +++ b/drivers/memory/ramdisk/proto @@ -1,5 +1,5 @@ boot -200 400 +500 400 d--755 0 0 bin d--755 0 0 at_wini ---755 0 0 at_wini diff --git a/etc/mk/minix.ack.mk b/etc/mk/minix.ack.mk index 345199f84..5280a5599 100644 --- a/etc/mk/minix.ack.mk +++ b/etc/mk/minix.ack.mk @@ -1,3 +1,5 @@ +CPPFLAGS+= -wo + .SUFFIXES: .o .e .S # Treated like a C file diff --git a/etc/mk/minix.dep.mk b/etc/mk/minix.dep.mk index 95be53edb..d1188b051 100644 --- a/etc/mk/minix.dep.mk +++ b/etc/mk/minix.dep.mk @@ -15,7 +15,7 @@ MKDEP_SUFFIXES?= .o # some of the rules involve .h sources, so remove them from mkdep line .if defined(SRCS) # { -_TRADITIONAL_CPP?=-traditional-cpp +#_TRADITIONAL_CPP?=-traditional-cpp __acpp_flags= ${_TRADITIONAL_CPP} __DPSRCS.all= ${SRCS:C/\.(c|m|s|S|C|cc|cpp|cxx)$/.d/} \ diff --git a/etc/mk/minix.gcc.mk b/etc/mk/minix.gcc.mk index 5d69cf02b..3a2b0185d 100644 --- a/etc/mk/minix.gcc.mk +++ b/etc/mk/minix.gcc.mk @@ -1,2 +1 @@ AFLAGS+=-D__ASSEMBLY__ -D_EM_WSIZE=4 -D__minix - diff --git a/etc/mk/minix.own.mk b/etc/mk/minix.own.mk index 9370afdc8..cd3aa84d9 100644 --- a/etc/mk/minix.own.mk +++ b/etc/mk/minix.own.mk @@ -6,9 +6,6 @@ _MINIX_OWN_MK_=1 MAKECONF?= /etc/make.conf .-include "${MAKECONF}" -#Set to ack by default -COMPILER_TYPE?=ack - # # CPU model, derived from MACHINE_ARCH # diff --git a/etc/mk/sys.mk b/etc/mk/sys.mk index 98167a076..5cc42e252 100644 --- a/etc/mk/sys.mk +++ b/etc/mk/sys.mk @@ -15,7 +15,8 @@ AS?= as AFLAGS?= COMPILE.s?= ${CC} ${AFLAGS} -c LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} -COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp +#COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp +COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} CC?= cc @@ -223,3 +224,11 @@ YACC.y?= ${YACC} ${YFLAGS} # rm -f ${.TARGET} # cp ${.IMPSRC} ${.TARGET} # chmod a+x ${.TARGET} + +# MINIX +.if !empty(CC:Mcc) +COMPILER_TYPE=ack +.elif !empty(CC:Mgcc) +COMPILER_TYPE=gnu +AR=gar +.endif diff --git a/kernel/Makefile b/kernel/Makefile index 44093da0f..d60d2107c 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -12,13 +12,19 @@ SRCS+= start.c table.c main.c proc.c \ DPADD+= ${LIBTIMERS} ${LIBSYS} LDADD+= -ltimers -lsys -LDFLAGS+= -.o +.if ${COMPILER_TYPE} == "ack" +LDFLAGS+= -.o +.elif ${COMPILER_TYPE} == "gnu" +CPPFLAGS+= -fno-builtin -ffreestanding -fno-stack-protector +LDFLAGS+= -T arch/${ARCH}/kernel.lds +LDFLAGS+= -nostdlib +DPADD+= ${LIBC} +LDADD+= -lgcc -lc -lgcc +.endif + CPPFLAGS+= -I${.CURDIR}/arch/${ARCH}/include -I${MINIXSRCDIR} AFLAGS+= -I${.CURDIR}/arch/${ARCH}/include -I${MINIXSRCDIR} -#Tell ASMCONV to prepend underscores to symbols -ASMCONVFLAGS+= -u - INSTALLFLAGS+= -S 0 BINDIR= /usr/sbin MAN= diff --git a/kernel/arch/i386/apic_asm.S b/kernel/arch/i386/apic_asm.S index b387333f5..b678a5a4f 100644 --- a/kernel/arch/i386/apic_asm.S +++ b/kernel/arch/i386/apic_asm.S @@ -3,29 +3,29 @@ #include "sconst.h" #include "apic_asm.h" -.globl apic_hwint00 /* handlers for hardware interrupts */ -.globl apic_hwint01 -.globl apic_hwint02 -.globl apic_hwint03 -.globl apic_hwint04 -.globl apic_hwint05 -.globl apic_hwint06 -.globl apic_hwint07 -.globl apic_hwint08 -.globl apic_hwint09 -.globl apic_hwint10 -.globl apic_hwint11 -.globl apic_hwint12 -.globl apic_hwint13 -.globl apic_hwint14 -.globl apic_hwint15 +.globl _apic_hwint00 /* handlers for hardware interrupts */ +.globl _apic_hwint01 +.globl _apic_hwint02 +.globl _apic_hwint03 +.globl _apic_hwint04 +.globl _apic_hwint05 +.globl _apic_hwint06 +.globl _apic_hwint07 +.globl _apic_hwint08 +.globl _apic_hwint09 +.globl _apic_hwint10 +.globl _apic_hwint11 +.globl _apic_hwint12 +.globl _apic_hwint13 +.globl _apic_hwint14 +.globl _apic_hwint15 .text #define APIC_IRQ_HANDLER(irq) \ push $irq ;\ - call irq_handle /* intr_handle(irq_handlers[irq]) */ ;\ + call _irq_handle /* intr_handle(irq_handlers[irq]) */ ;\ add $4, %esp ;\ - mov lapic_eoi_addr, %eax ;\ + mov _lapic_eoi_addr, %eax ;\ movl $0, (%eax) ;\ /*===========================================================================*/ @@ -38,15 +38,15 @@ \ SAVE_PROCESS_CTX(0) ;\ push %ebp ;\ - call context_stop ;\ + call _context_stop ;\ add $4, %esp ;\ movl $0, %ebp /* for stack trace */ ;\ APIC_IRQ_HANDLER(irq) ;\ - jmp switch_to_user ;\ + jmp _switch_to_user ;\ \ 0: \ pusha ;\ - call context_stop_idle ;\ + call _context_stop_idle ;\ APIC_IRQ_HANDLER(irq) ;\ CLEAR_IF(10*4(%esp)) ;\ popa ;\ @@ -54,82 +54,82 @@ /* Each of these entry points is an expansion of the hwint_master macro */ .balign 16 -apic_hwint00: +_apic_hwint00: /* Interrupt routine for irq 0 (the clock). */ apic_hwint(0) .balign 16 -apic_hwint01: +_apic_hwint01: /* Interrupt routine for irq 1 (keyboard) */ apic_hwint(1) .balign 16 -apic_hwint02: +_apic_hwint02: /* Interrupt routine for irq 2 (cascade!) */ apic_hwint(2) .balign 16 -apic_hwint03: +_apic_hwint03: /* Interrupt routine for irq 3 (second serial) */ apic_hwint(3) .balign 16 -apic_hwint04: +_apic_hwint04: /* Interrupt routine for irq 4 (first serial) */ apic_hwint(4) .balign 16 -apic_hwint05: +_apic_hwint05: /* Interrupt routine for irq 5 (XT winchester) */ apic_hwint(5) .balign 16 -apic_hwint06: +_apic_hwint06: /* Interrupt routine for irq 6 (floppy) */ apic_hwint(6) .balign 16 -apic_hwint07: +_apic_hwint07: /* Interrupt routine for irq 7 (printer) */ apic_hwint(7) .balign 16 -apic_hwint08: +_apic_hwint08: /* Interrupt routine for irq 8 (realtime clock) */ apic_hwint(8) .balign 16 -apic_hwint09: +_apic_hwint09: /* Interrupt routine for irq 9 (irq 2 redirected) */ apic_hwint(9) .balign 16 -apic_hwint10: +_apic_hwint10: /* Interrupt routine for irq 10 */ apic_hwint(10) .balign 16 -apic_hwint11: +_apic_hwint11: /* Interrupt routine for irq 11 */ apic_hwint(11) .balign 16 -apic_hwint12: +_apic_hwint12: /* Interrupt routine for irq 12 */ apic_hwint(12) .balign 16 -apic_hwint13: +_apic_hwint13: /* Interrupt routine for irq 13 (FPU exception) */ apic_hwint(13) .balign 16 -apic_hwint14: +_apic_hwint14: /* Interrupt routine for irq 14 (AT winchester) */ apic_hwint(14) .balign 16 -apic_hwint15: +_apic_hwint15: /* Interrupt routine for irq 15 */ apic_hwint(15) @@ -137,7 +137,7 @@ apic_hwint15: #define LAPIC_INTR_HANDLER(func) \ movl $func, %eax ;\ call *%eax /* call the actual handler */ ;\ - mov lapic_eoi_addr, %eax /* the end of handler*/ ;\ + mov _lapic_eoi_addr, %eax /* the end of handler*/ ;\ movl $0, (%eax) ; /*===========================================================================*/ @@ -149,28 +149,28 @@ apic_hwint15: \ SAVE_PROCESS_CTX(0) ;\ push %ebp ;\ - call context_stop ;\ + call _context_stop ;\ add $4, %esp ;\ movl $0, %ebp /* for stack trace */ ;\ LAPIC_INTR_HANDLER(func) ;\ - jmp switch_to_user ;\ + jmp _switch_to_user ;\ \ 0: \ pusha ;\ - call context_stop_idle ;\ + call _context_stop_idle ;\ LAPIC_INTR_HANDLER(func) ;\ CLEAR_IF(10*4(%esp)) ;\ popa ;\ iret ; /* apic timer tick handlers */ -.globl lapic_bsp_timer_int_handler -lapic_bsp_timer_int_handler: - lapic_intr(bsp_timer_int_handler) +.globl _lapic_bsp_timer_int_handler +_lapic_bsp_timer_int_handler: + lapic_intr(_bsp_timer_int_handler) -.globl lapic_ap_timer_int_handler -lapic_ap_timer_int_handler: - lapic_intr(ap_timer_int_handler) +.globl _lapic_ap_timer_int_handler +_lapic_ap_timer_int_handler: + lapic_intr(_ap_timer_int_handler) #ifdef CONFIG_APIC_DEBUG @@ -183,15 +183,15 @@ lapic_intr_dummy_handler_msg: #define lapic_intr_dummy_handler(vect) \ pushl $vect; \ push $lapic_intr_dummy_handler_msg; \ - call printf; \ + call _printf; \ 1: jmp 1b; /* never return */ #define LAPIC_INTR_DUMMY_HANDLER(vect) \ .balign LAPIC_INTR_DUMMY_HANDLER_SIZE; \ lapic_intr_dummy_handler_##vect: lapic_intr_dummy_handler(vect) -.globl lapic_intr_dummy_handles_start -lapic_intr_dummy_handles_start: +.globl _lapic_intr_dummy_handles_start +_lapic_intr_dummy_handles_start: LAPIC_INTR_DUMMY_HANDLER(0) LAPIC_INTR_DUMMY_HANDLER(1) @@ -450,8 +450,8 @@ LAPIC_INTR_DUMMY_HANDLER(253) LAPIC_INTR_DUMMY_HANDLER(254) LAPIC_INTR_DUMMY_HANDLER(255) -.globl lapic_intr_dummy_handles_end -lapic_intr_dummy_handles_end: +.globl _lapic_intr_dummy_handles_end +_lapic_intr_dummy_handles_end: #endif /* CONFIG_APIC_DEBUG */ diff --git a/kernel/arch/i386/debugreg.S b/kernel/arch/i386/debugreg.S index 1d220ab0f..2eaf244a6 100644 --- a/kernel/arch/i386/debugreg.S +++ b/kernel/arch/i386/debugreg.S @@ -1,15 +1,15 @@ .text #define LD_ST_REG(reg) ;\ -.globl ld_##reg ;\ -.globl st_##reg ;\ +.globl _ld_##reg ;\ +.globl _st_##reg ;\ ;\ -ld_##reg: ;\ +_ld_##reg: ;\ mov 4(%esp), %eax ;\ mov %eax, %reg ;\ ret ;\ ;\ -st_##reg: ;\ +_st_##reg: ;\ mov %reg, %eax ;\ ret diff --git a/kernel/arch/i386/kernel.lds b/kernel/arch/i386/kernel.lds new file mode 100644 index 000000000..bdb27862b --- /dev/null +++ b/kernel/arch/i386/kernel.lds @@ -0,0 +1,52 @@ +OUTPUT_ARCH("i386") +ENTRY(MINIX) +SECTIONS +{ + . = 0x0; + _text = .; + begtext = .; + .text.head . : AT (0x0) { + *(.text.head) + } + .text . : AT (ADDR(.text) - 0x0000) { + *(.text) + *(.text.*) + . = ALIGN(4096); + } + _etext = .; + etext = .; + + _data = .; + begdata = .; + .data . : AT (ADDR(.data) - 0x0000) { + _rodata = .; + /* kernel data starts with this magic number */ + SHORT(0x526f); + *(.rodata) + *(.rodata.*) + _erodata = .; + *(.data) + *(.data.*) + } + _edata = .; + _bss = .; + begbss = .; + .bss . : AT (ADDR(.bss) - 0x0000) { + *(.bss) + *(.bss.*) + *(COMMON) + } + _ebss = .; + endbss = .; + _end = .; + end = .; + + /DISCARD/ : + { + *(.eh_frame) + *(.comment) + *(.comment.*) + *(.note) + *(.note.*) + } +} diff --git a/kernel/arch/i386/klib.S b/kernel/arch/i386/klib.S index 446690fc1..ba78904f9 100644 --- a/kernel/arch/i386/klib.S +++ b/kernel/arch/i386/klib.S @@ -13,41 +13,43 @@ * kernel. They are: */ -.globl monitor /* exit Minix and return to the monitor */ -.globl int86 /* let the monitor make an 8086 interrupt call */ -.globl exit /* dummy for library routines */ +.globl _monitor/* exit Minix and return to the monitor */ +.globl _int86 /* let the monitor make an 8086 interrupt call */ +#ifdef __ACK__ .globl _exit /* dummy for library routines */ .globl __exit /* dummy for library routines */ -.globl __main /* dummy for GCC */ -.globl phys_insw /* transfer data from (disk controller) port to memory */ -.globl phys_insb /* likewise byte by byte */ -.globl phys_outsw /* transfer data from memory to (disk controller) port */ -.globl phys_outsb /* likewise byte by byte */ -.globl phys_copy /* copy data from anywhere to anywhere in memory */ -.globl phys_copy_fault /* phys_copy pagefault */ -.globl phys_copy_fault_in_kernel /* phys_copy pagefault in kernel */ -.globl phys_memset /* write pattern anywhere in memory */ +.globl ___exit /* dummy for library routines */ +#endif +.globl ___main /* dummy for GCC */ +.globl _phys_insw /* transfer data from (disk controller) port to memory */ +.globl _phys_insb /* likewise byte by byte */ +.globl _phys_outsw /* transfer data from memory to (disk controller) port */ +.globl _phys_outsb /* likewise byte by byte */ +.globl _phys_copy /* copy data from anywhere to anywhere in memory */ +.globl _phys_copy_fault /* phys_copy pagefault */ +.globl _phys_copy_fault_in_kernel /* phys_copy pagefault in kernel */ +.globl _phys_memset /* write pattern anywhere in memory */ .globl mem_rdw /* copy one word from [segment:offset] */ -.globl reset /* reset the system */ -.globl halt_cpu/* halts the current cpu when idle */ -.globl read_cpu_flags /* read the cpu flags */ -.globl read_cr0 /* read cr0 */ -.globl read_cr2 /* read cr2 */ -.globl getcr3val -.globl write_cr0 /* write a value in cr0 */ -.globl read_cr3 -.globl read_cr4 -.globl write_cr4 - -.globl catch_pagefaults -.globl read_ds -.globl read_cs -.globl read_ss -.globl idt_reload /* reload idt when returning to monitor. */ - -.globl fninit /* non-waiting FPU initialization */ -.globl fnstsw /* store status word (non-waiting) */ -.globl fnstcw /* store control word (non-waiting) */ +.globl _reset /* reset the system */ +.globl _halt_cpu/* halts the current cpu when idle */ +.globl _read_cpu_flags /* read the cpu flags */ +.globl _read_cr0 /* read cr0 */ +.globl _read_cr2 /* read cr2 */ +.globl _getcr3val +.globl _write_cr0 /* write a value in cr0 */ +.globl _read_cr3 +.globl _read_cr4 +.globl _write_cr4 + +.globl _catch_pagefaults +.globl _read_ds +.globl _read_cs +.globl _read_ss +.globl _idt_reload /* reload idt when returning to monitor. */ + +.globl _fninit /* non-waiting FPU initialization */ +.globl _fnstsw /* store status word (non-waiting) */ +.globl _fnstcw /* store control word (non-waiting) */ /* * The routines only guarantee to preserve the registers the C compiler @@ -62,8 +64,8 @@ /* PUBLIC void monitor(); */ /* Return to the monitor. */ -monitor: - movl mon_sp, %esp /* restore monitor stack pointer */ +_monitor: + movl _mon_sp, %esp /* restore monitor stack pointer */ movw $SS_SELECTOR, %dx /* monitor data segment */ mov %dx, %ds mov %dx, %es @@ -80,12 +82,12 @@ monitor: /* int86 */ /*===========================================================================*/ /* PUBLIC void int86(); */ -int86: - cmpb $0, mon_return /* is the monitor there? */ +_int86: + cmpb $0, _mon_return /* is the monitor there? */ jne 0f movb $0x01, %ah /* an int 13 error seems appropriate */ - movb %ah, reg86+0 /* reg86.w.f = 1 (set carry flag) */ - movb %ah, reg86+13 /* reg86.b.ah = 0x01 = "invalid command" */ + movb %ah, _reg86+0 /* reg86.w.f = 1 (set carry flag) */ + movb %ah, _reg86+13 /* reg86.b.ah = 0x01 = "invalid command" */ ret 0: push %ebp /* save C registers */ @@ -99,7 +101,7 @@ int86: movb %al, %ah inb $INT_CTLMASK push %eax /* save interrupt masks */ - movl irq_use, %eax /* map of in-use IRQ's */ + movl _irq_use, %eax /* map of in-use IRQ's */ and $~(1<