Browse Source

Merge branch 'master' into 3leaf-rewrite

tags/v0.9.3
Michael Brown 17 years ago
parent
commit
5f6439c828

+ 23
- 22
src/Makefile View File

@@ -42,30 +42,31 @@ include arch/$(ARCH)/Config
42 42
 # message.
43 43
 #
44 44
 noargs : blib $(BIN)/NIC $(BIN)/gpxe.dsk $(BIN)/gpxe.iso $(BIN)/gpxe.usb
45
-	@echo '==========================================================='
46
-	@echo
47
-	@echo 'To create a bootable floppy, type'
48
-	@echo '    cat $(BIN)/gpxe.dsk > /dev/fd0'
49
-	@echo 'where /dev/fd0 is your floppy drive.  This will erase any'
50
-	@echo 'data already on the disk.'
51
-	@echo
52
-	@echo 'To create a bootable USB key, type'
53
-	@echo '    cat $(BIN)/gpxe.usb > /dev/sdX'
54
-	@echo 'where /dev/sdX is your USB key, and is *not* a real hard'
55
-	@echo 'disk on your system.  This will erase any data already on'
56
-	@echo 'the USB key.'
57
-	@echo
58
-	@echo 'To create a bootable CD-ROM, burn the ISO image '
59
-	@echo '$(BIN)/gpxe.iso to a blank CD-ROM.'
60
-	@echo
61
-	@echo 'These images contain drivers for all supported cards.  You'
62
-	@echo 'can build more customised images, and ROM images, using'
63
-	@echo '    make bin/<rom-name>.<output-format>'
64
-	@echo
65
-	@echo '==========================================================='
45
+	@$(ECHO) '==========================================================='
46
+	@$(ECHO)
47
+	@$(ECHO) 'To create a bootable floppy, type'
48
+	@$(ECHO) '    cat $(BIN)/gpxe.dsk > /dev/fd0'
49
+	@$(ECHO) 'where /dev/fd0 is your floppy drive.  This will erase any'
50
+	@$(ECHO) 'data already on the disk.'
51
+	@$(ECHO)
52
+	@$(ECHO) 'To create a bootable USB key, type'
53
+	@$(ECHO) '    cat $(BIN)/gpxe.usb > /dev/sdX'
54
+	@$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
55
+	@$(ECHO) 'disk on your system.  This will erase any data already on'
56
+	@$(ECHO) 'the USB key.'
57
+	@$(ECHO)
58
+	@$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
59
+	@$(ECHO) '$(BIN)/gpxe.iso to a blank CD-ROM.'
60
+	@$(ECHO)
61
+	@$(ECHO) 'These images contain drivers for all supported cards.  You'
62
+	@$(ECHO) 'can build more customised images, and ROM images, using'
63
+	@$(ECHO) '    make bin/<rom-name>.<output-format>'
64
+	@$(ECHO)
65
+	@$(ECHO) '==========================================================='
66 66
 
67 67
 # Locations of utilities
68 68
 #
69
+ECHO		?= /bin/echo -e
69 70
 HOST_CC		?= gcc
70 71
 CPP		?= gcc -E -Wp,-Wall
71 72
 RM		?= rm -f
@@ -120,7 +121,7 @@ OBJECT		= $(firstword $(subst ., ,$(@F)))
120 121
 #
121 122
 OBJ_CFLAGS	= $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
122 123
 $(BIN)/%.flags :
123
-	@echo $(OBJ_CFLAGS)
124
+	@$(ECHO) $(OBJ_CFLAGS)
124 125
 
125 126
 # Rules for specific object types.
126 127
 #

+ 76
- 74
src/Makefile.housekeeping View File

@@ -20,33 +20,25 @@ CFLAGS		+= -DVERSION_MAJOR=$(VERSION_MAJOR) \
20 20
 		   -DVERSION=\"$(VERSION)\"
21 21
 IDENT		= '$(@F) $(VERSION) (GPL) etherboot.org'
22 22
 version :
23
-	@echo $(VERSION)
23
+	@$(ECHO) $(VERSION)
24 24
 
25 25
 # Check for tools that can cause failed builds
26 26
 #
27 27
 .toolcheck : Makefile Config
28 28
 	@if $(CC) -v 2>&1 | grep -is 'gcc version 2\.96' > /dev/null; then \
29
-		echo 'gcc 2.96 is unsuitable for compiling Etherboot'; \
30
-		echo 'Use gcc 2.95 or gcc 3.x instead'; \
29
+		$(ECHO) 'gcc 2.96 is unsuitable for compiling Etherboot'; \
30
+		$(ECHO) 'Use gcc 2.95 or gcc 3.x instead'; \
31 31
 		exit 1; \
32 32
 	fi
33 33
 	@if [ `perl -e 'use bytes; print chr(255)' | wc -c` = 2 ]; then \
34
-		echo 'Your Perl version has a Unicode handling bug'; \
35
-		echo 'Execute this command before compiling Etherboot:'; \
36
-		echo 'export LANG=$${LANG%.UTF-8}'; \
34
+		$(ECHO) 'Your Perl version has a Unicode handling bug'; \
35
+		$(ECHO) 'Execute this command before compiling Etherboot:'; \
36
+		$(ECHO) 'export LANG=$${LANG%.UTF-8}'; \
37 37
 		exit 1; \
38 38
 	fi
39 39
 	@$(TOUCH) $@
40 40
 VERYCLEANUP	+= .toolcheck
41 41
 
42
-# Check for correct syntax for echo -e
43
-#
44
-ifeq ($(shell echo '\0101'),A)
45
-ECHO_E = echo
46
-else
47
-ECHO_E = echo -e
48
-endif
49
-
50 42
 # Build verbosity
51 43
 #
52 44
 ifeq ($(V),1)
@@ -59,10 +51,10 @@ endif
59 51
 
60 52
 # Check for an old version of gas (binutils 2.9.1)
61 53
 #
62
-OLDGAS	:= $(shell $(AS) --version | grep -q '2\.9\.1' && echo -DGAS291)
54
+OLDGAS	:= $(shell $(AS) --version | grep -q '2\.9\.1' && $(ECHO) -DGAS291)
63 55
 CFLAGS	+= $(OLDGAS)
64 56
 oldgas :
65
-	@echo $(oldgas)
57
+	@$(ECHO) $(oldgas)
66 58
 
67 59
 # compiler.h is needed for our linking and debugging system
68 60
 #
