Revision 253d0942

b/Makefile
44 44
LIBS+=-lwinmm -lws2_32 -liphlpapi
45 45
endif
46 46

  
47
build-all: $(TOOLS) $(DOCS) recurse-all
47
build-all: $(TOOLS) $(DOCS) roms recurse-all
48 48

  
49 49
config-host.mak: configure
50 50
ifneq ($(wildcard config-host.mak),)
......
263 263
	rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d
264 264
	rm -f qemu-img-cmds.h
265 265
	$(MAKE) -C tests clean
266
	for d in $(TARGET_DIRS) libhw32 libhw64; do \
266
	for d in $(TARGET_DIRS) $(ROMS) libhw32 libhw64; do \
267 267
	$(MAKE) -C $$d $@ || exit 1 ; \
268 268
        done
269 269

  
......
282 282
BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
283 283
video.x openbios-sparc32 openbios-sparc64 openbios-ppc \
284 284
pxe-ne2k_pci.bin pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin \
285
bamboo.dtb petalogix-s3adsp1800.dtb
285
bamboo.dtb petalogix-s3adsp1800.dtb \
286
multiboot.bin
286 287
else
287 288
BLOBS=
288 289
endif
289 290

  
291
roms:
292
	for d in $(ROMS); do \
293
	$(MAKE) -C $$d || exit 1 ; \
294
        done
295

  
290 296
install-doc: $(DOCS)
291 297
	$(INSTALL_DIR) "$(DESTDIR)$(docdir)"
292 298
	$(INSTALL_DATA) qemu-doc.html  qemu-tech.html "$(DESTDIR)$(docdir)"
b/configure
1868 1868
fi
1869 1869
echo "TOOLS=$tools" >> $config_mak
1870 1870

  
1871
roms=
1872
if test "$cpu" = "i386" -o "$cpu" = "x86_64" ; then
1873
  roms="pc-bios/optionrom"
1874
fi
1875
echo "ROMS=$roms" >> $config_mak
1876

  
1871 1877
if test -f ${config_h}~ ; then
1872 1878
  if cmp -s $config_h ${config_h}~ ; then
1873 1879
    mv ${config_h}~ $config_h
......
2230 2236

  
2231 2237
# build tree in object directory if source path is different from current one
2232 2238
if test "$source_path_used" = "yes" ; then
2233
    DIRS="tests tests/cris slirp audio block"
2239
    DIRS="tests tests/cris slirp audio block pc-bios/optionrom"
2234 2240
    FILES="Makefile tests/Makefile"
2235 2241
    FILES="$FILES tests/cris/Makefile tests/cris/.gdbinit"
2236 2242
    FILES="$FILES tests/test-mmap.c"
2243
    FILES="$FILES pc-bios/optionrom/Makefile"
2237 2244
    for dir in $DIRS ; do
2238 2245
            mkdir -p $dir
2239 2246
    done
b/pc-bios/optionrom/Makefile
1
all: build-all
2

  
3
include ../../config-host.mak
4

  
5
VPATH=$(SRC_PATH)/pc-bios/optionrom
6
OBJCOPY=objcopy
7

  
8
# from kernel sources - scripts/Kbuild.include
9
# try-run
10
# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
11
# Exit code chooses option. "$$TMP" is can be used as temporary file and
12
# is automatically cleaned up.
13
try-run = $(shell set -e;		\
14
	TMP="$(TMPOUT).$$$$.tmp";	\
15
	if ($(1)) >/dev/null 2>&1;	\
16
	then echo "$(2)";		\
17
	else echo "$(3)";		\
18
	fi;				\
19
	rm -f "$$TMP")
20

  
21
# cc-option-yn
22
# Usage: flag := $(call cc-option-yn,-march=winchip-c6)
23
cc-option-yn = $(call try-run,\
24
	$(CC) $(KBUILD_CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",y,n)
25

  
26
CFLAGS = -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
27
CFLAGS += -I$(SRC_PATH)
28
ifeq ($(call cc-option-yn,-fno-stack-protector),y)
29
CFLAGS += -fno-stack-protector
30
endif
31

  
32
build-all: multiboot.bin
33

  
34
%.o: %.S
35
	$(CC) $(CFLAGS) -o $@ -c $<
36

  
37
%.img: %.o
38
	$(LD) --oformat binary -Ttext 0 -o $@ $<
39

  
40
%.bin: %.img signrom
41
	./signrom $< $@
42
	cp $@ $(SRC_PATH)/pc-bios/
43

  
44
signrom: signrom.c
45
	$(CC) -o $@ -g -Wall $^
46

  
47
clean:
48
	$(RM) *.o *.img *.bin signrom *~
b/pc-bios/optionrom/signrom.c
1
/*
2
 * Extended Boot Option ROM
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 2 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software
16
 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
 *
18
 * Copyright IBM Corporation, 2007
19
 *   Authors: Anthony Liguori <aliguori@us.ibm.com>
20
 */
21

  
22
#include <stdio.h>
23
#include <stdint.h>
24
#include <string.h>
25

  
26
int main(int argc, char **argv)
27
{
28
	FILE *fin, *fout;
29
	char buffer[512], oldbuffer[512];
30
	int i, size, lag = 0;
31
	uint8_t sum = 0;
32

  
33
	if (argc != 3) {
34
		printf("Usage: %s ROM OUTPUT\n", argv[0]);
35
		return 1;
36
	}
37

  
38
	fin = fopen(argv[1], "rb");
39
	fout = fopen(argv[2], "wb");
40

  
41
	if (fin == NULL || fout == NULL) {
42
		fprintf(stderr, "Could not open input/output files\n");
43
		return 1;
44
	}
45

  
46
	do {
47
		size = fread(buffer, 512, 1, fin);
48
		if (size == 1) {
49
			for (i = 0; i < 512; i++)
50
				sum += buffer[i];
51

  
52
			if (lag) {
53
				if (fwrite(oldbuffer, 512, 1, fout) != 1) {
54
					fprintf(stderr, "Write failed\n");
55
					return 1;
56
				}
57
			}
58
			lag = 1;
59
			memcpy(oldbuffer, buffer, 512);
60
		}
61
	} while (size == 1);
62

  
63
	if (size != 0) {
64
		fprintf(stderr, "Failed to read from input file\n");
65
		return 1;
66
	}
67

  
68
	oldbuffer[511] = -sum;
69

  
70
	if (fwrite(oldbuffer, 512, 1, fout) != 1) {
71
		fprintf(stderr, "Failed to write to output file\n");
72
		return 1;
73
	}
74

  
75
	fclose(fin);
76
	fclose(fout);
77

  
78
	return 0;
79
}

Also available in: Unified diff