blob: fc9c2bf733816e79cd56d64972e7dfd72c672f19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
CC := gcc
LD := ld
# Linker should relocate monitor to this address
MONITOR_BASE := 0xE0100000
# NB. '-Wcast-qual' is nasty, so I omitted it.
CFLAGS := -fno-builtin -O3 -Wall -Ih/ -Wredundant-decls
CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline -ansi
TARGET := mini-os
LOBJS := lib/malloc.o lib/math.o lib/printf.o lib/string.o
OBJS := entry.o kernel.o traps.o hypervisor.o mm.o events.o time.o ${LOBJS}
HINTF := h/hypervisor-ifs/hypervisor-if.h
HDRS := h/os.h h/types.h h/hypervisor.h h/mm.h h/events.h h/time.h h/lib.h
HDRS += $(HINTF)
default: $(TARGET)
hypervisor-ifs:
ln -sf ../../../xen/include/hypervisor-ifs h/hypervisor-ifs
$(TARGET): hypervisor-ifs head.o $(OBJS)
# Image will load at 0xC0000000. First bytes from head.o
#$(LD) -N -Ttext 0xC0000000 head.o $(OBJS) -o $@.elf
$(LD) -N -T minios.lds head.o $(OBJS) -o $@.elf
# Guest OS header -- first 8 bytes are identifier 'XenGuest'.
echo -e -n 'XenGuest' >$@
# Guest OS header -- next 4 bytes are load address (0xC0000000).
echo -e -n '\000\000\000\300' >>$@
# Create a raw bag of bytes from the ELF image.
objcopy -O binary -R .note -R .comment $@.elf $@.raw
# Guest OS header is immediately followed by raw OS image.
cat $@.raw >>$@
gzip -f -9 -c $@ >$@.gz
clean:
find . -type f -name '*.o' | xargs rm -f
rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
find . -type l | xargs rm -f
%.o: %.c $(HDRS) Makefile
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.S $(HDRS) Makefile
$(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $@
|