@@ -75,14 +67,14 @@ CLEANUP	+= config/*.h
75 67
 
76 68
 # SRCDIRS lists all directories containing source files.
77 69
 srcdirs :
78
-	@echo $(SRCDIRS)
70
+	@$(ECHO) $(SRCDIRS)
79 71
 
80 72
 # SRCS lists all .c or .S files found in any SRCDIR
81 73
 #
82 74
 SRCS	+= $(wildcard $(patsubst %,%/*.c,$(SRCDIRS)))
83 75
 SRCS	+= $(wildcard $(patsubst %,%/*.S,$(SRCDIRS)))
84 76
 srcs :
85
-	@echo $(SRCS)
77
+	@$(ECHO) $(SRCS)
86 78
 
87 79
 # AUTO_SRCS lists all files in SRCS that are not mentioned in
88 80
 # NON_AUTO_SRCS.  Files should be added to NON_AUTO_SRCS if they
@@ -90,7 +82,7 @@ srcs :
90 82
 #
91 83
 AUTO_SRCS = $(filter-out $(NON_AUTO_SRCS),$(SRCS))
92 84
 autosrcs :
93
-	@echo $(AUTO_SRCS)
85
+	@$(ECHO) $(AUTO_SRCS)
94 86
 
95 87
 # We automatically generate rules for any file mentioned in AUTO_SRCS
96 88
 # using the following set of templates.  It would be cleaner to use
@@ -105,7 +97,7 @@ autosrcs :
105 97
 #
106 98
 define src_template
107 99
 
108
-	@echo "Generating Makefile rules for $(1)"
100
+	@$(ECHO) "Generating Makefile rules for $(1)"
109 101
 	@$(MKDIR) -p $(dir $(2))
110 102
 	@$(RM) $(2)
111 103
 	@$(TOUCH) $(2)
@@ -129,14 +121,14 @@ define obj_template
129 121
 	@$(CPP) $(CFLAGS) $(CFLAGS_$(3)) $(CFLAGS_$(4)) -DOBJECT=$(4) \
130 122
 		-Wno-error -M $(1) -MT "$(4)_DEPS" -MG -MP | \
131 123
 		sed 's/_DEPS\s*:/_DEPS =/' >> $(2)
132
-	@$(ECHO_E) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
133
-		 '\n\t$$(QM)echo "  [BUILD] $$@"\n' \
124
+	@$(ECHO) '\n$$(BIN)/$(4).o : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
125
+		 '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"\n' \
134 126
 		 '\n\t$$(RULE_$(3))\n' \
135 127
 		 '\nBOBJS += $$(BIN)/$(4).o\n' \
136 128
 		 $(foreach TGT,$(DEBUG_TARGETS), \
137 129
 		    $(if $(RULE_$(3)_to_$(TGT)), \
138 130
 		    '\n$$(BIN)/$(4).$(TGT) : $(1) $$(MAKEDEPS) $$($(4)_DEPS)' \
139
-		    '\n\t$$(QM)echo "  [BUILD] $$@"\n' \
131
+		    '\n\t$$(QM)$(ECHO) "  [BUILD] $$@"\n' \
140 132
 		    '\n\t$$(RULE_$(3)_to_$(TGT))\n' \
141 133
 		    '\n$(TGT)_OBJS += $$(BIN)/$(4).$(TGT)\n' ) ) \
142 134
 		 '\n$(2) : $$($(4)_DEPS)\n' \
@@ -148,34 +140,34 @@ endef
148 140
 # Rule to generate the Makefile rules files to be included
149 141
 #
150 142
 $(BIN)/deps/%.d : % $(MAKEDEPS) $(PARSEROM)
151
-	$(if $(filter $(AUTO_SRCS),$<),$(call src_template,$<,$@,$(subst .,,$(suffix $<)),$(basename $(notdir $<))),@echo 'ERROR: $< is not an AUTO_SRC' ; exit 1)
143
+	$(if $(filter $(AUTO_SRCS),$<),$(call src_template,$<,$@,$(subst .,,$(suffix $<)),$(basename $(notdir $<))),@$(ECHO) 'ERROR: $< is not an AUTO_SRC' ; exit 1)
152 144
 
153 145
 # Calculate and include the list of Makefile rules files
154 146
 #
155 147
 AUTO_DEPS	= $(patsubst %,$(BIN)/deps/%.d,$(AUTO_SRCS))
156 148
 include $(AUTO_DEPS)
157 149
 autodeps :
158
-	@echo $(AUTO_DEPS)
150
+	@$(ECHO) $(AUTO_DEPS)
159 151
 VERYCLEANUP	+= $(BIN)/deps
160 152
 
161 153
 # The following variables are created by the Makefile rules files
162 154
 #
163 155
 bobjs :
164
-	@echo $(BOBJS)
156
+	@$(ECHO) $(BOBJS)
165 157
 drivers :
166
-	@echo $(DRIVERS)
158
+	@$(ECHO) $(DRIVERS)
167 159
 .PHONY : drivers
168 160
 roms :
169
-	@echo $(ROMS)
161
+	@$(ECHO) $(ROMS)
170 162
 
171 163
 # Generate the NIC file from the parsed source files.  The NIC file is
172 164
 # only for rom-o-matic.
173 165
 #
174 166
 $(BIN)/NIC : $(AUTO_DEPS)
175
-	@echo '# This is an automatically generated file, do not edit' > $@
176
-	@echo '# It does not affect anything in the build, ' \
167
+	@$(ECHO) '# This is an automatically generated file, do not edit' > $@
168
+	@$(ECHO) '# It does not affect anything in the build, ' \
177 169
 	     'it is only for rom-o-matic' >> $@
178
-	@echo >> $@
170
+	@$(ECHO) >> $@
179 171
 	@perl -ne 'chomp; print "$$1\n" if /\# NIC\t(.*)$$/' $^ >> $@
180 172
 CLEANUP		+= $(BIN)/NIC
181 173
 
@@ -258,25 +250,25 @@ BLIB_OBJS	= $(DEBUG_OBJS) $(filter-out $(DEBUG_ORIG_OBJS),$(BOBJS))
258 250
 # Print out all derived information for a given target.
259 251
 #
260 252
 $(BIN)/%.info :
261
-	@echo 'Elements             : $(TGT_ELEMENTS)'
262
-	@echo 'Prefix               : $(TGT_PREFIX)'
263
-	@echo 'Drivers              : $(TGT_DRIVERS)'
264
-	@echo 'ROM name             : $(TGT_ROM_NAME)'
265
-	@echo 'Media                : $(TGT_MEDIA)'
266
-	@echo
267
-	@echo 'PCI vendor           : $(TGT_PCI_VENDOR)'
268
-	@echo 'PCI device           : $(TGT_PCI_DEVICE)'
269
-	@echo
270
-	@echo 'LD driver symbols    : $(TGT_LD_DRIVERS)'
271
-	@echo 'LD prefix symbols    : $(TGT_LD_PREFIX)'
272
-	@echo 'LD ID symbols        : $(TGT_LD_IDS)'
273
-	@echo
274
-	@echo 'LD target flags      : $(TGT_LD_FLAGS)'
275
-	@echo
276
-	@echo 'makerom target flags : $(TGT_MAKEROM_FLAGS)'
277
-	@echo
278
-	@echo 'Debugging objects    : $(DEBUG_OBJS)'
279
-	@echo 'Replaced objects     : $(DEBUG_ORIG_OBJS)'
253
+	@$(ECHO) 'Elements             : $(TGT_ELEMENTS)'
254
+	@$(ECHO) 'Prefix               : $(TGT_PREFIX)'
255
+	@$(ECHO) 'Drivers              : $(TGT_DRIVERS)'
256
+	@$(ECHO) 'ROM name             : $(TGT_ROM_NAME)'
257
+	@$(ECHO) 'Media                : $(TGT_MEDIA)'
258
+	@$(ECHO)
259
+	@$(ECHO) 'PCI vendor           : $(TGT_PCI_VENDOR)'
260
+	@$(ECHO) 'PCI device           : $(TGT_PCI_DEVICE)'
261
+	@$(ECHO)
262
+	@$(ECHO) 'LD driver symbols    : $(TGT_LD_DRIVERS)'
263
+	@$(ECHO) 'LD prefix symbols    : $(TGT_LD_PREFIX)'
264
+	@$(ECHO) 'LD ID symbols        : $(TGT_LD_IDS)'
265
+	@$(ECHO)
266
+	@$(ECHO) 'LD target flags      : $(TGT_LD_FLAGS)'
267
+	@$(ECHO)
268
+	@$(ECHO) 'makerom target flags : $(TGT_MAKEROM_FLAGS)'
269
+	@$(ECHO)
270
+	@$(ECHO) 'Debugging objects    : $(DEBUG_OBJS)'
271
+	@$(ECHO) 'Replaced objects     : $(DEBUG_ORIG_OBJS)'
280 272
 
281 273
 # List of objects included in the last build of blib.  This is needed
282 274
 # in order to correctly rebuild blib whenever the list of objects
@@ -284,7 +276,7 @@ $(BIN)/%.info :
284 276
 #
285 277
 BLIB_LIST	= $(BIN)/.blib.list
286 278
 ifneq ($(shell cat $(BLIB_LIST)),$(BLIB_OBJS))
287
-$(shell echo "$(BLIB_OBJS)" > $(BLIB_LIST))
279
+$(shell $(ECHO) "$(BLIB_OBJS)" > $(BLIB_LIST))
288 280
 endif
289 281
 
290 282
 $(BLIB_LIST) :
@@ -296,7 +288,7 @@ VERYCLEANUP	+= $(BLIB_LIST)
296 288
 BLIB		= $(BIN)/blib.a
297 289
 $(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS)
298 290
 	$(Q)$(RM) $(BLIB)
299
-	$(QM)echo "  [AR] $@"
291
+	$(QM)$(ECHO) "  [AR] $@"
300 292
 	$(Q)$(AR) r $@ $(BLIB_OBJS)
301 293
 	$(Q)$(RANLIB) $@
302 294
 blib : $(BLIB)
@@ -305,7 +297,7 @@ blib : $(BLIB)
305 297
 # specified target.
306 298
 #
307 299
 $(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT) 
308
-	$(QM)echo "  [LD] $@"
300
+	$(QM)$(ECHO) "  [LD] $@"
309 301
 	$(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $(BLIB) -o $@ \
310 302
 		-Map $(BIN)/$*.tmp.map
311 303
 	$(Q)$(OBJDUMP) -ht $@ | $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map
@@ -318,19 +310,19 @@ $(BIN)/%.map : $(BIN)/%.tmp
318 310
 # Extract compression information from intermediate object file
319 311
 #
320 312
 $(BIN)/%.zinfo : $(BIN)/%.tmp
321
-	$(QM)echo "  [ZINFO] $@"
313
+	$(QM)$(ECHO) "  [ZINFO] $@"
322 314
 	$(Q)$(OBJCOPY) -O binary -j .zinfo $< $@
323 315
 
324 316
 # Build raw binary file from intermediate object file
325 317
 #
326 318
 $(BIN)/%.bin : $(BIN)/%.tmp
327
-	$(QM)echo "  [BIN] $@"
319
+	$(QM)$(ECHO) "  [BIN] $@"
328 320
 	$(Q)$(OBJCOPY) -O binary -R .zinfo $< $@
329 321
 
330 322
 # Compress raw binary file
331 323
 #
332 324
 $(BIN)/%.zbin : $(BIN)/%.bin $(BIN)/%.zinfo $(ZBIN)
333
-	$(QM)echo "  [ZBIN] $@"
325
+	$(QM)$(ECHO) "  [ZBIN] $@"
334 326
 	$(Q)$(ZBIN) $(BIN)/$*.bin $(BIN)/$*.zinfo > $@
335 327
 
336 328
 # Build bochs symbol table
@@ -359,11 +351,11 @@ $(BIN)/%.bxs : $(BIN)/%.tmp
359 351
 # much difference to the overall build time.
360 352
 
361 353
 media :
362
-	@echo $(MEDIA)
354
+	@$(ECHO) $(MEDIA)
363 355
 
364 356
 AUTO_MEDIA	= $(filter-out $(NON_AUTO_MEDIA),$(MEDIA))
365 357
 automedia :
366
-	@echo $(AUTO_MEDIA)
358
+	@$(ECHO) $(AUTO_MEDIA)
367 359
 
368 360
 # media_template : create Makefile rules for specified media
369 361
 #
@@ -372,12 +364,12 @@ automedia :
372 364
 #
373 365
 define media_template
374 366
 
375
-	@echo "Generating Makefile rules for $(1) media"
367
+	@$(ECHO) "Generating Makefile rules for $(1) media"
376 368
 	@$(MKDIR) -p $(dir $(2))
377 369
 	@$(RM) $(2)
378 370
 	@$(TOUCH) $(2)
379
-	@$(ECHO_E) '$$(BIN)/%$(1) : $$(BIN)/%$(1).zbin' \
380
-		  '\n\t$$(QM)echo "  [FINISH] $$@"' \
371
+	@$(ECHO) '$$(BIN)/%.$(1) : $$(BIN)/%.$(1).zbin' \
372
+		  '\n\t$$(QM)$(ECHO) "  [FINISH] $$@"' \
381 373
 		  '\n\t$$(Q)$$(CP) $$< $$@' \
382 374
 		  '\n\t$$(Q)$$(FINALISE_$(1))' \
383 375
 		> $(2)
@@ -389,35 +381,45 @@ endef
389 381
 $(BIN)/deps/%.media.d : $(MAKEDEPS)
390 382
 	$(if $(filter $(AUTO_MEDIA),$*), \
391 383
 		$(call media_template,$*,$@), \
392
-		@echo 'ERROR: $* is not an AUTO_MEDIA' ; exit 1)
384
+		@$(ECHO) 'ERROR: $* is not an AUTO_MEDIA' ; exit 1)
393 385
 
394 386
 # Calculate and include the list of Makefile rules files
395 387
 #
396 388
 MEDIA_DEPS		= $(patsubst %,$(BIN)/deps/%.media.d,$(AUTO_MEDIA))
397 389
 mediadeps :
398
-	@echo $(MEDIA_DEPS)
390
+	@$(ECHO) $(MEDIA_DEPS)
399 391
 include $(MEDIA_DEPS)
400 392
 
401 393
 # The "allXXXs" targets for each suffix
402 394
 #
395
+allall: allroms allzroms allpxes allisos alldsks
403 396
 allroms allzroms : all%s : $(foreach ROM,$(ROMS),$(BIN)/$(ROM).%)
404
-all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%)
397
+allpxes allisos alldsks : all%s : $(foreach DRIVER,$(DRIVERS),$(BIN)/$(DRIVER).%)
405 398
 
406 399
 # Alias for gpxe.%
407 400
 #
408 401
 $(BIN)/etherboot.% : $(BIN)/gpxe.%
409 402
 	ln -sf $(notdir $<) $@
410 403
 
404
+# Wrap up binary blobs
405
+#
406
+$(BIN)/%.o : payload/%.img
407
+	$(QM)echo "  [WRAP] $@"
408
+	$(Q)$(LD) -b binary -r -o $@ $< --undefined obj_payload \
409
+		--defsym obj_$*=0
410
+
411
+BOBJS += $(patsubst payload/%.img,$(BIN)/%.o,$(wildcard payload/*.img))
412
+
411 413
 # The compression utilities
412 414
 #
413 415
 $(NRV2B) : util/nrv2b.c $(MAKEDEPS)
414
-	$(QM)echo "  [HOSTCC] $@"
416
+	$(QM)$(ECHO) "  [HOSTCC] $@"
415 417
 	$(Q)$(HOST_CC) -O2 -DENCODE -DDECODE -DMAIN -DVERBOSE -DNDEBUG \
416 418
 		       -DBITSIZE=32 -DENDIAN=0 -o $@ $<
417 419
 CLEANUP	+= $(NRV2B)
418 420
 
419 421
 $(ZBIN) : util/zbin.c util/nrv2b.c $(MAKEDEPS)
420
-	$(QM)echo "  [HOSTCC] $@"
422
+	$(QM)$(ECHO) "  [HOSTCC] $@"
421 423
 	$(Q)$(HOST_CC) -O2 -o $@ $<
422 424
 CLEANUP += $(ZBIN)
423 425
 
@@ -430,10 +432,10 @@ BUILDSERIAL_NOW		= config/.buildserial.now
430 432
 BUILDSERIAL_NEXT	= config/.buildserial.next
431 433
 
432 434
 $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) :
433
-	echo 1 > $@
435
+	$(ECHO) 1 > $@
434 436
 
435 437
 $(BUILDSERIAL_H) : $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT)
436
-	echo '#define BUILD_SERIAL_NUM $(shell cat $<)' > $@
438
+	$(ECHO) '#define BUILD_SERIAL_NUM $(shell cat $<)' > $@
437 439
 
438 440
 ifeq ($(filter bs,$(MAKECMDGOALS)),bs)
439 441
 $(shell diff -q $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) > /dev/null || \
@@ -441,18 +443,18 @@ $(shell diff -q $(BUILDSERIAL_NOW) $(BUILDSERIAL_NEXT) > /dev/null || \
441 443
 endif
442 444
 
443 445
 bs : $(BUILDSERIAL_NOW)
444
-	@echo $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
445
-	@echo "Build serial number is $(shell cat $<)"
446
+	@$(ECHO) $$(( $(shell cat $<) + 1 )) > $(BUILDSERIAL_NEXT)
447
+	@$(ECHO) "Build serial number is $(shell cat $<)"
446 448
 
447 449
 # List of available architectures
448 450
 #
449 451
 ARCHS	= $(filter-out CVS,$(patsubst arch/%,%,$(wildcard arch/*)))
450 452
 archs :
451
-	@echo $(ARCHS)
453
+	@$(ECHO) $(ARCHS)
452 454
 
453 455
 OTHER_ARCHS	= $(filter-out $(ARCH),$(ARCHS))
454 456
 otherarchs :
455
-	@echo $(OTHER_ARCHS)
457
+	@$(ECHO) $(OTHER_ARCHS)
456 458
 
457 459
 # Build the TAGS file for emacs
458 460
 #
@@ -502,7 +504,7 @@ docview :
502 504
 	@if [ -n "$$BROWSER" ] ; then \
503 505
 		( $$BROWSER $(BIN)/doc/html/index.html & ) ; \
504 506
 	else \
505
-		echo "Documentation index in $(BIN)/doc/html/index.html" ; \
507
+		$(ECHO) "Documentation index in $(BIN)/doc/html/index.html" ; \
506 508
 	fi
507 509
 
508 510
 # Clean-up
@@ -516,7 +518,7 @@ veryclean : clean
516 518
 # Make clean tarballs for release
517 519
 
518 520
 gpxe-tarball : ../VERSION
519
-	(echo -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION
521
+	($(ECHO) -n $(VERSION) ''; date -u +'%Y-%m-%d') > ../VERSION
520 522
 	$(RM) -r /tmp/gpxe/gpxe-$(VERSION)
521 523
 	mkdir -p /tmp/gpxe/gpxe-$(VERSION)
522 524
 	cp -rP .. /tmp/gpxe/gpxe-$(VERSION)

+ 1
- 0
src/arch/i386/Makefile View File

@@ -38,6 +38,7 @@ LDSCRIPT		= arch/i386/scripts/i386.lds
38 38
 # 
39 39
 MEDIA			+= rom
40 40
 MEDIA			+= pxe
41
+MEDIA			+= kpxe
41 42
 MEDIA			+= elf
42 43
 MEDIA			+= elfd
43 44
 MEDIA			+= lmelf

+ 11
- 252
src/core/string.c View File

@@ -28,41 +28,6 @@
28 28
 
29 29
 /* *** FROM string.c *** */
