17
|
1 # specify path to QEMU, installed with MacPorts
|
|
2 QEMU = qemu-system-arm
|
|
3
|
|
4 include makefile.inc
|
|
5
|
24
|
6 CC = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc -B/mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-
|
|
7 #AS = arm-linux-gnu-gcc
|
|
8 AS = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-gcc
|
|
9 #LD = arm-linux-gnu-ld
|
|
10 LD = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-ld
|
|
11 #OBJCOPY = arm-linux-gnu-objcopy
|
|
12 OBJCOPY = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-objcopy
|
|
13 #OBJDUMP = arm-linux-gnu-objdump
|
|
14 OBJDUMP = /mnt/dalmore-home/one/src/armgcc/cross/bin/arm-none-eabi-objdump
|
17
|
15 CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -I. -g -O0
|
|
16
|
|
17 ASFLAGS =
|
|
18
|
|
19 LIBGCC = $(shell $(CC) -print-libgcc-file-name)
|
|
20
|
|
21 LINK_BIN = $(call quiet-command,$(LD) $(LDFLAGS) \
|
|
22 -T $(1) -o $(2) $(3) $(LIBS) -b binary $(4), " LINK $(TARGET_DIR)$@")
|
|
23
|
|
24 LINK_INIT = $(call quiet-command,$(LD) $(LDFLAGS) \
|
|
25 $(1) -o $@.out $<, " LINK $(TARGET_DIR)$@")
|
|
26 OBJCOPY_INIT = $(call quiet-command,$(OBJCOPY) \
|
|
27 -S -O binary --prefix-symbols="_binary_$@" $@.out $@, " OBJCOPY $(TARGET_DIR)$@")
|
|
28 AS_WITH = $(call quiet-command,$(AS) $(ASFLAGS) \
|
|
29 $(1) -c -o $@ $<," AS $(TARGET_DIR)$@")
|
|
30
|
|
31 # link the libgcc.a for __aeabi_idiv. ARM has no native support for div
|
|
32 LIBS = $(LIBGCC)
|
|
33
|
|
34 OBJS = \
|
|
35 lib/string.o \
|
|
36 \
|
|
37 arm.o\
|
|
38 asm.o\
|
|
39 bio.o\
|
|
40 buddy.o\
|
|
41 console.o\
|
|
42 exec.o\
|
|
43 file.o\
|
|
44 fs.o\
|
|
45 log.o\
|
|
46 main.o\
|
|
47 memide.o\
|
|
48 pipe.o\
|
|
49 proc.o\
|
|
50 spinlock.o\
|
|
51 start.o\
|
|
52 swtch.o\
|
|
53 syscall.o\
|
|
54 sysfile.o\
|
|
55 sysproc.o\
|
|
56 trap_asm.o\
|
|
57 trap.o\
|
|
58 vm.o \
|
|
59 \
|
|
60 device/picirq.o \
|
|
61 device/timer.o \
|
|
62 device/uart.o
|
|
63
|
|
64 KERN_OBJS = $(OBJS) entry.o
|
|
65 kernel.elf: $(addprefix build/,$(KERN_OBJS)) kernel.ld build/initcode build/fs.img
|
|
66 cp -f build/initcode initcode
|
|
67 cp -f build/fs.img fs.img
|
|
68 $(call LINK_BIN, kernel.ld, kernel.elf, \
|
|
69 $(addprefix build/,$(KERN_OBJS)), \
|
|
70 initcode fs.img)
|
|
71 $(OBJDUMP) -S kernel.elf > kernel.asm
|
|
72 $(OBJDUMP) -t kernel.elf | sed '1,/SYMBOL TABLE/d; s/ .* / /; /^$$/d' > kernel.sym
|
|
73 rm -f initcode fs.img
|
|
74
|
|
75 qemu: kernel.elf
|
|
76 @clear
|
|
77 @echo "Press Ctrl-A and then X to terminate QEMU session\n"
|
|
78 $(QEMU) -M versatilepb -m 128 -cpu arm1176 -nographic -kernel kernel.elf
|
|
79
|
|
80 INITCODE_OBJ = initcode.o
|
|
81 $(addprefix build/,$(INITCODE_OBJ)): initcode.S
|
|
82 $(call build-directory)
|
|
83 $(call AS_WITH, -nostdinc -I.)
|
|
84
|
|
85 #initcode is linked into the kernel, it will be used to craft the first process
|
|
86 build/initcode: $(addprefix build/,$(INITCODE_OBJ))
|
|
87 $(call LINK_INIT, -N -e start -Ttext 0)
|
|
88 $(call OBJCOPY_INIT)
|
|
89 $(OBJDUMP) -S $< > initcode.asm
|
|
90
|
|
91 build/fs.img:
|
|
92 make -C tools
|
|
93 make -C usr -f makfile-armgccbc
|
|
94
|
|
95 clean:
|
|
96 rm -rf build
|
|
97 rm -f *.o *.d *.asm *.sym vectors.S bootblock entryother \
|
|
98 initcode initcode.out kernel xv6.img fs.img kernel.elf memfs
|
|
99 make -C tools clean
|
|
100 make -C usr clean
|