分类:
2008-09-12 05:15:42
include $(FPTOP)/Makefile.configFile: ./Makefile.config
LIBBASE_DIR=$(FPTOP)/libbase
BASELIB=$(LIBBASE_DIR)/libbase.a
CRTOBJ=$(LIBBASE_DIR)/crt.o
CFLAGS := $(CFLAGS) -I$(LIBBASE_DIR) -fno-builtin
all: $(NAME).bin tftp_upload
$(NAME).bin: $(NAME).elf
$(OBJCOPY) -O binary $< $@
$(NAME).elf: $(INOBJS) $(CRTLIB) $(BASELIB)
$(LD) $(LDFLAGS) $(LDFLAGS) -Ttext $(LOAD_ADDR) $(CRTOBJ) $(INOBJS) $(BASELIB) -o $@
$(STRIP) $@
tftp_upload: $(NAME).bin
[ ! -z "$(TFTP_DIR)" ] && cp "$(NAME).bin" "$(TFTP_DIR)/$(NAME)$(TFTP_POSTFIX)"
clean:
rm -f *.o *.bin *.elf "$(TFTP_DIR)/$(NAME)$(TFTP_POSTFIX)"
.PHONY: all clean tftp_upload
AR=/home/hellwolf/dirs/apps/ycross/targets/ppc-elf_freestanding/bin/ppc-ycross-elf-ar
CC=/home/hellwolf/dirs/apps/ycross/targets/ppc-elf_freestanding/bin/ppc-ycross-elf-gcc
LD=/home/hellwolf/dirs/apps/ycross/targets/ppc-elf_freestanding/bin/ppc-ycross-elf-ld
STRIP=/home/hellwolf/dirs/apps/ycross/targets/ppc-elf_freestanding/bin/ppc-ycross-elf-strip
OBJCOPY=/home/hellwolf/dirs/apps/ycross/targets/ppc-elf_freestanding/bin/ppc-ycross-elf-objcopy
RANLIB=/home/hellwolf/dirs/apps/ycross/targets/ppc-elf_freestanding/bin/ppc-ycross-elf-ranlib
LOAD_ADDR=0x2000000
TFTP_DIR=/var/lib/tftpboot
TFTP_POSTFIX=.D00
include ../Makefile.config
CFLAGS := $(CFLAGS) -fno-builtin
OBJS=\
syscall.o \
io.o
HEADFILES = \
syscall.h \
io.h
all: crt.o libbase.a
libbase.a: $(OBJS)
$(AR) cru $@ $(OBJS)
$(RANLIB) $@
crt.o: crt.c $(HEADFILES)
clean:
rm -f *.o *.a
.PHONY: all clean
#include "syscall.h"sys_return 来自 syscall.c:
void _start(void);
int main(void);
void _start(void){
main();
sys_return();
}
#include "syscall.h"这些 syscall 由 MENMON 提供。
/* System Call RETURN */
void sys_return(void) {
__asm__ __volatile__ (
"li %r10, 0x63\n\t"
"sc"
);
}
/* System Call OUT_CHR */
void sys_out_chr(char _c) {
register char c __asm__ ("r3") = _c;
(void)c;
__asm__ __volatile__ (
"li %r10, 0x20\n\t"
"sc"
);
}
FPTOP=..File ./hello/hello.c
NAME := hello
INOBJS := hello.o
include $(FPTOP)/Makefile.base
#include "syscall.h"
#include "io.h"
int main(void) {
int i = 20;
char *s = "rocks";
printf("phigcsw %s %d\n", s, i);
return 0;
}