30 30
 
31
-#ifndef __HAVE_ARCH_STRNICMP
32
-/**
33
- * strnicmp - Case insensitive, length-limited string comparison
34
- * @s1: One string
35
- * @s2: The other string
36
- * @len: the maximum number of characters to compare
37
- */
38
-int strnicmp(const char *s1, const char *s2, size_t len)
39
-{
40
-	/* Yes, Virginia, it had better be unsigned */
41
-	unsigned char c1, c2;
42
-
43
-	c1 = 0;	c2 = 0;
44
-	if (len) {
45
-		do {
46
-			c1 = *s1; c2 = *s2;
47
-			s1++; s2++;
48
-			if (!c1)
49
-				break;
50
-			if (!c2)
51
-				break;
52
-			if (c1 == c2)
53
-				continue;
54
-			c1 = tolower(c1);
55
-			c2 = tolower(c2);
56
-			if (c1 != c2)
57
-				break;
58
-		} while (--len);
59
-	}
60
-	return (int)c1 - (int)c2;
61
-}
62
-#endif
63
-
64
-char * ___strtok;
65
-
66 31
 #ifndef __HAVE_ARCH_STRCPY
67 32
 /**
68 33
  * strcpy - Copy a %NUL terminated string
@@ -120,35 +85,6 @@ char * strcat(char * dest, const char * src)
120 85
 }
121 86
 #endif
122 87
 
123
-#ifndef __HAVE_ARCH_STRNCAT
124
-/**
125
- * strncat - Append a length-limited, %NUL-terminated string to another
126
- * @dest: The string to be appended to
127
- * @src: The string to append to it
128
- * @count: The maximum numbers of bytes to copy
129
- *
130
- * Note that in contrast to strncpy, strncat ensures the result is
131
- * terminated.
132
- */
133
-char * strncat(char *dest, const char *src, size_t count)
134
-{
135
-	char *tmp = dest;
136
-
137
-	if (count) {
138
-		while (*dest)
139
-			dest++;
140
-		while ((*dest++ = *src++)) {
141
-			if (--count == 0) {
142
-				*dest = '\0';
143
-				break;
144
-			}
145
-		}
146
-	}
147
-
148
-	return tmp;
149
-}
150
-#endif
151
-
152 88
 #ifndef __HAVE_ARCH_STRCMP
153 89
 /**
154 90
  * strcmp - Compare two strings
@@ -260,135 +196,6 @@ size_t strnlen(const char * s, size_t count)
260 196
 }
261 197
 #endif
262 198
 
263
-#ifndef __HAVE_ARCH_STRSPN
264
-/**
265
- * strspn - Calculate the length of the initial substring of @s which only
266
- * 	contain letters in @accept
267
- * @s: The string to be searched
268
- * @accept: The string to search for
269
- */
270
-size_t strspn(const char *s, const char *accept)
271
-{
272
-	const char *p;
273
-	const char *a;
274
-	size_t count = 0;
275
-
276
-	for (p = s; *p != '\0'; ++p) {
277
-		for (a = accept; *a != '\0'; ++a) {
278
-			if (*p == *a)
279
-				break;
280
-		}
281
-		if (*a == '\0')
282
-			return count;
283
-		++count;
284
-	}
285
-
286
-	return count;
287
-}
288
-#endif
289
-
290
-#ifndef __HAVE_ARCH_STRCSPN
291
-/**
292
- * strcspn - Calculate the length of the initial substring of @s which only
293
- * 	contain letters not in @reject
294
- * @s: The string to be searched
295
- * @accept: The string to search for
296
- */
297
-size_t strcspn(const char *s, const char *reject)
298
-{
299
-	const char *p;
300
-	const char *r;
301
-	size_t count = 0;
302
-
303
-	for (p = s; *p != '\0'; ++p) {
304
-		for (r = reject; *r != '\0'; ++r) {
305
-			if (*p == *r)
306
-				return count;
307
-		}
308
-		++count;
309
-	}
310
-
311
-	return count;
312
-}
313
-#endif
314
-
315
-#ifndef __HAVE_ARCH_STRPBRK
316
-/**
317
- * strpbrk - Find the first occurrence of a set of characters
318
- * @cs: The string to be searched
319
- * @ct: The characters to search for
320
- */
321
-char * strpbrk(const char * cs,const char * ct)
322
-{
323
-	const char *sc1,*sc2;
324
-
325
-	for( sc1 = cs; *sc1 != '\0'; ++sc1) {
326
-		for( sc2 = ct; *sc2 != '\0'; ++sc2) {
327
-			if (*sc1 == *sc2)
328
-				return (char *) sc1;
329
-		}
330
-	}
331
-	return NULL;
332
-}
333
-#endif
334
-
335
-#ifndef __HAVE_ARCH_STRTOK
336
-/**
337
- * strtok - Split a string into tokens
338
- * @s: The string to be searched
339
- * @ct: The characters to search for
340
- *
341
- * WARNING: strtok is deprecated, use strsep instead.
342
- */
343
-char * strtok(char * s,const char * ct)
344
-{
345
-	char *sbegin, *send;
346
-
347
-	sbegin  = s ? s : ___strtok;
348
-	if (!sbegin) {
349
-		return NULL;
350
-	}
351
-	sbegin += strspn(sbegin,ct);
352
-	if (*sbegin == '\0') {
353
-		___strtok = NULL;
354
-		return( NULL );
355
-	}
356
-	send = strpbrk( sbegin, ct);
357
-	if (send && *send != '\0')
358
-		*send++ = '\0';
359
-	___strtok = send;
360
-	return (sbegin);
361
-}
362
-#endif
363
-
364
-#ifndef __HAVE_ARCH_STRSEP
365
-/**
366
- * strsep - Split a string into tokens
367
- * @s: The string to be searched
368
- * @ct: The characters to search for
369
- *
370
- * strsep() updates @s to point after the token, ready for the next call.
371
- *
372
- * It returns empty tokens, too, behaving exactly like the libc function
373
- * of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
374
- * Same semantics, slimmer shape. ;)
375
- */
376
-char * strsep(char **s, const char *ct)
377
-{
378
-	char *sbegin = *s, *end;
379
-
380
-	if (sbegin == NULL)
381
-		return NULL;
382
-
383
-	end = strpbrk(sbegin, ct);
384
-	if (end)
385
-		*end++ = '\0';
386
-	*s = end;
387
-
388
-	return sbegin;
389
-}
390
-#endif
391
-
392 199
 #ifndef __HAVE_ARCH_MEMSET
393 200
 /**
394 201
  * memset - Fill a region of memory with the given value
@@ -409,30 +216,6 @@ void * memset(void * s,int c,size_t count)
409 216
 }
410 217
 #endif
411 218
 
412
-#ifndef __HAVE_ARCH_BCOPY
413
-/**
414
- * bcopy - Copy one area of memory to another
415
- * @src: Where to copy from
416
- * @dest: Where to copy to
417
- * @count: The size of the area.
418
- *
419
- * Note that this is the same as memcpy(), with the arguments reversed.
420
- * memcpy() is the standard, bcopy() is a legacy BSD function.
421
- *
422
- * You should not use this function to access IO space, use memcpy_toio()
423
- * or memcpy_fromio() instead.
424
- */
425
-char * bcopy(const char * src, char * dest, int count)
426
-{
427
-	char *tmp = dest;
428
-
429
-	while (count--)
430
-		*tmp++ = *src++;
431
-
432
-	return dest;
433
-}
434
-#endif
435
-
436 219
 #ifndef __HAVE_ARCH_MEMCPY
437 220
 /**
438 221
  * memcpy - Copy one area of memory to another
@@ -503,30 +286,6 @@ int memcmp(const void * cs,const void * ct,size_t count)
503 286
 }
504 287
 #endif
505 288
 
506
-#ifndef __HAVE_ARCH_MEMSCAN
507
-/**
508
- * memscan - Find a character in an area of memory.
509
- * @addr: The memory area
510
- * @c: The byte to search for
511
- * @size: The size of the area.
512
- *
513
- * returns the address of the first occurrence of @c, or 1 byte past
514
- * the area if @c is not found
515
- */
516
-void * memscan(void * addr, int c, size_t size)
517
-{
518
-	unsigned char * p = (unsigned char *) addr;
519
-
520
-	while (size) {
521
-		if (*p == c)
522
-			return (void *) p;
523
-		p++;
524
-		size--;
525
-	}
526
-  	return (void *) p;
527
-}
528
-#endif
529
-
530 289
 #ifndef __HAVE_ARCH_STRSTR
531 290
 /**
532 291
  * strstr - Find the first substring in a %NUL terminated string
@@ -576,17 +335,17 @@ void * memchr(const void *s, int c, size_t n)
576 335
 
577 336
 char * strndup(const char *s, size_t n)
578 337
 {
579
-	size_t len = strlen(s);
580
-	char *new;
581
-
582
-	if (len>n)
583
-		len = n;
584
-	new = malloc(len+1);
585
-	if (new) {
586
-		new[len] = '\0';
587
-		memcpy(new,s,len);
588
-	}
589
-	return new;
338
+        size_t len = strlen(s);
339
+        char *new;
340
+
341
+        if (len>n)
342
+                len = n;
343
+        new = malloc(len+1);
344
+        if (new) {
345
+                new[len] = '\0';
346
+                memcpy(new,s,len);
347
+        }
348
+        return new;
590 349
 }
591 350
 
592 351
 char * strdup(const char *s) {

+ 273
- 0
src/core/stringextra.c View File

@@ -0,0 +1,273 @@
1
+/*
2
+ *  Copyright (C) 1991, 1992  Linus Torvalds
3
+ *  Copyright (C) 2004 Tobias Lorenz
4
+ *
5
+ *  string handling functions
6
+ *  based on linux/lib/string.c
7
+ *
8
+ * This program is free software; you can redistribute it and/or modify
9
+ * it under the terms of the GNU General Public License version 2 as
10
+ * published by the Free Software Foundation.
11
+ */
12
+
13
+/*
14
+ * stupid library routines.. The optimized versions should generally be found
15
+ * as inline code in <asm-xx/string.h>
16
+ *
17
+ * These are buggy as well..
18
+ *
19
+ * * Fri Jun 25 1999, Ingo Oeser <ioe@informatik.tu-chemnitz.de>
20
+ * -  Added strsep() which will replace strtok() soon (because strsep() is
21
+ *    reentrant and should be faster). Use only strsep() in new code, please.
22
+ */
23
+
24
+/*
25
+ * these are the standard string functions that are currently not used by
26
+ * any code in etherboot. put into a separate file to avoid linking them in
27
+ * with the rest of string.o
28
+ * if anything ever does want to use a function of these, consider moving
29
+ * the function in question back into string.c
30
+ */
31
+ 
32
+#include <stdint.h>
33
+#include <stdlib.h>
34
+#include <string.h>
35
+#include <ctype.h>
36
+
37
+/* *** FROM string.c *** */
38
+
39
+#ifndef __HAVE_ARCH_STRNICMP
40
+/**
41
+ * strnicmp - Case insensitive, length-limited string comparison
42
+ * @s1: One string
43
+ * @s2: The other string
44
+ * @len: the maximum number of characters to compare
45
+ */
46
+int strnicmp(const char *s1, const char *s2, size_t len)
47
+{
48
+	/* Yes, Virginia, it had better be unsigned */
49
+	unsigned char c1, c2;
50
+
51
+	c1 = 0;	c2 = 0;
52
+	if (len) {
53
+		do {
54
+			c1 = *s1; c2 = *s2;
55
+			s1++; s2++;
56
+			if (!c1)
57
+				break;
58
+			if (!c2)
59
+				break;
60
+			if (c1 == c2)
61
+				continue;
62
+			c1 = tolower(c1);
63
+			c2 = tolower(c2);
64
+			if (c1 != c2)
65
+				break;
66
+		} while (--len);
67
+	}
68
+	return (int)c1 - (int)c2;
69
+}
70
+#endif
71
+
72
+char * ___strtok;
73
+
74
+#ifndef __HAVE_ARCH_STRNCAT
75
+/**
76
+ * strncat - Append a length-limited, %NUL-terminated string to another
77
+ * @dest: The string to be appended to
78
+ * @src: The string to append to it
79
+ * @count: The maximum numbers of bytes to copy
80
+ *
81
+ * Note that in contrast to strncpy, strncat ensures the result is
82
+ * terminated.
83
+ */
84
+char * strncat(char *dest, const char *src, size_t count)
85
+{
86
+	char *tmp = dest;
87
+
88
+	if (count) {
89
+		while (*dest)
90
+			dest++;
91
+		while ((*dest++ = *src++)) {
92
+			if (--count == 0) {
93
+				*dest = '\0';
94
+				break;
95
+			}
96
+		}
97
+	}
98
+
99
+	return tmp;
100
+}
101
+#endif
102
+
103
+#ifndef __HAVE_ARCH_STRSPN
104
+/**
105
+ * strspn - Calculate the length of the initial substring of @s which only
106
+ * 	contain letters in @accept
107
+ * @s: The string to be searched
108
+ * @accept: The string to search for
109
+ */
110
+size_t strspn(const char *s, const char *accept)
111
+{
112
+	const char *p;
113
+	const char *a;
114
+	size_t count = 0;
115
+
116
+	for (p = s; *p != '\0'; ++p) {
117
+		for (a = accept; *a != '\0'; ++a) {
118
+			if (*p == *a)
119
+				break;
120
+		}
121
+		if (*a == '\0')
122
+			return count;
123
+		++count;
124
+	}
125
+
126
+	return count;
127
+}
128
+#endif
129
+
130
+#ifndef __HAVE_ARCH_STRCSPN
131
+/**
132
+ * strcspn - Calculate the length of the initial substring of @s which only
133
+ * 	contain letters not in @reject
134
+ * @s: The string to be searched
135
+ * @accept: The string to search for
136
+ */
137
+size_t strcspn(const char *s, const char *reject)
138
+{
139
+	const char *p;
140
+	const char *r;
141
+	size_t count = 0;
142
+
143
+	for (p = s; *p != '\0'; ++p) {
144
+		for (r = reject; *r != '\0'; ++r) {
145
+			if (*p == *r)
146
+				return count;
147
+		}
148
+		++count;
149
+	}
150
+
151
+	return count;
152
+}
153
+#endif
154
+
155
+#ifndef __HAVE_ARCH_STRPBRK
156
+/**
157
+ * strpbrk - Find the first occurrence of a set of characters
158
+ * @cs: The string to be searched
159
+ * @ct: The characters to search for
160
+ */
161
+char * strpbrk(const char * cs,const char * ct)
162
+{
163
+	const char *sc1,*sc2;
164
+
165
+	for( sc1 = cs; *sc1 != '\0'; ++sc1) {
166
+		for( sc2 = ct; *sc2 != '\0'; ++sc2) {
167
+			if (*sc1 == *sc2)
168
+				return (char *) sc1;
169
+		}
170
+	}
171
+	return NULL;
172
+}
173
+#endif
174
+
175
+#ifndef __HAVE_ARCH_STRTOK
176
+/**
177
+ * strtok - Split a string into tokens
178
+ * @s: The string to be searched
179
+ * @ct: The characters to search for
180
+ *
181
+ * WARNING: strtok is deprecated, use strsep instead.
182
+ */
183
+char * strtok(char * s,const char * ct)
184
+{
185
+	char *sbegin, *send;
186
+
187
+	sbegin  = s ? s : ___strtok;
188
+	if (!sbegin) {
189
+		return NULL;
190
+	}
191
+	sbegin += strspn(sbegin,ct);
192
+	if (*sbegin == '\0') {
193
+		___strtok = NULL;
194
+		return( NULL );
195
+	}
196
+	send = strpbrk( sbegin, ct);
197
+	if (send && *send != '\0')
198
+		*send++ = '\0';
199
+	___strtok = send;
200
+	return (sbegin);
201
+}
202
+#endif
203
+
204
+#ifndef __HAVE_ARCH_STRSEP
205
+/**
206
+ * strsep - Split a string into tokens
207
+ * @s: The string to be searched
208
+ * @ct: The characters to search for
209
+ *
210
+ * strsep() updates @s to point after the token, ready for the next call.
211
+ *
212
+ * It returns empty tokens, too, behaving exactly like the libc function
213
+ * of that name. In fact, it was stolen from glibc2 and de-fancy-fied.
214
+ * Same semantics, slimmer shape. ;)
215
+ */
216
+char * strsep(char **s, const char *ct)
217
+{
218
+	char *sbegin = *s, *end;
219
+
220
+	if (sbegin == NULL)
221
+		return NULL;
222
+
223
+	end = strpbrk(sbegin, ct);
224
+	if (end)
225
+		*end++ = '\0';
226
+	*s = end;
227
+
228
+	return sbegin;
229
+}
230
+#endif
231
+
232
+#ifndef __HAVE_ARCH_BCOPY
233
+/**
234
+ * bcopy - Copy one area of memory to another
235
+ * @src: Where to copy from
236
+ * @dest: Where to copy to
237
+ * @count: The size of the area.
238
+ *
239
+ * Note that this is the same as memcpy(), with the arguments reversed.
240
+ * memcpy() is the standard, bcopy() is a legacy BSD function.
241
+ *
242
+ * You should not use this function to access IO space, use memcpy_toio()
243
+ * or memcpy_fromio() instead.
244
+ */
245
+char * bcopy(const char * src, char * dest, int count)
246
+{
247
+	return memmove(dest,src,count);
248
+}
249
+#endif
250
+
251
+#ifndef __HAVE_ARCH_MEMSCAN
252
+/**
253
+ * memscan - Find a character in an area of memory.
254
+ * @addr: The memory area
255
+ * @c: The byte to search for
256
+ * @size: The size of the area.
257
+ *
258
+ * returns the address of the first occurrence of @c, or 1 byte past
259
+ * the area if @c is not found
260
+ */
261
+void * memscan(const void * addr, int c, size_t size)
262
+{
263
+	unsigned char * p = (unsigned char *) addr;
264
+
265
+	while (size) {
266
+		if (*p == c)
267
+			return (void *) p;
268
+		p++;
269
+		size--;
270
+	}
271
+  	return (void *) p;
272
+}
273
+#endif

+ 1
- 1
src/crypto/axtls/bigint.c View File

@@ -58,7 +58,7 @@
58 58
 
59 59
 static bigint *bi_int_multiply(BI_CTX *ctx, bigint *bi, comp i);
60 60
 static bigint *bi_int_divide(BI_CTX *ctx, bigint *biR, comp denom);
61
-static bigint *alloc(BI_CTX *ctx, int size);
61
+static bigint __malloc *alloc(BI_CTX *ctx, int size);
62 62
 static bigint *trim(bigint *bi);
63 63
 static void more_comps(bigint *bi, int n);
64 64
 #if defined(CONFIG_BIGINT_KARATSUBA) || defined(CONFIG_BIGINT_BARRETT) || \

+ 1
- 1
src/crypto/cryptoLayer.h View File

@@ -31,7 +31,7 @@ typedef void psPool_t;
31 31
 
32 32
 #define sslAssert( ... ) assert ( __VA_ARGS__ )
33 33
 
34
-static inline __attribute__ (( always_inline )) void *
34
+static inline __attribute__ (( always_inline )) void * __malloc
35 35
 psMalloc ( psPool_t *pool __unused, size_t len ) {
36 36
 	return malloc ( len );
37 37
 }

+ 1
- 0
src/drivers/net/sis900.c View File

@@ -103,6 +103,7 @@ static struct mii_chip_info {
103 103
 } mii_chip_table[] = {
104 104
     {"SiS 900 Internal MII PHY", 0x001d, 0x8000, sis900_read_mode},
105 105
     {"SiS 7014 Physical Layer Solution", 0x0016, 0xf830,sis900_read_mode},
106
+    {"SiS 900 on Foxconn 661 7MI", 0x0143, 0xBC70, sis900_read_mode},
106 107
     {"AMD 79C901 10BASE-T PHY",  0x0000, 0x6B70, amd79c901_read_mode},
107 108
     {"AMD 79C901 HomePNA PHY",   0x0000, 0x6B90, amd79c901_read_mode},
108 109
     {"ICS 1893 Integrated PHYceiver"   , 0x0015, 0xf440,ics1893_read_mode},

+ 9
- 0
src/hci/editstring.c View File

@@ -27,6 +27,15 @@
27 27
  *
28 28
  */
29 29
 
30
+static void insert_delete ( struct edit_string *string, size_t delete_len,
31
+                            const char *insert_text ) 
32
+			    __attribute__ (( nonnull (1) ));
33
+static void insert_character ( struct edit_string *string,
34
+                               unsigned int character ) __nonnull;
35
+static void delete_character ( struct edit_string *string ) __nonnull;
36
+static void backspace ( struct edit_string *string ) __nonnull;
37
+static void kill_eol ( struct edit_string *string ) __nonnull;
38
+
30 39
 /**
31 40
  * Insert and/or delete text within an editable string
32 41
  *

+ 5
- 0
src/hci/mucurses/ansi_screen.c View File

@@ -2,6 +2,11 @@
2 2
 #include <curses.h>
3 3
 #include <console.h>
4 4
 
5
+static void ansiscr_reset(struct _curses_screen *scr) __nonnull;
6
+static void ansiscr_movetoyx(struct _curses_screen *scr,
7
+                               unsigned int y, unsigned int x) __nonnull;
8
+static void ansiscr_putc(struct _curses_screen *scr, chtype c) __nonnull;
9
+
5 10
 unsigned short _COLS = 80;
6 11
 unsigned short _LINES = 24;
7 12
 

+ 8
- 0
src/hci/mucurses/mucurses.c View File

@@ -8,6 +8,14 @@
8 8
  *
9 9
  */
10 10
 
11
+static void _wupdcurs ( WINDOW *win ) __nonnull;
12
+void _wputch ( WINDOW *win, chtype ch, int wrap ) __nonnull;
13
+void _wputc ( WINDOW *win, char c, int wrap ) __nonnull;
14
+void _wcursback ( WINDOW *win ) __nonnull;
15
+void _wputchstr ( WINDOW *win, const chtype *chstr, int wrap, int n ) __nonnull;
16
+void _wputstr ( WINDOW *win, const char *str, int wrap, int n ) __nonnull;
17
+int wmove ( WINDOW *win, int y, int x ) __nonnull;
18
+
11 19
 WINDOW _stdscr = {
12 20
 	.attrs = A_DEFAULT,
13 21
 	.ori_y = 0,

+ 5
- 5
src/hci/mucurses/mucurses.h View File

@@ -12,10 +12,10 @@
12 12
 
13 13
 extern SCREEN _ansi_screen;
14 14
 
15
-extern void _wputch ( WINDOW *win, chtype ch, int wrap );
16
-extern void _wputc ( WINDOW *win, char c, int wrap );
17
-extern void _wputchstr ( WINDOW *win, const chtype *chstr, int wrap, int n );
18
-extern void _wputstr ( WINDOW *win, const char *str, int wrap, int n );
19
-extern void _wcursback ( WINDOW *win );
15
+extern void _wputch ( WINDOW *win, chtype ch, int wrap ) __nonnull;
16
+extern void _wputc ( WINDOW *win, char c, int wrap ) __nonnull;
17
+extern void _wputchstr ( WINDOW *win, const chtype *chstr, int wrap, int n ) __nonnull;
18
+extern void _wputstr ( WINDOW *win, const char *str, int wrap, int n ) __nonnull;
19
+extern void _wcursback ( WINDOW *win ) __nonnull;
20 20
 
21 21
 #endif /* _MUCURSES_H */

+ 2
- 0
src/hci/readline.c View File

@@ -32,6 +32,8 @@
32 32
 
33 33
 #define READLINE_MAX 256
34 34
 
35
+static void sync_console ( struct edit_string *string ) __nonnull;
36
+
35 37
 /**
36 38
  * Synchronise console with edited string
37 39
  *

+ 18
- 1
src/hci/tui/settings_ui.c View File

@@ -36,7 +36,6 @@
36 36
 #include <gpxe/nvo.h>
37 37
 extern struct nvo_block *ugly_nvo_hack;
38 38
 
39
-
40 39
 /* Colour pairs */
41 40
 #define CPAIR_NORMAL	1
42 41
 #define CPAIR_SELECT	2
@@ -88,6 +87,24 @@ static struct config_setting config_settings_end[0]
88 87
 	__table_end ( struct config_setting, config_settings );
89 88
 #define NUM_SETTINGS ( ( unsigned ) ( config_settings_end - config_settings ) )
90 89
 
90
+static void load_setting ( struct setting_widget *widget ) __nonnull;
91
+static int save_setting ( struct setting_widget *widget ) __nonnull;
92
+static void init_setting ( struct setting_widget *widget,
93
+                           struct config_context *context,
94
+                           struct config_setting *setting,
95
+                           unsigned int row, unsigned int col ) __nonnull;
96
+static void draw_setting ( struct setting_widget *widget ) __nonnull;
97
+static int edit_setting ( struct setting_widget *widget, int key ) __nonnull;
98
+static void init_setting_index ( struct setting_widget *widget,
99
+                                 struct config_context *context,
100
+                                 unsigned int index ) __nonnull;
101
+static void vmsg ( unsigned int row, const char *fmt, va_list args ) __nonnull;
102
+static void msg ( unsigned int row, const char *fmt, ... ) __nonnull;
103
+static void valert ( const char *fmt, va_list args ) __nonnull;
104
+static void alert ( const char *fmt, ... ) __nonnull;
105
+static void draw_info_row ( struct config_setting *setting ) __nonnull;
106
+static int main_loop ( struct config_context *context ) __nonnull;
107
+
91 108
 /**
92 109
  * Load setting widget value from configuration context
93 110
  *

+ 25
- 0
src/include/compiler.h View File

@@ -279,6 +279,31 @@ extern void dbg_hex_dump_da ( unsigned long dispaddr,
279 279
 /** Apply standard C calling conventions */
280 280
 #define __cdecl __attribute__ (( cdecl , regparm(0) ))
281 281
 
282
+/**
283
+ * Declare a function as pure - i.e. without side effects
284
+ */
285
+#define __pure __attribute__ (( pure ))
286
+
287
+/**
288
+ * Declare a function as const - i.e. it does not access global memory
289
+ * (including dereferencing pointers passed to it) at all.
290
+ * Must also not call any non-const functions.
291
+ */
292
+#define __const __attribute__ (( const ))
293
+
294
+/**
295
+ * Declare a function's pointer parameters as non-null - i.e. force
296
+ * compiler to check pointers at compile time and enable possible
297
+ * optimizations based on that fact
298
+ */
299
+#define __nonnull __attribute__ (( nonnull ))
300
+
301
+/**
302
+ * Declare a pointer returned by a function as a unique memory address
303
+ * as returned by malloc-type functions.
304
+ */
305
+#define __malloc __attribute__ (( malloc ))
306
+
282 307
 /**
283 308
  * Declare a function as used.
284 309
  *

+ 35
- 31
src/include/curses.h View File

@@ -213,13 +213,13 @@ extern int beep ( void );
213 213
 //extern void bkgdset ( chtype );
214 214
 /*extern int border ( chtype, chtype, chtype, chtype, chtype, chtype, chtype,
215 215
   chtype );*/
216
-extern int box ( WINDOW *, chtype, chtype );
216
+extern int box ( WINDOW *, chtype, chtype ) __nonnull;
217 217
 //extern bool can_change_colour ( void );
218 218
 #define can_change_color() can_change_colour()
219 219
 extern int cbreak ( void ); 
220 220
 //extern int clrtobot ( void );
221 221
 //extern int clrtoeol ( void );
222
-extern int colour_content ( short, short *, short *, short * );
222
+extern int colour_content ( short, short *, short *, short * ) __nonnull;
223 223
 #define color_content( c, r, g, b ) colour_content( (c), (r), (g), (b) )
224 224
 //extern int colour_set ( short, void * );
225 225
 #define color_set( cpno, opts ) colour_set( (cpno), (opts) )
@@ -232,10 +232,10 @@ extern int delay_output ( int );
232 232
 //extern int delch ( void );
233 233
 //extern int deleteln ( void );
234 234
 extern void delscreen ( SCREEN * );
235
-extern int delwin ( WINDOW * );
236
-extern WINDOW *derwin ( WINDOW *, int, int, int, int );
235
+extern int delwin ( WINDOW * ) __nonnull;
236
+extern WINDOW *derwin ( WINDOW *, int, int, int, int ) __nonnull;
237 237
 //extern int doupdate ( void );
238
-extern WINDOW *dupwin ( WINDOW * );
238
+extern WINDOW *dupwin ( WINDOW * ) __nonnull;
239 239
 extern int echo ( void );
240 240
 extern int echochar ( const chtype );
241 241
 extern int endwin ( void );
@@ -244,7 +244,7 @@ extern char erasechar ( void );
244 244
 extern void filter ( void );
245 245
 extern int flash ( void );
246 246
 extern int flushinp ( void );
247
-extern chtype getbkgd ( WINDOW * );
247
+extern __pure chtype getbkgd ( WINDOW * ) __nonnull;
248 248
 //extern int getch ( void );
249 249
 //extern int getnstr ( char *, int );
250 250
 //extern int getstr ( char * );
@@ -312,7 +312,7 @@ extern int mvderwin ( WINDOW *, int, int );
312 312
 //extern int mvwgetnstr ( WINDOW *, int, int, char *, int );
313 313
 //extern int mvwgetstr ( WINDOW *, int, int, char * );
314 314
 //extern int mvwhline ( WINDOW *, int, int, chtype, int );
315
-extern int mvwin ( WINDOW *, int, int );
315
+extern int mvwin ( WINDOW *, int, int ) __nonnull;
316 316
 //extern chtype mvwinch ( WINDOW *, int, int );
317 317
 //extern int mvwinchnstr ( WINDOW *, int, int, chtype *, int );
318 318
 //extern int mvwinchstr ( WINDOW *, int, int, chtype * );
@@ -337,7 +337,7 @@ extern int noraw ( void );
337 337
 extern int notimeout ( WINDOW *, bool );
338 338
 extern int overlay ( const WINDOW *, WINDOW * );
339 339
 extern int overwrite ( const WINDOW *, WINDOW * );
340
-extern int pair_content ( short, short *, short * );
340
+extern int pair_content ( short, short *, short * ) __nonnull;
341 341
 //extern int pechochar ( WINDOW *, chtype );
342 342
 //extern int pnoutrefresh ( WINDOW *, int, int, int, int, int, int );
343 343
 //extern int prefresh ( WINDOW *, int, int, int, int, int, int );
@@ -373,14 +373,14 @@ extern char *slk_label ( int );
373 373
 extern int slk_noutrefresh ( void );
374 374
 //extern int slk_refresh ( void );
375 375
 extern int slk_restore ( void );
376
-extern int slk_set ( int, const char *, int );
376
+extern int slk_set ( int, const char *, int ) __nonnull;
377 377
 extern int slk_touch ( void );
378 378
 extern int standend ( void );
379 379
 extern int standout ( void );
380 380
 //extern int start_colour ( void );
381 381
 #define start_color() start_colour()
382 382
 //extern WINDOW *subpad ( WINDOW *, int, int, int, int );
383
-extern WINDOW *subwin ( WINDOW *, int, int, int, int );
383
+extern WINDOW *subwin ( WINDOW *, int, int, int, int ) __nonnull;
384 384
 extern int syncok ( WINDOW *, bool );
385 385
 extern chtype termattrs ( void );
386 386
 extern attr_t term_attrs ( void );
@@ -403,37 +403,41 @@ extern int vid_puts ( attr_t, short, void *, int  ( *) ( int) );
403 403
 extern int vidputs ( chtype, int  ( *) ( int) );
404 404
 //extern int vline ( chtype, int );
405 405
 //extern int vwprintw ( WINDOW *, const char *, va_list );
406
-extern int vw_printw ( WINDOW *, const char *, va_list );
406
+extern int vw_printw ( WINDOW *, const char *, va_list ) __nonnull;
407 407
 //extern int vwscanw ( WINDOW *, char *, va_list );
408 408
 //extern int vw_scanw ( WINDOW *, char *, va_list );
409
-extern int waddch ( WINDOW *, const chtype );
410
-extern int waddchnstr ( WINDOW *, const chtype *, int );
409
+extern int waddch ( WINDOW *, const chtype ) __nonnull;
410
+extern int waddchnstr ( WINDOW *, const chtype *, int ) __nonnull;
411 411
 //extern int waddchstr ( WINDOW *, const chtype * );
412
-extern int waddnstr ( WINDOW *, const char *, int );
412
+extern int waddnstr ( WINDOW *, const char *, int ) __nonnull;
413 413
 //extern int waddstr ( WINDOW *, const char * );
414
-extern int wattroff ( WINDOW *, int );
415
-extern int wattron ( WINDOW *, int );
416
-extern int wattrset ( WINDOW *, int );
417
-extern int wattr_get ( WINDOW *, attr_t *, short *, void * );
418
-extern int wattr_off ( WINDOW *, attr_t, void * );
419
-extern int wattr_on ( WINDOW *, attr_t, void * );
420
-extern int wattr_set ( WINDOW *, attr_t, short, void * );
414
+extern int wattroff ( WINDOW *, int ) __nonnull;
415
+extern int wattron ( WINDOW *, int ) __nonnull;
416
+extern int wattrset ( WINDOW *, int ) __nonnull;
417
+extern int wattr_get ( WINDOW *, attr_t *, short *, void * )
418
+	__attribute__ (( nonnull (1, 2, 3)));
419
+extern int wattr_off ( WINDOW *, attr_t, void * )
420
+	__attribute__ (( nonnull (1)));
421
+extern int wattr_on ( WINDOW *, attr_t, void * )
422
+	__attribute__ (( nonnull (1)));
423
+extern int wattr_set ( WINDOW *, attr_t, short, void * )
424
+	__attribute__ (( nonnull (1)));
421 425
 //extern void wbkgdset ( WINDOW *, chtype );
422 426
 extern int wborder ( WINDOW *, chtype, chtype, chtype, chtype, chtype, chtype,
423
-		   chtype, chtype );
424
-extern int wclrtobot ( WINDOW * );
425
-extern int wclrtoeol ( WINDOW * );
427
+		   chtype, chtype ) __nonnull;
428
+extern int wclrtobot ( WINDOW * ) __nonnull;
429
+extern int wclrtoeol ( WINDOW * ) __nonnull;
426 430
 extern void wcursyncup ( WINDOW * );
427
-extern int wcolour_set ( WINDOW *, short, void * );
431
+extern int wcolour_set ( WINDOW *, short, void * ) __nonnull;
428 432
 #define wcolor_set(w,s,v) wcolour_set((w),(s),(v))
429
-extern int wdelch ( WINDOW * );
430
-extern int wdeleteln ( WINDOW * );
433
+extern int wdelch ( WINDOW * ) __nonnull;
434
+extern int wdeleteln ( WINDOW * ) __nonnull;
431 435
 extern int wechochar ( WINDOW *, const chtype );
432
-extern int werase ( WINDOW * );
436
+extern int werase ( WINDOW * ) __nonnull;
433 437
 extern int wgetch ( WINDOW * );
434 438
 extern int wgetnstr ( WINDOW *, char *, int );
435 439
 //extern int wgetstr ( WINDOW *, char * );
436
-extern int whline ( WINDOW *, chtype, int );
440
+extern int whline ( WINDOW *, chtype, int ) __nonnull;
437 441
 //extern chtype winch ( WINDOW * );
438 442
 //extern int winchnstr ( WINDOW *, chtype *, int );
439 443
 //extern int winchstr ( WINDOW *, chtype * );
@@ -444,7 +448,7 @@ extern int whline ( WINDOW *, chtype, int );
444 448
 //extern int winstr ( WINDOW *, char * );
445 449
 extern int wmove ( WINDOW *, int, int );
446 450
 //extern int wnoutrefresh ( WINDOW * );
447
-extern int wprintw ( WINDOW *, const char *, ... );
451
+extern int wprintw ( WINDOW *, const char *, ... ) __nonnull;
448 452
 //extern int wredrawln ( WINDOW *, int, int );
449 453
 //extern int wrefresh ( WINDOW * );
450 454
 //extern int wscanw ( WINDOW *, char *, ... );
@@ -456,7 +460,7 @@ extern void wsyncup ( WINDOW * );
456 460
 extern void wsyncdown ( WINDOW * );
457 461
 extern void wtimeout ( WINDOW *, int );
458 462
 //extern int wtouchln ( WINDOW *, int, int, int );
459
-extern int wvline ( WINDOW *, chtype, int );
463
+extern int wvline ( WINDOW *, chtype, int ) __nonnull;
460 464
 
461 465
 /*
462 466
  * There is frankly a ridiculous amount of redundancy within the

+ 1
- 1
src/include/gpxe/dhcp.h View File

@@ -507,7 +507,7 @@ extern void register_dhcp_options ( struct dhcp_option_block *options );
507 507
 extern void unregister_dhcp_options ( struct dhcp_option_block *options );
508 508
 extern void init_dhcp_options ( struct dhcp_option_block *options,
509 509
 				void *data, size_t max_len );
510
-extern struct dhcp_option_block * alloc_dhcp_options ( size_t max_len );
510
+extern struct dhcp_option_block * __malloc alloc_dhcp_options ( size_t max_len );
511 511
 extern struct dhcp_option *
512 512
 set_dhcp_option ( struct dhcp_option_block *options, unsigned int tag,
513 513
 		  const void *data, size_t len );

+ 4
- 2
src/include/gpxe/editbox.h View File

@@ -28,8 +28,10 @@ struct edit_box {
28 28
 
29 29
 extern void init_editbox ( struct edit_box *box, char *buf, size_t len,
30 30
 			   WINDOW *win, unsigned int row, unsigned int col,
31
-			   unsigned int width );
32
-extern void draw_editbox ( struct edit_box *box );
31
+			   unsigned int width ) 
32
+			   __attribute__ (( nonnull (1, 2) ));
33
+extern void draw_editbox ( struct edit_box *box ) __nonnull;
34
+static inline int __pure edit_editbox ( struct edit_box *box, int key ) __nonnull;
33 35
 
34 36
 /**
35 37
  * Edit text box widget

+ 1
- 1
src/include/gpxe/editstring.h View File

@@ -26,6 +26,6 @@ struct edit_string {
26 26
 	unsigned int mod_end;
27 27
 };
28 28
 
29
-extern int edit_string ( struct edit_string *string, int key );
29
+extern int edit_string ( struct edit_string *string, int key ) __nonnull;
30 30
 
31 31
 #endif /* _GPXE_EDITSTRING_H */

+ 1
- 1
src/include/gpxe/iobuf.h View File

@@ -161,7 +161,7 @@ static inline size_t iob_tailroom ( struct io_buffer *iobuf ) {
161 161
 	return ( iobuf->end - iobuf->tail );
162 162
 }
163 163
 
164
-extern struct io_buffer * alloc_iob ( size_t len );
164
+extern struct io_buffer * __malloc alloc_iob ( size_t len );
165 165
 extern void free_iob ( struct io_buffer *iobuf );
166 166
 extern void iob_pad ( struct io_buffer *iobuf, size_t min_len );
167 167
 extern int iob_ensure_headroom ( struct io_buffer *iobuf, size_t len );

+ 2
- 2
src/include/gpxe/malloc.h View File

@@ -19,7 +19,7 @@
19 19
 
20 20
 extern size_t freemem;
21 21
 
22
-extern void * alloc_memblock ( size_t size, size_t align );
22
+extern void * __malloc alloc_memblock ( size_t size, size_t align );
23 23
 extern void free_memblock ( void *ptr, size_t size );
24 24
 extern void mpopulate ( void *start, size_t len );
25 25
 extern void mdumpfree ( void );
@@ -35,7 +35,7 @@ extern void mdumpfree ( void );
35 35
  *
36 36
  * @c align must be a power of two.  @c size may not be zero.
37 37
  */
38
-static inline void * malloc_dma ( size_t size, size_t phys_align ) {
38
+static inline void * __malloc malloc_dma ( size_t size, size_t phys_align ) {
39 39
 	return alloc_memblock ( size, phys_align );
40 40
 }
41 41
 

+ 1
- 1
src/include/gpxe/settings_ui.h View File

@@ -9,6 +9,6 @@
9 9
 
10 10
 struct config_context;
11 11
 
12
-extern int settings_ui ( struct config_context *context );
12
+extern int settings_ui ( struct config_context *context ) __nonnull;
13 13
 
14 14
 #endif /* _GPXE_SETTINGS_UI_H */

+ 1
- 1
src/include/readline/readline.h View File

@@ -7,6 +7,6 @@
7 7
  *
8 8
  */
9 9
 
10
-extern char * readline ( const char *prompt );
10
+extern char * __malloc readline ( const char *prompt );
11 11
 
12 12
 #endif /* _READLINE_H */

+ 3
- 3
src/include/stdlib.h View File

@@ -20,10 +20,10 @@ extern unsigned long strtoul ( const char *p, char **endp, int base );
20 20
  ****************************************************************************
21 21
  */
22 22
 
23
-extern void * malloc ( size_t size );
23
+extern void * __malloc malloc ( size_t size );
24 24
 extern void * realloc ( void *old_ptr, size_t new_size );
25 25
 extern void free ( void *ptr );
26
-extern void * zalloc ( size_t len );
26
+extern void * __malloc zalloc ( size_t len );
27 27
 
28 28
 /**
29 29
  * Allocate cleared memory
@@ -38,7 +38,7 @@ extern void * zalloc ( size_t len );
38 38
  * function in zalloc(), since in most cases @c nmemb will be 1 and
39 39
  * doing the multiply is just wasteful.
40 40
  */
41
-static inline void * calloc ( size_t nmemb, size_t size ) {
41
+static inline void * __malloc calloc ( size_t nmemb, size_t size ) {
42 42
 	return zalloc ( nmemb * size );
43 43
 }
44 44
 

+ 27
- 27
src/include/string.h View File

@@ -17,33 +17,33 @@
17 17
 #include <stddef.h>
18 18
 #include <bits/string.h>
19 19
 
20
-int strnicmp(const char *s1, const char *s2, size_t len);
21
-char * strcpy(char * dest,const char *src);
22
-char * strncpy(char * dest,const char *src,size_t count);
23
-char * strcat(char * dest, const char * src);
24
-char * strncat(char *dest, const char *src, size_t count);
25
-int __attribute__ (( pure )) strcmp(const char * cs,const char * ct);
26
-int __attribute__ (( pure )) strncmp(const char * cs,const char * ct,
27
-				     size_t count);
28
-char * strchr(const char * s, int c);
29
-char * strrchr(const char * s, int c);
30
-size_t strlen(const char * s);
31
-size_t strnlen(const char * s, size_t count);
32
-size_t strspn(const char *s, const char *accept);
33
-size_t strcspn(const char *s, const char *reject);
34
-char * strpbrk(const char * cs,const char * ct);
35
-char * strtok(char * s,const char * ct);
36
-char * strsep(char **s, const char *ct);
37
-void * memset(void * s,int c,size_t count);
38
-void * memmove(void * dest,const void *src,size_t count);
39
-int __attribute__ (( pure )) memcmp(const void * cs,const void * ct,
40
-				    size_t count);
41
-void * memscan(void * addr, int c, size_t size);
42
-char * strstr(const char * s1,const char * s2);
43
-void * memchr(const void *s, int c, size_t n);
44
-char * strdup(const char *s);
45
-char * strndup(const char *s, size_t n);
20
+int __pure strnicmp(const char *s1, const char *s2, size_t len) __nonnull;
21
+char * strcpy(char * dest,const char *src) __nonnull;
22
+char * strncpy(char * dest,const char *src,size_t count) __nonnull;
23
+char * strcat(char * dest, const char * src) __nonnull;
24
+char * strncat(char *dest, const char *src, size_t count) __nonnull;
25
+int __pure strcmp(const char * cs,const char * ct) __nonnull;
26
+int __pure strncmp(const char * cs,const char * ct,
27
+				     size_t count) __nonnull;
28
+char * __pure strchr(const char * s, int c) __nonnull;
29
+char * __pure strrchr(const char * s, int c) __nonnull;
30
+size_t __pure strlen(const char * s) __nonnull;
31
+size_t __pure strnlen(const char * s, size_t count) __nonnull;
32
+size_t __pure strspn(const char *s, const char *accept) __nonnull;
33
+size_t __pure strcspn(const char *s, const char *reject) __nonnull;
34
+char * __pure strpbrk(const char * cs,const char * ct) __nonnull;
35
+char * strtok(char * s,const char * ct) __nonnull;
36
+char * strsep(char **s, const char *ct) __nonnull;
37
+void * memset(void * s,int c,size_t count) __nonnull;
38
+void * memmove(void * dest,const void *src,size_t count) __nonnull;
39
+int __pure memcmp(const void * cs,const void * ct,
40
+				    size_t count) __nonnull;
41
+void * __pure memscan(const void * addr, int c, size_t size) __nonnull;
42
+char * __pure strstr(const char * s1,const char * s2) __nonnull;
43
+void * __pure memchr(const void *s, int c, size_t n) __nonnull;
44
+char * __malloc strdup(const char *s) __nonnull;
45
+char * __malloc strndup(const char *s, size_t n) __nonnull;
46 46
 
47
-extern const char * strerror ( int errno );
47
+extern const char * __pure strerror ( int errno );
48 48
 
49 49
 #endif /* ETHERBOOT_STRING */

+ 3
- 4
src/net/ipv4.c View File

@@ -39,10 +39,9 @@ static LIST_HEAD ( frag_buffers );
39 39
  * @v gateway		Gateway address (or @c INADDR_NONE for no gateway)
40 40
  * @ret miniroute	Routing table entry, or NULL
41 41
  */
42
-static struct ipv4_miniroute * add_ipv4_miniroute ( struct net_device *netdev,
43
-						    struct in_addr address,
44
-						    struct in_addr netmask,
45
-						    struct in_addr gateway ) {
42
+static struct ipv4_miniroute * __malloc
43
+add_ipv4_miniroute ( struct net_device *netdev, struct in_addr address,
44
+		     struct in_addr netmask, struct in_addr gateway ) {
46 45
 	struct ipv4_miniroute *miniroute;
47 46
 
48 47
 	DBG ( "IPv4 add %s", inet_ntoa ( address ) );

+ 4
- 5
src/net/ipv6.c View File

@@ -52,11 +52,10 @@ static LIST_HEAD ( miniroutes );
52 52
  * @v gateway		Gateway address (or ::0 for no gateway)
53 53
  * @ret miniroute	Routing table entry, or NULL
54 54
  */
55
-static struct ipv6_miniroute * add_ipv6_miniroute ( struct net_device *netdev,
56
-						    struct in6_addr prefix,
57
-						    int prefix_len,
58
-						    struct in6_addr address,
59
-						    struct in6_addr gateway ) {
55
+static struct ipv6_miniroute * __malloc 
56
+add_ipv6_miniroute ( struct net_device *netdev, struct in6_addr prefix,
57
+		     int prefix_len, struct in6_addr address,
58
+		     struct in6_addr gateway ) {
60 59
 	struct ipv6_miniroute *miniroute;
61 60
 	
62 61
 	miniroute = malloc ( sizeof ( *miniroute ) );

+ 1
- 1
src/net/tls.c View File

@@ -1044,7 +1044,7 @@ static void tls_hmac ( struct tls_session *tls __unused,
1044 1044
  * @ret plaintext_len	Length of plaintext record
1045 1045
  * @ret plaintext	Allocated plaintext record
1046 1046
  */
1047
-static void * tls_assemble_stream ( struct tls_session *tls,
1047
+static void * __malloc tls_assemble_stream ( struct tls_session *tls,
1048 1048
 				    const void *data, size_t len,
1049 1049
 				    void *digest, size_t *plaintext_len ) {
1050 1050
 	size_t mac_len = tls->tx_cipherspec.digest->digestsize;

+ 10
- 1
src/net/udp/tftp.c View File

@@ -415,7 +415,7 @@ static int tftp_rx_oack ( struct tftp_request *tftp, void *buf, size_t len ) {
415 415
 static int tftp_rx_data ( struct tftp_request *tftp,
416 416
 			  struct io_buffer *iobuf ) {
417 417
 	struct tftp_data *data = iobuf->data;
418
-	unsigned int block;
418
+	int block;
419 419
 	size_t data_len;
420 420
 	int rc;
421 421
 
@@ -432,6 +432,14 @@ static int tftp_rx_data ( struct tftp_request *tftp,
432 432
 	iob_pull ( iobuf, sizeof ( *data ) );
433 433
 	data_len = iob_len ( iobuf );
434 434
 
435
+	/* Check for correct block */
436
+	if ( block != ( tftp->state + 1 ) ) {
437
+		DBGC ( tftp, "TFTP %p received out-of-order block %d "
438
+		       "(expecting %d)\n", tftp, block, ( tftp->state + 1 ) );
439
+		free_iob ( iobuf );
440
+		return 0;
441
+	}
442
+
435 443
 	/* Deliver data */
436 444
 	if ( ( rc = xfer_deliver_iob ( &tftp->xfer, iobuf ) ) != 0 ) {
437 445
 		DBGC ( tftp, "TFTP %p could not deliver data: %s\n",
@@ -645,6 +653,7 @@ int tftp_open ( struct xfer_interface *xfer, struct uri *uri ) {
645 653
 	xfer_init ( &tftp->xfer, &tftp_xfer_operations, &tftp->refcnt );
646 654
 	tftp->uri = uri_get ( uri );
647 655
 	xfer_init ( &tftp->socket, &tftp_socket_operations, &tftp->refcnt );
656
+	tftp->blksize = TFTP_DEFAULT_BLKSIZE;
648 657
 	tftp->state = -1;
649 658
 	tftp->timer.expired = tftp_timer_expired;
650 659
 

+ 1
- 0
src/payload/hello.img View File

@@ -0,0 +1 @@
1
+hello world!

Loading…
Cancel
Save