ia64/xen-unstable
changeset 18080:400e5d4877ca
merge with xen-unstable.hg
author | Isaku Yamahata <yamahata@valinux.co.jp> |
---|---|
date | Fri Jul 18 12:12:41 2008 +0900 (2008-07-18) |
parents | eb0fc71cfc72 a8603b2fb786 |
children | 4d5de1e4d85a |
files | stubdom/binutils.patch stubdom/gcc.patch tools/firmware/vgabios/vbetables.h |
line diff
1.1 --- a/.hgignore Tue Jul 08 11:41:43 2008 +0900 1.2 +++ b/.hgignore Fri Jul 18 12:12:41 2008 +0900 1.3 @@ -135,9 +135,8 @@ 1.4 ^tools/firmware/rombios/_rombios[^/]*_\.c$ 1.5 ^tools/firmware/rombios/rombios[^/]*\.s$ 1.6 ^tools/firmware/rombios/32bit/32bitbios_flat\.h$ 1.7 -^tools/firmware/vmxassist/gen$ 1.8 -^tools/firmware/vmxassist/offsets\.h$ 1.9 -^tools/firmware/vmxassist/vmxassist$ 1.10 +^tools/firmware/vgabios/vbetables-gen$ 1.11 +^tools/firmware/vgabios/vbetables\.h$ 1.12 ^tools/flask/loadpolicy/flask-loadpolicy$ 1.13 ^tools/include/xen/.*$ 1.14 ^tools/include/xen-foreign/.*\.(c|h|size)$ 1.15 @@ -248,6 +247,8 @@ 1.16 ^tools/xm-test/lib/XmTestLib/config.py$ 1.17 ^tools/xm-test/lib/XmTestReport/xmtest.py$ 1.18 ^tools/xm-test/tests/.*\.test$ 1.19 +^tools/ioemu-remote 1.20 +^tools/ioemu-dir$ 1.21 ^xen/\.banner.*$ 1.22 ^xen/BLOG$ 1.23 ^xen/System.map$
2.1 --- a/Config.mk Tue Jul 08 11:41:43 2008 +0900 2.2 +++ b/Config.mk Fri Jul 18 12:12:41 2008 +0900 2.3 @@ -78,6 +78,14 @@ XSM_ENABLE ?= n 2.4 FLASK_ENABLE ?= n 2.5 ACM_SECURITY ?= n 2.6 2.7 +QEMU_REMOTE=http://xenbits.xensource.com/git-http/qemu-xen-unstable.git 2.8 + 2.9 +# Specify which qemu-dm to use. This may be `ioemu' to use the old 2.10 +# Mercurial in-tree version, or a local directory, or a git URL. 2.11 +# CONFIG_QEMU ?= ioemu 2.12 +# CONFIG_QEMU ?= ../qemu-xen.git 2.13 +CONFIG_QEMU ?= $(QEMU_REMOTE) 2.14 + 2.15 # Optional components 2.16 XENSTAT_XENTOP ?= y 2.17 VTPM_TOOLS ?= n
3.1 --- a/Makefile Tue Jul 08 11:41:43 2008 +0900 3.2 +++ b/Makefile Fri Jul 18 12:12:41 2008 +0900 3.3 @@ -15,12 +15,13 @@ include buildconfigs/Rules.mk 3.4 3.5 # build and install everything into the standard system directories 3.6 .PHONY: install 3.7 -install: install-xen install-kernels install-tools install-docs 3.8 +install: install-xen install-kernels install-tools install-stubdom install-docs 3.9 3.10 .PHONY: build 3.11 build: kernels 3.12 $(MAKE) -C xen build 3.13 $(MAKE) -C tools build 3.14 + $(MAKE) -C stubdom build 3.15 $(MAKE) -C docs build 3.16 3.17 # The test target is for unit tests that can run without an installation. Of 3.18 @@ -33,7 +34,7 @@ test: 3.19 # build and install everything into local dist directory 3.20 .PHONY: dist 3.21 dist: DESTDIR=$(DISTDIR)/install 3.22 -dist: dist-xen dist-kernels dist-tools dist-docs 3.23 +dist: dist-xen dist-kernels dist-tools dist-stubdom dist-docs 3.24 $(INSTALL_DIR) $(DISTDIR)/check 3.25 $(INSTALL_DATA) ./COPYING $(DISTDIR) 3.26 $(INSTALL_DATA) ./README $(DISTDIR) 3.27 @@ -44,10 +45,11 @@ dist-%: install-% 3.28 @: # do nothing 3.29 3.30 # Legacy dist targets 3.31 -.PHONY: xen tools kernels docs 3.32 +.PHONY: xen tools stubdom kernels docs 3.33 xen: dist-xen 3.34 tools: dist-tools 3.35 kernels: dist-kernels 3.36 +stubdom: dist-stubdom 3.37 docs: dist-docs 3.38 3.39 .PHONY: prep-kernels 3.40 @@ -66,6 +68,10 @@ install-tools: 3.41 install-kernels: 3.42 for i in $(XKERNELS) ; do $(MAKE) $$i-install || exit 1; done 3.43 3.44 +.PHONY: install-stubdom 3.45 +install-stubdom: 3.46 + $(MAKE) -C stubdom install 3.47 + 3.48 .PHONY: install-docs 3.49 install-docs: 3.50 sh ./docs/check_pkgs && $(MAKE) -C docs install || true 3.51 @@ -102,6 +108,7 @@ world: 3.52 clean:: 3.53 $(MAKE) -C xen clean 3.54 $(MAKE) -C tools clean 3.55 + $(MAKE) -C stubdom crossclean 3.56 $(MAKE) -C docs clean 3.57 3.58 # clean, but blow away kernel build tree plus tarballs 3.59 @@ -109,6 +116,7 @@ clean:: 3.60 distclean: 3.61 $(MAKE) -C xen distclean 3.62 $(MAKE) -C tools distclean 3.63 + $(MAKE) -C stubdom distclean 3.64 $(MAKE) -C docs distclean 3.65 rm -rf dist patches/tmp 3.66 for i in $(ALLKERNELS) ; do $(MAKE) $$i-delete ; done 3.67 @@ -132,6 +140,7 @@ help: 3.68 @echo ' install-xen - build and install the Xen hypervisor' 3.69 @echo ' install-tools - build and install the control tools' 3.70 @echo ' install-kernels - build and install guest kernels' 3.71 + @echo ' install-stubdom - build and install the stubdomain images' 3.72 @echo ' install-docs - build and install user documentation' 3.73 @echo '' 3.74 @echo 'Building targets:' 3.75 @@ -140,6 +149,7 @@ help: 3.76 @echo ' trees then make dist' 3.77 @echo ' xen - build and install Xen hypervisor' 3.78 @echo ' tools - build and install tools' 3.79 + @echo ' stubdomain - build and install the stubdomain images' 3.80 @echo ' kernels - build and install guest kernels' 3.81 @echo ' kbuild - synonym for make kernels' 3.82 @echo ' docs - build and install user documentation' 3.83 @@ -214,7 +224,7 @@ linux26: 3.84 # tboot targets 3.85 # 3.86 3.87 -TBOOT_TARFILE = tboot-20071128.tar.gz 3.88 +TBOOT_TARFILE = tboot-20080613.tar.gz 3.89 TBOOT_BASE_URL = http://downloads.sourceforge.net/tboot 3.90 3.91 .PHONY: build-tboot
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/buildconfigs/mk.linux-2.6-tip-latest Fri Jul 18 12:12:41 2008 +0900 4.3 @@ -0,0 +1,14 @@ 4.4 +XEN_LINUX_SOURCE ?= git-clone 4.5 +LINUX_VER ?= 2.6-x86-latest 4.6 + 4.7 +IMAGE_TARGET ?= bzImage vmlinux 4.8 + 4.9 +XEN_LINUX_CONFIG_UPDATE := buildconfigs/enable-xen-config 4.10 + 4.11 +XEN_LINUX_GIT_URL ?= git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-tip.git 4.12 +XEN_LINUX_GIT_REMOTENAME ?= x86 4.13 +XEN_LINUX_GIT_REMOTEBRANCH ?= auto-latest 4.14 + 4.15 +EXTRAVERSION ?= 4.16 + 4.17 +include buildconfigs/mk.linux-2.6-common
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/buildconfigs/src.git-clone Fri Jul 18 12:12:41 2008 +0900 5.3 @@ -0,0 +1,60 @@ 5.4 +# Mercurial 5.5 +GIT ?= git 5.6 + 5.7 +LINUX_SRCDIR ?= linux-$(LINUX_VER).git 5.8 + 5.9 +# The URL of the remote GIT repository 5.10 +ifeq ($(XEN_LINUX_GIT_URL),) 5.11 +.ERROR: XEN_LINUX_GIT_URL not specified 5.12 +endif 5.13 + 5.14 +# The name to use for the remote repository 5.15 +XEN_LINUX_GIT_REMOTENAME ?= origin 5.16 + 5.17 +# The branch in the remote repository 5.18 +ifeq ($(XEN_LINUX_GIT_REMOTEBRANCH),) 5.19 +.ERROR: XEN_LINUX_GIT_REMOTEBRANCH not specified 5.20 +endif 5.21 + 5.22 +XEN_LINUX_GIT_LOCALBRANCH ?= master 5.23 + 5.24 +# Set XEN_LINUX_GITREV to update to a particlar revision. 5.25 +XEN_LINUX_GITREV ?= 5.26 + 5.27 +$(LINUX_SRCDIR)/.valid-src: $(__XEN_LINUX_UPDATE) 5.28 + @set -e ; if [ -d $(LINUX_SRCDIR) ] && [ ! -d $(GIT_DIR) ] ; then \ 5.29 + echo "$(LINUX_SRCDIR) exists but is not a git repository." 1>&2 ; \ 5.30 + false ; \ 5.31 + fi 5.32 + 5.33 + @set -e ; if [ ! -e $(LINUX_SRCDIR)/.git ] ; then \ 5.34 + mkdir $(LINUX_SRCDIR) ; \ 5.35 + cd $(LINUX_SRCDIR) ; \ 5.36 + $(GIT) init-db ; \ 5.37 + fi 5.38 + 5.39 + @set -e ; cd $(LINUX_SRCDIR) ; \ 5.40 + if ! $(GIT) remote | grep -q $(XEN_LINUX_GIT_REMOTENAME) ; then \ 5.41 + echo "Adding remote git repository \`$(XEN_LINUX_GIT_URL)' as \`$(XEN_LINUX_GIT_REMOTENAME)'" ; \ 5.42 + $(GIT) remote add $(XEN_LINUX_GIT_REMOTENAME) $(XEN_LINUX_GIT_URL) ; \ 5.43 + fi 5.44 + 5.45 + @echo "Updating remote \`$(XEN_LINUX_GIT_REMOTENAME)'" 5.46 + @cd $(LINUX_SRCDIR) && $(GIT) fetch $(XEN_LINUX_GIT_REMOTENAME) 5.47 + 5.48 + @set -e ; cd $(LINUX_SRCDIR) ; \ 5.49 + if ! $(GIT) branch -l | grep -q $(XEN_LINUX_GIT_LOCALBRANCH) ; then \ 5.50 + $(GIT) branch --track $(XEN_LINUX_GIT_LOCALBRANCH) \ 5.51 + $(XEN_LINUX_GIT_REMOTENAME)/$(XEN_LINUX_GIT_REMOTEBRANCH) ; \ 5.52 + $(GIT) checkout ; \ 5.53 + fi 5.54 + 5.55 + @ set -e ; cd $(LINUX_SRCDIR) ; \ 5.56 + if [ -n "$(XEN_LINUX_GITREV)" ] ; then \ 5.57 + echo "Updating $(LINUX_SRCDIR) to revision \'$(XEN_LINUX_GITREV)'." ; \ 5.58 + $(GIT) reset --hard $(XEN_LINUX_GITREV) ; \ 5.59 + else \ 5.60 + $(GIT) reset --hard $(XEN_LINUX_GIT_REMOTENAME)/$(XEN_LINUX_GIT_REMOTEBRANCH) ; \ 5.61 + fi 5.62 + 5.63 + touch $@
6.1 --- a/config/StdGNU.mk Tue Jul 08 11:41:43 2008 +0900 6.2 +++ b/config/StdGNU.mk Fri Jul 18 12:12:41 2008 +0900 6.3 @@ -13,6 +13,9 @@ SIZEUTIL = $(CROSS_COMPILE)size 6.4 MSGFMT = msgfmt 6.5 MSGMERGE = msgmerge 6.6 6.7 +# Allow git to be wrappered in the environment 6.8 +GIT ?= git 6.9 + 6.10 INSTALL = install 6.11 INSTALL_DIR = $(INSTALL) -d -m0755 -p 6.12 INSTALL_DATA = $(INSTALL) -m0644 -p
7.1 --- a/docs/ChangeLog Tue Jul 08 11:41:43 2008 +0900 7.2 +++ b/docs/ChangeLog Fri Jul 18 12:12:41 2008 +0900 7.3 @@ -16,6 +16,9 @@ http://lists.xensource.com/archives/html 7.4 Xen 3.3 release 7.5 --------------- 7.6 7.7 +17974: PHYSDEVOP_manage_pci_add/PHYSDEVOP_manage_pci_remove 7.8 +http://xenbits.xensource.com/xen-unstable.hg?rev/183ca809e1d7 7.9 + 7.10 17903: Add greater than 16 xvd device availability 7.11 http://xenbits.xensource.com/xen-unstable.hg?rev/0728459b3c8d 7.12
8.1 --- a/extras/mini-os/Config.mk Tue Jul 08 11:41:43 2008 +0900 8.2 +++ b/extras/mini-os/Config.mk Fri Jul 18 12:12:41 2008 +0900 8.3 @@ -38,20 +38,20 @@ EXTRA_INC = $(ARCH_INC) 8.4 # This must be before include minios.mk! 8.5 include $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk 8.6 8.7 -extra_incl := $(foreach dir,$(EXTRA_INC),-I$(MINI-OS_ROOT)/include/$(dir)) 8.8 +extra_incl := $(foreach dir,$(EXTRA_INC),-isystem $(CURDIR)/$(MINI-OS_ROOT)/include/$(dir)) 8.9 8.10 -DEF_CPPFLAGS += -I$(MINI-OS_ROOT)/include 8.11 +DEF_CPPFLAGS += -isystem $(CURDIR)/$(MINI-OS_ROOT)/include 8.12 DEF_CPPFLAGS += -D__MINIOS__ 8.13 8.14 ifeq ($(libc),y) 8.15 DEF_CPPFLAGS += -DHAVE_LIBC 8.16 -DEF_CPPFLAGS += -I$(MINI-OS_ROOT)/include/posix 8.17 -DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/xenstore 8.18 +DEF_CPPFLAGS += -isystem $(CURDIR)/$(MINI-OS_ROOT)/include/posix 8.19 +DEF_CPPFLAGS += -isystem $(CURDIR)/$(XEN_ROOT)/tools/xenstore 8.20 endif 8.21 8.22 ifneq ($(LWIPDIR),) 8.23 lwip=y 8.24 DEF_CPPFLAGS += -DHAVE_LWIP 8.25 -DEF_CPPFLAGS += -I$(LWIPDIR)/src/include 8.26 -DEF_CPPFLAGS += -I$(LWIPDIR)/src/include/ipv4 8.27 +DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include 8.28 +DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include/ipv4 8.29 endif
9.1 --- a/extras/mini-os/Makefile Tue Jul 08 11:41:43 2008 +0900 9.2 +++ b/extras/mini-os/Makefile Fri Jul 18 12:12:41 2008 +0900 9.3 @@ -55,6 +55,8 @@ endif 9.4 .PHONY: links 9.5 links: $(ARCH_LINKS) 9.6 [ -e include/xen ] || ln -sf ../../../xen/include/public include/xen 9.7 + [ -e include/mini-os ] || ln -sf . include/mini-os 9.8 + [ -e include/$(TARGET_ARCH_FAM)/mini-os ] || ln -sf . include/$(TARGET_ARCH_FAM)/mini-os 9.9 9.10 .PHONY: arch_lib 9.11 arch_lib: 9.12 @@ -89,7 +91,7 @@ OBJS := $(filter-out $(OBJ_DIR)/daytime. 9.13 endif 9.14 9.15 $(OBJ_DIR)/$(TARGET)_app.o: $(APP_OBJS) app.lds 9.16 - $(LD) -r -d $(LDFLAGS) $^ $(APP_LDLIBS) --undefined main -o $@ 9.17 + $(LD) -r -d $(LDFLAGS) -\( $^ -\) $(APP_LDLIBS) --undefined main -o $@ 9.18 9.19 $(OBJ_DIR)/$(TARGET): links $(OBJS) $(OBJ_DIR)/$(TARGET)_app.o arch_lib 9.20 $(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJ_DIR)/$(TARGET)_app.o $(OBJS) $(LDARCHLIB) $(LDLIBS) -o $@.o
10.1 --- a/extras/mini-os/arch/ia64/minios-ia64.lds Tue Jul 08 11:41:43 2008 +0900 10.2 +++ b/extras/mini-os/arch/ia64/minios-ia64.lds Fri Jul 18 12:12:41 2008 +0900 10.3 @@ -55,8 +55,8 @@ SECTIONS 10.4 .ctors : { 10.5 __CTOR_LIST__ = .; 10.6 QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2) 10.7 - *(SORT_BY_NAME(.ctors)) 10.8 - SORT_BY_NAME(CONSTRUCTORS) 10.9 + *(.ctors) 10.10 + CONSTRUCTORS 10.11 QUAD(0) 10.12 __CTOR_END__ = .; 10.13 } 10.14 @@ -64,7 +64,7 @@ SECTIONS 10.15 .dtors : { 10.16 __DTOR_LIST__ = .; 10.17 QUAD((__DTOR_END__ - __DTOR_LIST__) / 8 - 2) 10.18 - *(SORT_BY_NAME(.dtors)) 10.19 + *(.dtors) 10.20 QUAD(0) 10.21 __DTOR_END__ = .; 10.22 }
11.1 --- a/extras/mini-os/arch/x86/minios-x86_32.lds Tue Jul 08 11:41:43 2008 +0900 11.2 +++ b/extras/mini-os/arch/x86/minios-x86_32.lds Fri Jul 18 12:12:41 2008 +0900 11.3 @@ -31,8 +31,8 @@ SECTIONS 11.4 .ctors : { 11.5 __CTOR_LIST__ = .; 11.6 LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 11.7 - *(SORT_BY_NAME(.ctors)) 11.8 - SORT_BY_NAME(CONSTRUCTORS) 11.9 + *(.ctors) 11.10 + CONSTRUCTORS 11.11 LONG(0) 11.12 __CTOR_END__ = .; 11.13 } 11.14 @@ -40,7 +40,7 @@ SECTIONS 11.15 .dtors : { 11.16 __DTOR_LIST__ = .; 11.17 LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 11.18 - *(SORT_BY_NAME(.dtors)) 11.19 + *(.dtors) 11.20 LONG(0) 11.21 __DTOR_END__ = .; 11.22 }
12.1 --- a/extras/mini-os/arch/x86/minios-x86_64.lds Tue Jul 08 11:41:43 2008 +0900 12.2 +++ b/extras/mini-os/arch/x86/minios-x86_64.lds Fri Jul 18 12:12:41 2008 +0900 12.3 @@ -31,8 +31,8 @@ SECTIONS 12.4 .ctors : { 12.5 __CTOR_LIST__ = .; 12.6 QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2) 12.7 - *(SORT_BY_NAME(.ctors)) 12.8 - SORT_BY_NAME(CONSTRUCTORS) 12.9 + *(.ctors) 12.10 + CONSTRUCTORS 12.11 QUAD(0) 12.12 __CTOR_END__ = .; 12.13 } 12.14 @@ -40,7 +40,7 @@ SECTIONS 12.15 .dtors : { 12.16 __DTOR_LIST__ = .; 12.17 QUAD((__DTOR_END__ - __DTOR_LIST__) / 8 - 2) 12.18 - *(SORT_BY_NAME(.dtors)) 12.19 + *(.dtors) 12.20 QUAD(0) 12.21 __DTOR_END__ = .; 12.22 }
13.1 --- a/extras/mini-os/arch/x86/mm.c Tue Jul 08 11:41:43 2008 +0900 13.2 +++ b/extras/mini-os/arch/x86/mm.c Fri Jul 18 12:12:41 2008 +0900 13.3 @@ -549,7 +549,7 @@ void arch_init_p2m(unsigned long max_pfn 13.4 #define L2_P2M_MASK (L2_P2M_ENTRIES - 1) 13.5 #define L3_P2M_MASK (L3_P2M_ENTRIES - 1) 13.6 13.7 - unsigned long *l1_list, *l2_list, *l3_list; 13.8 + unsigned long *l1_list = NULL, *l2_list = NULL, *l3_list; 13.9 unsigned long pfn; 13.10 13.11 l3_list = (unsigned long *)alloc_page();
14.1 --- a/extras/mini-os/blkfront.c Tue Jul 08 11:41:43 2008 +0900 14.2 +++ b/extras/mini-os/blkfront.c Fri Jul 18 12:12:41 2008 +0900 14.3 @@ -84,7 +84,7 @@ static void free_blkfront(struct blkfron 14.4 free(dev); 14.5 } 14.6 14.7 -struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info) 14.8 +struct blkfront_dev *init_blkfront(char *_nodename, struct blkfront_info *info) 14.9 { 14.10 xenbus_transaction_t xbt; 14.11 char* err; 14.12 @@ -93,12 +93,10 @@ struct blkfront_dev *init_blkfront(char 14.13 int retry=0; 14.14 char* msg; 14.15 char* c; 14.16 + char* nodename = _nodename ? _nodename : "device/vbd/768"; 14.17 14.18 struct blkfront_dev *dev; 14.19 14.20 - if (!nodename) 14.21 - nodename = "device/vbd/768"; 14.22 - 14.23 char path[strlen(nodename) + 1 + 10 + 1]; 14.24 14.25 printk("******************* BLKFRONT for %s **********\n\n\n", nodename); 14.26 @@ -342,13 +340,14 @@ static void blkfront_aio_cb(struct blkfr 14.27 void blkfront_io(struct blkfront_aiocb *aiocbp, int write) 14.28 { 14.29 unsigned long flags; 14.30 + DEFINE_WAIT(w); 14.31 + 14.32 ASSERT(!aiocbp->aio_cb); 14.33 aiocbp->aio_cb = blkfront_aio_cb; 14.34 blkfront_aio(aiocbp, write); 14.35 aiocbp->data = NULL; 14.36 14.37 local_irq_save(flags); 14.38 - DEFINE_WAIT(w); 14.39 while (1) { 14.40 blkfront_aio_poll(aiocbp->aio_dev); 14.41 if (aiocbp->data) 14.42 @@ -393,6 +392,7 @@ void blkfront_aio_push_operation(struct 14.43 void blkfront_sync(struct blkfront_dev *dev) 14.44 { 14.45 unsigned long flags; 14.46 + DEFINE_WAIT(w); 14.47 14.48 if (dev->info.mode == O_RDWR) { 14.49 if (dev->info.barrier == 1) 14.50 @@ -404,7 +404,6 @@ void blkfront_sync(struct blkfront_dev * 14.51 14.52 /* Note: This won't finish if another thread enqueues requests. */ 14.53 local_irq_save(flags); 14.54 - DEFINE_WAIT(w); 14.55 while (1) { 14.56 blkfront_aio_poll(dev); 14.57 if (RING_FREE_REQUESTS(&dev->ring) == RING_SIZE(&dev->ring)) 14.58 @@ -424,6 +423,7 @@ int blkfront_aio_poll(struct blkfront_de 14.59 RING_IDX rp, cons; 14.60 struct blkif_response *rsp; 14.61 int more; 14.62 + int nr_consumed; 14.63 14.64 moretodo: 14.65 #ifdef HAVE_LIBC 14.66 @@ -437,14 +437,17 @@ moretodo: 14.67 rmb(); /* Ensure we see queued responses up to 'rp'. */ 14.68 cons = dev->ring.rsp_cons; 14.69 14.70 - int nr_consumed = 0; 14.71 + nr_consumed = 0; 14.72 while ((cons != rp)) 14.73 { 14.74 + struct blkfront_aiocb *aiocbp; 14.75 + int status; 14.76 + 14.77 rsp = RING_GET_RESPONSE(&dev->ring, cons); 14.78 nr_consumed++; 14.79 14.80 - struct blkfront_aiocb *aiocbp = (void*) (uintptr_t) rsp->id; 14.81 - int status = rsp->status; 14.82 + aiocbp = (void*) (uintptr_t) rsp->id; 14.83 + status = rsp->status; 14.84 14.85 if (status != BLKIF_RSP_OKAY) 14.86 printk("block error %d for op %d\n", status, rsp->operation);
15.1 --- a/extras/mini-os/events.c Tue Jul 08 11:41:43 2008 +0900 15.2 +++ b/extras/mini-os/events.c Fri Jul 18 12:12:41 2008 +0900 15.3 @@ -136,6 +136,23 @@ evtchn_port_t bind_virq(uint32_t virq, e 15.4 return op.port; 15.5 } 15.6 15.7 +evtchn_port_t bind_pirq(uint32_t pirq, int will_share, evtchn_handler_t handler, void *data) 15.8 +{ 15.9 + evtchn_bind_pirq_t op; 15.10 + 15.11 + /* Try to bind the pirq to a port */ 15.12 + op.pirq = pirq; 15.13 + op.flags = will_share ? BIND_PIRQ__WILL_SHARE : 0; 15.14 + 15.15 + if ( HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &op) != 0 ) 15.16 + { 15.17 + printk("Failed to bind physical IRQ %d\n", pirq); 15.18 + return -1; 15.19 + } 15.20 + bind_evtchn(op.port, handler, data); 15.21 + return op.port; 15.22 +} 15.23 + 15.24 #if defined(__x86_64__) 15.25 char irqstack[2 * STACK_SIZE]; 15.26 15.27 @@ -190,10 +207,11 @@ void default_handler(evtchn_port_t port, 15.28 int evtchn_alloc_unbound(domid_t pal, evtchn_handler_t handler, 15.29 void *data, evtchn_port_t *port) 15.30 { 15.31 + int err; 15.32 evtchn_alloc_unbound_t op; 15.33 op.dom = DOMID_SELF; 15.34 op.remote_dom = pal; 15.35 - int err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &op); 15.36 + err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &op); 15.37 if (err) 15.38 return err; 15.39 *port = bind_evtchn(op.port, handler, data); 15.40 @@ -207,13 +225,15 @@ int evtchn_bind_interdomain(domid_t pal, 15.41 evtchn_handler_t handler, void *data, 15.42 evtchn_port_t *local_port) 15.43 { 15.44 + int err; 15.45 + evtchn_port_t port; 15.46 evtchn_bind_interdomain_t op; 15.47 op.remote_dom = pal; 15.48 op.remote_port = remote_port; 15.49 - int err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &op); 15.50 + err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &op); 15.51 if (err) 15.52 return err; 15.53 - evtchn_port_t port = op.local_port; 15.54 + port = op.local_port; 15.55 *local_port = bind_evtchn(port, handler, data); 15.56 return err; 15.57 }
16.1 --- a/extras/mini-os/fbfront.c Tue Jul 08 11:41:43 2008 +0900 16.2 +++ b/extras/mini-os/fbfront.c Fri Jul 18 12:12:41 2008 +0900 16.3 @@ -64,7 +64,7 @@ static void free_kbdfront(struct kbdfron 16.4 free(dev); 16.5 } 16.6 16.7 -struct kbdfront_dev *init_kbdfront(char *nodename, int abs_pointer) 16.8 +struct kbdfront_dev *init_kbdfront(char *_nodename, int abs_pointer) 16.9 { 16.10 xenbus_transaction_t xbt; 16.11 char* err; 16.12 @@ -72,12 +72,9 @@ struct kbdfront_dev *init_kbdfront(char 16.13 struct xenkbd_page *s; 16.14 int retry=0; 16.15 char* msg; 16.16 - 16.17 + char* nodename = _nodename ? _nodename : "device/vkbd/0"; 16.18 struct kbdfront_dev *dev; 16.19 16.20 - if (!nodename) 16.21 - nodename = "device/vkbd/0"; 16.22 - 16.23 char path[strlen(nodename) + 1 + 10 + 1]; 16.24 16.25 printk("******************* KBDFRONT for %s **********\n\n\n", nodename); 16.26 @@ -351,7 +348,7 @@ int fbfront_receive(struct fbfront_dev * 16.27 return i; 16.28 } 16.29 16.30 -struct fbfront_dev *init_fbfront(char *nodename, unsigned long *mfns, int width, int height, int depth, int stride, int n) 16.31 +struct fbfront_dev *init_fbfront(char *_nodename, unsigned long *mfns, int width, int height, int depth, int stride, int n) 16.32 { 16.33 xenbus_transaction_t xbt; 16.34 char* err; 16.35 @@ -361,9 +358,9 @@ struct fbfront_dev *init_fbfront(char *n 16.36 char* msg; 16.37 int i, j; 16.38 struct fbfront_dev *dev; 16.39 - 16.40 - if (!nodename) 16.41 - nodename = "device/vfb/0"; 16.42 + int max_pd; 16.43 + unsigned long mapped; 16.44 + char* nodename = _nodename ? _nodename : "device/vfb/0"; 16.45 16.46 char path[strlen(nodename) + 1 + 10 + 1]; 16.47 16.48 @@ -392,8 +389,8 @@ struct fbfront_dev *init_fbfront(char *n 16.49 dev->offset = 0; 16.50 dev->events = NULL; 16.51 16.52 - const int max_pd = sizeof(s->pd) / sizeof(s->pd[0]); 16.53 - unsigned long mapped = 0; 16.54 + max_pd = sizeof(s->pd) / sizeof(s->pd[0]); 16.55 + mapped = 0; 16.56 16.57 for (i = 0; mapped < n && i < max_pd; i++) { 16.58 unsigned long *pd = (unsigned long *) alloc_page();
17.1 --- a/extras/mini-os/fs-front.c Tue Jul 08 11:41:43 2008 +0900 17.2 +++ b/extras/mini-os/fs-front.c Fri Jul 18 12:12:41 2008 +0900 17.3 @@ -3,7 +3,7 @@ 17.4 * 17.5 * Frontend driver for FS split device driver. 17.6 * 17.7 - * Copyright (c) 2007, Grzegorz Milos, Sun Microsystems, Inc. 17.8 + * Copyright (c) 2007, Grzegorz Milos, <gm281@cam.ac.uk>. 17.9 * 17.10 * Permission is hereby granted, free of charge, to any person obtaining a copy 17.11 * of this software and associated documentation files (the "Software"), to
18.1 --- a/extras/mini-os/hypervisor.c Tue Jul 08 11:41:43 2008 +0900 18.2 +++ b/extras/mini-os/hypervisor.c Fri Jul 18 12:12:41 2008 +0900 18.3 @@ -72,9 +72,10 @@ void do_hypervisor_callback(struct pt_re 18.4 18.5 void force_evtchn_callback(void) 18.6 { 18.7 + int save; 18.8 vcpu_info_t *vcpu; 18.9 vcpu = &HYPERVISOR_shared_info->vcpu_info[smp_processor_id()]; 18.10 - int save = vcpu->evtchn_upcall_mask; 18.11 + save = vcpu->evtchn_upcall_mask; 18.12 18.13 while (vcpu->evtchn_upcall_pending) { 18.14 vcpu->evtchn_upcall_mask = 1;
19.1 --- a/extras/mini-os/include/arch/cc.h Tue Jul 08 11:41:43 2008 +0900 19.2 +++ b/extras/mini-os/include/arch/cc.h Fri Jul 18 12:12:41 2008 +0900 19.3 @@ -10,8 +10,8 @@ 19.4 #define __LWIP_ARCH_CC_H__ 19.5 19.6 /* Typedefs for the types used by lwip - */ 19.7 -#include <os.h> 19.8 -#include <types.h> 19.9 +#include <mini-os/os.h> 19.10 +#include <mini-os/types.h> 19.11 #include <time.h> 19.12 typedef u8 u8_t; 19.13 typedef s8 s8_t; 19.14 @@ -46,7 +46,7 @@ extern void lwip_die(char *fmt, ...); 19.15 19.16 /* If the compiler does not provide memset() this file must include a */ 19.17 /* definition of it, or include a file which defines it. */ 19.18 -#include <lib.h> 19.19 +#include <mini-os/lib.h> 19.20 19.21 /* This file must either include a system-local <errno.h> which defines */ 19.22 /* the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO */
20.1 --- a/extras/mini-os/include/arch/sys_arch.h Tue Jul 08 11:41:43 2008 +0900 20.2 +++ b/extras/mini-os/include/arch/sys_arch.h Fri Jul 18 12:12:41 2008 +0900 20.3 @@ -9,9 +9,9 @@ 20.4 #ifndef __LWIP_ARCH_SYS_ARCH_H__ 20.5 #define __LWIP_ARCH_SYS_ARCH_H__ 20.6 20.7 -#include <os.h> 20.8 -#include <xmalloc.h> 20.9 -#include <semaphore.h> 20.10 +#include <mini-os/os.h> 20.11 +#include <mini-os/xmalloc.h> 20.12 +#include <mini-os/semaphore.h> 20.13 20.14 typedef struct semaphore *sys_sem_t; 20.15 #define SYS_SEM_NULL ((sys_sem_t) NULL)
21.1 --- a/extras/mini-os/include/blkfront.h Tue Jul 08 11:41:43 2008 +0900 21.2 +++ b/extras/mini-os/include/blkfront.h Fri Jul 18 12:12:41 2008 +0900 21.3 @@ -1,6 +1,6 @@ 21.4 -#include <wait.h> 21.5 +#include <mini-os/wait.h> 21.6 #include <xen/io/blkif.h> 21.7 -#include <types.h> 21.8 +#include <mini-os/types.h> 21.9 struct blkfront_dev; 21.10 struct blkfront_aiocb 21.11 {
22.1 --- a/extras/mini-os/include/byteswap.h Tue Jul 08 11:41:43 2008 +0900 22.2 +++ b/extras/mini-os/include/byteswap.h Fri Jul 18 12:12:41 2008 +0900 22.3 @@ -3,7 +3,7 @@ 22.4 22.5 /* Unfortunately not provided by newlib. */ 22.6 22.7 -#include <types.h> 22.8 +#include <mini-os/types.h> 22.9 static inline uint16_t bswap_16(uint16_t x) 22.10 { 22.11 return
23.1 --- a/extras/mini-os/include/console.h Tue Jul 08 11:41:43 2008 +0900 23.2 +++ b/extras/mini-os/include/console.h Fri Jul 18 12:12:41 2008 +0900 23.3 @@ -36,8 +36,8 @@ 23.4 #ifndef _LIB_CONSOLE_H_ 23.5 #define _LIB_CONSOLE_H_ 23.6 23.7 -#include<os.h> 23.8 -#include<traps.h> 23.9 +#include<mini-os/os.h> 23.10 +#include<mini-os/traps.h> 23.11 #include<stdarg.h> 23.12 23.13 void print(int direct, const char *fmt, va_list args);
24.1 --- a/extras/mini-os/include/ctype.h Tue Jul 08 11:41:43 2008 +0900 24.2 +++ b/extras/mini-os/include/ctype.h Fri Jul 18 12:12:41 2008 +0900 24.3 @@ -1,6 +1,9 @@ 24.4 #ifndef _CTYPE_H 24.5 #define _CTYPE_H 24.6 24.7 +#ifdef HAVE_LIBC 24.8 +#include_next <ctype.h> 24.9 +#else 24.10 /* 24.11 * NOTE! This ctype does not handle EOF like the standard C 24.12 * library is required to. 24.13 @@ -53,3 +56,5 @@ static inline unsigned char __toupper(un 24.14 #define toupper(c) __toupper(c) 24.15 24.16 #endif 24.17 + 24.18 +#endif
25.1 --- a/extras/mini-os/include/err.h Tue Jul 08 11:41:43 2008 +0900 25.2 +++ b/extras/mini-os/include/err.h Fri Jul 18 12:12:41 2008 +0900 25.3 @@ -1,7 +1,7 @@ 25.4 #ifndef _ERR_H 25.5 #define _ERR_H 25.6 25.7 -#include <errno.h> 25.8 +#include <mini-os/errno.h> 25.9 25.10 /* 25.11 * Kernel pointers have redundant information, so we can use a
26.1 --- a/extras/mini-os/include/errno.h Tue Jul 08 11:41:43 2008 +0900 26.2 +++ b/extras/mini-os/include/errno.h Fri Jul 18 12:12:41 2008 +0900 26.3 @@ -1,7 +1,9 @@ 26.4 #ifndef _ERRNO_H 26.5 #define _ERRNO_H 26.6 26.7 -#include <errno-base.h> 26.8 +#include <mini-os/errno-base.h> 26.9 + 26.10 +typedef int error_t; 26.11 26.12 #define EDEADLK 35 /* Resource deadlock would occur */ 26.13 #define ENAMETOOLONG 36 /* File name too long */ 26.14 @@ -107,8 +109,11 @@ 26.15 #define EOWNERDEAD 130 /* Owner died */ 26.16 #define ENOTRECOVERABLE 131 /* State not recoverable */ 26.17 26.18 + 26.19 +#define EFTYPE 132 /* Inappropriate file type or format */ 26.20 + 26.21 #ifdef HAVE_LIBC 26.22 -#include <sched.h> 26.23 +#include <mini-os/sched.h> 26.24 extern int errno; 26.25 #define ERRNO 26.26 #define errno (get_current()->reent._errno)
27.1 --- a/extras/mini-os/include/events.h Tue Jul 08 11:41:43 2008 +0900 27.2 +++ b/extras/mini-os/include/events.h Fri Jul 18 12:12:41 2008 +0900 27.3 @@ -19,7 +19,7 @@ 27.4 #ifndef _EVENTS_H_ 27.5 #define _EVENTS_H_ 27.6 27.7 -#include<traps.h> 27.8 +#include<mini-os/traps.h> 27.9 #include<xen/event_channel.h> 27.10 27.11 typedef void (*evtchn_handler_t)(evtchn_port_t, struct pt_regs *, void *); 27.12 @@ -27,6 +27,7 @@ typedef void (*evtchn_handler_t)(evtchn_ 27.13 /* prototypes */ 27.14 int do_event(evtchn_port_t port, struct pt_regs *regs); 27.15 evtchn_port_t bind_virq(uint32_t virq, evtchn_handler_t handler, void *data); 27.16 +evtchn_port_t bind_pirq(uint32_t pirq, int will_share, evtchn_handler_t handler, void *data); 27.17 evtchn_port_t bind_evtchn(evtchn_port_t port, evtchn_handler_t handler, 27.18 void *data); 27.19 void unbind_evtchn(evtchn_port_t port);
28.1 --- a/extras/mini-os/include/fbfront.h Tue Jul 08 11:41:43 2008 +0900 28.2 +++ b/extras/mini-os/include/fbfront.h Fri Jul 18 12:12:41 2008 +0900 28.3 @@ -1,6 +1,6 @@ 28.4 #include <xen/io/kbdif.h> 28.5 #include <xen/io/fbif.h> 28.6 -#include <wait.h> 28.7 +#include <mini-os/wait.h> 28.8 28.9 /* from <linux/input.h> */ 28.10 #ifndef BTN_LEFT
29.1 --- a/extras/mini-os/include/fs.h Tue Jul 08 11:41:43 2008 +0900 29.2 +++ b/extras/mini-os/include/fs.h Fri Jul 18 12:12:41 2008 +0900 29.3 @@ -2,8 +2,8 @@ 29.4 #define __FS_H__ 29.5 29.6 #include <xen/io/fsif.h> 29.7 -#include <semaphore.h> 29.8 -#include <types.h> 29.9 +#include <mini-os/semaphore.h> 29.10 +#include <mini-os/types.h> 29.11 29.12 struct fs_import 29.13 {
30.1 --- a/extras/mini-os/include/hypervisor.h Tue Jul 08 11:41:43 2008 +0900 30.2 +++ b/extras/mini-os/include/hypervisor.h Fri Jul 18 12:12:41 2008 +0900 30.3 @@ -13,7 +13,7 @@ 30.4 #ifndef _HYPERVISOR_H_ 30.5 #define _HYPERVISOR_H_ 30.6 30.7 -#include <types.h> 30.8 +#include <mini-os/types.h> 30.9 #include <xen/xen.h> 30.10 #if defined(__i386__) 30.11 #include <hypercall-x86_32.h> 30.12 @@ -24,7 +24,7 @@ 30.13 #else 30.14 #error "Unsupported architecture" 30.15 #endif 30.16 -#include <traps.h> 30.17 +#include <mini-os/traps.h> 30.18 30.19 /* 30.20 * a placeholder for the start of day information passed up from the hypervisor
31.1 --- a/extras/mini-os/include/ia64/arch_spinlock.h Tue Jul 08 11:41:43 2008 +0900 31.2 +++ b/extras/mini-os/include/ia64/arch_spinlock.h Fri Jul 18 12:12:41 2008 +0900 31.3 @@ -27,7 +27,7 @@ 31.4 31.5 #include "atomic.h" 31.6 31.7 -#define ARCH_SPIN_LOCK_UNLOCKED (spinlock_t) { 0 } 31.8 +#define ARCH_SPIN_LOCK_UNLOCKED { 0 } 31.9 31.10 #define SPIN_LOCK_UNUSED 0 31.11 #define SPIN_LOCK_USED 1
32.1 --- a/extras/mini-os/include/ia64/atomic.h Tue Jul 08 11:41:43 2008 +0900 32.2 +++ b/extras/mini-os/include/ia64/atomic.h Fri Jul 18 12:12:41 2008 +0900 32.3 @@ -38,7 +38,7 @@ 32.4 32.5 #if !defined(__ASSEMBLY__) 32.6 32.7 -#include <types.h> 32.8 +#include <mini-os/types.h> 32.9 32.10 32.11 /*
33.1 --- a/extras/mini-os/include/ia64/efi.h Tue Jul 08 11:41:43 2008 +0900 33.2 +++ b/extras/mini-os/include/ia64/efi.h Fri Jul 18 12:12:41 2008 +0900 33.3 @@ -32,7 +32,7 @@ 33.4 #ifndef _EFI_H_ 33.5 #define _EFI_H_ 33.6 33.7 -#include "types.h" 33.8 +#include <mini-os/types.h> 33.9 33.10 33.11 #define EFIWARN(a) (a)
34.1 --- a/extras/mini-os/include/ia64/endian.h Tue Jul 08 11:41:43 2008 +0900 34.2 +++ b/extras/mini-os/include/ia64/endian.h Fri Jul 18 12:12:41 2008 +0900 34.3 @@ -26,7 +26,7 @@ 34.4 #if !defined(_ENDIAN_H_) 34.5 #define _ENDIAN_H_ 34.6 34.7 -#include "types.h" 34.8 +#include <mini-os/types.h> 34.9 34.10 34.11 #if !defined(__ASSEMBLY__)
35.1 --- a/extras/mini-os/include/ia64/hypercall-ia64.h Tue Jul 08 11:41:43 2008 +0900 35.2 +++ b/extras/mini-os/include/ia64/hypercall-ia64.h Fri Jul 18 12:12:41 2008 +0900 35.3 @@ -34,8 +34,8 @@ 35.4 #ifndef __HYPERCALL_H__ 35.5 #define __HYPERCALL_H__ 35.6 35.7 -#include "lib.h" /* memcpy() */ 35.8 -#include "errno.h" /* ENOSYS() */ 35.9 +#include <mini-os/lib.h> /* memcpy() */ 35.10 +#include <mini-os/errno.h> /* ENOSYS() */ 35.11 #include <xen/event_channel.h> 35.12 #include <xen/sched.h> 35.13 #include <xen/version.h>
36.1 --- a/extras/mini-os/include/ia64/os.h Tue Jul 08 11:41:43 2008 +0900 36.2 +++ b/extras/mini-os/include/ia64/os.h Fri Jul 18 12:12:41 2008 +0900 36.3 @@ -27,15 +27,15 @@ 36.4 36.5 #if !defined(__ASSEMBLY__) 36.6 36.7 -#include "types.h" 36.8 +#include <mini-os/types.h> 36.9 #include "endian.h" 36.10 #include "ia64_cpu.h" 36.11 #include "atomic.h" 36.12 #include "efi.h" 36.13 #include "sal.h" 36.14 #include "pal.h" 36.15 -#include "hypervisor.h" 36.16 -#include <kernel.h> 36.17 +#include <mini-os/hypervisor.h> 36.18 +#include <mini-os/kernel.h> 36.19 36.20 36.21 typedef uint64_t paddr_t; /* Physical address. */
37.1 --- a/extras/mini-os/include/lib.h Tue Jul 08 11:41:43 2008 +0900 37.2 +++ b/extras/mini-os/include/lib.h Fri Jul 18 12:12:41 2008 +0900 37.3 @@ -99,13 +99,13 @@ char *strstr(const char *s1, const char 37.4 char * strcat(char * dest, const char * src); 37.5 char *strdup(const char *s); 37.6 #endif 37.7 -#include <console.h> 37.8 +#include <mini-os/console.h> 37.9 37.10 #define RAND_MIX 2654435769U 37.11 37.12 int rand(void); 37.13 37.14 -#include <xenbus.h> 37.15 +#include <mini-os/xenbus.h> 37.16 37.17 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 37.18
38.1 --- a/extras/mini-os/include/linux/types.h Tue Jul 08 11:41:43 2008 +0900 38.2 +++ b/extras/mini-os/include/linux/types.h Fri Jul 18 12:12:41 2008 +0900 38.3 @@ -1,5 +1,5 @@ 38.4 #ifndef _LINUX_TYPES_H_ 38.5 #define _LINUX_TYPES_H_ 38.6 -#include <types.h> 38.7 +#include <mini-os/types.h> 38.8 typedef u64 __u64; 38.9 #endif /* _LINUX_TYPES_H_ */
39.1 --- a/extras/mini-os/include/mm.h Tue Jul 08 11:41:43 2008 +0900 39.2 +++ b/extras/mini-os/include/mm.h Fri Jul 18 12:12:41 2008 +0900 39.3 @@ -35,10 +35,10 @@ 39.4 #error "Unsupported architecture" 39.5 #endif 39.6 39.7 -#include <lib.h> 39.8 +#include <mini-os/lib.h> 39.9 39.10 -#include <arch_limits.h> 39.11 -#include <arch_mm.h> 39.12 +#include <mini-os/arch_limits.h> 39.13 +#include <mini-os/arch_mm.h> 39.14 39.15 #define STACK_SIZE_PAGE_ORDER __STACK_SIZE_PAGE_ORDER 39.16 #define STACK_SIZE __STACK_SIZE
40.1 --- a/extras/mini-os/include/netfront.h Tue Jul 08 11:41:43 2008 +0900 40.2 +++ b/extras/mini-os/include/netfront.h Fri Jul 18 12:12:41 2008 +0900 40.3 @@ -1,4 +1,4 @@ 40.4 -#include <wait.h> 40.5 +#include <mini-os/wait.h> 40.6 #ifdef HAVE_LWIP 40.7 #include <lwip/netif.h> 40.8 #endif
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 41.2 +++ b/extras/mini-os/include/pcifront.h Fri Jul 18 12:12:41 2008 +0900 41.3 @@ -0,0 +1,28 @@ 41.4 +#include <mini-os/types.h> 41.5 +#include <xen/io/pciif.h> 41.6 +struct pcifront_dev; 41.7 +struct pcifront_dev *init_pcifront(char *nodename); 41.8 +void pcifront_op(struct pcifront_dev *dev, struct xen_pci_op *op); 41.9 +void pcifront_scan(struct pcifront_dev *dev, void (*fun)(unsigned int domain, unsigned int bus, unsigned slot, unsigned int fun)); 41.10 +int pcifront_conf_read(struct pcifront_dev *dev, 41.11 + unsigned int dom, 41.12 + unsigned int bus, unsigned int slot, unsigned long fun, 41.13 + unsigned int off, unsigned int size, unsigned int *val); 41.14 +int pcifront_conf_write(struct pcifront_dev *dev, 41.15 + unsigned int dom, 41.16 + unsigned int bus, unsigned int slot, unsigned long fun, 41.17 + unsigned int off, unsigned int size, unsigned int val); 41.18 +int pcifront_enable_msi(struct pcifront_dev *dev, 41.19 + unsigned int dom, 41.20 + unsigned int bus, unsigned int slot, unsigned long fun); 41.21 +int pcifront_disable_msi(struct pcifront_dev *dev, 41.22 + unsigned int dom, 41.23 + unsigned int bus, unsigned int slot, unsigned long fun); 41.24 +int pcifront_enable_msix(struct pcifront_dev *dev, 41.25 + unsigned int dom, 41.26 + unsigned int bus, unsigned int slot, unsigned long fun, 41.27 + struct xen_msix_entry *entries, int n); 41.28 +int pcifront_disable_msix(struct pcifront_dev *dev, 41.29 + unsigned int dom, 41.30 + unsigned int bus, unsigned int slot, unsigned long fun); 41.31 +void shutdown_pcifront(struct pcifront_dev *dev);
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 42.2 +++ b/extras/mini-os/include/posix/fcntl.h Fri Jul 18 12:12:41 2008 +0900 42.3 @@ -0,0 +1,11 @@ 42.4 +#ifndef _POSIX_FCNTL_H 42.5 +#define _POSIX_FCNTL_H 42.6 + 42.7 +#include_next <fcntl.h> 42.8 + 42.9 +#define F_ULOCK 0 42.10 +#define F_LOCK 1 42.11 +#define F_TLOCK 2 42.12 +#define F_TEST 3 42.13 + 42.14 +#endif /* _POSIX_FCNTL_H */
43.1 --- a/extras/mini-os/include/posix/limits.h Tue Jul 08 11:41:43 2008 +0900 43.2 +++ b/extras/mini-os/include/posix/limits.h Fri Jul 18 12:12:41 2008 +0900 43.3 @@ -1,9 +1,46 @@ 43.4 #ifndef _POSIX_LIMITS_H 43.5 #define _POSIX_LIMITS_H 43.6 43.7 -#include_next <limits.h> 43.8 -#include <arch_limits.h> 43.9 +#include <mini-os/arch_limits.h> 43.10 + 43.11 +#define CHAR_BIT 8 43.12 + 43.13 +#define SCHAR_MAX 0x7f 43.14 +#define SCHAR_MIN (-SCHAR_MAX-1) 43.15 +#define UCHAR_MAX 0xff 43.16 + 43.17 +#ifdef __CHAR_UNSIGNED__ 43.18 +# define CHAR_MIN 0 43.19 +# define CHAR_MAX UCHAR_MAX 43.20 +#else 43.21 +# define CHAR_MIN SCHAR_MIN 43.22 +# define CHAR_MAX SCHAR_MAX 43.23 +#endif 43.24 + 43.25 +#define INT_MAX 0x7fffffff 43.26 +#define INT_MIN (-INT_MAX-1) 43.27 +#define UINT_MAX 0xffffffff 43.28 + 43.29 +#define SHRT_MAX 0x7fff 43.30 + 43.31 +#if defined(__x86_64__) || defined(__ia64__) 43.32 +# define LONG_MAX 0x7fffffffffffffffL 43.33 +# define ULONG_MAX 0xffffffffffffffffUL 43.34 +#else 43.35 +# define LONG_MAX 0x7fffffffL 43.36 +# define ULONG_MAX 0xffffffffUL 43.37 +#endif 43.38 +#define LONG_MIN (-LONG_MAX-1L) 43.39 + 43.40 +#define LLONG_MAX 0x7fffffffffffffffLL 43.41 +#define LLONG_MIN (-LLONG_MAX-1LL) 43.42 +#define ULLONG_MAX 0xffffffffffffffffULL 43.43 + 43.44 +#define LONG_LONG_MIN LLONG_MIN 43.45 +#define LONG_LONG_MAX LLONG_MAX 43.46 +#define ULONG_LONG_MAX ULLONG_MAX 43.47 43.48 #define PATH_MAX __PAGE_SIZE 43.49 +#define PAGE_SIZE __PAGE_SIZE 43.50 43.51 #endif /* _POSIX_LIMITS_H */
44.1 --- a/extras/mini-os/include/posix/sys/mman.h Tue Jul 08 11:41:43 2008 +0900 44.2 +++ b/extras/mini-os/include/posix/sys/mman.h Fri Jul 18 12:12:41 2008 +0900 44.3 @@ -9,6 +9,9 @@ 44.4 #define MAP_PRIVATE 0x02 44.5 #define MAP_ANON 0x20 44.6 44.7 +/* Pages are always resident anyway */ 44.8 +#define MAP_LOCKED 0x0 44.9 + 44.10 #define MAP_FAILED ((void*)0) 44.11 44.12 void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset);
45.1 --- a/extras/mini-os/include/posix/sys/select.h Tue Jul 08 11:41:43 2008 +0900 45.2 +++ b/extras/mini-os/include/posix/sys/select.h Fri Jul 18 12:12:41 2008 +0900 45.3 @@ -2,6 +2,7 @@ 45.4 #define _POSIX_SELECT_H 45.5 45.6 #include <sys/time.h> 45.7 +#include <lwip/sockets.h> 45.8 int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); 45.9 45.10 #endif /* _POSIX_SELECT_H */
46.1 --- a/extras/mini-os/include/posix/unistd.h Tue Jul 08 11:41:43 2008 +0900 46.2 +++ b/extras/mini-os/include/posix/unistd.h Fri Jul 18 12:12:41 2008 +0900 46.3 @@ -2,11 +2,8 @@ 46.4 #define _POSIX_UNISTD_H 46.5 46.6 #include_next <unistd.h> 46.7 -#include <sys/select.h> 46.8 -#include <arch_limits.h> 46.9 46.10 -#define getpagesize() __PAGE_SIZE 46.11 - 46.12 +size_t getpagesize(void); 46.13 int ftruncate(int fd, off_t length); 46.14 46.15 #endif /* _POSIX_UNISTD_H */
47.1 --- a/extras/mini-os/include/sched.h Tue Jul 08 11:41:43 2008 +0900 47.2 +++ b/extras/mini-os/include/sched.h Fri Jul 18 12:12:41 2008 +0900 47.3 @@ -1,9 +1,12 @@ 47.4 #ifndef __SCHED_H__ 47.5 #define __SCHED_H__ 47.6 47.7 -#include <list.h> 47.8 -#include <time.h> 47.9 -#include <arch_sched.h> 47.10 +#include <mini-os/list.h> 47.11 +#include <mini-os/time.h> 47.12 +#include <mini-os/arch_sched.h> 47.13 +#ifdef HAVE_LIBC 47.14 +#include <sys/reent.h> 47.15 +#endif 47.16 47.17 struct thread 47.18 {
48.1 --- a/extras/mini-os/include/semaphore.h Tue Jul 08 11:41:43 2008 +0900 48.2 +++ b/extras/mini-os/include/semaphore.h Fri Jul 18 12:12:41 2008 +0900 48.3 @@ -1,8 +1,8 @@ 48.4 #ifndef _SEMAPHORE_H_ 48.5 #define _SEMAPHORE_H_ 48.6 48.7 -#include <wait.h> 48.8 -#include <spinlock.h> 48.9 +#include <mini-os/wait.h> 48.10 +#include <mini-os/spinlock.h> 48.11 48.12 /* 48.13 * Implementation of semaphore in Mini-os is simple, because
49.1 --- a/extras/mini-os/include/spinlock.h Tue Jul 08 11:41:43 2008 +0900 49.2 +++ b/extras/mini-os/include/spinlock.h Fri Jul 18 12:12:41 2008 +0900 49.3 @@ -1,7 +1,7 @@ 49.4 #ifndef __ASM_SPINLOCK_H 49.5 #define __ASM_SPINLOCK_H 49.6 49.7 -#include <lib.h> 49.8 +#include <mini-os/lib.h> 49.9 49.10 /* 49.11 * Your basic SMP spinlocks, allowing only a single CPU anywhere 49.12 @@ -12,7 +12,7 @@ typedef struct { 49.13 } spinlock_t; 49.14 49.15 49.16 -#include "arch_spinlock.h" 49.17 +#include <mini-os/arch_spinlock.h> 49.18 49.19 49.20 #define SPINLOCK_MAGIC 0xdead4ead
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/extras/mini-os/include/sys/lock.h Fri Jul 18 12:12:41 2008 +0900 50.3 @@ -0,0 +1,52 @@ 50.4 +#ifndef _MINIOS_SYS_LOCK_H_ 50.5 +#define _MINIOS_SYS_LOCK_H_ 50.6 + 50.7 +#ifdef HAVE_LIBC 50.8 + 50.9 +/* Due to inclusion loop, we can not include sched.h, so have to hide things */ 50.10 + 50.11 +#include <mini-os/waittypes.h> 50.12 + 50.13 + 50.14 +typedef struct { 50.15 + int busy; 50.16 + struct wait_queue_head wait; 50.17 +} _LOCK_T; 50.18 + 50.19 +#define __LOCK_INIT(class,lock) \ 50.20 + class _LOCK_T lock = { .wait = __WAIT_QUEUE_HEAD_INITIALIZER(lock.wait) } 50.21 +int ___lock_init(_LOCK_T *lock); 50.22 +int ___lock_acquire(_LOCK_T *lock); 50.23 +int ___lock_try_acquire(_LOCK_T *lock); 50.24 +int ___lock_release(_LOCK_T *lock); 50.25 +int ___lock_close(_LOCK_T *lock); 50.26 +#define __lock_init(__lock) ___lock_init(&__lock) 50.27 +#define __lock_acquire(__lock) ___lock_acquire(&__lock) 50.28 +#define __lock_release(__lock) ___lock_release(&__lock) 50.29 +#define __lock_try_acquire(__lock) ___lock_try_acquire(&__lock) 50.30 +#define __lock_close(__lock) 0 50.31 + 50.32 + 50.33 +typedef struct { 50.34 + struct thread *owner; 50.35 + int count; 50.36 + struct wait_queue_head wait; 50.37 +} _LOCK_RECURSIVE_T; 50.38 + 50.39 +#define __LOCK_INIT_RECURSIVE(class, lock) \ 50.40 + class _LOCK_RECURSIVE_T lock = { .wait = __WAIT_QUEUE_HEAD_INITIALIZER((lock).wait) } 50.41 + 50.42 +int ___lock_init_recursive(_LOCK_RECURSIVE_T *lock); 50.43 +int ___lock_acquire_recursive(_LOCK_RECURSIVE_T *lock); 50.44 +int ___lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock); 50.45 +int ___lock_release_recursive(_LOCK_RECURSIVE_T *lock); 50.46 +int ___lock_close_recursive(_LOCK_RECURSIVE_T *lock); 50.47 +#define __lock_init_recursive(__lock) ___lock_init_recursive(&__lock) 50.48 +#define __lock_acquire_recursive(__lock) ___lock_acquire_recursive(&__lock) 50.49 +#define __lock_release_recursive(__lock) ___lock_release_recursive(&__lock) 50.50 +#define __lock_try_acquire_recursive(__lock) ___lock_try_acquire_recursive(&__lock) 50.51 +#define __lock_close_recursive(__lock) 0 50.52 + 50.53 +#endif 50.54 + 50.55 +#endif /* _MINIOS_SYS_LOCK_H_ */
51.1 --- a/extras/mini-os/include/time.h Tue Jul 08 11:41:43 2008 +0900 51.2 +++ b/extras/mini-os/include/time.h Fri Jul 18 12:12:41 2008 +0900 51.3 @@ -19,7 +19,7 @@ 51.4 51.5 #ifndef _MINIOS_TIME_H_ 51.6 #define _MINIOS_TIME_H_ 51.7 -#include <types.h> 51.8 +#include <mini-os/types.h> 51.9 51.10 /* 51.11 * System Time
52.1 --- a/extras/mini-os/include/types.h Tue Jul 08 11:41:43 2008 +0900 52.2 +++ b/extras/mini-os/include/types.h Fri Jul 18 12:12:41 2008 +0900 52.3 @@ -36,9 +36,11 @@ typedef unsigned long u64; 52.4 #endif 52.5 52.6 /* FreeBSD compat types */ 52.7 +#ifndef HAVE_LIBC 52.8 typedef unsigned char u_char; 52.9 typedef unsigned int u_int; 52.10 typedef unsigned long u_long; 52.11 +#endif 52.12 #ifdef __i386__ 52.13 typedef long long quad_t; 52.14 typedef unsigned long long u_quad_t; 52.15 @@ -79,11 +81,13 @@ typedef s32 int32_t; 52.16 typedef u64 uint64_t, uintmax_t; 52.17 typedef s64 int64_t, intmax_t; 52.18 typedef u64 off_t; 52.19 +#endif 52.20 + 52.21 +typedef intptr_t ptrdiff_t; 52.22 52.23 52.24 -#define INT_MAX ((int)(~0U>>1)) 52.25 -#define UINT_MAX (~0U) 52.26 - 52.27 +#ifndef HAVE_LIBC 52.28 typedef long ssize_t; 52.29 #endif 52.30 + 52.31 #endif /* _TYPES_H_ */
53.1 --- a/extras/mini-os/include/wait.h Tue Jul 08 11:41:43 2008 +0900 53.2 +++ b/extras/mini-os/include/wait.h Fri Jul 18 12:12:41 2008 +0900 53.3 @@ -1,30 +1,9 @@ 53.4 #ifndef __WAIT_H__ 53.5 #define __WAIT_H__ 53.6 53.7 -#include <sched.h> 53.8 -#include <list.h> 53.9 -#include <lib.h> 53.10 -#include <os.h> 53.11 - 53.12 -struct wait_queue 53.13 -{ 53.14 - struct thread *thread; 53.15 - struct list_head thread_list; 53.16 -}; 53.17 - 53.18 -struct wait_queue_head 53.19 -{ 53.20 - /* TODO - lock required? */ 53.21 - struct list_head thread_list; 53.22 -}; 53.23 - 53.24 -#define DECLARE_WAIT_QUEUE_HEAD(name) \ 53.25 - struct wait_queue_head name = \ 53.26 - { .thread_list = { &(name).thread_list, &(name).thread_list} } 53.27 - 53.28 -#define __WAIT_QUEUE_HEAD_INITIALIZER(name) { \ 53.29 - .thread_list = { &(name).thread_list, &(name).thread_list } } 53.30 - 53.31 +#include <mini-os/sched.h> 53.32 +#include <mini-os/os.h> 53.33 +#include <mini-os/waittypes.h> 53.34 53.35 #define DEFINE_WAIT(name) \ 53.36 struct wait_queue name = { \
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/extras/mini-os/include/waittypes.h Fri Jul 18 12:12:41 2008 +0900 54.3 @@ -0,0 +1,26 @@ 54.4 +#ifndef __WAITTYPE_H__ 54.5 +#define __WAITTYPE_H__ 54.6 + 54.7 +#include <mini-os/list.h> 54.8 + 54.9 +struct thread; 54.10 +struct wait_queue 54.11 +{ 54.12 + struct thread *thread; 54.13 + struct list_head thread_list; 54.14 +}; 54.15 + 54.16 +struct wait_queue_head 54.17 +{ 54.18 + /* TODO - lock required? */ 54.19 + struct list_head thread_list; 54.20 +}; 54.21 + 54.22 +#define DECLARE_WAIT_QUEUE_HEAD(name) \ 54.23 + struct wait_queue_head name = \ 54.24 + { .thread_list = { &(name).thread_list, &(name).thread_list} } 54.25 + 54.26 +#define __WAIT_QUEUE_HEAD_INITIALIZER(name) { \ 54.27 + .thread_list = { &(name).thread_list, &(name).thread_list } } 54.28 + 54.29 +#endif
55.1 --- a/extras/mini-os/include/x86/arch_sched.h Tue Jul 08 11:41:43 2008 +0900 55.2 +++ b/extras/mini-os/include/x86/arch_sched.h Fri Jul 18 12:12:41 2008 +0900 55.3 @@ -2,7 +2,7 @@ 55.4 #ifndef __ARCH_SCHED_H__ 55.5 #define __ARCH_SCHED_H__ 55.6 55.7 -#include <arch_limits.h> 55.8 +#include "arch_limits.h" 55.9 55.10 static inline struct thread* get_current(void) 55.11 {
56.1 --- a/extras/mini-os/include/x86/arch_spinlock.h Tue Jul 08 11:41:43 2008 +0900 56.2 +++ b/extras/mini-os/include/x86/arch_spinlock.h Fri Jul 18 12:12:41 2008 +0900 56.3 @@ -3,11 +3,11 @@ 56.4 #ifndef __ARCH_ASM_SPINLOCK_H 56.5 #define __ARCH_ASM_SPINLOCK_H 56.6 56.7 -#include <lib.h> 56.8 +#include <mini-os/lib.h> 56.9 #include "os.h" 56.10 56.11 56.12 -#define ARCH_SPIN_LOCK_UNLOCKED (spinlock_t) { 1 } 56.13 +#define ARCH_SPIN_LOCK_UNLOCKED { 1 } 56.14 56.15 /* 56.16 * Simple spin lock operations. There are two variants, one clears IRQ's
57.1 --- a/extras/mini-os/include/x86/os.h Tue Jul 08 11:41:43 2008 +0900 57.2 +++ b/extras/mini-os/include/x86/os.h Fri Jul 18 12:12:41 2008 +0900 57.3 @@ -16,9 +16,9 @@ 57.4 57.5 57.6 #ifndef __ASSEMBLY__ 57.7 -#include <types.h> 57.8 -#include <hypervisor.h> 57.9 -#include <kernel.h> 57.10 +#include <mini-os/types.h> 57.11 +#include <mini-os/hypervisor.h> 57.12 +#include <mini-os/kernel.h> 57.13 57.14 #define USED __attribute__ ((used)) 57.15
58.1 --- a/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h Tue Jul 08 11:41:43 2008 +0900 58.2 +++ b/extras/mini-os/include/x86/x86_32/hypercall-x86_32.h Fri Jul 18 12:12:41 2008 +0900 58.3 @@ -33,7 +33,7 @@ 58.4 #include <xen/xen.h> 58.5 #include <xen/sched.h> 58.6 #include <xen/nmi.h> 58.7 -#include <mm.h> 58.8 +#include <mini-os/mm.h> 58.9 58.10 #define __STR(x) #x 58.11 #define STR(x) __STR(x)
59.1 --- a/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h Tue Jul 08 11:41:43 2008 +0900 59.2 +++ b/extras/mini-os/include/x86/x86_64/hypercall-x86_64.h Fri Jul 18 12:12:41 2008 +0900 59.3 @@ -36,7 +36,7 @@ 59.4 59.5 #include <xen/xen.h> 59.6 #include <xen/sched.h> 59.7 -#include <mm.h> 59.8 +#include <mini-os/mm.h> 59.9 59.10 #define __STR(x) #x 59.11 #define STR(x) __STR(x)
60.1 --- a/extras/mini-os/include/xmalloc.h Tue Jul 08 11:41:43 2008 +0900 60.2 +++ b/extras/mini-os/include/xmalloc.h Fri Jul 18 12:12:41 2008 +0900 60.3 @@ -11,6 +11,8 @@ 60.4 60.5 #else 60.6 60.7 +#include <limits.h> 60.8 + 60.9 #define DEFAULT_ALIGN (sizeof(unsigned long)) 60.10 #define malloc(size) _xmalloc(size, DEFAULT_ALIGN) 60.11 #define free(ptr) xfree(ptr)
61.1 --- a/extras/mini-os/kernel.c Tue Jul 08 11:41:43 2008 +0900 61.2 +++ b/extras/mini-os/kernel.c Fri Jul 18 12:12:41 2008 +0900 61.3 @@ -40,6 +40,7 @@ 61.4 #include <netfront.h> 61.5 #include <blkfront.h> 61.6 #include <fbfront.h> 61.7 +#include <pcifront.h> 61.8 #include <fs.h> 61.9 #include <xmalloc.h> 61.10 #include <fcntl.h> 61.11 @@ -431,6 +432,29 @@ static void kbdfront_thread(void *p) 61.12 } 61.13 } 61.14 61.15 +static struct pcifront_dev *pci_dev; 61.16 + 61.17 +static void pcifront_thread(void *p) 61.18 +{ 61.19 + void print(unsigned int domain, unsigned int bus, unsigned int slot, unsigned int fun) 61.20 + { 61.21 + unsigned int vendor, device, rev, class; 61.22 + 61.23 + pcifront_conf_read(pci_dev, domain, bus, slot, fun, 0x00, 2, &vendor); 61.24 + pcifront_conf_read(pci_dev, domain, bus, slot, fun, 0x02, 2, &device); 61.25 + pcifront_conf_read(pci_dev, domain, bus, slot, fun, 0x08, 1, &rev); 61.26 + pcifront_conf_read(pci_dev, domain, bus, slot, fun, 0x0a, 2, &class); 61.27 + 61.28 + printk("%04x:%02x:%02x.%02x %04x: %04x:%04x (rev %02x)\n", domain, bus, slot, fun, class, vendor, device, rev); 61.29 + } 61.30 + 61.31 + pci_dev = init_pcifront(NULL); 61.32 + if (!pci_dev) 61.33 + return; 61.34 + printk("PCI devices:\n"); 61.35 + pcifront_scan(pci_dev, print); 61.36 +} 61.37 + 61.38 static void fs_thread(void *p) 61.39 { 61.40 init_fs_frontend(); 61.41 @@ -446,6 +470,7 @@ static void fs_thread(void *p) 61.42 create_thread("blkfront", blkfront_thread, si); 61.43 create_thread("fbfront", fbfront_thread, si); 61.44 create_thread("kbdfront", kbdfront_thread, si); 61.45 + create_thread("pcifront", pcifront_thread, si); 61.46 create_thread("fs-frontend", fs_thread, si); 61.47 return 0; 61.48 } 61.49 @@ -524,6 +549,9 @@ void stop_kernel(void) 61.50 if (kbd_dev) 61.51 shutdown_kbdfront(kbd_dev); 61.52 61.53 + if (pci_dev) 61.54 + shutdown_pcifront(pci_dev); 61.55 + 61.56 /* TODO: fs import */ 61.57 61.58 local_irq_disable();
62.1 --- a/extras/mini-os/lib/ctype.c Tue Jul 08 11:41:43 2008 +0900 62.2 +++ b/extras/mini-os/lib/ctype.c Fri Jul 18 12:12:41 2008 +0900 62.3 @@ -1,3 +1,4 @@ 62.4 +#ifndef HAVE_LIBC 62.5 #include <ctype.h> 62.6 62.7 unsigned char _ctype[] = { 62.8 @@ -25,3 +26,4 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 62.9 _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ 62.10 _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ 62.11 _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ 62.12 +#endif
63.1 --- a/extras/mini-os/lib/printf.c Tue Jul 08 11:41:43 2008 +0900 63.2 +++ b/extras/mini-os/lib/printf.c Fri Jul 18 12:12:41 2008 +0900 63.3 @@ -62,6 +62,7 @@ 63.4 #include <lib.h> 63.5 #include <mm.h> 63.6 #include <ctype.h> 63.7 +#include <limits.h> 63.8 63.9 /** 63.10 * simple_strtoul - convert a string to an unsigned long
64.1 --- a/extras/mini-os/lib/sys.c Tue Jul 08 11:41:43 2008 +0900 64.2 +++ b/extras/mini-os/lib/sys.c Fri Jul 18 12:12:41 2008 +0900 64.3 @@ -733,7 +733,7 @@ static int select_poll(int nfds, fd_set 64.4 FD_CLR(i, exceptfds); 64.5 break; 64.6 case FTYPE_CONSOLE: 64.7 - if (FD_ISSET(i, writefds)) { 64.8 + if (FD_ISSET(i, readfds)) { 64.9 if (xencons_ring_avail()) 64.10 n++; 64.11 else 64.12 @@ -1094,6 +1094,11 @@ int clock_gettime(clockid_t clk_id, stru 64.13 return 0; 64.14 } 64.15 64.16 +size_t getpagesize(void) 64.17 +{ 64.18 + return PAGE_SIZE; 64.19 +} 64.20 + 64.21 void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) 64.22 { 64.23 unsigned long n = (length + PAGE_SIZE - 1) / PAGE_SIZE; 64.24 @@ -1185,6 +1190,7 @@ void sparse(unsigned long data, size_t s 64.25 /* Not supported by FS yet. */ 64.26 unsupported_function_crash(link); 64.27 unsupported_function(int, readlink, -1); 64.28 +unsupported_function_crash(umask); 64.29 64.30 /* We could support that. */ 64.31 unsupported_function_log(int, chdir, -1); 64.32 @@ -1207,6 +1213,18 @@ unsupported_function(int, __sigsetjmp, 0 64.33 unsupported_function(int, sigaltstack, -1); 64.34 unsupported_function_crash(kill); 64.35 64.36 +/* Unsupported */ 64.37 +unsupported_function_crash(pipe); 64.38 +unsupported_function_crash(fork); 64.39 +unsupported_function_crash(execv); 64.40 +unsupported_function_crash(execve); 64.41 +unsupported_function_crash(waitpid); 64.42 +unsupported_function_crash(wait); 64.43 +unsupported_function_crash(lockf); 64.44 +unsupported_function_crash(sysconf); 64.45 +unsupported_function(int, tcsetattr, -1); 64.46 +unsupported_function(int, tcgetattr, 0); 64.47 + 64.48 /* Linuxish abi for the Caml runtime, don't support */ 64.49 unsupported_function_log(struct dirent *, readdir64, NULL); 64.50 unsupported_function_log(int, getrusage, -1);
65.1 --- a/extras/mini-os/lib/xmalloc.c Tue Jul 08 11:41:43 2008 +0900 65.2 +++ b/extras/mini-os/lib/xmalloc.c Fri Jul 18 12:12:41 2008 +0900 65.3 @@ -139,7 +139,7 @@ static void *xmalloc_whole_pages(size_t 65.4 65.5 void *_xmalloc(size_t size, size_t align) 65.6 { 65.7 - struct xmalloc_hdr *i, *hdr = NULL; 65.8 + struct xmalloc_hdr *i, *tmp, *hdr = NULL; 65.9 uintptr_t data_begin; 65.10 size_t hdr_size; 65.11 /* unsigned long flags; */ 65.12 @@ -155,7 +155,7 @@ void *_xmalloc(size_t size, size_t align 65.13 65.14 /* Search free list. */ 65.15 /* spin_lock_irqsave(&freelist_lock, flags); */ 65.16 - list_for_each_entry( i, &freelist, freelist ) 65.17 + list_for_each_entry_safe( i, tmp, &freelist, freelist ) 65.18 { 65.19 data_begin = align_up((uintptr_t)i + hdr_size, align); 65.20
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 66.2 +++ b/extras/mini-os/lock.c Fri Jul 18 12:12:41 2008 +0900 66.3 @@ -0,0 +1,111 @@ 66.4 +/* 66.5 + * locks for newlib 66.6 + * 66.7 + * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, July 20008 66.8 + */ 66.9 + 66.10 +#ifdef HAVE_LIBC 66.11 + 66.12 +#include <sys/lock.h> 66.13 +#include <sched.h> 66.14 +#include <wait.h> 66.15 + 66.16 +int ___lock_init(_LOCK_T *lock) 66.17 +{ 66.18 + lock->busy = 0; 66.19 + init_waitqueue_head(&lock->wait); 66.20 + return 0; 66.21 +} 66.22 + 66.23 +int ___lock_acquire(_LOCK_T *lock) 66.24 +{ 66.25 + unsigned long flags; 66.26 + while(1) { 66.27 + wait_event(lock->wait, !lock->busy); 66.28 + local_irq_save(flags); 66.29 + if (!lock->busy) 66.30 + break; 66.31 + local_irq_restore(flags); 66.32 + } 66.33 + lock->busy = 1; 66.34 + local_irq_restore(flags); 66.35 + return 0; 66.36 +} 66.37 + 66.38 +int ___lock_try_acquire(_LOCK_T *lock) 66.39 +{ 66.40 + unsigned long flags; 66.41 + int ret = -1; 66.42 + local_irq_save(flags); 66.43 + if (!lock->busy) { 66.44 + lock->busy = 1; 66.45 + ret = 0; 66.46 + } 66.47 + local_irq_restore(flags); 66.48 + return ret; 66.49 +} 66.50 + 66.51 +int ___lock_release(_LOCK_T *lock) 66.52 +{ 66.53 + unsigned long flags; 66.54 + local_irq_save(flags); 66.55 + lock->busy = 0; 66.56 + wake_up(&lock->wait); 66.57 + local_irq_restore(flags); 66.58 + return 0; 66.59 +} 66.60 + 66.61 + 66.62 +int ___lock_init_recursive(_LOCK_RECURSIVE_T *lock) 66.63 +{ 66.64 + lock->owner = NULL; 66.65 + init_waitqueue_head(&lock->wait); 66.66 + return 0; 66.67 +} 66.68 + 66.69 +int ___lock_acquire_recursive(_LOCK_RECURSIVE_T *lock) 66.70 +{ 66.71 + unsigned long flags; 66.72 + if (lock->owner != get_current()) { 66.73 + while (1) { 66.74 + wait_event(lock->wait, lock->owner == NULL); 66.75 + local_irq_save(flags); 66.76 + if (lock->owner == NULL) 66.77 + break; 66.78 + local_irq_restore(flags); 66.79 + } 66.80 + lock->owner = get_current(); 66.81 + local_irq_restore(flags); 66.82 + } 66.83 + lock->count++; 66.84 + return 0; 66.85 +} 66.86 + 66.87 +int ___lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock) 66.88 +{ 66.89 + unsigned long flags; 66.90 + int ret = -1; 66.91 + local_irq_save(flags); 66.92 + if (!lock->owner) { 66.93 + ret = 0; 66.94 + lock->owner = get_current(); 66.95 + lock->count++; 66.96 + } 66.97 + local_irq_restore(flags); 66.98 + return ret; 66.99 +} 66.100 + 66.101 +int ___lock_release_recursive(_LOCK_RECURSIVE_T *lock) 66.102 +{ 66.103 + unsigned long flags; 66.104 + BUG_ON(lock->owner != get_current()); 66.105 + if (--lock->count) 66.106 + return 0; 66.107 + local_irq_save(flags); 66.108 + lock->owner = NULL; 66.109 + wake_up(&lock->wait); 66.110 + local_irq_restore(flags); 66.111 + return 0; 66.112 +} 66.113 + 66.114 +#endif
67.1 --- a/extras/mini-os/lwip-net.c Tue Jul 08 11:41:43 2008 +0900 67.2 +++ b/extras/mini-os/lwip-net.c Fri Jul 18 12:12:41 2008 +0900 67.3 @@ -93,6 +93,9 @@ static err_t netfront_output(struct neti 67.4 static err_t 67.5 low_level_output(struct netif *netif, struct pbuf *p) 67.6 { 67.7 + if (!dev) 67.8 + return ERR_OK; 67.9 + 67.10 #ifdef ETH_PAD_SIZE 67.11 pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ 67.12 #endif 67.13 @@ -342,7 +345,7 @@ void start_networking(void) 67.14 struct ip_addr ipaddr = { htonl(IF_IPADDR) }; 67.15 struct ip_addr netmask = { htonl(IF_NETMASK) }; 67.16 struct ip_addr gw = { 0 }; 67.17 - char *ip; 67.18 + char *ip = NULL; 67.19 67.20 tprintk("Waiting for network.\n"); 67.21 67.22 @@ -380,5 +383,6 @@ void start_networking(void) 67.23 /* Shut down the network */ 67.24 void stop_networking(void) 67.25 { 67.26 - shutdown_netfront(dev); 67.27 + if (dev) 67.28 + shutdown_netfront(dev); 67.29 }
68.1 --- a/extras/mini-os/main.c Tue Jul 08 11:41:43 2008 +0900 68.2 +++ b/extras/mini-os/main.c Fri Jul 18 12:12:41 2008 +0900 68.3 @@ -52,6 +52,7 @@ static void call_main(void *p) 68.4 #ifdef CONFIG_QEMU 68.5 char *vm; 68.6 char path[128]; 68.7 + int domid; 68.8 #endif 68.9 int i; 68.10 68.11 @@ -74,7 +75,6 @@ static void call_main(void *p) 68.12 } 68.13 68.14 /* Fetch argc, argv from XenStore */ 68.15 - int domid; 68.16 domid = xenbus_read_integer("target"); 68.17 if (domid == -1) { 68.18 printk("Couldn't read target\n");
69.1 --- a/extras/mini-os/minios.mk Tue Jul 08 11:41:43 2008 +0900 69.2 +++ b/extras/mini-os/minios.mk Fri Jul 18 12:12:41 2008 +0900 69.3 @@ -6,13 +6,14 @@ debug = y 69.4 69.5 # Define some default flags. 69.6 # NB. '-Wcast-qual' is nasty, so I omitted it. 69.7 -DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format 69.8 +DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format -Wno-redundant-decls 69.9 DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,) 69.10 +DEF_CFLAGS += $(call cc-option,$(CC),-fgnu89-inline) 69.11 DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline 69.12 DEF_CPPFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION) 69.13 69.14 -DEF_ASFLAGS = -D__ASSEMBLY__ 69.15 -DEF_LDFLAGS = 69.16 +DEF_ASFLAGS += -D__ASSEMBLY__ 69.17 +DEF_LDFLAGS += 69.18 69.19 ifeq ($(debug),y) 69.20 DEF_CFLAGS += -g
70.1 --- a/extras/mini-os/mm.c Tue Jul 08 11:41:43 2008 +0900 70.2 +++ b/extras/mini-os/mm.c Fri Jul 18 12:12:41 2008 +0900 70.3 @@ -361,6 +361,7 @@ void free_pages(void *pointer, int order 70.4 70.5 } 70.6 70.7 +#ifndef __ia64__ 70.8 int free_physical_pages(xen_pfn_t *mfns, int n) 70.9 { 70.10 struct xen_memory_reservation reservation; 70.11 @@ -371,6 +372,7 @@ int free_physical_pages(xen_pfn_t *mfns, 70.12 reservation.domid = DOMID_SELF; 70.13 return HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation); 70.14 } 70.15 +#endif 70.16 70.17 #ifdef HAVE_LIBC 70.18 void *sbrk(ptrdiff_t increment)
71.1 --- a/extras/mini-os/netfront.c Tue Jul 08 11:41:43 2008 +0900 71.2 +++ b/extras/mini-os/netfront.c Fri Jul 18 12:12:41 2008 +0900 71.3 @@ -95,8 +95,9 @@ static inline int xennet_rxidx(RING_IDX 71.4 71.5 void network_rx(struct netfront_dev *dev) 71.6 { 71.7 - RING_IDX rp,cons; 71.8 + RING_IDX rp,cons,req_prod; 71.9 struct netif_rx_response *rx; 71.10 + int nr_consumed, some, more, i, notify; 71.11 71.12 71.13 moretodo: 71.14 @@ -104,12 +105,13 @@ moretodo: 71.15 rmb(); /* Ensure we see queued responses up to 'rp'. */ 71.16 cons = dev->rx.rsp_cons; 71.17 71.18 - int nr_consumed=0; 71.19 - int some = 0; 71.20 + nr_consumed = 0; 71.21 + some = 0; 71.22 while ((cons != rp) && !some) 71.23 { 71.24 struct net_buffer* buf; 71.25 unsigned char* page; 71.26 + int id; 71.27 71.28 rx = RING_GET_RESPONSE(&dev->rx, cons); 71.29 71.30 @@ -122,7 +124,7 @@ moretodo: 71.31 71.32 if (rx->status == NETIF_RSP_NULL) continue; 71.33 71.34 - int id = rx->id; 71.35 + id = rx->id; 71.36 BUG_ON(id >= NET_TX_RING_SIZE); 71.37 71.38 buf = &dev->rx_buffers[id]; 71.39 @@ -151,19 +153,15 @@ moretodo: 71.40 } 71.41 dev->rx.rsp_cons=cons; 71.42 71.43 - int more; 71.44 RING_FINAL_CHECK_FOR_RESPONSES(&dev->rx,more); 71.45 if(more && !some) goto moretodo; 71.46 71.47 - RING_IDX req_prod = dev->rx.req_prod_pvt; 71.48 - 71.49 - int i; 71.50 - netif_rx_request_t *req; 71.51 + req_prod = dev->rx.req_prod_pvt; 71.52 71.53 for(i=0; i<nr_consumed; i++) 71.54 { 71.55 int id = xennet_rxidx(req_prod + i); 71.56 - req = RING_GET_REQUEST(&dev->rx, req_prod + i); 71.57 + netif_rx_request_t *req = RING_GET_REQUEST(&dev->rx, req_prod + i); 71.58 struct net_buffer* buf = &dev->rx_buffers[id]; 71.59 void* page = buf->page; 71.60 71.61 @@ -178,7 +176,6 @@ moretodo: 71.62 71.63 dev->rx.req_prod_pvt = req_prod + i; 71.64 71.65 - int notify; 71.66 RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&dev->rx, notify); 71.67 if (notify) 71.68 notify_remote_via_evtchn(dev->evtchn); 71.69 @@ -199,6 +196,7 @@ void network_tx_buf_gc(struct netfront_d 71.70 for (cons = dev->tx.rsp_cons; cons != prod; cons++) 71.71 { 71.72 struct netif_tx_response *txrsp; 71.73 + struct net_buffer *buf; 71.74 71.75 txrsp = RING_GET_RESPONSE(&dev->tx, cons); 71.76 if (txrsp->status == NETIF_RSP_NULL) 71.77 @@ -209,7 +207,7 @@ void network_tx_buf_gc(struct netfront_d 71.78 71.79 id = txrsp->id; 71.80 BUG_ON(id >= NET_TX_RING_SIZE); 71.81 - struct net_buffer* buf = &dev->tx_buffers[id]; 71.82 + buf = &dev->tx_buffers[id]; 71.83 gnttab_end_access(buf->gref); 71.84 buf->gref=GRANT_INVALID_REF; 71.85 71.86 @@ -298,7 +296,7 @@ static void free_netfront(struct netfron 71.87 free(dev); 71.88 } 71.89 71.90 -struct netfront_dev *init_netfront(char *nodename, void (*thenetif_rx)(unsigned char* data, int len), unsigned char rawmac[6], char **ip) 71.91 +struct netfront_dev *init_netfront(char *_nodename, void (*thenetif_rx)(unsigned char* data, int len), unsigned char rawmac[6], char **ip) 71.92 { 71.93 xenbus_transaction_t xbt; 71.94 char* err; 71.95 @@ -308,12 +306,10 @@ struct netfront_dev *init_netfront(char 71.96 int retry=0; 71.97 int i; 71.98 char* msg; 71.99 + char* nodename = _nodename ? _nodename : "device/vif/0"; 71.100 71.101 struct netfront_dev *dev; 71.102 71.103 - if (!nodename) 71.104 - nodename = "device/vif/0"; 71.105 - 71.106 char path[strlen(nodename) + 1 + 10 + 1]; 71.107 71.108 if (!thenetif_rx)
72.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 72.2 +++ b/extras/mini-os/pcifront.c Fri Jul 18 12:12:41 2008 +0900 72.3 @@ -0,0 +1,364 @@ 72.4 +/* Minimal PCI driver for Mini-OS. 72.5 + * Copyright (c) 2007-2008 Samuel Thibault. 72.6 + * Based on blkfront.c. 72.7 + */ 72.8 + 72.9 +#include <os.h> 72.10 +#include <xenbus.h> 72.11 +#include <events.h> 72.12 +#include <errno.h> 72.13 +#include <gnttab.h> 72.14 +#include <xmalloc.h> 72.15 +#include <wait.h> 72.16 +#include <pcifront.h> 72.17 + 72.18 +#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) 72.19 + 72.20 +DECLARE_WAIT_QUEUE_HEAD(pcifront_queue); 72.21 + 72.22 +struct pcifront_dev { 72.23 + domid_t dom; 72.24 + 72.25 + struct xen_pci_sharedinfo *info; 72.26 + grant_ref_t info_ref; 72.27 + evtchn_port_t evtchn; 72.28 + 72.29 + char *nodename; 72.30 + char *backend; 72.31 + 72.32 + xenbus_event_queue events; 72.33 +}; 72.34 + 72.35 +void pcifront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) 72.36 +{ 72.37 + wake_up(&pcifront_queue); 72.38 +} 72.39 + 72.40 +static void free_pcifront(struct pcifront_dev *dev) 72.41 +{ 72.42 + mask_evtchn(dev->evtchn); 72.43 + 72.44 + free(dev->backend); 72.45 + 72.46 + gnttab_end_access(dev->info_ref); 72.47 + free_page(dev->info); 72.48 + 72.49 + unbind_evtchn(dev->evtchn); 72.50 + 72.51 + free(dev->nodename); 72.52 + free(dev); 72.53 +} 72.54 + 72.55 +struct pcifront_dev *init_pcifront(char *_nodename) 72.56 +{ 72.57 + xenbus_transaction_t xbt; 72.58 + char* err; 72.59 + char* message=NULL; 72.60 + int retry=0; 72.61 + char* msg; 72.62 + char* nodename = _nodename ? _nodename : "device/pci/0"; 72.63 + 72.64 + struct pcifront_dev *dev; 72.65 + 72.66 + char path[strlen(nodename) + 1 + 10 + 1]; 72.67 + 72.68 + printk("******************* PCIFRONT for %s **********\n\n\n", nodename); 72.69 + 72.70 + dev = malloc(sizeof(*dev)); 72.71 + memset(dev, 0, sizeof(*dev)); 72.72 + dev->nodename = strdup(nodename); 72.73 + 72.74 + snprintf(path, sizeof(path), "%s/backend-id", nodename); 72.75 + dev->dom = xenbus_read_integer(path); 72.76 + evtchn_alloc_unbound(dev->dom, pcifront_handler, dev, &dev->evtchn); 72.77 + 72.78 + dev->info = (struct xen_pci_sharedinfo*) alloc_page(); 72.79 + memset(dev->info,0,PAGE_SIZE); 72.80 + 72.81 + dev->info_ref = gnttab_grant_access(dev->dom,virt_to_mfn(dev->info),0); 72.82 + 72.83 + dev->events = NULL; 72.84 + 72.85 +again: 72.86 + err = xenbus_transaction_start(&xbt); 72.87 + if (err) { 72.88 + printk("starting transaction\n"); 72.89 + } 72.90 + 72.91 + err = xenbus_printf(xbt, nodename, "pci-op-ref","%u", 72.92 + dev->info_ref); 72.93 + if (err) { 72.94 + message = "writing pci-op-ref"; 72.95 + goto abort_transaction; 72.96 + } 72.97 + err = xenbus_printf(xbt, nodename, 72.98 + "event-channel", "%u", dev->evtchn); 72.99 + if (err) { 72.100 + message = "writing event-channel"; 72.101 + goto abort_transaction; 72.102 + } 72.103 + err = xenbus_printf(xbt, nodename, 72.104 + "magic", XEN_PCI_MAGIC); 72.105 + if (err) { 72.106 + message = "writing magic"; 72.107 + goto abort_transaction; 72.108 + } 72.109 + 72.110 + err = xenbus_printf(xbt, nodename, "state", "%u", 72.111 + 3); /* initialised */ 72.112 + 72.113 + 72.114 + err = xenbus_transaction_end(xbt, 0, &retry); 72.115 + if (retry) { 72.116 + goto again; 72.117 + printk("completing transaction\n"); 72.118 + } 72.119 + 72.120 + goto done; 72.121 + 72.122 +abort_transaction: 72.123 + xenbus_transaction_end(xbt, 1, &retry); 72.124 + goto error; 72.125 + 72.126 +done: 72.127 + 72.128 + snprintf(path, sizeof(path), "%s/backend", nodename); 72.129 + msg = xenbus_read(XBT_NIL, path, &dev->backend); 72.130 + if (msg) { 72.131 + printk("Error %s when reading the backend path %s\n", msg, path); 72.132 + goto error; 72.133 + } 72.134 + 72.135 + printk("backend at %s\n", dev->backend); 72.136 + 72.137 + { 72.138 + char path[strlen(dev->backend) + 1 + 5 + 1]; 72.139 + snprintf(path, sizeof(path), "%s/state", dev->backend); 72.140 + 72.141 + xenbus_watch_path_token(XBT_NIL, path, path, &dev->events); 72.142 + 72.143 + xenbus_wait_for_value(path, "4", &dev->events); 72.144 + 72.145 + xenbus_printf(xbt, nodename, "state", "%u", 4); /* connected */ 72.146 + } 72.147 + unmask_evtchn(dev->evtchn); 72.148 + 72.149 + printk("**************************\n"); 72.150 + 72.151 + return dev; 72.152 + 72.153 +error: 72.154 + free_pcifront(dev); 72.155 + return NULL; 72.156 +} 72.157 + 72.158 +void pcifront_scan(struct pcifront_dev *dev, void (*func)(unsigned int domain, unsigned int bus, unsigned slot, unsigned int fun)) 72.159 +{ 72.160 + char path[strlen(dev->backend) + 1 + 5 + 10 + 1]; 72.161 + int i, n; 72.162 + char *s, *msg; 72.163 + unsigned int domain, bus, slot, fun; 72.164 + 72.165 + snprintf(path, sizeof(path), "%s/num_devs", dev->backend); 72.166 + n = xenbus_read_integer(path); 72.167 + 72.168 + for (i = 0; i < n; i++) { 72.169 + snprintf(path, sizeof(path), "%s/vdev-%d", dev->backend, i); 72.170 + msg = xenbus_read(XBT_NIL, path, &s); 72.171 + if (msg) { 72.172 + printk("Error %s when reading the PCI root name at %s\n", path); 72.173 + continue; 72.174 + } 72.175 + 72.176 + if (sscanf(s, "%x:%x:%x.%x", &domain, &bus, &slot, &fun) != 4) { 72.177 + printk("\"%s\" does not look like a PCI device address\n", s); 72.178 + free(s); 72.179 + continue; 72.180 + } 72.181 + free(s); 72.182 + 72.183 + func(domain, bus, slot, fun); 72.184 + } 72.185 +} 72.186 + 72.187 +void shutdown_pcifront(struct pcifront_dev *dev) 72.188 +{ 72.189 + char* err; 72.190 + char *nodename = dev->nodename; 72.191 + 72.192 + char path[strlen(dev->backend) + 1 + 5 + 1]; 72.193 + 72.194 + printk("close pci: backend at %s\n",dev->backend); 72.195 + 72.196 + snprintf(path, sizeof(path), "%s/state", dev->backend); 72.197 + err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 5); /* closing */ 72.198 + xenbus_wait_for_value(path, "5", &dev->events); 72.199 + 72.200 + err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 6); 72.201 + xenbus_wait_for_value(path, "6", &dev->events); 72.202 + 72.203 + err = xenbus_printf(XBT_NIL, nodename, "state", "%u", 1); 72.204 + xenbus_wait_for_value(path, "2", &dev->events); 72.205 + 72.206 + xenbus_unwatch_path(XBT_NIL, path); 72.207 + 72.208 + snprintf(path, sizeof(path), "%s/info-ref", nodename); 72.209 + xenbus_rm(XBT_NIL, path); 72.210 + snprintf(path, sizeof(path), "%s/event-channel", nodename); 72.211 + xenbus_rm(XBT_NIL, path); 72.212 + 72.213 + free_pcifront(dev); 72.214 +} 72.215 + 72.216 + 72.217 +void pcifront_op(struct pcifront_dev *dev, struct xen_pci_op *op) 72.218 +{ 72.219 + dev->info->op = *op; 72.220 + /* Make sure info is written before the flag */ 72.221 + wmb(); 72.222 + set_bit(_XEN_PCIF_active, (void*) &dev->info->flags); 72.223 + notify_remote_via_evtchn(dev->evtchn); 72.224 + 72.225 + wait_event(pcifront_queue, !test_bit(_XEN_PCIF_active, (void*) &dev->info->flags)); 72.226 + 72.227 + /* Make sure flag is read before info */ 72.228 + rmb(); 72.229 + *op = dev->info->op; 72.230 +} 72.231 + 72.232 +int pcifront_conf_read(struct pcifront_dev *dev, 72.233 + unsigned int dom, 72.234 + unsigned int bus, unsigned int slot, unsigned long fun, 72.235 + unsigned int off, unsigned int size, unsigned int *val) 72.236 +{ 72.237 + struct xen_pci_op op; 72.238 + 72.239 + memset(&op, 0, sizeof(op)); 72.240 + 72.241 + op.cmd = XEN_PCI_OP_conf_read; 72.242 + op.domain = dom; 72.243 + op.bus = bus; 72.244 + op.devfn = PCI_DEVFN(slot, fun); 72.245 + op.offset = off; 72.246 + op.size = size; 72.247 + 72.248 + pcifront_op(dev, &op); 72.249 + 72.250 + if (op.err) 72.251 + return op.err; 72.252 + 72.253 + *val = op.value; 72.254 + 72.255 + return 0; 72.256 +} 72.257 + 72.258 +int pcifront_conf_write(struct pcifront_dev *dev, 72.259 + unsigned int dom, 72.260 + unsigned int bus, unsigned int slot, unsigned long fun, 72.261 + unsigned int off, unsigned int size, unsigned int val) 72.262 +{ 72.263 + struct xen_pci_op op; 72.264 + 72.265 + memset(&op, 0, sizeof(op)); 72.266 + 72.267 + op.cmd = XEN_PCI_OP_conf_write; 72.268 + op.domain = dom; 72.269 + op.bus = bus; 72.270 + op.devfn = PCI_DEVFN(slot, fun); 72.271 + op.offset = off; 72.272 + op.size = size; 72.273 + 72.274 + op.value = val; 72.275 + 72.276 + pcifront_op(dev, &op); 72.277 + 72.278 + return op.err; 72.279 +} 72.280 + 72.281 +int pcifront_enable_msi(struct pcifront_dev *dev, 72.282 + unsigned int dom, 72.283 + unsigned int bus, unsigned int slot, unsigned long fun) 72.284 +{ 72.285 + struct xen_pci_op op; 72.286 + 72.287 + memset(&op, 0, sizeof(op)); 72.288 + 72.289 + op.cmd = XEN_PCI_OP_enable_msi; 72.290 + op.domain = dom; 72.291 + op.bus = bus; 72.292 + op.devfn = PCI_DEVFN(slot, fun); 72.293 + 72.294 + pcifront_op(dev, &op); 72.295 + 72.296 + if (op.err) 72.297 + return op.err; 72.298 + else 72.299 + return op.value; 72.300 +} 72.301 + 72.302 +int pcifront_disable_msi(struct pcifront_dev *dev, 72.303 + unsigned int dom, 72.304 + unsigned int bus, unsigned int slot, unsigned long fun) 72.305 +{ 72.306 + struct xen_pci_op op; 72.307 + 72.308 + memset(&op, 0, sizeof(op)); 72.309 + 72.310 + op.cmd = XEN_PCI_OP_disable_msi; 72.311 + op.domain = dom; 72.312 + op.bus = bus; 72.313 + op.devfn = PCI_DEVFN(slot, fun); 72.314 + 72.315 + pcifront_op(dev, &op); 72.316 + 72.317 + return op.err; 72.318 +} 72.319 + 72.320 +int pcifront_enable_msix(struct pcifront_dev *dev, 72.321 + unsigned int dom, 72.322 + unsigned int bus, unsigned int slot, unsigned long fun, 72.323 + struct xen_msix_entry *entries, int n) 72.324 +{ 72.325 + struct xen_pci_op op; 72.326 + 72.327 + if (n > SH_INFO_MAX_VEC) 72.328 + return XEN_PCI_ERR_op_failed; 72.329 + 72.330 + memset(&op, 0, sizeof(op)); 72.331 + 72.332 + op.cmd = XEN_PCI_OP_enable_msix; 72.333 + op.domain = dom; 72.334 + op.bus = bus; 72.335 + op.devfn = PCI_DEVFN(slot, fun); 72.336 + op.value = n; 72.337 + 72.338 + memcpy(op.msix_entries, entries, n * sizeof(*entries)); 72.339 + 72.340 + pcifront_op(dev, &op); 72.341 + 72.342 + if (op.err) 72.343 + return op.err; 72.344 + 72.345 + memcpy(entries, op.msix_entries, n * sizeof(*entries)); 72.346 + 72.347 + return 0; 72.348 +} 72.349 + 72.350 + 72.351 +int pcifront_disable_msix(struct pcifront_dev *dev, 72.352 + unsigned int dom, 72.353 + unsigned int bus, unsigned int slot, unsigned long fun) 72.354 +{ 72.355 + struct xen_pci_op op; 72.356 + 72.357 + memset(&op, 0, sizeof(op)); 72.358 + 72.359 + op.cmd = XEN_PCI_OP_disable_msix; 72.360 + op.domain = dom; 72.361 + op.bus = bus; 72.362 + op.devfn = PCI_DEVFN(slot, fun); 72.363 + 72.364 + pcifront_op(dev, &op); 72.365 + 72.366 + return op.err; 72.367 +}
73.1 --- a/extras/mini-os/sched.c Tue Jul 08 11:41:43 2008 +0900 73.2 +++ b/extras/mini-os/sched.c Fri Jul 18 12:12:41 2008 +0900 73.3 @@ -75,7 +75,7 @@ void inline print_runqueue(void) 73.4 void schedule(void) 73.5 { 73.6 struct thread *prev, *next, *thread; 73.7 - struct list_head *iterator; 73.8 + struct list_head *iterator, *next_iterator; 73.9 unsigned long flags; 73.10 73.11 prev = current; 73.12 @@ -97,7 +97,7 @@ void schedule(void) 73.13 s_time_t now = NOW(); 73.14 s_time_t min_wakeup_time = now + SECONDS(10); 73.15 next = NULL; 73.16 - list_for_each(iterator, &idle_thread->thread_list) 73.17 + list_for_each_safe(iterator, next_iterator, &idle_thread->thread_list) 73.18 { 73.19 thread = list_entry(iterator, struct thread, thread_list); 73.20 if (!is_runnable(thread) && thread->wakeup_time != 0LL) 73.21 @@ -128,7 +128,7 @@ void schedule(void) 73.22 inturrupted at the return instruction. And therefore at safe point. */ 73.23 if(prev != next) switch_threads(prev, next); 73.24 73.25 - list_for_each(iterator, &exited_threads) 73.26 + list_for_each_safe(iterator, next_iterator, &exited_threads) 73.27 { 73.28 thread = list_entry(iterator, struct thread, thread_list); 73.29 if(thread != prev)
74.1 --- a/extras/mini-os/xenbus/xenbus.c Tue Jul 08 11:41:43 2008 +0900 74.2 +++ b/extras/mini-os/xenbus/xenbus.c Fri Jul 18 12:12:41 2008 +0900 74.3 @@ -78,9 +78,9 @@ static void memcpy_from_ring(const void 74.4 char **xenbus_wait_for_watch_return(xenbus_event_queue *queue) 74.5 { 74.6 struct xenbus_event *event; 74.7 + DEFINE_WAIT(w); 74.8 if (!queue) 74.9 queue = &xenbus_events; 74.10 - DEFINE_WAIT(w); 74.11 while (!(event = *queue)) { 74.12 add_waiter(w, xenbus_watch_queue); 74.13 schedule(); 74.14 @@ -382,6 +382,7 @@ xenbus_msg_reply(int type, 74.15 74.16 static char *errmsg(struct xsd_sockmsg *rep) 74.17 { 74.18 + char *res; 74.19 if (!rep) { 74.20 char msg[] = "No reply"; 74.21 size_t len = strlen(msg) + 1; 74.22 @@ -389,7 +390,7 @@ static char *errmsg(struct xsd_sockmsg * 74.23 } 74.24 if (rep->type != XS_ERROR) 74.25 return NULL; 74.26 - char *res = malloc(rep->len + 1); 74.27 + res = malloc(rep->len + 1); 74.28 memcpy(res, rep + 1, rep->len); 74.29 res[rep->len] = 0; 74.30 free(rep); 74.31 @@ -419,10 +420,10 @@ char *xenbus_ls(xenbus_transaction_t xbt 74.32 struct xsd_sockmsg *reply, *repmsg; 74.33 struct write_req req[] = { { pre, strlen(pre)+1 } }; 74.34 int nr_elems, x, i; 74.35 - char **res; 74.36 + char **res, *msg; 74.37 74.38 repmsg = xenbus_msg_reply(XS_DIRECTORY, xbt, req, ARRAY_SIZE(req)); 74.39 - char *msg = errmsg(repmsg); 74.40 + msg = errmsg(repmsg); 74.41 if (msg) { 74.42 *contents = NULL; 74.43 return msg; 74.44 @@ -447,9 +448,9 @@ char *xenbus_read(xenbus_transaction_t x 74.45 { 74.46 struct write_req req[] = { {path, strlen(path) + 1} }; 74.47 struct xsd_sockmsg *rep; 74.48 - char *res; 74.49 + char *res, *msg; 74.50 rep = xenbus_msg_reply(XS_READ, xbt, req, ARRAY_SIZE(req)); 74.51 - char *msg = errmsg(rep); 74.52 + msg = errmsg(rep); 74.53 if (msg) { 74.54 *value = NULL; 74.55 return msg; 74.56 @@ -469,8 +470,9 @@ char *xenbus_write(xenbus_transaction_t 74.57 {value, strlen(value)}, 74.58 }; 74.59 struct xsd_sockmsg *rep; 74.60 + char *msg; 74.61 rep = xenbus_msg_reply(XS_WRITE, xbt, req, ARRAY_SIZE(req)); 74.62 - char *msg = errmsg(rep); 74.63 + msg = errmsg(rep); 74.64 if (msg) return msg; 74.65 free(rep); 74.66 return NULL; 74.67 @@ -487,6 +489,8 @@ char* xenbus_watch_path_token( xenbus_tr 74.68 74.69 struct watch *watch = malloc(sizeof(*watch)); 74.70 74.71 + char *msg; 74.72 + 74.73 if (!events) 74.74 events = &xenbus_events; 74.75 74.76 @@ -497,7 +501,7 @@ char* xenbus_watch_path_token( xenbus_tr 74.77 74.78 rep = xenbus_msg_reply(XS_WATCH, xbt, req, ARRAY_SIZE(req)); 74.79 74.80 - char *msg = errmsg(rep); 74.81 + msg = errmsg(rep); 74.82 if (msg) return msg; 74.83 free(rep); 74.84 74.85 @@ -515,9 +519,11 @@ char* xenbus_unwatch_path_token( xenbus_ 74.86 74.87 struct watch *watch, **prev; 74.88 74.89 + char *msg; 74.90 + 74.91 rep = xenbus_msg_reply(XS_UNWATCH, xbt, req, ARRAY_SIZE(req)); 74.92 74.93 - char *msg = errmsg(rep); 74.94 + msg = errmsg(rep); 74.95 if (msg) return msg; 74.96 free(rep); 74.97 74.98 @@ -536,8 +542,9 @@ char *xenbus_rm(xenbus_transaction_t xbt 74.99 { 74.100 struct write_req req[] = { {path, strlen(path) + 1} }; 74.101 struct xsd_sockmsg *rep; 74.102 + char *msg; 74.103 rep = xenbus_msg_reply(XS_RM, xbt, req, ARRAY_SIZE(req)); 74.104 - char *msg = errmsg(rep); 74.105 + msg = errmsg(rep); 74.106 if (msg) 74.107 return msg; 74.108 free(rep); 74.109 @@ -548,9 +555,9 @@ char *xenbus_get_perms(xenbus_transactio 74.110 { 74.111 struct write_req req[] = { {path, strlen(path) + 1} }; 74.112 struct xsd_sockmsg *rep; 74.113 - char *res; 74.114 + char *res, *msg; 74.115 rep = xenbus_msg_reply(XS_GET_PERMS, xbt, req, ARRAY_SIZE(req)); 74.116 - char *msg = errmsg(rep); 74.117 + msg = errmsg(rep); 74.118 if (msg) { 74.119 *value = NULL; 74.120 return msg; 74.121 @@ -567,14 +574,16 @@ char *xenbus_get_perms(xenbus_transactio 74.122 char *xenbus_set_perms(xenbus_transaction_t xbt, const char *path, domid_t dom, char perm) 74.123 { 74.124 char value[PERM_MAX_SIZE]; 74.125 - snprintf(value, PERM_MAX_SIZE, "%c%hu", perm, dom); 74.126 struct write_req req[] = { 74.127 {path, strlen(path) + 1}, 74.128 - {value, strlen(value) + 1}, 74.129 + {value, 0}, 74.130 }; 74.131 struct xsd_sockmsg *rep; 74.132 + char *msg; 74.133 + snprintf(value, PERM_MAX_SIZE, "%c%hu", perm, dom); 74.134 + req[1].len = strlen(value) + 1; 74.135 rep = xenbus_msg_reply(XS_SET_PERMS, xbt, req, ARRAY_SIZE(req)); 74.136 - char *msg = errmsg(rep); 74.137 + msg = errmsg(rep); 74.138 if (msg) 74.139 return msg; 74.140 free(rep); 74.141 @@ -659,11 +668,11 @@ char* xenbus_printf(xenbus_transaction_t 74.142 74.143 static void do_ls_test(const char *pre) 74.144 { 74.145 - char **dirs; 74.146 + char **dirs, *msg; 74.147 int x; 74.148 74.149 DEBUG("ls %s...\n", pre); 74.150 - char *msg = xenbus_ls(XBT_NIL, pre, &dirs); 74.151 + msg = xenbus_ls(XBT_NIL, pre, &dirs); 74.152 if (msg) { 74.153 DEBUG("Error in xenbus ls: %s\n", msg); 74.154 free(msg); 74.155 @@ -679,9 +688,9 @@ static void do_ls_test(const char *pre) 74.156 74.157 static void do_read_test(const char *path) 74.158 { 74.159 - char *res; 74.160 + char *res, *msg; 74.161 DEBUG("Read %s...\n", path); 74.162 - char *msg = xenbus_read(XBT_NIL, path, &res); 74.163 + msg = xenbus_read(XBT_NIL, path, &res); 74.164 if (msg) { 74.165 DEBUG("Error in xenbus read: %s\n", msg); 74.166 free(msg); 74.167 @@ -693,8 +702,9 @@ static void do_read_test(const char *pat 74.168 74.169 static void do_write_test(const char *path, const char *val) 74.170 { 74.171 + char *msg; 74.172 DEBUG("Write %s to %s...\n", val, path); 74.173 - char *msg = xenbus_write(XBT_NIL, path, val); 74.174 + msg = xenbus_write(XBT_NIL, path, val); 74.175 if (msg) { 74.176 DEBUG("Result %s\n", msg); 74.177 free(msg); 74.178 @@ -705,8 +715,9 @@ static void do_write_test(const char *pa 74.179 74.180 static void do_rm_test(const char *path) 74.181 { 74.182 + char *msg; 74.183 DEBUG("rm %s...\n", path); 74.184 - char *msg = xenbus_rm(XBT_NIL, path); 74.185 + msg = xenbus_rm(XBT_NIL, path); 74.186 if (msg) { 74.187 DEBUG("Result %s\n", msg); 74.188 free(msg);
75.1 --- a/stubdom/Makefile Tue Jul 08 11:41:43 2008 +0900 75.2 +++ b/stubdom/Makefile Fri Jul 18 12:12:41 2008 +0900 75.3 @@ -3,18 +3,18 @@ MINI_OS = $(XEN_ROOT)/extras/mini-os 75.4 75.5 export XEN_OS=MiniOS 75.6 75.7 -include $(XEN_ROOT)/Config.mk 75.8 +CONFIG_QEMU=ioemu 75.9 + 75.10 export stubdom=y 75.11 export debug=y 75.12 +include $(XEN_ROOT)/Config.mk 75.13 75.14 -IOEMU_OPTIONS=--disable-vnc-tls 75.15 -BINUTILS_VERSION=2.18 75.16 -GCC_VERSION=4.2.2 75.17 +IOEMU_OPTIONS=--disable-sdl --disable-opengl --disable-gfx-check --disable-vnc-tls --disable-brlapi --disable-kqemu 75.18 ZLIB_VERSION=1.2.3 75.19 LIBPCI_VERSION=2.2.9 75.20 -NEWLIB_DATE=2008-01-01 75.21 -LWIP_DATE=2008-06-01 75.22 -GRUB_DATE=2008-06-01 75.23 +NEWLIB_VERSION=1.16.0 75.24 +LWIP_VERSION=1.3.0 75.25 +GRUB_VERSION=0.97 75.26 75.27 WGET=wget -c 75.28 75.29 @@ -26,10 +26,12 @@ endif 75.30 ifeq ($(GNU_TARGET_ARCH), i686) 75.31 TARGET_CFLAGS= 75.32 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS 75.33 +STUBDOM_SUPPORTED=1 75.34 endif 75.35 ifeq ($(GNU_TARGET_ARCH), x86_64) 75.36 TARGET_CFLAGS=-mno-red-zone 75.37 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS 75.38 +STUBDOM_SUPPORTED=1 75.39 endif 75.40 ifeq ($(GNU_TARGET_ARCH), ia64) 75.41 TARGET_CFLAGS=-mconstant-gp 75.42 @@ -37,82 +39,65 @@ endif 75.43 75.44 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH) 75.45 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT) 75.46 -export CROSS_COMPILE=$(GNU_TARGET_ARCH)-xen-elf- 75.47 -export PATH:=$(CROSS_PREFIX)/bin:$(PATH) 75.48 + 75.49 +# Disable PIE/SSP if GCC supports them. They can break us. 75.50 +TARGET_CFLAGS += $(CFLAGS) 75.51 +TARGET_CPPFLAGS += $(CPPFLAGS) 75.52 +TARGET_CFLAGS += $(call cc-option,$(CC),-nopie,) 75.53 +TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,) 75.54 +TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,) 75.55 + 75.56 +# Do not use host headers and libs 75.57 +GCC_INSTALL = $(shell gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p') 75.58 +TARGET_CPPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__ 75.59 +TARGET_CPPFLAGS += -nostdinc 75.60 +TARGET_CPPFLAGS += -isystem $(CURDIR)/$(MINI_OS)/include/posix 75.61 +TARGET_CPPFLAGS += -isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include 75.62 +TARGET_CPPFLAGS += -isystem $(GCC_INSTALL)include 75.63 +TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip/src/include 75.64 +TARGET_CPPFLAGS += -isystem $(CURDIR)/lwip/src/include/ipv4 75.65 +TARGET_CPPFLAGS += -I$(CURDIR)/include 75.66 + 75.67 +TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib 75.68 75.69 TARGETS=ioemu c caml grub 75.70 75.71 .PHONY: all 75.72 -all: ioemu-stubdom c-stubdom pv-grub 75.73 - 75.74 -################ 75.75 -# Cross-binutils 75.76 -################ 75.77 - 75.78 -binutils-$(BINUTILS_VERSION).tar.bz2: 75.79 - $(WGET) http://ftp.gnu.org/gnu/binutils/$@ 75.80 -binutils-$(BINUTILS_VERSION): binutils-$(BINUTILS_VERSION).tar.bz2 75.81 - tar xjf $< 75.82 - patch -d $@ -p1 < binutils.patch 75.83 - touch $@ 75.84 - 75.85 -BINUTILS_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-ar 75.86 -.PHONY: cross-binutils 75.87 -cross-binutils: $(BINUTILS_STAMPFILE) 75.88 -$(BINUTILS_STAMPFILE): binutils-$(BINUTILS_VERSION) 75.89 - mkdir -p binutils-build 75.90 - ( cd binutils-build && \ 75.91 - ../binutils-$(BINUTILS_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf && \ 75.92 - $(MAKE) && \ 75.93 - $(MAKE) check && \ 75.94 - $(MAKE) install ) 75.95 - 75.96 -########### 75.97 -# Cross-gcc 75.98 -########### 75.99 - 75.100 -gcc-$(GCC_VERSION).tar.bz2: 75.101 - $(WGET) http://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.bz2 75.102 -gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2 75.103 - tar xjf $< 75.104 - patch -d $@ -p1 < gcc.patch 75.105 - touch $@ 75.106 - 75.107 -GCC_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-gcc-$(GCC_VERSION) 75.108 -.PHONY: cross-gcc 75.109 -cross-gcc: $(GCC_STAMPFILE) 75.110 -$(GCC_STAMPFILE): gcc-$(GCC_VERSION) $(BINUTILS_STAMPFILE) 75.111 - mkdir -p gcc-build 75.112 - ( cd gcc-build && \ 75.113 - ../gcc-$(GCC_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-languages=c --disable-libssp --with-gnu-as --with-gnu-ld && \ 75.114 - $(MAKE) GCC_FOR_TARGET='$$$$r/gcc/xgcc -B$$$$r/gcc/ '"$(TARGET_CFLAGS)"' $$(FLAGS_FOR_TARGET)' && \ 75.115 - $(MAKE) install ) 75.116 +all: build 75.117 +ifeq ($(STUBDOM_SUPPORTED),1) 75.118 +build: ioemu-stubdom c-stubdom pv-grub 75.119 +else 75.120 +build: 75.121 +endif 75.122 75.123 ############## 75.124 # Cross-newlib 75.125 ############## 75.126 75.127 -newlib-cvs: 75.128 - cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src co -D $(NEWLIB_DATE) newlib 75.129 - mv src newlib-cvs 75.130 +newlib-$(NEWLIB_VERSION).tar.gz: 75.131 + $(WGET) ftp://sources.redhat.com/pub/newlib/$@ 75.132 + 75.133 +newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz 75.134 + tar xzf $< 75.135 patch -d $@ -p0 < newlib.patch 75.136 + touch $@ 75.137 75.138 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a 75.139 .PHONY: cross-newlib 75.140 cross-newlib: $(NEWLIB_STAMPFILE) 75.141 -$(NEWLIB_STAMPFILE): newlib-cvs $(GCC_STAMPFILE) 75.142 +$(NEWLIB_STAMPFILE): newlib-$(NEWLIB_VERSION) 75.143 mkdir -p newlib-build 75.144 ( cd newlib-build && \ 75.145 - CC_FOR_TARGET="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" ../newlib-cvs/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long && \ 75.146 + CC_FOR_TARGET="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" AR_FOR_TARGET=$(AR) LD_FOR_TARGET=$(LD) RANLIB_FOR_TARGET=$(RANLIB) ../newlib-$(NEWLIB_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long --disable-multilib && \ 75.147 $(MAKE) && \ 75.148 - $(MAKE) install ) 75.149 + DESTDIR= $(MAKE) install ) 75.150 75.151 ############ 75.152 # Cross-zlib 75.153 ############ 75.154 75.155 zlib-$(ZLIB_VERSION).tar.gz: 75.156 - $(WGET) http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz 75.157 + $(WGET) http://www.zlib.net/$@ 75.158 75.159 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a 75.160 .PHONY: cross-zlib 75.161 @@ -120,7 +105,7 @@ cross-zlib: $(ZLIB_STAMPFILE) 75.162 $(ZLIB_STAMPFILE): zlib-$(ZLIB_VERSION).tar.gz $(NEWLIB_STAMPFILE) 75.163 tar xzf $< 75.164 ( cd zlib-$(ZLIB_VERSION) && \ 75.165 - CFLAGS="$(TARGET_CFLAGS)" CC=$(GNU_TARGET_ARCH)-xen-elf-gcc ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \ 75.166 + CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \ 75.167 $(MAKE) libz.a && \ 75.168 $(MAKE) install ) 75.169 75.170 @@ -129,18 +114,22 @@ cross-zlib: $(ZLIB_STAMPFILE) 75.171 ############## 75.172 75.173 pciutils-$(LIBPCI_VERSION).tar.bz2: 75.174 - $(WGET) http://www.kernel.org/pub/software/utils/pciutils/pciutils-$(LIBPCI_VERSION).tar.bz2 75.175 + $(WGET) http://www.kernel.org/pub/software/utils/pciutils/$@ 75.176 + 75.177 +pciutils-$(LIBPCI_VERSION): pciutils-$(LIBPCI_VERSION).tar.bz2 75.178 + tar xjf $< 75.179 + patch -d $@ -p1 < pciutils.patch 75.180 + touch $@ 75.181 75.182 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a 75.183 .PHONY: cross-libpci 75.184 cross-libpci: $(LIBPCI_STAMPFILE) 75.185 -$(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION).tar.bz2 $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE) 75.186 - tar xjf $< 75.187 +$(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION) $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE) 75.188 ( cd pciutils-$(LIBPCI_VERSION) && \ 75.189 cp ../libpci.config.h lib/config.h && \ 75.190 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \ 75.191 cp ../libpci.config.mak lib/config.mk && \ 75.192 - $(MAKE) CC="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" lib/libpci.a && \ 75.193 + $(MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \ 75.194 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \ 75.195 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \ 75.196 $(INSTALL_DATA) lib/{config,header,pci,types}.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \ 75.197 @@ -150,8 +139,13 @@ cross-libpci: $(LIBPCI_STAMPFILE) 75.198 # lwIP 75.199 ###### 75.200 75.201 -lwip-cvs: 75.202 - cvs -z 9 -d :pserver:anonymous@cvs.savannah.nongnu.org:/sources/lwip co -D $(LWIP_DATE) -d $@ lwip 75.203 +lwip-$(LWIP_VERSION).tar.gz: 75.204 + $(WGET) http://download.savannah.gnu.org/releases/lwip/$@ 75.205 + 75.206 +lwip: lwip-$(LWIP_VERSION).tar.gz 75.207 + tar xzf $< 75.208 + patch -d $@ -p0 < lwip.patch-cvs 75.209 + touch $@ 75.210 75.211 ####### 75.212 # Links 75.213 @@ -160,9 +154,16 @@ lwip-cvs: 75.214 .PHONY: $(CROSS_ROOT) 75.215 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci 75.216 75.217 -.PHONY: mk-symlinks 75.218 -mk-symlinks: 75.219 - [ -h include ] || ln -sf ../tools/include . 75.220 +.PHONY: mk-headers 75.221 +mk-headers: 75.222 + mkdir -p include/xen && \ 75.223 + ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/xen/include/public/*.h)) include/xen && \ 75.224 + ln -sf $(addprefix ../../$(XEN_ROOT)/xen/include/public/,arch-ia64 arch-x86 hvm io xsm) include/xen && \ 75.225 + ( [ -h include/xen/sys ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen-sys/MiniOS include/xen/sys ) && \ 75.226 + mkdir -p include/xen-foreign && \ 75.227 + ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/tools/include/xen-foreign/*)) include/xen-foreign/ && \ 75.228 + $(MAKE) -C include/xen-foreign/ && \ 75.229 + ( [ -h include/xen/foreign ] || ln -sf ../xen-foreign include/xen/foreign ) 75.230 mkdir -p libxc 75.231 [ -h libxc/Makefile ] || ( cd libxc && \ 75.232 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \ 75.233 @@ -174,10 +175,21 @@ mk-symlinks: 75.234 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \ 75.235 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . ) 75.236 mkdir -p ioemu 75.237 +ifeq ($(CONFIG_QEMU),ioemu) 75.238 [ -h ioemu/Makefile ] || ( cd ioemu && \ 75.239 - ln -sf ../$(XEN_ROOT)/tools/ioemu/* . && \ 75.240 - ([ ! -h config-host.h ] || rm -f config-host.h) && \ 75.241 - ([ ! -h config-host.mak ] || rm -f config-host.mak) ) 75.242 + ln -sf ../$(XEN_ROOT)/tools/ioemu/* .) 75.243 +else 75.244 + [ -h ioemu/Makefile ] || ( cd ioemu && \ 75.245 + ln -sf $(CONFIG_QEMU)/* . && \ 75.246 + rm -fr i386-dm && \ 75.247 + rm -fr i386-stubdom && \ 75.248 + mkdir i386-dm && \ 75.249 + mkdir i386-stubdom && \ 75.250 + ln -sf $(CONFIG_QEMU)/i386-dm/* i386-dm/ && \ 75.251 + ln -sf $(CONFIG_QEMU)/i386-stubdom/* i386-stubdom/ ) 75.252 +endif 75.253 + [ ! -h ioemu/config-host.h ] || rm -f ioemu/config-host.h 75.254 + [ ! -h ioemu/config-host.mak ] || rm -f ioemu/config-host.mak 75.255 $(MAKE) -C $(MINI_OS) links 75.256 75.257 TARGETS_MINIOS=$(addprefix mini-os-,$(TARGETS)) 75.258 @@ -193,82 +205,106 @@ TARGETS_MINIOS=$(addprefix mini-os-,$(TA 75.259 75.260 .PHONY: libxc 75.261 libxc: libxc/libxenctrl.a libxc/libxenguest.a 75.262 -libxc/libxenctrl.a libxc/libxenguest.a: cross-zlib mk-symlinks 75.263 - $(MAKE) -C libxc 75.264 +libxc/libxenctrl.a libxc/libxenguest.a:: cross-zlib mk-headers 75.265 + CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc 75.266 75.267 ####### 75.268 # ioemu 75.269 ####### 75.270 75.271 .PHONY: ioemu 75.272 -ioemu: cross-zlib cross-libpci mk-symlinks libxc 75.273 +ioemu: cross-zlib cross-libpci mk-headers libxc 75.274 +ifeq ($(CONFIG_QEMU),ioemu) 75.275 [ -f ioemu/config-host.mak ] || \ 75.276 - ( cd ioemu ; XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS)) 75.277 - $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs 75.278 + ( cd ioemu ; \ 75.279 + XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS)) 75.280 + CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip TOOLS= 75.281 +else 75.282 + [ -f ioemu/config-host.mak ] || \ 75.283 + ( cd ioemu ; \ 75.284 + CONFIG_STUBDOM=yes XEN_ROOT=$(abspath $(XEN_ROOT)) XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh ./xen-setup --cc=$(CC) --disable-gcc-check $(IOEMU_OPTIONS)) 75.285 + CPPFLAGS= TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip TOOLS= CONFIG_STUBDOM=yes 75.286 +endif 75.287 75.288 ###### 75.289 # caml 75.290 ###### 75.291 75.292 .PHONY: caml 75.293 -caml: cross-newlib mk-symlinks 75.294 - $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs 75.295 +caml: cross-newlib mk-headers 75.296 + CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip 75.297 75.298 ### 75.299 # C 75.300 ### 75.301 75.302 .PHONY: c 75.303 -c: cross-newlib mk-symlinks 75.304 - $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs 75.305 +c: cross-newlib mk-headers 75.306 + CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip 75.307 75.308 ###### 75.309 # Grub 75.310 ###### 75.311 75.312 -grub-cvs: 75.313 - cvs -z 9 -d :pserver:anonymous@cvs.sv.gnu.org:/sources/grub co -D $(GRUB_DATE) -d $@ grub 75.314 +grub-$(GRUB_VERSION).tar.gz: 75.315 + $(WGET) ftp://alpha.gnu.org/gnu/grub/$@ 75.316 + 75.317 +grub-upstream: grub-$(GRUB_VERSION).tar.gz 75.318 + tar xzf $< 75.319 + mv grub-$(GRUB_VERSION) $@ 75.320 for i in grub.patches/* ; do \ 75.321 patch -d $@ -p1 < $$i ; \ 75.322 done 75.323 75.324 .PHONY: grub 75.325 -grub: grub-cvs cross-newlib mk-symlinks 75.326 - $(MAKE) -C $@ 75.327 +grub: grub-upstream cross-newlib mk-headers 75.328 + CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ 75.329 75.330 ######## 75.331 # minios 75.332 ######## 75.333 75.334 .PHONY: ioemu-stubdom 75.335 -ioemu-stubdom: mini-os-ioemu lwip-cvs libxc ioemu 75.336 - DEF_CFLAGS=-DCONFIG_QEMU $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS="$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a $(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a" 75.337 +ifeq ($(CONFIG_QEMU),ioemu) 75.338 +ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a $(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a 75.339 +else 75.340 +ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a $(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a 75.341 +endif 75.342 +ioemu-stubdom: mini-os-ioemu lwip libxc ioemu 75.343 + DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_QEMU $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip APP_OBJS="$(APP_OBJS)" 75.344 75.345 CAMLLIB = $(shell ocamlc -where) 75.346 .PHONY: caml-stubdom 75.347 -caml-stubdom: mini-os-caml lwip-cvs libxc caml 75.348 - DEF_CFLAGS=-DCONFIG_CAML $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a" 75.349 +caml-stubdom: mini-os-caml lwip libxc caml 75.350 + DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_CAML $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a" 75.351 75.352 .PHONY: c-stubdom 75.353 -c-stubdom: mini-os-c lwip-cvs libxc c 75.354 - DEF_CFLAGS=-DCONFIG_C $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS=$(CURDIR)/c/main.a 75.355 +c-stubdom: mini-os-c lwip libxc c 75.356 + DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_C $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip APP_OBJS=$(CURDIR)/c/main.a 75.357 75.358 .PHONY: pv-grub 75.359 pv-grub: mini-os-grub libxc grub 75.360 - DEF_CFLAGS=-DCONFIG_GRUB $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub/main.a 75.361 + DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub/main.a 75.362 75.363 ######### 75.364 # install 75.365 ######### 75.366 75.367 +ifeq ($(STUBDOM_SUPPORTED),1) 75.368 install: install-ioemu install-grub 75.369 +else 75.370 +install: 75.371 +endif 75.372 75.373 -install-ioemu: mini-os-ioemu/mini-os.gz 75.374 +install-ioemu: ioemu-stubdom 75.375 + $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/bin" 75.376 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin" 75.377 - $(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz" 75.378 + $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot" 75.379 + $(INSTALL_PROG) mini-os-ioemu/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz" 75.380 75.381 -install-grub: mini-os-grub/mini-os.gz 75.382 - $(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/pv-grub.gz" 75.383 +install-grub: pv-grub 75.384 + $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot" 75.385 + $(INSTALL_PROG) mini-os-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub.gz" 75.386 75.387 ####### 75.388 # clean 75.389 @@ -290,25 +326,24 @@ clean: 75.390 .PHONY: crossclean 75.391 crossclean: clean 75.392 rm -fr $(CROSS_ROOT) 75.393 - rm -fr binutils-build gcc-build newlib-build 75.394 + rm -fr newlib-build 75.395 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION) 75.396 75.397 # clean patched sources 75.398 .PHONY: patchclean 75.399 patchclean: crossclean 75.400 - rm -fr binutils-$(BINUTILS_VERSION) 75.401 - rm -fr gcc-$(GCC_VERSION) 75.402 - rm -fr newlib-cvs 75.403 - rm -fr lwip-cvs 75.404 - rm -fr grub-cvs 75.405 + rm -fr newlib-$(NEWLIB_VERSION) 75.406 + rm -fr lwip 75.407 + rm -fr grub-upstream 75.408 75.409 # clean downloads 75.410 .PHONY: downloadclean 75.411 downloadclean: patchclean 75.412 - rm -f binutils-$(BINUTILS_VERSION).tar.bz2 75.413 - rm -f gcc-$(GCC_VERSION).tar.bz2 75.414 + rm -f newlib-$(NEWLIB_VERSION).tar.gz 75.415 rm -f zlib-$(ZLIB_VERSION).tar.gz 75.416 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2 75.417 + rm -f grub-$(GRUB_VERSION).tar.gz 75.418 + rm -f lwip-$(LWIP_VERSION).tar.gz 75.419 75.420 .PHONY: distclean 75.421 distclean: downloadclean
76.1 --- a/stubdom/binutils.patch Tue Jul 08 11:41:43 2008 +0900 76.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 76.3 @@ -1,14 +0,0 @@ 76.4 -It looks like binutils has troubles with makeinfo and the doc generation. 76.5 -We don't need it anyway 76.6 - 76.7 ---- binutils-2.18/bfd/Makefile.inorig 2008-01-16 16:17:43.004484000 +0000 76.8 -+++ binutils-2.18/bfd/Makefile.in 2008-01-16 16:17:50.505526000 +0000 76.9 -@@ -271,7 +271,7 @@ 76.10 - INCDIR = $(srcdir)/../include 76.11 - CSEARCH = -I. -I$(srcdir) -I$(INCDIR) 76.12 - MKDEP = gcc -MM 76.13 --SUBDIRS = doc po 76.14 -+SUBDIRS = po 76.15 - bfddocdir = doc 76.16 - bfdlib_LTLIBRARIES = libbfd.la 76.17 - AM_CFLAGS = $(WARN_CFLAGS)
77.1 --- a/stubdom/gcc.patch Tue Jul 08 11:41:43 2008 +0900 77.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 77.3 @@ -1,31 +0,0 @@ 77.4 -Backported from later versions 77.5 - 77.6 ---- gcc-4.2.2/gcc/config.gcc 2007-11-22 16:27:45.000000000 +0000 77.7 -+++ gcc-4.2.2/gcc/config.gcc 2007-11-22 16:23:00.000000000 +0000 77.8 -@@ -1033,6 +1033,11 @@ 77.9 - tmake_file="i386/t-i386elf t-svr4" 77.10 - use_fixproto=yes 77.11 - ;; 77.12 -+x86_64-*-elf*) 77.13 -+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/i386elf.h i386/x86-64.h" 77.14 -+ tmake_file="i386/t-i386elf t-svr4" 77.15 -+ use_fixproto=yes 77.16 -+ ;; 77.17 - i[34567]86-sequent-ptx4* | i[34567]86-sequent-sysv4*) 77.18 - if test x$gas = xyes 77.19 - then 77.20 - 77.21 -We don't have a libc yet at this stage. Unused anyway 77.22 - 77.23 ---- gcc-4.2.2/gcc/unwind-generic.h.orig 2008-01-11 18:54:40.000000000 +0100 77.24 -+++ gcc-4.2.2/gcc/unwind-generic.h 2008-01-11 18:54:31.000000000 +0100 77.25 -@@ -203,7 +203,6 @@ 77.26 - compatible with the standard ABI for IA-64, we inline these. */ 77.27 - 77.28 - #ifdef __ia64__ 77.29 --#include <stdlib.h> 77.30 - 77.31 - static inline _Unwind_Ptr 77.32 - _Unwind_GetDataRelBase (struct _Unwind_Context *_C) 77.33 -Backported from later versions 77.34 -
78.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 78.2 +++ b/stubdom/grub.patches/00cvs Fri Jul 18 12:12:41 2008 +0900 78.3 @@ -0,0 +1,1382 @@ 78.4 +diff -uprN grub-0.97/acinclude.m4 grub/acinclude.m4 78.5 +--- grub-0.97/acinclude.m4 2004-04-27 21:48:06.000000000 +0100 78.6 ++++ grub/acinclude.m4 2007-11-05 01:29:46.000000000 +0000 78.7 +@@ -57,7 +57,7 @@ else 78.8 + fi 78.9 + grub_cv_prog_objcopy_absolute=yes 78.10 + for link_addr in 2000 8000 7C00; do 78.11 +- if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then : 78.12 ++ if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} ${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then : 78.13 + else 78.14 + AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr]) 78.15 + fi 78.16 +diff -uprN grub-0.97/ChangeLog grub/ChangeLog 78.17 +--- grub-0.97/ChangeLog 2005-05-08 03:47:02.000000000 +0100 78.18 ++++ grub/ChangeLog 2008-05-20 12:04:18.000000000 +0100 78.19 +@@ -1,3 +1,127 @@ 78.20 ++2008-05-20 Robert Millan <rmh@aybabtu.com> 78.21 ++ 78.22 ++ * netboot/cs89x0.c: Fix license violation. 78.23 ++ * netboot/cs89x0.h: Likewise. 78.24 ++ 78.25 ++2008-04-10 Pavel Roskin <proski@gnu.org> 78.26 ++ 78.27 ++ * configure.ac: Always use "_cv_" in cache variables for 78.28 ++ compatibility with Autoconf 2.62. 78.29 ++ 78.30 ++2008-03-28 Robert Millan <rmh@aybabtu.com> 78.31 ++ 78.32 ++ Surpass 1 TiB disk addressing limit. Note: there are no plans to handle 78.33 ++ the 2 TiB disk limit in GRUB Legacy, since that would need considerable 78.34 ++ rework. If you have >2TiB disks, use GRUB 2 instead. 78.35 ++ 78.36 ++ * grub/asmstub.c (biosdisk): Add unsigned qualifier to `sector'. 78.37 ++ * stage2/bios.c (biosdisk): Likewise. 78.38 ++ * stage2/disk_io.c (rawread, devread, rawwrite, devwrite): Likewise. 78.39 ++ * stage2/shared.h (rawread, devread, rawwrite, devwrite): Likewise. 78.40 ++ * lib/device.c (get_drive_geometry): Replace BLKGETSIZE with 78.41 ++ BLKGETSIZE64. 78.42 ++ 78.43 ++2007-10-29 Pavel Roskin <proski@gnu.org> 78.44 ++ 78.45 ++ * configure.ac: Test if '--build-id=none' is supported by the 78.46 ++ linker and add it to LDFLAGS if possible. Build ID causes 78.47 ++ objcopy to generate huge binary files. 78.48 ++ * aclocal.m4 (grub_PROG_OBJCOPY_ABSOLUTE): Use LDFLAGS when 78.49 ++ linking, so that build ID doesn't break the test. 78.50 ++ * stage1/Makefile.am: Preserve LDFLAGS, use stage1_exec_LDFLAGS. 78.51 ++ 78.52 ++2007-02-22 Pavel Roskin <proski@gnu.org> 78.53 ++ 78.54 ++ * stage2/iso9660.h: Remove unnecessary packed attributes. 78.55 ++ 78.56 ++2007-02-22 Robert Millan <rmh@aybabtu.com> 78.57 ++ 78.58 ++ * util/mkbimage: Update my email address, and remove my name from 78.59 ++ some places where unnecessary credit is given. 78.60 ++ 78.61 ++2006-09-10 Pavel Roskin <proski@gnu.org> 78.62 ++ 78.63 ++ * netboot/natsemi.c: Fix compile error with gcc 4.1.1. Cast 78.64 ++ cannot make a variable volatile - it should be declared as such. 78.65 ++ * netboot/sis900.c: Likewise. 78.66 ++ 78.67 ++2006-09-08 Pavel Roskin <proski@gnu.org> 78.68 ++ 78.69 ++ * netboot/etherboot.h: Remove incorrect extern declarations of 78.70 ++ the variables later declared static. Move BOOTP_DATA_ADDR ... 78.71 ++ * netboot/main.c: ... here. Eliminate end_of_rfc1533 - it's 78.72 ++ write-only. 78.73 ++ 78.74 ++2006-06-24 Yoshinori K. Okuji <okuji@enbug.org> 78.75 ++ 78.76 ++ * docs/grub.texi: Changed the license term to the GNU Free 78.77 ++ Documentation License 1.2. 78.78 ++ 78.79 ++ * docs/multiboot.texi: Reformatted to show the license term 78.80 ++ and the version number explicitly. 78.81 ++ 78.82 ++ * docs/fdl.texi: New file. 78.83 ++ 78.84 ++ * docs/Makefile.am (grub_TEXINFOS): Added fdl.texi. 78.85 ++ 78.86 ++2006-06-24 Robert Millan <robertmh@gnu.org> 78.87 ++ 78.88 ++ * lib/device.c (write_to_partition): /dev/ataraid/ and /dev/rd/ 78.89 ++ partitions have a "p" prefix. Add it. 78.90 ++ 78.91 ++2006-06-24 Robert Millan <robertmh@gnu.org> 78.92 ++ 78.93 ++ * lib/device.c (get_i2o_disk_name): New function. 78.94 ++ (init_device_map) [__linux__]: Add support for I2O devices. 78.95 ++ 78.96 ++2006-05-02 Pavel Roskin <proski@gnu.org> 78.97 ++ 78.98 ++ * stage2/stage2.c (run_menu): Fix "savedefault" to save only top 78.99 ++ level menu positions. Remember current position when calling a 78.100 ++ submenu. Don't recalculate it when booting from a submenu. 78.101 ++ 78.102 ++ * grub/main.c (main): Make sure the boot drive number doesn't 78.103 ++ exceed 255. 78.104 ++ 78.105 ++2006-05-02 Vesa Jaaskelainen <chaac@nic.fi> 78.106 ++ 78.107 ++ * stage2/shared.h (vbe_mode): Back ported aligment fix from GRUB 2 78.108 ++ to GRUB Legacy. Problem reported by Gerardo Richarte. 78.109 ++ 78.110 ++2006-04-23 Robert Millan <robertmh@gnu.org> 78.111 ++ 78.112 ++ * grub/asmstub.c (get_diskinfo): Optimize sysctl routine. 78.113 ++ 78.114 ++2006-04-20 Robert Millan <robertmh@gnu.org> 78.115 ++ 78.116 ++ Fixes for kernel of FreeBSD: 78.117 ++ * grub/asmstub.c (get_diskinfo): Toggle "kern.geom.debugflags" sysctl 78.118 ++ before opening a device for writing. 78.119 ++ * util/grub-install.in: Devices don't have this "r" prefix anymore. 78.120 ++ 78.121 ++2006-04-16 Yoshinori K. Okuji <okuji@enbug.org> 78.122 ++ 78.123 ++ * docs/multiboot.texi: Correct the offset of address 78.124 ++ fields. Reported by Jeroen Dekkers. 78.125 ++ 78.126 ++2006-03-21 Yoshinori K. Okuji <okuji@enbug.org> 78.127 ++ 78.128 ++ * stage2/builtins.c (setup_func): Specify the size of DEVICE to 78.129 ++ grub_strncat instead of a strange number 256. Reported by Vitaly 78.130 ++ Fertman <vitaly@namesys.com>. 78.131 ++ 78.132 ++2005-09-29 Yoshinori K. Okuji <okuji@enbug.org> 78.133 ++ 78.134 ++ * docs/multiboot.texi: Fix a bug in the byte order of 78.135 ++ boot_device. I hope this won't affect any OS image. 78.136 ++ Increased the version number to 0.6.94. 78.137 ++ 78.138 ++2005-09-28 Yoshinori K. Okuji <okuji@enbug.org> 78.139 ++ 78.140 ++ * stage2/boot.c (load_image): Even if an OS image is an ELF 78.141 ++ object, use the a.out kludge if MULTIBOOT_AOUT_KLUDGE is 78.142 ++ specified. 78.143 ++ 78.144 + 2005-05-08 Yoshinori K. Okuji <okuji@enbug.org> 78.145 + 78.146 + * configure.ac (AC_INIT): Upgraded to 0.97. 78.147 +diff -uprN grub-0.97/configure grub/configure 78.148 +--- grub-0.97/configure 2005-05-08 03:48:12.000000000 +0100 78.149 ++++ grub/configure 2007-11-05 01:29:46.000000000 +0000 78.150 +@@ -3694,6 +3694,64 @@ if test "x$undef_flag" = xyes; then 78.151 + CPPFLAGS="$CPPFLAGS -Wundef" 78.152 + fi 78.153 + 78.154 ++# Check if build ID can be disabled in the linker 78.155 ++echo "$as_me:$LINENO: checking whether linker accepts \`--build-id=none'" >&5 78.156 ++echo $ECHO_N "checking whether linker accepts \`--build-id=none'... $ECHO_C" >&6 78.157 ++save_LDFLAGS="$LDFLAGS" 78.158 ++LDFLAGS="$LDFLAGS -Wl,--build-id=none" 78.159 ++cat >conftest.$ac_ext <<_ACEOF 78.160 ++/* confdefs.h. */ 78.161 ++_ACEOF 78.162 ++cat confdefs.h >>conftest.$ac_ext 78.163 ++cat >>conftest.$ac_ext <<_ACEOF 78.164 ++/* end confdefs.h. */ 78.165 ++ 78.166 ++int 78.167 ++main () 78.168 ++{ 78.169 ++ 78.170 ++ ; 78.171 ++ return 0; 78.172 ++} 78.173 ++_ACEOF 78.174 ++rm -f conftest.$ac_objext conftest$ac_exeext 78.175 ++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 78.176 ++ (eval $ac_link) 2>conftest.er1 78.177 ++ ac_status=$? 78.178 ++ grep -v '^ *+' conftest.er1 >conftest.err 78.179 ++ rm -f conftest.er1 78.180 ++ cat conftest.err >&5 78.181 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 78.182 ++ (exit $ac_status); } && 78.183 ++ { ac_try='test -z "$ac_c_werror_flag" 78.184 ++ || test ! -s conftest.err' 78.185 ++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 78.186 ++ (eval $ac_try) 2>&5 78.187 ++ ac_status=$? 78.188 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 78.189 ++ (exit $ac_status); }; } && 78.190 ++ { ac_try='test -s conftest$ac_exeext' 78.191 ++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 78.192 ++ (eval $ac_try) 2>&5 78.193 ++ ac_status=$? 78.194 ++ echo "$as_me:$LINENO: \$? = $ac_status" >&5 78.195 ++ (exit $ac_status); }; }; then 78.196 ++ build_id_flag=yes 78.197 ++else 78.198 ++ echo "$as_me: failed program was:" >&5 78.199 ++sed 's/^/| /' conftest.$ac_ext >&5 78.200 ++ 78.201 ++build_id_flag=no 78.202 ++fi 78.203 ++rm -f conftest.err conftest.$ac_objext \ 78.204 ++ conftest$ac_exeext conftest.$ac_ext 78.205 ++echo "$as_me:$LINENO: result: $build_id_flag" >&5 78.206 ++echo "${ECHO_T}$build_id_flag" >&6 78.207 ++LDFLAGS="$save_LDFLAGS" 78.208 ++if test "x$build_id_flag" = xyes; then 78.209 ++ LDFLAGS="$LDFLAGS -Wl,--build-id=none" 78.210 ++fi 78.211 ++ 78.212 + if test "x$with_binutils" != x; then 78.213 + # Extract the first word of "objcopy", so it can be a program name with args. 78.214 + set dummy objcopy; ac_word=$2 78.215 +@@ -3892,7 +3950,7 @@ echo "$as_me: error: ${CC-cc} cannot com 78.216 + fi 78.217 + grub_cv_prog_objcopy_absolute=yes 78.218 + for link_addr in 2000 8000 7C00; do 78.219 +- if { ac_try='${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec' 78.220 ++ if { ac_try='${CC-cc} ${CFLAGS} ${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec' 78.221 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 78.222 + (eval $ac_try) 2>&5 78.223 + ac_status=$? 78.224 +diff -uprN grub-0.97/configure.ac grub/configure.ac 78.225 +--- grub-0.97/configure.ac 2005-05-08 03:36:03.000000000 +0100 78.226 ++++ grub/configure.ac 2008-04-10 23:26:50.000000000 +0100 78.227 +@@ -86,13 +86,13 @@ if test "x$ac_cv_prog_gcc" = xyes; then 78.228 + fi 78.229 + STAGE1_CFLAGS="-O2" 78.230 + GRUB_CFLAGS="-O2" 78.231 +- AC_CACHE_CHECK([whether optimization for size works], size_flag, [ 78.232 ++ AC_CACHE_CHECK([whether optimization for size works], grub_cv_cc_Os, [ 78.233 + saved_CFLAGS=$CFLAGS 78.234 + CFLAGS="-Os -g" 78.235 +- AC_TRY_COMPILE(, , size_flag=yes, size_flag=no) 78.236 ++ AC_TRY_COMPILE(, , grub_cv_cc_Os=yes, grub_cv_cc_Os=no) 78.237 + CFLAGS=$saved_CFLAGS 78.238 + ]) 78.239 +- if test "x$size_flag" = xyes; then 78.240 ++ if test "x$grub_cv_cc_Os" = xyes; then 78.241 + STAGE2_CFLAGS="-Os" 78.242 + else 78.243 + STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops" 78.244 +@@ -100,16 +100,16 @@ if test "x$ac_cv_prog_gcc" = xyes; then 78.245 + # OpenBSD has a GCC extension for protecting applications from 78.246 + # stack smashing attacks, but GRUB doesn't want this feature. 78.247 + AC_CACHE_CHECK([whether gcc has -fno-stack-protector], 78.248 +- no_stack_protector_flag, [ 78.249 ++ grub_cv_cc_no_stack_protector, [ 78.250 + saved_CFLAGS=$CFLAGS 78.251 + CFLAGS="-fno-stack-protector" 78.252 + AC_TRY_COMPILE(, 78.253 + , 78.254 +- no_stack_protector_flag=yes, 78.255 +- no_stack_protector_flag=no) 78.256 ++ grub_cv_cc_no_stack_protector=yes, 78.257 ++ grub_cv_cc_no_stack_protector=no) 78.258 + CFLAGS=$saved_CFLAGS 78.259 + ]) 78.260 +- if test "x$no_stack_protector_flag" = xyes; then 78.261 ++ if test "x$grub_cv_cc_no_stack_protector" = xyes; then 78.262 + STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-stack-protector" 78.263 + fi 78.264 + fi 78.265 +@@ -123,33 +123,44 @@ AC_SUBST(GRUB_CFLAGS) 78.266 + CPPFLAGS="$CPPFLAGS -Wall -Wmissing-prototypes -Wunused -Wshadow" 78.267 + CPPFLAGS="$CPPFLAGS -Wpointer-arith" 78.268 + 78.269 +-AC_CACHE_CHECK([whether -Wundef works], undef_flag, [ 78.270 ++AC_CACHE_CHECK([whether -Wundef works], grub_cv_cc_Wundef, [ 78.271 + saved_CPPFLAGS="$CPPFLAGS" 78.272 + CPPFLAGS="-Wundef" 78.273 +- AC_TRY_COMPILE(, , undef_flag=yes, undef_flag=no) 78.274 ++ AC_TRY_COMPILE(, , grub_cv_cc_Wundef=yes, grub_cv_cc_Wundef=no) 78.275 + CPPFLAGS="$saved_CPPFLAGS" 78.276 + ]) 78.277 + 78.278 + # The options `-falign-*' are supported by gcc 3.0 or later. 78.279 + # Probably it is sufficient to only check for -falign-loops. 78.280 +-AC_CACHE_CHECK([whether -falign-loops works], [falign_loop_flag], [ 78.281 ++AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ 78.282 + saved_CPPFLAGS="$CPPFLAGS" 78.283 + CPPFLAGS="-falign-loops=1" 78.284 +- AC_TRY_COMPILE(, , [falign_loop_flag=yes], [falign_loop_flag=no]) 78.285 ++ AC_TRY_COMPILE(, , [grub_cv_cc_falign_loop=yes], [grub_cv_cc_falign_loop=no]) 78.286 + CPPFLAGS="$saved_CPPFLAGS" 78.287 + ]) 78.288 + 78.289 + # Force no alignment to save space. 78.290 +-if test "x$falign_loop_flag" = xyes; then 78.291 ++if test "x$grub_cv_cc_falign_loop" = xyes; then 78.292 + CPPFLAGS="$CPPFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1" 78.293 + else 78.294 + CPPFLAGS="$CPPFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1" 78.295 + fi 78.296 + 78.297 +-if test "x$undef_flag" = xyes; then 78.298 ++if test "x$grub_cv_cc_Wundef" = xyes; then 78.299 + CPPFLAGS="$CPPFLAGS -Wundef" 78.300 + fi 78.301 + 78.302 ++# Check if build ID can be disabled in the linker 78.303 ++AC_MSG_CHECKING([whether linker accepts `--build-id=none']) 78.304 ++save_LDFLAGS="$LDFLAGS" 78.305 ++LDFLAGS="$LDFLAGS -Wl,--build-id=none" 78.306 ++AC_TRY_LINK(, , build_id_flag=yes, build_id_flag=no) 78.307 ++AC_MSG_RESULT([$build_id_flag]) 78.308 ++LDFLAGS="$save_LDFLAGS" 78.309 ++if test "x$build_id_flag" = xyes; then 78.310 ++ LDFLAGS="$LDFLAGS -Wl,--build-id=none" 78.311 ++fi 78.312 ++ 78.313 + if test "x$with_binutils" != x; then 78.314 + dnl AC_PATH_TOOL(OBJCOPY, objcopy, , "$with_binutils:$PATH") 78.315 + AC_PATH_PROG(OBJCOPY, objcopy, , "$with_binutils:$PATH") 78.316 +diff -uprN grub-0.97/docs/grub.8 grub/docs/grub.8 78.317 +--- grub-0.97/docs/grub.8 2005-05-08 03:48:56.000000000 +0100 78.318 ++++ grub/docs/grub.8 2006-06-24 15:40:02.000000000 +0100 78.319 +@@ -1,5 +1,5 @@ 78.320 + .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. 78.321 +-.TH GRUB "8" "May 2005" "grub (GNU GRUB 0.97)" FSF 78.322 ++.TH GRUB "8" "June 2006" "grub (GNU GRUB 0.97)" FSF 78.323 + .SH NAME 78.324 + grub \- the grub shell 78.325 + .SH SYNOPSIS 78.326 +diff -uprN grub-0.97/docs/grub-install.8 grub/docs/grub-install.8 78.327 +--- grub-0.97/docs/grub-install.8 2005-05-08 03:48:56.000000000 +0100 78.328 ++++ grub/docs/grub-install.8 2006-06-24 15:40:02.000000000 +0100 78.329 +@@ -1,5 +1,5 @@ 78.330 + .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. 78.331 +-.TH GRUB-INSTALL "8" "May 2005" "grub-install (GNU GRUB 0.97)" FSF 78.332 ++.TH GRUB-INSTALL "8" "June 2006" "grub-install (GNU GRUB 0.97)" FSF 78.333 + .SH NAME 78.334 + grub-install \- install GRUB on your drive 78.335 + .SH SYNOPSIS 78.336 +diff -uprN grub-0.97/docs/grub-md5-crypt.8 grub/docs/grub-md5-crypt.8 78.337 +--- grub-0.97/docs/grub-md5-crypt.8 2005-05-08 03:48:56.000000000 +0100 78.338 ++++ grub/docs/grub-md5-crypt.8 2006-06-24 15:40:02.000000000 +0100 78.339 +@@ -1,5 +1,5 @@ 78.340 + .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. 78.341 +-.TH GRUB-MD5-CRYPT "8" "May 2005" "grub-md5-crypt (GNU GRUB )" FSF 78.342 ++.TH GRUB-MD5-CRYPT "8" "June 2006" "grub-md5-crypt (GNU GRUB )" FSF 78.343 + .SH NAME 78.344 + grub-md5-crypt \- Encrypt a password in MD5 format 78.345 + .SH SYNOPSIS 78.346 +diff -uprN grub-0.97/docs/grub-terminfo.8 grub/docs/grub-terminfo.8 78.347 +--- grub-0.97/docs/grub-terminfo.8 2005-05-08 03:48:56.000000000 +0100 78.348 ++++ grub/docs/grub-terminfo.8 2006-06-24 15:40:02.000000000 +0100 78.349 +@@ -1,5 +1,5 @@ 78.350 + .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. 78.351 +-.TH GRUB-TERMINFO "8" "May 2005" "grub-terminfo (GNU GRUB 0.97)" FSF 78.352 ++.TH GRUB-TERMINFO "8" "June 2006" "grub-terminfo (GNU GRUB 0.97)" FSF 78.353 + .SH NAME 78.354 + grub-terminfo \- Generate a terminfo command from a terminfo name 78.355 + .SH SYNOPSIS 78.356 +diff -uprN grub-0.97/docs/grub.texi grub/docs/grub.texi 78.357 +--- grub-0.97/docs/grub.texi 2005-05-08 03:59:59.000000000 +0100 78.358 ++++ grub/docs/grub.texi 2006-06-24 15:40:02.000000000 +0100 78.359 +@@ -2,22 +2,41 @@ 78.360 + @c -*-texinfo-*- 78.361 + @c %**start of header 78.362 + @setfilename grub.info 78.363 +-@settitle GRUB Manual 78.364 +-@c %**end of header 78.365 +- 78.366 + @include version.texi 78.367 +- 78.368 ++@settitle GNU GRUB Manual @value{VERSION} 78.369 + @c Unify all our little indices for now. 78.370 + @syncodeindex fn cp 78.371 + @syncodeindex vr cp 78.372 + @syncodeindex ky cp 78.373 + @syncodeindex pg cp 78.374 + @syncodeindex tp cp 78.375 ++@c %**end of header 78.376 + 78.377 + @footnotestyle separate 78.378 + @paragraphindent 3 78.379 + @finalout 78.380 + 78.381 ++@copying 78.382 ++This manual is for GNU GRUB (version @value{VERSION}, 78.383 ++@value{UPDATED}). 78.384 ++ 78.385 ++Copyright @copyright{} 1999,2000,2001,2002,2004,2006 Free Software Foundation, Inc. 78.386 ++ 78.387 ++@quotation 78.388 ++Permission is granted to copy, distribute and/or modify this document 78.389 ++under the terms of the GNU Free Documentation License, Version 1.2 or 78.390 ++any later version published by the Free Software Foundation; with no 78.391 ++Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,'' 78.392 ++and with the Back-Cover Texts as in (a) below. A copy of the 78.393 ++license is included in the section entitled ``GNU Free Documentation 78.394 ++License.'' 78.395 ++ 78.396 ++(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify 78.397 ++this GNU Manual, like GNU software. Copies published by the Free 78.398 ++Software Foundation raise funds for GNU development.'' 78.399 ++@end quotation 78.400 ++@end copying 78.401 ++ 78.402 + @dircategory Kernel 78.403 + @direntry 78.404 + * GRUB: (grub). The GRand Unified Bootloader 78.405 +@@ -34,53 +53,16 @@ 78.406 + 78.407 + @setchapternewpage odd 78.408 + 78.409 +-@ifinfo 78.410 +-Copyright @copyright{} 1999,2000,2001,2002,2004 Free Software Foundation, Inc. 78.411 +- 78.412 +-Permission is granted to make and distribute verbatim copies of 78.413 +-this manual provided the copyright notice and this permission notice 78.414 +-are preserved on all copies. 78.415 +- 78.416 +-@ignore 78.417 +-Permission is granted to process this file through TeX and print the 78.418 +-results, provided the printed document carries a copying permission 78.419 +-notice identical to this one except for the removal of this paragraph 78.420 +-(this paragraph not being relevant to the printed manual). 78.421 +- 78.422 +-@end ignore 78.423 +- 78.424 +-Permission is granted to copy and distribute modified versions of this 78.425 +-manual under the conditions for verbatim copying, provided also that 78.426 +-the entire resulting derived work is distributed under the terms of a 78.427 +-permission notice identical to this one. 78.428 +- 78.429 +-Permission is granted to copy and distribute translations of this manual 78.430 +-into another language, under the above conditions for modified versions. 78.431 +-@end ifinfo 78.432 +- 78.433 + @titlepage 78.434 + @sp 10 78.435 +-@title the GRUB manual 78.436 ++@title the GNU GRUB manual 78.437 + @subtitle The GRand Unified Bootloader, version @value{VERSION}, @value{UPDATED}. 78.438 + @author Gordon Matzigkeit 78.439 + @author Yoshinori K. Okuji 78.440 + @c The following two commands start the copyright page. 78.441 + @page 78.442 + @vskip 0pt plus 1filll 78.443 +-Copyright @copyright{} 1999,2000,2001,2002,2004 Free Software Foundation, Inc. 78.444 +- 78.445 +-Permission is granted to make and distribute verbatim copies of 78.446 +-this manual provided the copyright notice and this permission notice 78.447 +-are preserved on all copies. 78.448 +-Permission is granted to copy and distribute modified versions of this 78.449 +-manual under the conditions for verbatim copying, provided that the entire 78.450 +-resulting derived work is distributed under the terms of a permission 78.451 +-notice identical to this one. 78.452 +- 78.453 +-Permission is granted to copy and distribute translations of this manual 78.454 +-into another language, under the above conditions for modified versions, 78.455 +-except that this permission notice may be stated in a translation approved 78.456 +-by Free Software Foundation. 78.457 ++@insertcopying 78.458 + @end titlepage 78.459 + 78.460 + @c Output the table of contents at the beginning. 78.461 +@@ -91,12 +73,14 @@ by Free Software Foundation. 78.462 + 78.463 + @ifnottex 78.464 + @node Top 78.465 +-@top GRUB manual 78.466 ++@top GNU GRUB manual 78.467 + 78.468 + This is the documentation of GNU GRUB, the GRand Unified Bootloader, 78.469 + a flexible and powerful boot loader program for @sc{pc}s. 78.470 + 78.471 + This edition documents version @value{VERSION}. 78.472 ++ 78.473 ++@insertcopying 78.474 + @end ifnottex 78.475 + 78.476 + @menu 78.477 +@@ -124,6 +108,7 @@ This edition documents version @value{VE 78.478 + * Reporting bugs:: Where you should send a bug report 78.479 + * Future:: Some future plans on GRUB 78.480 + * Internals:: Hacking GRUB 78.481 ++* Copying This Manual:: Copying This Manual 78.482 + * Index:: 78.483 + @end menu 78.484 + 78.485 +@@ -3965,6 +3950,16 @@ homepage}. 78.486 + @include internals.texi 78.487 + 78.488 + 78.489 ++@node Copying This Manual 78.490 ++@appendix Copying This Manual 78.491 ++ 78.492 ++@menu 78.493 ++* GNU Free Documentation License:: License for copying this manual. 78.494 ++@end menu 78.495 ++ 78.496 ++@include fdl.texi 78.497 ++ 78.498 ++ 78.499 + @node Index 78.500 + @unnumbered Index 78.501 + 78.502 +diff -uprN grub-0.97/docs/Makefile.am grub/docs/Makefile.am 78.503 +--- grub-0.97/docs/Makefile.am 2003-07-09 12:45:35.000000000 +0100 78.504 ++++ grub/docs/Makefile.am 2006-06-24 15:40:02.000000000 +0100 78.505 +@@ -1,5 +1,5 @@ 78.506 + info_TEXINFOS = grub.texi multiboot.texi 78.507 +-grub_TEXINFOS = internals.texi 78.508 ++grub_TEXINFOS = internals.texi fdl.texi 78.509 + EXAMPLES = boot.S kernel.c multiboot.h 78.510 + multiboot_TEXINFOS = boot.S.texi kernel.c.texi multiboot.h.texi 78.511 + man_MANS = grub.8 mbchk.1 grub-install.8 grub-md5-crypt.8 grub-terminfo.8 78.512 +diff -uprN grub-0.97/docs/Makefile.in grub/docs/Makefile.in 78.513 +--- grub-0.97/docs/Makefile.in 2005-05-08 03:42:34.000000000 +0100 78.514 ++++ grub/docs/Makefile.in 2006-06-24 15:40:02.000000000 +0100 78.515 +@@ -202,7 +202,7 @@ sharedstatedir = @sharedstatedir@ 78.516 + sysconfdir = @sysconfdir@ 78.517 + target_alias = @target_alias@ 78.518 + info_TEXINFOS = grub.texi multiboot.texi 78.519 +-grub_TEXINFOS = internals.texi 78.520 ++grub_TEXINFOS = internals.texi fdl.texi 78.521 + EXAMPLES = boot.S kernel.c multiboot.h 78.522 + multiboot_TEXINFOS = boot.S.texi kernel.c.texi multiboot.h.texi 78.523 + man_MANS = grub.8 mbchk.1 grub-install.8 grub-md5-crypt.8 grub-terminfo.8 78.524 +diff -uprN grub-0.97/docs/mbchk.1 grub/docs/mbchk.1 78.525 +--- grub-0.97/docs/mbchk.1 2005-05-08 03:48:56.000000000 +0100 78.526 ++++ grub/docs/mbchk.1 2006-06-24 15:40:02.000000000 +0100 78.527 +@@ -1,5 +1,5 @@ 78.528 + .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.23. 78.529 +-.TH MBCHK "1" "May 2005" "mbchk (GNU GRUB 0.97)" FSF 78.530 ++.TH MBCHK "1" "June 2006" "mbchk (GNU GRUB 0.97)" FSF 78.531 + .SH NAME 78.532 + mbchk \- check the format of a Multiboot kernel 78.533 + .SH SYNOPSIS 78.534 +diff -uprN grub-0.97/docs/multiboot.texi grub/docs/multiboot.texi 78.535 +--- grub-0.97/docs/multiboot.texi 2003-07-09 12:45:36.000000000 +0100 78.536 ++++ grub/docs/multiboot.texi 2006-06-24 15:40:02.000000000 +0100 78.537 +@@ -1,32 +1,28 @@ 78.538 + \input texinfo @c -*-texinfo-*- 78.539 +-@c -*-texinfo-*- 78.540 + @c %**start of header 78.541 + @setfilename multiboot.info 78.542 +-@settitle Multiboot Specification 78.543 +-@c %**end of header 78.544 +- 78.545 ++@set VERSION 0.6.95 78.546 ++@settitle Multiboot Specification version @value{VERSION} 78.547 + @c Unify all our little indices for now. 78.548 + @syncodeindex fn cp 78.549 + @syncodeindex vr cp 78.550 + @syncodeindex ky cp 78.551 + @syncodeindex pg cp 78.552 + @syncodeindex tp cp 78.553 ++@c %**end of header 78.554 + 78.555 + @footnotestyle separate 78.556 + @paragraphindent 3 78.557 + @finalout 78.558 + 78.559 ++@copying 78.560 ++Copyright @copyright{} 1995,96 Bryan Ford <baford@@cs.utah.edu> 78.561 + 78.562 +-@dircategory Kernel 78.563 +-@direntry 78.564 +-* Multiboot Specification: (multiboot). Multiboot Specification. 78.565 +-@end direntry 78.566 ++Copyright @copyright{} 1995,96 Erich Stefan Boleyn <erich@@uruk.org> 78.567 + 78.568 +-@ifinfo 78.569 +-Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu> 78.570 +-Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org> 78.571 +-Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc. 78.572 ++Copyright @copyright{} 1999,2000,2001,2002,2005,2006 Free Software Foundation, Inc. 78.573 + 78.574 ++@quotation 78.575 + Permission is granted to make and distribute verbatim copies of 78.576 + this manual provided the copyright notice and this permission notice 78.577 + are preserved on all copies. 78.578 +@@ -36,7 +32,6 @@ Permission is granted to process this fi 78.579 + results, provided the printed document carries a copying permission 78.580 + notice identical to this one except for the removal of this paragraph 78.581 + (this paragraph not being relevant to the printed manual). 78.582 +- 78.583 + @end ignore 78.584 + 78.585 + Permission is granted to copy and distribute modified versions of this 78.586 +@@ -45,31 +40,23 @@ the entire resulting derived work is dis 78.587 + permission notice identical to this one. 78.588 + 78.589 + Permission is granted to copy and distribute translations of this manual 78.590 +-into another language, under the above conditions for modified versions. 78.591 +-@end ifinfo 78.592 ++into another language, under the above conditions for modified 78.593 ++versions. 78.594 ++@end quotation 78.595 ++@end copying 78.596 ++ 78.597 ++@dircategory Kernel 78.598 ++@direntry 78.599 ++* Multiboot Specification: (multiboot). Multiboot Specification. 78.600 ++@end direntry 78.601 + 78.602 + @titlepage 78.603 + @sp 10 78.604 +-@title The Multiboot Specification 78.605 ++@title The Multiboot Specification version @value{VERSION} 78.606 + @author Yoshinori K. Okuji, Bryan Ford, Erich Stefan Boleyn, Kunihiro Ishiguro 78.607 + @page 78.608 +- 78.609 + @vskip 0pt plus 1filll 78.610 +-Copyright @copyright{} 1995, 96 Bryan Ford <baford@@cs.utah.edu> 78.611 +-Copyright @copyright{} 1995, 96 Erich Stefan Boleyn <erich@@uruk.org> 78.612 +-Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software Foundation, Inc. 78.613 +- 78.614 +-Permission is granted to make and distribute verbatim copies of 78.615 +-this manual provided the copyright notice and this permission notice 78.616 +-are preserved on all copies. 78.617 +- 78.618 +-Permission is granted to copy and distribute modified versions of this 78.619 +-manual under the conditions for verbatim copying, provided also that 78.620 +-the entire resulting derived work is distributed under the terms of a 78.621 +-permission notice identical to this one. 78.622 +- 78.623 +-Permission is granted to copy and distribute translations of this manual 78.624 +-into another language, under the above conditions for modified versions. 78.625 ++@insertcopying 78.626 + @end titlepage 78.627 + 78.628 + @finalout 78.629 +@@ -80,7 +67,9 @@ into another language, under the above c 78.630 + @top Multiboot Specification 78.631 + 78.632 + This file documents Multiboot Specification, the proposal for the boot 78.633 +-sequence standard. This edition documents version 0.6.93. 78.634 ++sequence standard. This edition documents version @value{VERSION}. 78.635 ++ 78.636 ++@insertcopying 78.637 + @end ifnottex 78.638 + 78.639 + @menu 78.640 +@@ -426,7 +415,7 @@ mode table (@pxref{Boot information form 78.641 + kernel. 78.642 + 78.643 + If bit 16 in the @samp{flags} word is set, then the fields at offsets 78.644 +-8-24 in the Multiboot header are valid, and the boot loader should use 78.645 ++12-28 in the Multiboot header are valid, and the boot loader should use 78.646 + them instead of the fields in the actual executable header to calculate 78.647 + where to load the OS image. This information does not need to be 78.648 + provided if the kernel image is in @sc{elf} format, but it @emph{must} 78.649 +@@ -677,7 +666,7 @@ follows: 78.650 + @example 78.651 + @group 78.652 + +-------+-------+-------+-------+ 78.653 +-| drive | part1 | part2 | part3 | 78.654 ++| part3 | part2 | part1 | drive | 78.655 + +-------+-------+-------+-------+ 78.656 + @end group 78.657 + @end example 78.658 +@@ -1197,6 +1186,17 @@ Rewritten, using more strict words. 78.659 + @item 78.660 + The maintainer changes to the GNU GRUB maintainer team 78.661 + @email{bug-grub@@gnu.org}, from Bryan Ford and Erich Stefan Boleyn. 78.662 ++ 78.663 ++@item 78.664 ++The byte order of the @samp{boot_device} in Multiboot information is 78.665 ++reversed. This was a mistake. 78.666 ++ 78.667 ++@item 78.668 ++The offset of the address fields were wrong. 78.669 ++ 78.670 ++@item 78.671 ++The format is adapted to a newer Texinfo, and the version number is 78.672 ++specified more explicitly in the title. 78.673 + @end itemize 78.674 + 78.675 + @item 0.6 78.676 +diff -uprN grub-0.97/grub/asmstub.c grub/grub/asmstub.c 78.677 +--- grub-0.97/grub/asmstub.c 2005-02-16 20:45:14.000000000 +0000 78.678 ++++ grub/grub/asmstub.c 2008-03-28 13:22:28.000000000 +0000 78.679 +@@ -55,6 +55,10 @@ int grub_stage2 (void); 78.680 + # endif /* ! BLKFLSBUF */ 78.681 + #endif /* __linux__ */ 78.682 + 78.683 ++#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__) 78.684 ++# include <sys/sysctl.h> 78.685 ++#endif 78.686 ++ 78.687 + /* We want to prevent any circularararity in our stubs, as well as 78.688 + libc name clashes. */ 78.689 + #define WITHOUT_LIBC_STUBS 1 78.690 +@@ -777,7 +781,39 @@ get_diskinfo (int drive, struct geometry 78.691 + 78.692 + /* Open read/write, or read-only if that failed. */ 78.693 + if (! read_only) 78.694 +- disks[drive].flags = open (devname, O_RDWR); 78.695 ++ { 78.696 ++/* By default, kernel of FreeBSD does not allow overwriting MBR */ 78.697 ++#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__) 78.698 ++#define GEOM_SYSCTL "kern.geom.debugflags" 78.699 ++ int old_flags, flags; 78.700 ++ size_t sizeof_int = sizeof (int); 78.701 ++ 78.702 ++ if (sysctlbyname (GEOM_SYSCTL, &old_flags, &sizeof_int, NULL, 0) != 0) 78.703 ++ grub_printf ("failed to get " GEOM_SYSCTL "sysctl: %s\n", strerror (errno)); 78.704 ++ 78.705 ++ if ((old_flags & 0x10) == 0) 78.706 ++ { 78.707 ++ /* "allow foot shooting", see geom(4) */ 78.708 ++ flags = old_flags | 0x10; 78.709 ++ 78.710 ++ if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &flags, sizeof (int)) != 0) 78.711 ++ { 78.712 ++ flags = old_flags; 78.713 ++ grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno)); 78.714 ++ } 78.715 ++ } 78.716 ++ else 78.717 ++ flags = old_flags; 78.718 ++#endif 78.719 ++ disks[drive].flags = open (devname, O_RDWR); 78.720 ++#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__) 78.721 ++ if (flags != old_flags) 78.722 ++ { 78.723 ++ if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &old_flags, sizeof (int)) != 0) 78.724 ++ grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (errno)); 78.725 ++ } 78.726 ++#endif 78.727 ++ } 78.728 + 78.729 + if (disks[drive].flags == -1) 78.730 + { 78.731 +@@ -926,7 +962,7 @@ hex_dump (void *buf, size_t size) 78.732 + 78.733 + int 78.734 + biosdisk (int subfunc, int drive, struct geometry *geometry, 78.735 +- int sector, int nsec, int segment) 78.736 ++ unsigned int sector, int nsec, int segment) 78.737 + { 78.738 + char *buf; 78.739 + int fd = geometry->flags; 78.740 +diff -uprN grub-0.97/grub/main.c grub/grub/main.c 78.741 +--- grub-0.97/grub/main.c 2003-07-09 12:45:36.000000000 +0100 78.742 ++++ grub/grub/main.c 2006-05-05 22:43:46.000000000 +0100 78.743 +@@ -32,6 +32,7 @@ int grub_stage2 (void); 78.744 + #define WITHOUT_LIBC_STUBS 1 78.745 + #include <shared.h> 78.746 + #include <term.h> 78.747 ++#include <device.h> 78.748 + 78.749 + char *program_name = 0; 78.750 + int use_config_file = 1; 78.751 +@@ -192,6 +193,12 @@ main (int argc, char **argv) 78.752 + perror ("strtoul"); 78.753 + exit (1); 78.754 + } 78.755 ++ if (boot_drive >= NUM_DISKS) 78.756 ++ { 78.757 ++ fprintf (stderr, "boot_drive should be from 0 to %d\n", 78.758 ++ NUM_DISKS - 1); 78.759 ++ exit (1); 78.760 ++ } 78.761 + break; 78.762 + 78.763 + case OPT_NO_CONFIG_FILE: 78.764 +diff -uprN grub-0.97/lib/device.c grub/lib/device.c 78.765 +--- grub-0.97/lib/device.c 2005-03-28 00:14:25.000000000 +0100 78.766 ++++ grub/lib/device.c 2008-03-28 13:22:28.000000000 +0000 78.767 +@@ -69,9 +69,9 @@ struct hd_geometry 78.768 + # ifndef CDROM_GET_CAPABILITY 78.769 + # define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ 78.770 + # endif /* ! CDROM_GET_CAPABILITY */ 78.771 +-# ifndef BLKGETSIZE 78.772 +-# define BLKGETSIZE _IO(0x12,96) /* return device size */ 78.773 +-# endif /* ! BLKGETSIZE */ 78.774 ++# ifndef BLKGETSIZE64 78.775 ++# define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size */ 78.776 ++# endif /* ! BLKGETSIZE64 */ 78.777 + #endif /* __linux__ */ 78.778 + 78.779 + /* Use __FreeBSD_kernel__ instead of __FreeBSD__ for compatibility with 78.780 +@@ -152,19 +152,19 @@ get_drive_geometry (struct geometry *geo 78.781 + /* Linux */ 78.782 + { 78.783 + struct hd_geometry hdg; 78.784 +- unsigned long nr; 78.785 ++ unsigned long long nr; 78.786 + 78.787 + if (ioctl (fd, HDIO_GETGEO, &hdg)) 78.788 + goto fail; 78.789 + 78.790 +- if (ioctl (fd, BLKGETSIZE, &nr)) 78.791 ++ if (ioctl (fd, BLKGETSIZE64, &nr)) 78.792 + goto fail; 78.793 + 78.794 + /* Got the geometry, so save it. */ 78.795 + geom->cylinders = hdg.cylinders; 78.796 + geom->heads = hdg.heads; 78.797 + geom->sectors = hdg.sectors; 78.798 +- geom->total_sectors = nr; 78.799 ++ geom->total_sectors = nr / 512; 78.800 + 78.801 + goto success; 78.802 + } 78.803 +@@ -407,6 +407,12 @@ get_ataraid_disk_name (char *name, int u 78.804 + { 78.805 + sprintf (name, "/dev/ataraid/d%c", unit + '0'); 78.806 + } 78.807 ++ 78.808 ++static void 78.809 ++get_i2o_disk_name (char *name, char unit) 78.810 ++{ 78.811 ++ sprintf (name, "/dev/i2o/hd%c", unit); 78.812 ++} 78.813 + #endif 78.814 + 78.815 + /* Check if DEVICE can be read. If an error occurs, return zero, 78.816 +@@ -801,6 +807,29 @@ init_device_map (char ***map, const char 78.817 + } 78.818 + } 78.819 + } 78.820 ++ 78.821 ++ /* This is for I2O - we have /dev/i2o/hd<logical drive><partition> */ 78.822 ++ { 78.823 ++ int unit; 78.824 ++ 78.825 ++ for (unit = 'a'; unit < 'f'; unit++) 78.826 ++ { 78.827 ++ char name[24]; 78.828 ++ 78.829 ++ get_i2o_disk_name (name, unit); 78.830 ++ if (check_device (name)) 78.831 ++ { 78.832 ++ (*map)[num_hd + 0x80] = strdup (name); 78.833 ++ assert ((*map)[num_hd + 0x80]); 78.834 ++ 78.835 ++ /* If the device map file is opened, write the map. */ 78.836 ++ if (fp) 78.837 ++ fprintf (fp, "(hd%d)\t%s\n", num_hd, name); 78.838 ++ 78.839 ++ num_hd++; 78.840 ++ } 78.841 ++ } 78.842 ++ } 78.843 + #endif /* __linux__ */ 78.844 + 78.845 + /* OK, close the device map file if opened. */ 78.846 +@@ -861,6 +890,12 @@ write_to_partition (char **map, int driv 78.847 + if (strcmp (dev + strlen(dev) - 5, "/disc") == 0) 78.848 + strcpy (dev + strlen(dev) - 5, "/part"); 78.849 + } 78.850 ++ else 78.851 ++ { 78.852 ++ if ((strncmp (dev, "/dev/ataraid/", 13) == 0) || 78.853 ++ (strncmp (dev, "/dev/rd/", 8) == 0)) 78.854 ++ strcpy (dev + strlen(dev), "p"); 78.855 ++ } 78.856 + sprintf (dev + strlen(dev), "%d", ((partition >> 16) & 0xFF) + 1); 78.857 + 78.858 + /* Open the partition. */ 78.859 +diff -uprN grub-0.97/netboot/3c509.c grub/netboot/3c509.c 78.860 +--- grub-0.97/netboot/3c509.c 2003-07-09 12:45:37.000000000 +0100 78.861 ++++ grub/netboot/3c509.c 2002-01-02 21:56:40.000000000 +0000 78.862 +@@ -18,7 +18,7 @@ Author: Martin Renters. 78.863 + 78.864 + 3c509 support added by Serge Babkin (babkin@hq.icb.chel.su) 78.865 + 78.866 +-$Id: 3c509.c,v 1.4 2002/01/02 21:56:40 okuji Exp $ 78.867 ++$Id: 3c509.c 609 2002-01-02 21:56:40Z okuji $ 78.868 + 78.869 + ***************************************************************************/ 78.870 + 78.871 +diff -uprN grub-0.97/netboot/cs89x0.c grub/netboot/cs89x0.c 78.872 +--- grub-0.97/netboot/cs89x0.c 2003-07-09 12:45:37.000000000 +0100 78.873 ++++ grub/netboot/cs89x0.c 2008-05-20 12:04:18.000000000 +0100 78.874 +@@ -1,3 +1,21 @@ 78.875 ++/** 78.876 ++ Per an email message from Russ Nelson <nelson@crynwr.com> on 78.877 ++ 18 March 2008 this file is now licensed under GPL Version 2. 78.878 ++ 78.879 ++ From: Russ Nelson <nelson@crynwr.com> 78.880 ++ Date: Tue, 18 Mar 2008 12:42:00 -0400 78.881 ++ Subject: Re: [Etherboot-developers] cs89x0 driver in etherboot 78.882 ++ -- quote from email 78.883 ++ As copyright holder, if I say it doesn't conflict with the GPL, 78.884 ++ then it doesn't conflict with the GPL. 78.885 ++ 78.886 ++ However, there's no point in causing people's brains to overheat, 78.887 ++ so yes, I grant permission for the code to be relicensed under the 78.888 ++ GPLv2. Please make sure that this change in licensing makes its 78.889 ++ way upstream. -russ 78.890 ++ -- quote from email 78.891 ++**/ 78.892 ++ 78.893 + /* cs89x0.c: A Crystal Semiconductor CS89[02]0 driver for etherboot. */ 78.894 + /* 78.895 + Permission is granted to distribute the enclosed cs89x0.[ch] driver 78.896 +diff -uprN grub-0.97/netboot/cs89x0.h grub/netboot/cs89x0.h 78.897 +--- grub-0.97/netboot/cs89x0.h 2003-07-09 12:45:37.000000000 +0100 78.898 ++++ grub/netboot/cs89x0.h 2008-05-20 12:04:18.000000000 +0100 78.899 +@@ -1,3 +1,21 @@ 78.900 ++/** 78.901 ++ Per an email message from Russ Nelson <nelson@crynwr.com> on 78.902 ++ 18 March 2008 this file is now licensed under GPL Version 2. 78.903 ++ 78.904 ++ From: Russ Nelson <nelson@crynwr.com> 78.905 ++ Date: Tue, 18 Mar 2008 12:42:00 -0400 78.906 ++ Subject: Re: [Etherboot-developers] cs89x0 driver in etherboot 78.907 ++ -- quote from email 78.908 ++ As copyright holder, if I say it doesn't conflict with the GPL, 78.909 ++ then it doesn't conflict with the GPL. 78.910 ++ 78.911 ++ However, there's no point in causing people's brains to overheat, 78.912 ++ so yes, I grant permission for the code to be relicensed under the 78.913 ++ GPLv2. Please make sure that this change in licensing makes its 78.914 ++ way upstream. -russ 78.915 ++ -- quote from email 78.916 ++**/ 78.917 ++ 78.918 + /* Copyright, 1988-1992, Russell Nelson, Crynwr Software 78.919 + 78.920 + This program is free software; you can redistribute it and/or modify 78.921 +diff -uprN grub-0.97/netboot/etherboot.h grub/netboot/etherboot.h 78.922 +--- grub-0.97/netboot/etherboot.h 2003-07-09 12:45:37.000000000 +0100 78.923 ++++ grub/netboot/etherboot.h 2006-09-08 13:56:22.000000000 +0100 78.924 +@@ -531,9 +531,6 @@ extern int ip_abort; 78.925 + extern int network_ready; 78.926 + extern struct rom_info rom; 78.927 + extern struct arptable_t arptable[MAX_ARP]; 78.928 +-extern struct bootpd_t bootp_data; 78.929 +-#define BOOTP_DATA_ADDR (&bootp_data) 78.930 +-extern unsigned char *end_of_rfc1533; 78.931 + 78.932 + /* config.c */ 78.933 + extern struct nic nic; 78.934 +diff -uprN grub-0.97/netboot/main.c grub/netboot/main.c 78.935 +--- grub-0.97/netboot/main.c 2004-05-20 23:19:33.000000000 +0100 78.936 ++++ grub/netboot/main.c 2006-09-08 13:56:22.000000000 +0100 78.937 +@@ -56,7 +56,8 @@ static int vendorext_isvalid; 78.938 + static unsigned long netmask; 78.939 + static struct bootpd_t bootp_data; 78.940 + static unsigned long xid; 78.941 +-static unsigned char *end_of_rfc1533 = NULL; 78.942 ++ 78.943 ++#define BOOTP_DATA_ADDR (&bootp_data) 78.944 + 78.945 + #ifndef NO_DHCP_SUPPORT 78.946 + #endif /* NO_DHCP_SUPPORT */ 78.947 +@@ -967,7 +968,6 @@ decode_rfc1533 (unsigned char *p, int bl 78.948 + 78.949 + if (block == 0) 78.950 + { 78.951 +- end_of_rfc1533 = NULL; 78.952 + vendorext_isvalid = 0; 78.953 + 78.954 + if (grub_memcmp (p, rfc1533_cookie, 4)) 78.955 +@@ -1021,7 +1021,7 @@ decode_rfc1533 (unsigned char *p, int bl 78.956 + } 78.957 + else if (c == RFC1533_END) 78.958 + { 78.959 +- end_of_rfc1533 = endp = p; 78.960 ++ endp = p; 78.961 + continue; 78.962 + } 78.963 + else if (c == RFC1533_NETMASK) 78.964 +diff -uprN grub-0.97/netboot/natsemi.c grub/netboot/natsemi.c 78.965 +--- grub-0.97/netboot/natsemi.c 2003-07-09 12:45:38.000000000 +0100 78.966 ++++ grub/netboot/natsemi.c 2006-09-10 08:26:10.000000000 +0100 78.967 +@@ -608,7 +608,7 @@ natsemi_transmit(struct nic *nic, 78.968 + const char *p) /* Packet */ 78.969 + { 78.970 + u32 status, to, nstype; 78.971 +- u32 tx_status; 78.972 ++ volatile u32 tx_status; 78.973 + 78.974 + /* Stop the transmitter */ 78.975 + outl(TxOff, ioaddr + ChipCmd); 78.976 +@@ -647,7 +647,7 @@ natsemi_transmit(struct nic *nic, 78.977 + 78.978 + to = currticks() + TX_TIMEOUT; 78.979 + 78.980 +- while ((((volatile u32) tx_status=txd.cmdsts) & OWN) && (currticks() < to)) 78.981 ++ while (((tx_status=txd.cmdsts) & OWN) && (currticks() < to)) 78.982 + /* wait */ ; 78.983 + 78.984 + if (currticks() >= to) { 78.985 +diff -uprN grub-0.97/netboot/sis900.c grub/netboot/sis900.c 78.986 +--- grub-0.97/netboot/sis900.c 2003-07-09 12:45:38.000000000 +0100 78.987 ++++ grub/netboot/sis900.c 2006-09-10 08:26:10.000000000 +0100 78.988 +@@ -901,7 +901,7 @@ sis900_transmit(struct nic *nic, 78.989 + const char *p) /* Packet */ 78.990 + { 78.991 + u32 status, to, nstype; 78.992 +- u32 tx_status; 78.993 ++ volatile u32 tx_status; 78.994 + 78.995 + /* Stop the transmitter */ 78.996 + outl(TxDIS, ioaddr + cr); 78.997 +@@ -940,7 +940,7 @@ sis900_transmit(struct nic *nic, 78.998 + 78.999 + to = currticks() + TX_TIMEOUT; 78.1000 + 78.1001 +- while ((((volatile u32) tx_status=txd.cmdsts) & OWN) && (currticks() < to)) 78.1002 ++ while (((tx_status=txd.cmdsts) & OWN) && (currticks() < to)) 78.1003 + /* wait */ ; 78.1004 + 78.1005 + if (currticks() >= to) { 78.1006 +diff -uprN grub-0.97/netboot/sk_g16.c grub/netboot/sk_g16.c 78.1007 +--- grub-0.97/netboot/sk_g16.c 2003-07-09 12:45:38.000000000 +0100 78.1008 ++++ grub/netboot/sk_g16.c 2002-01-02 21:56:40.000000000 +0000 78.1009 +@@ -13,12 +13,12 @@ Changes to make it work with Etherboot b 78.1010 + * 78.1011 + * Module : sk_g16.c 78.1012 + * 78.1013 +- * Version : $Revision: 1.4 $ 78.1014 ++ * Version : $Revision: 609 $ 78.1015 + * 78.1016 + * Author : Patrick J.D. Weichmann 78.1017 + * 78.1018 + * Date Created : 94/05/26 78.1019 +- * Last Updated : $Date: 2002/01/02 21:56:40 $ 78.1020 ++ * Last Updated : $Date: 2002-01-02 21:56:40 +0000 (mer 02 jan 2002) $ 78.1021 + * 78.1022 + * Description : Schneider & Koch G16 Ethernet Device Driver for 78.1023 + * Linux Kernel >= 1.1.22 78.1024 +diff -uprN grub-0.97/netboot/sk_g16.h grub/netboot/sk_g16.h 78.1025 +--- grub-0.97/netboot/sk_g16.h 2003-07-09 12:45:38.000000000 +0100 78.1026 ++++ grub/netboot/sk_g16.h 2000-07-29 20:22:54.000000000 +0100 78.1027 +@@ -4,7 +4,7 @@ 78.1028 + * of the GNU Public License, incorporated herein by reference. 78.1029 + * 78.1030 + * Module : sk_g16.h 78.1031 +- * Version : $Revision: 1.3 $ 78.1032 ++ * Version : $Revision: 388 $ 78.1033 + * 78.1034 + * Author : M.Hipp (mhipp@student.uni-tuebingen.de) 78.1035 + * changes by : Patrick J.D. Weichmann 78.1036 +@@ -15,8 +15,8 @@ 78.1037 + * the am7990 (LANCE) chip used for writing a 78.1038 + * network device driver which uses this chip 78.1039 + * 78.1040 +- * $Log: sk_g16.h,v $ 78.1041 +- * Revision 1.3 2000/07/29 19:22:54 okuji 78.1042 ++ * $Log$ 78.1043 ++ * Revision 1.3 2000-07-29 19:22:54 okuji 78.1044 + * update the network support to etherboot-4.6.4. 78.1045 + * 78.1046 + -*/ 78.1047 +diff -uprN grub-0.97/stage1/Makefile.am grub/stage1/Makefile.am 78.1048 +--- grub-0.97/stage1/Makefile.am 2004-07-16 12:44:56.000000000 +0100 78.1049 ++++ grub/stage1/Makefile.am 2007-11-05 01:29:46.000000000 +0000 78.1050 +@@ -5,7 +5,7 @@ CLEANFILES = $(nodist_pkglib_DATA) 78.1051 + 78.1052 + # We can't use builtins or standard includes. 78.1053 + AM_CCASFLAGS = $(STAGE1_CFLAGS) -fno-builtin -nostdinc 78.1054 +-LDFLAGS = -nostdlib -Wl,-N,-Ttext,7C00 78.1055 ++stage1_exec_LDFLAGS = -nostdlib -Wl,-N,-Ttext,7C00 78.1056 + 78.1057 + noinst_PROGRAMS = stage1.exec 78.1058 + stage1_exec_SOURCES = stage1.S stage1.h 78.1059 +diff -uprN grub-0.97/stage1/Makefile.in grub/stage1/Makefile.in 78.1060 +--- grub-0.97/stage1/Makefile.in 2005-05-08 03:42:36.000000000 +0100 78.1061 ++++ grub/stage1/Makefile.in 2007-11-05 01:29:46.000000000 +0000 78.1062 +@@ -110,7 +110,7 @@ INSTALL_DATA = @INSTALL_DATA@ 78.1063 + INSTALL_PROGRAM = @INSTALL_PROGRAM@ 78.1064 + INSTALL_SCRIPT = @INSTALL_SCRIPT@ 78.1065 + INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 78.1066 +-LDFLAGS = -nostdlib -Wl,-N,-Ttext,7C00 78.1067 ++LDFLAGS = @LDFLAGS@ 78.1068 + LIBOBJS = @LIBOBJS@ 78.1069 + LIBS = @LIBS@ 78.1070 + LTLIBOBJS = @LTLIBOBJS@ 78.1071 +@@ -188,6 +188,7 @@ CLEANFILES = $(nodist_pkglib_DATA) 78.1072 + 78.1073 + # We can't use builtins or standard includes. 78.1074 + AM_CCASFLAGS = $(STAGE1_CFLAGS) -fno-builtin -nostdinc 78.1075 ++stage1_exec_LDFLAGS = -nostdlib -Wl,-N,-Ttext,7C00 78.1076 + stage1_exec_SOURCES = stage1.S stage1.h 78.1077 + SUFFIXES = .exec 78.1078 + all: all-am 78.1079 +diff -uprN grub-0.97/stage2/bios.c grub/stage2/bios.c 78.1080 +--- grub-0.97/stage2/bios.c 2004-03-27 16:34:04.000000000 +0000 78.1081 ++++ grub/stage2/bios.c 2008-03-28 13:22:28.000000000 +0000 78.1082 +@@ -47,7 +47,7 @@ extern int get_diskinfo_floppy (int driv 78.1083 + return the error number. Otherwise, return 0. */ 78.1084 + int 78.1085 + biosdisk (int read, int drive, struct geometry *geometry, 78.1086 +- int sector, int nsec, int segment) 78.1087 ++ unsigned int sector, int nsec, int segment) 78.1088 + { 78.1089 + int err; 78.1090 + 78.1091 +diff -uprN grub-0.97/stage2/boot.c grub/stage2/boot.c 78.1092 +--- grub-0.97/stage2/boot.c 2004-03-30 12:44:08.000000000 +0100 78.1093 ++++ grub/stage2/boot.c 2005-09-28 22:47:55.000000000 +0100 78.1094 +@@ -1,7 +1,7 @@ 78.1095 + /* boot.c - load and bootstrap a kernel */ 78.1096 + /* 78.1097 + * GRUB -- GRand Unified Bootloader 78.1098 +- * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc. 78.1099 ++ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc. 78.1100 + * 78.1101 + * This program is free software; you can redistribute it and/or modify 78.1102 + * it under the terms of the GNU General Public License as published by 78.1103 +@@ -96,7 +96,7 @@ load_image (char *kernel, char *arg, ker 78.1104 + lh = (struct linux_kernel_header *) buffer; 78.1105 + 78.1106 + /* ELF loading supported if multiboot, FreeBSD and NetBSD. */ 78.1107 +- if ((type == KERNEL_TYPE_MULTIBOOT 78.1108 ++ if (((type == KERNEL_TYPE_MULTIBOOT && ! (flags & MULTIBOOT_AOUT_KLUDGE)) 78.1109 + || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD 78.1110 + || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0 78.1111 + || suggested_type == KERNEL_TYPE_NETBSD) 78.1112 +diff -uprN grub-0.97/stage2/builtins.c grub/stage2/builtins.c 78.1113 +--- grub-0.97/stage2/builtins.c 2005-02-15 21:58:23.000000000 +0000 78.1114 ++++ grub/stage2/builtins.c 2006-03-21 20:51:58.000000000 +0000 78.1115 +@@ -3830,15 +3830,15 @@ setup_func (char *arg, int flags) 78.1116 + { 78.1117 + char tmp[16]; 78.1118 + grub_sprintf (tmp, ",%d", (partition >> 16) & 0xFF); 78.1119 +- grub_strncat (device, tmp, 256); 78.1120 ++ grub_strncat (device, tmp, sizeof (device)); 78.1121 + } 78.1122 + if ((partition & 0x00FF00) != 0x00FF00) 78.1123 + { 78.1124 + char tmp[16]; 78.1125 + grub_sprintf (tmp, ",%c", 'a' + ((partition >> 8) & 0xFF)); 78.1126 +- grub_strncat (device, tmp, 256); 78.1127 ++ grub_strncat (device, tmp, sizeof (device)); 78.1128 + } 78.1129 +- grub_strncat (device, ")", 256); 78.1130 ++ grub_strncat (device, ")", sizeof (device)); 78.1131 + } 78.1132 + 78.1133 + int embed_stage1_5 (char *stage1_5, int drive, int partition) 78.1134 +diff -uprN grub-0.97/stage2/disk_io.c grub/stage2/disk_io.c 78.1135 +--- grub-0.97/stage2/disk_io.c 2004-05-23 17:35:24.000000000 +0100 78.1136 ++++ grub/stage2/disk_io.c 2008-03-28 13:22:28.000000000 +0000 78.1137 +@@ -137,7 +137,7 @@ log2 (unsigned long word) 78.1138 + } 78.1139 + 78.1140 + int 78.1141 +-rawread (int drive, int sector, int byte_offset, int byte_len, char *buf) 78.1142 ++rawread (int drive, unsigned int sector, int byte_offset, int byte_len, char *buf) 78.1143 + { 78.1144 + int slen, sectors_per_vtrack; 78.1145 + int sector_size_bits = log2 (buf_geom.sector_size); 78.1146 +@@ -261,7 +261,7 @@ rawread (int drive, int sector, int byte 78.1147 + */ 78.1148 + if (disk_read_func) 78.1149 + { 78.1150 +- int sector_num = sector; 78.1151 ++ unsigned int sector_num = sector; 78.1152 + int length = buf_geom.sector_size - byte_offset; 78.1153 + if (length > size) 78.1154 + length = size; 78.1155 +@@ -291,7 +291,7 @@ rawread (int drive, int sector, int byte 78.1156 + 78.1157 + 78.1158 + int 78.1159 +-devread (int sector, int byte_offset, int byte_len, char *buf) 78.1160 ++devread (unsigned int sector, int byte_offset, int byte_len, char *buf) 78.1161 + { 78.1162 + /* 78.1163 + * Check partition boundaries 78.1164 +@@ -330,7 +330,7 @@ devread (int sector, int byte_offset, in 78.1165 + 78.1166 + #ifndef STAGE1_5 78.1167 + int 78.1168 +-rawwrite (int drive, int sector, char *buf) 78.1169 ++rawwrite (int drive, unsigned int sector, char *buf) 78.1170 + { 78.1171 + if (sector == 0) 78.1172 + { 78.1173 +@@ -363,7 +363,7 @@ rawwrite (int drive, int sector, char *b 78.1174 + } 78.1175 + 78.1176 + int 78.1177 +-devwrite (int sector, int sector_count, char *buf) 78.1178 ++devwrite (unsigned int sector, int sector_count, char *buf) 78.1179 + { 78.1180 + #if defined(GRUB_UTIL) && defined(__linux__) 78.1181 + if (current_partition != 0xFFFFFF 78.1182 +diff -uprN grub-0.97/stage2/fsys_ffs.c grub/stage2/fsys_ffs.c 78.1183 +--- grub-0.97/stage2/fsys_ffs.c 2003-07-09 12:45:52.000000000 +0100 78.1184 ++++ grub/stage2/fsys_ffs.c 2001-11-12 06:57:29.000000000 +0000 78.1185 +@@ -50,7 +50,7 @@ 78.1186 + * the rights to redistribute these changes. 78.1187 + * 78.1188 + * from: Mach, Revision 2.2 92/04/04 11:35:49 rpd 78.1189 +- * $Id: fsys_ffs.c,v 1.10 2001/11/12 06:57:29 okuji Exp $ 78.1190 ++ * $Id: fsys_ffs.c 594 2001-11-12 06:57:29Z okuji $ 78.1191 + */ 78.1192 + 78.1193 + #ifdef FSYS_FFS 78.1194 +diff -uprN grub-0.97/stage2/fsys_ufs2.c grub/stage2/fsys_ufs2.c 78.1195 +--- grub-0.97/stage2/fsys_ufs2.c 2004-06-19 13:17:52.000000000 +0100 78.1196 ++++ grub/stage2/fsys_ufs2.c 2004-06-19 13:17:52.000000000 +0100 78.1197 +@@ -51,7 +51,7 @@ 78.1198 + * the rights to redistribute these changes. 78.1199 + * 78.1200 + * from: Mach, Revision 2.2 92/04/04 11:35:49 rpd 78.1201 +- * $Id: fsys_ufs2.c,v 1.2 2004/06/19 12:17:52 okuji Exp $ 78.1202 ++ * $Id: fsys_ufs2.c 841 2004-06-19 12:17:52Z okuji $ 78.1203 + */ 78.1204 + 78.1205 + #ifdef FSYS_UFS2 78.1206 +diff -uprN grub-0.97/stage2/imgact_aout.h grub/stage2/imgact_aout.h 78.1207 +--- grub-0.97/stage2/imgact_aout.h 2003-07-09 12:45:53.000000000 +0100 78.1208 ++++ grub/stage2/imgact_aout.h 1999-06-24 01:03:29.000000000 +0100 78.1209 +@@ -32,7 +32,7 @@ 78.1210 + * SUCH DAMAGE. 78.1211 + * 78.1212 + * from: @(#)exec.h 8.1 (Berkeley) 6/11/93 78.1213 +- * $Id: imgact_aout.h,v 1.1 1999/06/24 00:03:22 okuji Exp $ 78.1214 ++ * $Id: imgact_aout.h 98 1999-06-24 00:03:29Z okuji $ 78.1215 + */ 78.1216 + /* 78.1217 + * 11/23/95 - Kludge to get "ntohl" null macro added. -- ESB 78.1218 +diff -uprN grub-0.97/stage2/iso9660.h grub/stage2/iso9660.h 78.1219 +--- grub-0.97/stage2/iso9660.h 2004-03-27 16:02:38.000000000 +0000 78.1220 ++++ grub/stage2/iso9660.h 2007-02-22 23:40:25.000000000 +0000 78.1221 +@@ -73,11 +73,11 @@ typedef union { 78.1222 + 78.1223 + typedef struct __iso_16bit { 78.1224 + u_int16_t l, b; 78.1225 +-} iso_16bit_t __attribute__ ((packed)); 78.1226 ++} iso_16bit_t; 78.1227 + 78.1228 + typedef struct __iso_32bit { 78.1229 + u_int32_t l, b; 78.1230 +-} iso_32bit_t __attribute__ ((packed)); 78.1231 ++} iso_32bit_t; 78.1232 + 78.1233 + typedef u_int8_t iso_date_t[7]; 78.1234 + 78.1235 +diff -uprN grub-0.97/stage2/shared.h grub/stage2/shared.h 78.1236 +--- grub-0.97/stage2/shared.h 2004-06-19 17:40:09.000000000 +0100 78.1237 ++++ grub/stage2/shared.h 2008-03-28 13:22:28.000000000 +0000 78.1238 +@@ -499,7 +499,11 @@ struct vbe_mode 78.1239 + unsigned char linear_reserved_field_position; 78.1240 + unsigned long max_pixel_clock; 78.1241 + 78.1242 +- unsigned char reserved3[189]; 78.1243 ++ /* Reserved field to make structure to be 256 bytes long, VESA BIOS 78.1244 ++ Extension 3.0 Specification says to reserve 189 bytes here but 78.1245 ++ that doesn't make structure to be 256 bytes. So additional one is 78.1246 ++ added here. */ 78.1247 ++ unsigned char reserved3[189 + 1]; 78.1248 + } __attribute__ ((packed)); 78.1249 + 78.1250 + 78.1251 +@@ -807,7 +811,7 @@ int checkkey (void); 78.1252 + /* Low-level disk I/O */ 78.1253 + int get_diskinfo (int drive, struct geometry *geometry); 78.1254 + int biosdisk (int subfunc, int drive, struct geometry *geometry, 78.1255 +- int sector, int nsec, int segment); 78.1256 ++ unsigned int sector, int nsec, int segment); 78.1257 + void stop_floppy (void); 78.1258 + 78.1259 + /* Command-line interface functions. */ 78.1260 +@@ -920,10 +924,10 @@ int gunzip_test_header (void); 78.1261 + int gunzip_read (char *buf, int len); 78.1262 + #endif /* NO_DECOMPRESSION */ 78.1263 + 78.1264 +-int rawread (int drive, int sector, int byte_offset, int byte_len, char *buf); 78.1265 +-int devread (int sector, int byte_offset, int byte_len, char *buf); 78.1266 +-int rawwrite (int drive, int sector, char *buf); 78.1267 +-int devwrite (int sector, int sector_len, char *buf); 78.1268 ++int rawread (int drive, unsigned int sector, int byte_offset, int byte_len, char *buf); 78.1269 ++int devread (unsigned int sector, int byte_offset, int byte_len, char *buf); 78.1270 ++int rawwrite (int drive, unsigned int sector, char *buf); 78.1271 ++int devwrite (unsigned int sector, int sector_len, char *buf); 78.1272 + 78.1273 + /* Parse a device string and initialize the global parameters. */ 78.1274 + char *set_device (char *device); 78.1275 +diff -uprN grub-0.97/stage2/stage2.c grub/stage2/stage2.c 78.1276 +--- grub-0.97/stage2/stage2.c 2005-03-19 17:51:57.000000000 +0000 78.1277 ++++ grub/stage2/stage2.c 2006-05-05 23:06:31.000000000 +0100 78.1278 +@@ -651,7 +651,10 @@ restart: 78.1279 + *(new_heap++) = 0; 78.1280 + 78.1281 + if (config_entries) 78.1282 +- run_menu (heap, NULL, new_num_entries, new_heap, 0); 78.1283 ++ { 78.1284 ++ current_entryno = first_entry + entryno; 78.1285 ++ run_menu (heap, NULL, new_num_entries, new_heap, 0); 78.1286 ++ } 78.1287 + else 78.1288 + { 78.1289 + cls (); 78.1290 +@@ -727,7 +730,8 @@ restart: 78.1291 + cur_entry = get_entry (config_entries, first_entry + entryno, 1); 78.1292 + 78.1293 + /* Set CURRENT_ENTRYNO for the command "savedefault". */ 78.1294 +- current_entryno = first_entry + entryno; 78.1295 ++ if (config_entries) 78.1296 ++ current_entryno = first_entry + entryno; 78.1297 + 78.1298 + if (run_script (cur_entry, heap)) 78.1299 + { 78.1300 +diff -uprN grub-0.97/stage2/tparm.c grub/stage2/tparm.c 78.1301 +--- grub-0.97/stage2/tparm.c 2003-07-09 12:45:53.000000000 +0100 78.1302 ++++ grub/stage2/tparm.c 2002-11-29 20:39:24.000000000 +0000 78.1303 +@@ -63,7 +63,7 @@ typedef char grub_bool; 78.1304 + #define MAX_FORMAT_LEN 256 78.1305 + #define max(a,b) ((a) > (b) ? (a) : (b)) 78.1306 + 78.1307 +-//MODULE_ID("$Id: tparm.c,v 1.1 2002/11/29 20:39:24 okuji Exp $") 78.1308 ++//MODULE_ID("$Id: tparm.c 708 2002-11-29 20:39:24Z okuji $") 78.1309 + 78.1310 + /* 78.1311 + * char * 78.1312 +diff -uprN grub-0.97/stamp-h.in grub/stamp-h.in 78.1313 +--- grub-0.97/stamp-h.in 1970-01-01 01:00:00.000000000 +0100 78.1314 ++++ grub/stamp-h.in 1999-09-13 14:32:31.000000000 +0100 78.1315 +@@ -0,0 +1 @@ 78.1316 ++timestamp 78.1317 +diff -uprN grub-0.97/THANKS grub/THANKS 78.1318 +--- grub-0.97/THANKS 2005-05-08 03:17:43.000000000 +0100 78.1319 ++++ grub/THANKS 2006-03-21 20:51:58.000000000 +0000 78.1320 +@@ -121,3 +121,4 @@ Vesa Jaaskelainen <jaaskela@tietomyrsky. 78.1321 + Yedidyah Bar-David <didi@post.tau.ac.il> 78.1322 + Yury V. Umanets <umka@namesys.com> 78.1323 + Yuri Zaporogets <yuriz@ukr.net> 78.1324 ++Vitaly Fertman <vitaly@namesys.com> 78.1325 +diff -uprN grub-0.97/util/grub-install.in grub/util/grub-install.in 78.1326 +--- grub-0.97/util/grub-install.in 2004-07-24 19:57:31.000000000 +0100 78.1327 ++++ grub/util/grub-install.in 2006-04-20 14:46:46.000000000 +0100 78.1328 +@@ -112,8 +112,8 @@ convert () { 78.1329 + tmp_disk=`echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%'` 78.1330 + tmp_part=`echo "$1" | sed "s%$tmp_disk%%"` ;; 78.1331 + freebsd* | kfreebsd*-gnu) 78.1332 +- tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%r\1%' \ 78.1333 +- | sed 's%r\{0,1\}\(da[0-9]*\).*$%r\1%'` 78.1334 ++ tmp_disk=`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%\1%' \ 78.1335 ++ | sed 's%r\{0,1\}\(da[0-9]*\).*$%\1%'` 78.1336 + tmp_part=`echo "$1" \ 78.1337 + | sed "s%.*/r\{0,1\}[saw]d[0-9]\(s[0-9]*[a-h]\)%\1%" \ 78.1338 + | sed "s%.*/r\{0,1\}da[0-9]\(s[0-9]*[a-h]\)%\1%"` 78.1339 +diff -uprN grub-0.97/util/mkbimage grub/util/mkbimage 78.1340 +--- grub-0.97/util/mkbimage 2004-07-24 19:57:31.000000000 +0100 78.1341 ++++ grub/util/mkbimage 2007-02-22 16:01:03.000000000 +0000 78.1342 +@@ -1,7 +1,7 @@ 78.1343 + #!/bin/sh 78.1344 + # MaKe a Bootable IMAGE --- 1.44, 2.88 and El Torito no-emulation mode 78.1345 + # C) 2001,2002,2003 Thierry Laronde <tlaronde@polynum.org> 78.1346 +-# C) 2001,2002,2003 Robert Millan <robertmh@gnu.org> 78.1347 ++# C) 2001,2002,2003 Robert Millan <rmh@aybabtu.com> 78.1348 + 78.1349 + 78.1350 + # This program is free software; you can redistribute it and/or modify 78.1351 +@@ -19,7 +19,7 @@ 78.1352 + # program's maintainer or write to: The Free Software Foundation, 78.1353 + # Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. 78.1354 + 78.1355 +-# $Id: mkbimage,v 1.19 2004/07/21 14:43:04 robertmh Exp $ 78.1356 ++# $Id: mkbimage 1233 2007-02-22 16:01:03Z robertmh $ 78.1357 + 78.1358 + # Global variables 78.1359 + tarfile= 78.1360 +@@ -58,7 +58,7 @@ stage2_os_name= 78.1361 + 78.1362 + # Name by which this script was invoked. 78.1363 + program=`echo "$0" | sed -e 's/[^\/]*\///g'` 78.1364 +-version_number='$Revision: 1.19 $' 78.1365 ++version_number='$Revision: 1233 $' 78.1366 + 78.1367 + usage=" 78.1368 + Usage: $program [-hVF] [-t TYPE] [-d DIRECTORY] [-s FS_TYPE] -f TAR_FILE 78.1369 +@@ -94,15 +94,13 @@ Options: 78.1370 + display Version information and exit 78.1371 + 78.1372 + Copyright (c) 2001,2002,2003 Thierry Laronde <tlaronde@polynum.org>. 78.1373 +-Copyright (c) 2001,2002 Robert Millan <zeratul2@wanadoo.es>. 78.1374 + GPLed." 78.1375 + 78.1376 + version="mkbimage $version_number 78.1377 + 78.1378 +-Written by Thierry Laronde and Robert Millan. 78.1379 ++Written by Thierry Laronde. 78.1380 + 78.1381 + Copyright (c) 2001,2002,2003 Thierry Laronde <tlaronde@polynum.org>. 78.1382 +-Copyright (c) 2001,2002,2003 Robert Millan <zeratul2@wanadoo.es>. 78.1383 + 78.1384 + This is free software under the GPL version 2 or later; see the source for 78.1385 + copying conditions. There is NO warranty, not even for MERCHANTABILITY or
79.1 --- a/stubdom/grub.patches/99minios Tue Jul 08 11:41:43 2008 +0900 79.2 +++ b/stubdom/grub.patches/99minios Fri Jul 18 12:12:41 2008 +0900 79.3 @@ -1465,3 +1465,31 @@ Index: grub/stage2/stage2.c 79.4 # endif /* SUPPORT_DISKLESS */ 79.5 79.6 static int preset_menu_offset; 79.7 +Index: grub/stage2/fsys_xfs.c 79.8 +=================================================================== 79.9 +RCS file: /sources/grub/grub/stage2/fsys_xfs.c,v 79.10 +retrieving revision 1.5 79.11 +diff -u -p -r1.5 fsys_xfs.c 79.12 +--- grub/stage2/fsys_xfs.c 8 May 2005 02:18:14 -0000 1.5 79.13 ++++ grub/stage2/fsys_xfs.c 10 Jul 2008 13:09:50 -0000 79.14 +@@ -101,7 +101,7 @@ static inline __const__ xfs_uint16_t 79.15 + le16 (xfs_uint16_t x) 79.16 + { 79.17 + __asm__("xchgb %b0,%h0" \ 79.18 +- : "=q" (x) \ 79.19 ++ : "=Q" (x) \ 79.20 + : "0" (x)); \ 79.21 + return x; 79.22 + } 79.23 +@@ -109,9 +109,9 @@ le16 (xfs_uint16_t x) 79.24 + static inline __const__ xfs_uint32_t 79.25 + le32 (xfs_uint32_t x) 79.26 + { 79.27 +-#if 0 79.28 ++#if 1 79.29 + /* 386 doesn't have bswap. */ 79.30 +- __asm__("bswap %0" : "=r" (x) : "0" (x)); 79.31 ++ __asm__("bswapl %k0" : "=r" (x) : "0" (x)); 79.32 + #else 79.33 + /* This is slower but this works on all x86 architectures. */ 79.34 + __asm__("xchgb %b0, %h0" \
80.1 --- a/stubdom/grub/Makefile Tue Jul 08 11:41:43 2008 +0900 80.2 +++ b/stubdom/grub/Makefile Fri Jul 18 12:12:41 2008 +0900 80.3 @@ -1,14 +1,14 @@ 80.4 XEN_ROOT = ../.. 80.5 80.6 include $(XEN_ROOT)/Config.mk 80.7 -vpath %.c ../grub-cvs 80.8 +vpath %.c ../grub-upstream 80.9 80.10 BOOT=boot-$(XEN_TARGET_ARCH).o 80.11 80.12 DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libxc -I$(XEN_ROOT)/tools/include -I. 80.13 -DEF_CPPFLAGS += -I../grub-cvs/stage1 80.14 -DEF_CPPFLAGS += -I../grub-cvs/stage2 80.15 -DEF_CPPFLAGS += -I../grub-cvs/netboot 80.16 +DEF_CPPFLAGS += -I../grub-upstream/stage1 80.17 +DEF_CPPFLAGS += -I../grub-upstream/stage2 80.18 +DEF_CPPFLAGS += -I../grub-upstream/netboot 80.19 DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/firmware/vgabios 80.20 DEF_CPPFLAGS += -DWITHOUT_LIBC_STUBS 80.21 DEF_CPPFLAGS += -DSUPPORT_NETBOOT 80.22 @@ -51,10 +51,8 @@ CPPFLAGS += -DFSYS_UFS2=1 80.23 STAGE2_SOURCES+=fsys_vstafs.c 80.24 CPPFLAGS += -DFSYS_VSTAFS=1 80.25 80.26 -ifeq (0,1) 80.27 STAGE2_SOURCES+=fsys_xfs.c 80.28 CPPFLAGS += -DFSYS_XFS=1 80.29 -endif 80.30 80.31 STAGE2_SOURCES:=$(addprefix stage2/,$(STAGE2_SOURCES)) 80.32 NETBOOT_SOURCES:=$(addprefix netboot/,$(NETBOOT_SOURCES))
81.1 --- a/stubdom/grub/mini-os.c Tue Jul 08 11:41:43 2008 +0900 81.2 +++ b/stubdom/grub/mini-os.c Fri Jul 18 12:12:41 2008 +0900 81.3 @@ -681,7 +681,9 @@ int main(int argc, char *argv[]) 81.4 config_file[sizeof(config_file) - 1] = 0; 81.5 if (!strncmp(config_file, "(nd)", 4)) 81.6 preset_menu = "dhcp"; 81.7 - } else 81.8 + } else if (start_info.mod_len) 81.9 + preset_menu = (void*) start_info.mod_start; 81.10 + else 81.11 preset_menu = "dhcp --with-configfile"; 81.12 81.13 mbi.drives_addr = BOOTSEC_LOCATION + (60 * 1024);
82.1 --- a/stubdom/libpci.config.h Tue Jul 08 11:41:43 2008 +0900 82.2 +++ b/stubdom/libpci.config.h Fri Jul 18 12:12:41 2008 +0900 82.3 @@ -1,4 +1,4 @@ 82.4 -#define PCI_OS_STUBDOM 82.5 +#define PCI_OS_MINIOS 82.6 #define PCI_HAVE_STDINT_H 82.7 #define PCI_PATH_IDS_DIR "." 82.8 #define PCI_COMPRESSED_IDS
83.1 --- a/stubdom/libpci.config.mak Tue Jul 08 11:41:43 2008 +0900 83.2 +++ b/stubdom/libpci.config.mak Fri Jul 18 12:12:41 2008 +0900 83.3 @@ -1,2 +1,7 @@ 83.4 LIBZ=-lz 83.5 LDLIBS+=$(LIBZ) 83.6 +PCI_OS_MINIOS=1 83.7 +PCI_HAVE_STDINT_H=1 83.8 +PCI_PATH_IDS_DIR=. 83.9 +PCI_COMPRESSED_IDS=1 83.10 +PCI_IDS=pci.ids.gz
84.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 84.2 +++ b/stubdom/lwip.patch-cvs Fri Jul 18 12:12:41 2008 +0900 84.3 @@ -0,0 +1,2398 @@ 84.4 +? .ChangeLog.swp 84.5 +? ChangeLog 84.6 +Index: CHANGELOG 84.7 +=================================================================== 84.8 +RCS file: /sources/lwip/lwip/CHANGELOG,v 84.9 +retrieving revision 1.300 84.10 +retrieving revision 1.318 84.11 +diff -u -p -r1.300 -r1.318 84.12 +--- CHANGELOG 23 Mar 2008 13:49:39 -0000 1.300 84.13 ++++ CHANGELOG 14 Jul 2008 20:12:36 -0000 1.318 84.14 +@@ -19,9 +19,77 @@ HISTORY 84.15 + 84.16 + ++ New features: 84.17 + 84.18 ++ 2008-06-30 Simon Goldschmidt 84.19 ++ * mem.c, opt.h, stats.h: fixed bug #21433: Calling mem_free/pbuf_free from 84.20 ++ interrupt context isn't safe: LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT allows 84.21 ++ mem_free to run between mem_malloc iterations. Added illegal counter for 84.22 ++ mem stats. 84.23 ++ 84.24 ++ 2008-06-27 Simon Goldschmidt 84.25 ++ * stats.h/.c, some other files: patch #6483: stats module improvement: 84.26 ++ Added defines to display each module's statistic individually, added stats 84.27 ++ defines for MEM, MEMP and SYS modules, removed (unused) rexmit counter. 84.28 ++ 84.29 ++ 2008-06-17 Simon Goldschmidt 84.30 ++ * err.h: patch #6459: Made err_t overridable to use a more efficient type 84.31 ++ (define LWIP_ERR_T in cc.h) 84.32 ++ 84.33 ++ 2008-06-17 Simon Goldschmidt 84.34 ++ * slipif.c: patch #6480: Added a configuration option for slipif for symmetry 84.35 ++ to loopif 84.36 ++ 84.37 ++ 2008-06-17 Simon Goldschmidt (patch by Luca Ceresoli) 84.38 ++ * netif.c, loopif.c, ip.c, netif.h, loopif.h, opt.h: Checked in slightly 84.39 ++ modified version of patch # 6370: Moved loopif code to netif.c so that 84.40 ++ loopback traffic is supported on all netifs (all local IPs). 84.41 ++ Added option to limit loopback packets for each netifs. 84.42 ++ 84.43 + 84.44 + ++ Bugfixes: 84.45 + 84.46 ++ 2008-08-14 Simon Goldschmidt 84.47 ++ * api_msg.c: fixed bug #23847: do_close_internal references freed memory (when 84.48 ++ tcp_close returns != ERR_OK) 84.49 ++ 84.50 ++ 2008-07-08 Frédéric Bernon 84.51 ++ * stats.h: Fix some build bugs introduced with patch #6483 (missing some parameters 84.52 ++ in macros, mainly if MEM_STATS=0 and MEMP_STATS=0). 84.53 ++ 84.54 ++ 2008-06-24 Jonathan Larmour 84.55 ++ * tcp_in.c: Fix for bug #23693 as suggested by Art R. Ensure cseg is unused 84.56 ++ if tcp_seg_copy fails. 84.57 ++ 84.58 ++ 2008-06-17 Simon Goldschmidt 84.59 ++ * inet_chksum.c: Checked in some ideas of patch #6460 (loop optimizations) 84.60 ++ and created defines for swapping bytes and folding u32 to u16. 84.61 ++ 84.62 ++ 2008-05-30 Kieran Mansley 84.63 ++ * tcp_in.c Remove redundant "if" statement, and use real rcv_wnd 84.64 ++ rather than rcv_ann_wnd when deciding if packets are in-window. 84.65 ++ Contributed by <arasmussen@consultant.datasys.swri.edu> 84.66 ++ 84.67 ++ 2008-05-30 Kieran Mansley 84.68 ++ * mem.h: Fix BUG#23254. Change macro definition of mem_* to allow 84.69 ++ passing as function pointers when MEM_LIBC_MALLOC is defined. 84.70 ++ 84.71 ++ 2008-05-09 Jonathan Larmour 84.72 ++ * err.h, err.c, sockets.c: Fix bug #23119: Reorder timeout error code to 84.73 ++ stop it being treated as a fatal error. 84.74 ++ 84.75 ++ 2008-04-15 Simon Goldschmidt 84.76 ++ * dhcp.c: fixed bug #22804: dhcp_stop doesn't clear NETIF_FLAG_DHCP 84.77 ++ (flag now cleared) 84.78 ++ 84.79 ++ 2008-03-27 Simon Goldschmidt 84.80 ++ * mem.c, tcpip.c, tcpip.h, opt.h: fixed bug #21433 (Calling mem_free/pbuf_free 84.81 ++ from interrupt context isn't safe): set LWIP_USE_HEAP_FROM_INTERRUPT to 1 84.82 ++ in lwipopts.h or use pbuf_free_callback(p)/mem_free_callback(m) to free pbufs 84.83 ++ or heap memory from interrupt context 84.84 ++ 84.85 ++ 2008-03-26 Simon Goldschmidt 84.86 ++ * tcp_in.c, tcp.c: fixed bug #22249: division by zero could occur if a remote 84.87 ++ host sent a zero mss as TCP option. 84.88 ++ 84.89 + 84.90 + (STABLE-1.3.0) 84.91 + 84.92 +Index: src/api/api_msg.c 84.93 +=================================================================== 84.94 +RCS file: /sources/lwip/lwip/src/api/api_msg.c,v 84.95 +retrieving revision 1.102 84.96 +retrieving revision 1.104 84.97 +diff -u -p -r1.102 -r1.104 84.98 +--- src/api/api_msg.c 21 Mar 2008 16:23:14 -0000 1.102 84.99 ++++ src/api/api_msg.c 15 Jul 2008 11:18:58 -0000 1.104 84.100 +@@ -598,11 +598,16 @@ do_close_internal(struct netconn *conn) 84.101 + LWIP_ASSERT("pcb already closed", (conn->pcb.tcp != NULL)); 84.102 + 84.103 + /* Set back some callback pointers */ 84.104 ++ tcp_arg(conn->pcb.tcp, NULL); 84.105 + if (conn->pcb.tcp->state == LISTEN) { 84.106 +- tcp_arg(conn->pcb.tcp, NULL); 84.107 + tcp_accept(conn->pcb.tcp, NULL); 84.108 + } else { 84.109 + tcp_recv(conn->pcb.tcp, NULL); 84.110 ++ tcp_accept(conn->pcb.tcp, NULL); 84.111 ++ /* some callbacks have to be reset if tcp_close is not successful */ 84.112 ++ tcp_sent(conn->pcb.tcp, NULL); 84.113 ++ tcp_poll(conn->pcb.tcp, NULL, 4); 84.114 ++ tcp_err(conn->pcb.tcp, NULL); 84.115 + } 84.116 + /* Try to close the connection */ 84.117 + err = tcp_close(conn->pcb.tcp); 84.118 +@@ -610,11 +615,6 @@ do_close_internal(struct netconn *conn) 84.119 + /* Closing succeeded */ 84.120 + conn->state = NETCONN_NONE; 84.121 + /* Set back some callback pointers as conn is going away */ 84.122 +- tcp_err(conn->pcb.tcp, NULL); 84.123 +- tcp_poll(conn->pcb.tcp, NULL, 4); 84.124 +- tcp_sent(conn->pcb.tcp, NULL); 84.125 +- tcp_recv(conn->pcb.tcp, NULL); 84.126 +- tcp_arg(conn->pcb.tcp, NULL); 84.127 + conn->pcb.tcp = NULL; 84.128 + conn->err = ERR_OK; 84.129 + /* Trigger select() in socket layer. This send should something else so the 84.130 +@@ -623,6 +623,14 @@ do_close_internal(struct netconn *conn) 84.131 + API_EVENT(conn, NETCONN_EVT_SENDPLUS, 0); 84.132 + /* wake up the application task */ 84.133 + sys_sem_signal(conn->op_completed); 84.134 ++ } else { 84.135 ++ /* Closing failed, restore some of the callbacks */ 84.136 ++ /* Closing of listen pcb will never fail! */ 84.137 ++ LWIP_ASSERT("Closing a listen pcb may not fail!", (conn->pcb.tcp->state != LISTEN)); 84.138 ++ tcp_sent(conn->pcb.tcp, sent_tcp); 84.139 ++ tcp_poll(conn->pcb.tcp, poll_tcp, 4); 84.140 ++ tcp_err(conn->pcb.tcp, err_tcp); 84.141 ++ tcp_arg(conn->pcb.tcp, conn); 84.142 + } 84.143 + /* If closing didn't succeed, we get called again either 84.144 + from poll_tcp or from sent_tcp */ 84.145 +Index: src/api/err.c 84.146 +=================================================================== 84.147 +RCS file: /sources/lwip/lwip/src/api/err.c,v 84.148 +retrieving revision 1.11 84.149 +retrieving revision 1.12 84.150 +diff -u -p -r1.11 -r1.12 84.151 +--- src/api/err.c 13 Dec 2007 23:06:50 -0000 1.11 84.152 ++++ src/api/err.c 9 May 2008 12:14:23 -0000 1.12 84.153 +@@ -44,17 +44,17 @@ static const char *err_strerr[] = { 84.154 + "Ok.", /* ERR_OK 0 */ 84.155 + "Out of memory error.", /* ERR_MEM -1 */ 84.156 + "Buffer error.", /* ERR_BUF -2 */ 84.157 +- "Routing problem.", /* ERR_RTE -3 */ 84.158 +- "Connection aborted.", /* ERR_ABRT -4 */ 84.159 +- "Connection reset.", /* ERR_RST -5 */ 84.160 +- "Connection closed.", /* ERR_CLSD -6 */ 84.161 +- "Not connected.", /* ERR_CONN -7 */ 84.162 +- "Illegal value.", /* ERR_VAL -8 */ 84.163 +- "Illegal argument.", /* ERR_ARG -9 */ 84.164 +- "Address in use.", /* ERR_USE -10 */ 84.165 +- "Low-level netif error.", /* ERR_IF -11 */ 84.166 +- "Already connected.", /* ERR_ISCONN -12 */ 84.167 +- "Timeout.", /* ERR_TIMEOUT -13 */ 84.168 ++ "Timeout.", /* ERR_TIMEOUT -3 */ 84.169 ++ "Routing problem.", /* ERR_RTE -4 */ 84.170 ++ "Connection aborted.", /* ERR_ABRT -5 */ 84.171 ++ "Connection reset.", /* ERR_RST -6 */ 84.172 ++ "Connection closed.", /* ERR_CLSD -7 */ 84.173 ++ "Not connected.", /* ERR_CONN -8 */ 84.174 ++ "Illegal value.", /* ERR_VAL -9 */ 84.175 ++ "Illegal argument.", /* ERR_ARG -10 */ 84.176 ++ "Address in use.", /* ERR_USE -11 */ 84.177 ++ "Low-level netif error.", /* ERR_IF -12 */ 84.178 ++ "Already connected.", /* ERR_ISCONN -13 */ 84.179 + "Operation in progress." /* ERR_INPROGRESS -14 */ 84.180 + }; 84.181 + 84.182 +Index: src/api/netdb.c 84.183 +=================================================================== 84.184 +RCS file: /sources/lwip/lwip/src/api/netdb.c,v 84.185 +retrieving revision 1.4 84.186 +retrieving revision 1.5 84.187 +diff -u -p -r1.4 -r1.5 84.188 +--- src/api/netdb.c 26 Jan 2008 16:11:39 -0000 1.4 84.189 ++++ src/api/netdb.c 16 Jul 2008 20:36:12 -0000 1.5 84.190 +@@ -326,7 +326,8 @@ lwip_getaddrinfo(const char *nodename, c 84.191 + if (nodename != NULL) { 84.192 + /* copy nodename to canonname if specified */ 84.193 + size_t namelen = strlen(nodename); 84.194 +- ai->ai_canonname = mem_malloc(namelen + 1); 84.195 ++ LWIP_ASSERT("namelen is too long", (namelen + 1) <= (mem_size_t)-1); 84.196 ++ ai->ai_canonname = mem_malloc((mem_size_t)(namelen + 1)); 84.197 + if (ai->ai_canonname == NULL) { 84.198 + goto memerr; 84.199 + } 84.200 +Index: src/api/sockets.c 84.201 +=================================================================== 84.202 +RCS file: /sources/lwip/lwip/src/api/sockets.c,v 84.203 +retrieving revision 1.116 84.204 +retrieving revision 1.117 84.205 +diff -u -p -r1.116 -r1.117 84.206 +--- src/api/sockets.c 13 Mar 2008 20:03:57 -0000 1.116 84.207 ++++ src/api/sockets.c 9 May 2008 12:14:24 -0000 1.117 84.208 +@@ -128,17 +128,17 @@ static const int err_to_errno_table[] = 84.209 + 0, /* ERR_OK 0 No error, everything OK. */ 84.210 + ENOMEM, /* ERR_MEM -1 Out of memory error. */ 84.211 + ENOBUFS, /* ERR_BUF -2 Buffer error. */ 84.212 +- EHOSTUNREACH, /* ERR_RTE -3 Routing problem. */ 84.213 +- ECONNABORTED, /* ERR_ABRT -4 Connection aborted. */ 84.214 +- ECONNRESET, /* ERR_RST -5 Connection reset. */ 84.215 +- ESHUTDOWN, /* ERR_CLSD -6 Connection closed. */ 84.216 +- ENOTCONN, /* ERR_CONN -7 Not connected. */ 84.217 +- EINVAL, /* ERR_VAL -8 Illegal value. */ 84.218 +- EIO, /* ERR_ARG -9 Illegal argument. */ 84.219 +- EADDRINUSE, /* ERR_USE -10 Address in use. */ 84.220 +- -1, /* ERR_IF -11 Low-level netif error */ 84.221 +- -1, /* ERR_ISCONN -12 Already connected. */ 84.222 +- ETIMEDOUT, /* ERR_TIMEOUT -13 Timeout */ 84.223 ++ ETIMEDOUT, /* ERR_TIMEOUT -3 Timeout */ 84.224 ++ EHOSTUNREACH, /* ERR_RTE -4 Routing problem. */ 84.225 ++ ECONNABORTED, /* ERR_ABRT -5 Connection aborted. */ 84.226 ++ ECONNRESET, /* ERR_RST -6 Connection reset. */ 84.227 ++ ESHUTDOWN, /* ERR_CLSD -7 Connection closed. */ 84.228 ++ ENOTCONN, /* ERR_CONN -8 Not connected. */ 84.229 ++ EINVAL, /* ERR_VAL -9 Illegal value. */ 84.230 ++ EIO, /* ERR_ARG -10 Illegal argument. */ 84.231 ++ EADDRINUSE, /* ERR_USE -11 Address in use. */ 84.232 ++ -1, /* ERR_IF -12 Low-level netif error */ 84.233 ++ -1, /* ERR_ISCONN -13 Already connected. */ 84.234 + EINPROGRESS /* ERR_INPROGRESS -14 Operation in progress */ 84.235 + }; 84.236 + 84.237 +Index: src/api/tcpip.c 84.238 +=================================================================== 84.239 +RCS file: /sources/lwip/lwip/src/api/tcpip.c,v 84.240 +retrieving revision 1.70 84.241 +retrieving revision 1.73 84.242 +diff -u -p -r1.70 -r1.73 84.243 +--- src/api/tcpip.c 12 Jan 2008 11:52:22 -0000 1.70 84.244 ++++ src/api/tcpip.c 27 Jun 2008 20:34:51 -0000 1.73 84.245 +@@ -518,4 +518,42 @@ tcpip_init(void (* initfunc)(void *), vo 84.246 + sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO); 84.247 + } 84.248 + 84.249 ++/** 84.250 ++ * Simple callback function used with tcpip_callback to free a pbuf 84.251 ++ * (pbuf_free has a wrong signature for tcpip_callback) 84.252 ++ * 84.253 ++ * @param p The pbuf (chain) to be dereferenced. 84.254 ++ */ 84.255 ++static void 84.256 ++pbuf_free_int(void *p) 84.257 ++{ 84.258 ++ struct pbuf *q = p; 84.259 ++ pbuf_free(q); 84.260 ++} 84.261 ++ 84.262 ++/** 84.263 ++ * A simple wrapper function that allows you to free a pbuf from interrupt context. 84.264 ++ * 84.265 ++ * @param p The pbuf (chain) to be dereferenced. 84.266 ++ * @return ERR_OK if callback could be enqueued, an err_t if not 84.267 ++ */ 84.268 ++err_t 84.269 ++pbuf_free_callback(struct pbuf *p) 84.270 ++{ 84.271 ++ return tcpip_callback_with_block(pbuf_free_int, p, 0); 84.272 ++} 84.273 ++ 84.274 ++/** 84.275 ++ * A simple wrapper function that allows you to free heap memory from 84.276 ++ * interrupt context. 84.277 ++ * 84.278 ++ * @param m the heap memory to free 84.279 ++ * @return ERR_OK if callback could be enqueued, an err_t if not 84.280 ++ */ 84.281 ++err_t 84.282 ++mem_free_callback(void *m) 84.283 ++{ 84.284 ++ return tcpip_callback_with_block(mem_free, m, 0); 84.285 ++} 84.286 ++ 84.287 + #endif /* !NO_SYS */ 84.288 +Index: src/core/dhcp.c 84.289 +=================================================================== 84.290 +RCS file: /sources/lwip/lwip/src/core/dhcp.c,v 84.291 +retrieving revision 1.86 84.292 +retrieving revision 1.87 84.293 +diff -u -p -r1.86 -r1.87 84.294 +--- src/core/dhcp.c 4 Mar 2008 14:25:58 -0000 1.86 84.295 ++++ src/core/dhcp.c 15 Apr 2008 17:24:55 -0000 1.87 84.296 +@@ -568,6 +568,8 @@ dhcp_start(struct netif *netif) 84.297 + LWIP_ERROR("netif != NULL", (netif != NULL), return ERR_ARG;); 84.298 + dhcp = netif->dhcp; 84.299 + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); 84.300 ++ /* Remove the flag that says this netif is handled by DHCP, 84.301 ++ it is set when we succeeded starting. */ 84.302 + netif->flags &= ~NETIF_FLAG_DHCP; 84.303 + 84.304 + /* no DHCP client attached yet? */ 84.305 +@@ -609,6 +611,7 @@ dhcp_start(struct netif *netif) 84.306 + dhcp_stop(netif); 84.307 + return ERR_MEM; 84.308 + } 84.309 ++ /* Set the flag that says this netif is handled by DHCP. */ 84.310 + netif->flags |= NETIF_FLAG_DHCP; 84.311 + return result; 84.312 + } 84.313 +@@ -1063,6 +1066,8 @@ dhcp_stop(struct netif *netif) 84.314 + { 84.315 + struct dhcp *dhcp = netif->dhcp; 84.316 + LWIP_ERROR("dhcp_stop: netif != NULL", (netif != NULL), return;); 84.317 ++ /* Remove the flag that says this netif is handled by DHCP. */ 84.318 ++ netif->flags &= ~NETIF_FLAG_DHCP; 84.319 + 84.320 + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | 3, ("dhcp_stop()\n")); 84.321 + /* netif is DHCP configured? */ 84.322 +Index: src/core/mem.c 84.323 +=================================================================== 84.324 +RCS file: /sources/lwip/lwip/src/core/mem.c,v 84.325 +retrieving revision 1.59 84.326 +retrieving revision 1.62 84.327 +diff -u -p -r1.59 -r1.62 84.328 +--- src/core/mem.c 4 Mar 2008 16:31:32 -0000 1.59 84.329 ++++ src/core/mem.c 30 Jun 2008 18:16:51 -0000 1.62 84.330 +@@ -177,9 +177,36 @@ static u8_t *ram; 84.331 + static struct mem *ram_end; 84.332 + /** pointer to the lowest free block, this is used for faster search */ 84.333 + static struct mem *lfree; 84.334 ++ 84.335 + /** concurrent access protection */ 84.336 + static sys_sem_t mem_sem; 84.337 + 84.338 ++#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 84.339 ++ 84.340 ++static volatile u8_t mem_free_count; 84.341 ++ 84.342 ++/* Allow mem_free from other (e.g. interrupt) context */ 84.343 ++#define LWIP_MEM_FREE_DECL_PROTECT() SYS_ARCH_DECL_PROTECT(lev_free) 84.344 ++#define LWIP_MEM_FREE_PROTECT() SYS_ARCH_PROTECT(lev_free) 84.345 ++#define LWIP_MEM_FREE_UNPROTECT() SYS_ARCH_UNPROTECT(lev_free) 84.346 ++#define LWIP_MEM_ALLOC_DECL_PROTECT() SYS_ARCH_DECL_PROTECT(lev_alloc) 84.347 ++#define LWIP_MEM_ALLOC_PROTECT() SYS_ARCH_PROTECT(lev_alloc) 84.348 ++#define LWIP_MEM_ALLOC_UNPROTECT() SYS_ARCH_UNPROTECT(lev_alloc) 84.349 ++ 84.350 ++#else /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ 84.351 ++ 84.352 ++/* Protect the heap only by using a semaphore */ 84.353 ++#define LWIP_MEM_FREE_DECL_PROTECT() 84.354 ++#define LWIP_MEM_FREE_PROTECT() sys_arch_sem_wait(mem_sem, 0) 84.355 ++#define LWIP_MEM_FREE_UNPROTECT() sys_sem_signal(mem_sem) 84.356 ++/* mem_malloc is protected using semaphore AND LWIP_MEM_ALLOC_PROTECT */ 84.357 ++#define LWIP_MEM_ALLOC_DECL_PROTECT() 84.358 ++#define LWIP_MEM_ALLOC_PROTECT() 84.359 ++#define LWIP_MEM_ALLOC_UNPROTECT() 84.360 ++ 84.361 ++#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ 84.362 ++ 84.363 ++ 84.364 + /** 84.365 + * "Plug holes" by combining adjacent empty struct mems. 84.366 + * After this function is through, there should not exist 84.367 +@@ -255,9 +282,7 @@ mem_init(void) 84.368 + /* initialize the lowest-free pointer to the start of the heap */ 84.369 + lfree = (struct mem *)ram; 84.370 + 84.371 +-#if MEM_STATS 84.372 +- lwip_stats.mem.avail = MEM_SIZE_ALIGNED; 84.373 +-#endif /* MEM_STATS */ 84.374 ++ MEM_STATS_AVAIL(avail, MEM_SIZE_ALIGNED); 84.375 + } 84.376 + 84.377 + /** 84.378 +@@ -270,6 +295,7 @@ void 84.379 + mem_free(void *rmem) 84.380 + { 84.381 + struct mem *mem; 84.382 ++ LWIP_MEM_FREE_DECL_PROTECT(); 84.383 + 84.384 + if (rmem == NULL) { 84.385 + LWIP_DEBUGF(MEM_DEBUG | LWIP_DBG_TRACE | 2, ("mem_free(p == NULL) was called.\n")); 84.386 +@@ -277,20 +303,20 @@ mem_free(void *rmem) 84.387 + } 84.388 + LWIP_ASSERT("mem_free: sanity check alignment", (((mem_ptr_t)rmem) & (MEM_ALIGNMENT-1)) == 0); 84.389 + 84.390 +- /* protect the heap from concurrent access */ 84.391 +- sys_arch_sem_wait(mem_sem, 0); 84.392 +- 84.393 + LWIP_ASSERT("mem_free: legal memory", (u8_t *)rmem >= (u8_t *)ram && 84.394 + (u8_t *)rmem < (u8_t *)ram_end); 84.395 + 84.396 + if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { 84.397 ++ SYS_ARCH_DECL_PROTECT(lev); 84.398 + LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_free: illegal memory\n")); 84.399 +-#if MEM_STATS 84.400 +- ++lwip_stats.mem.err; 84.401 +-#endif /* MEM_STATS */ 84.402 +- sys_sem_signal(mem_sem); 84.403 ++ /* protect mem stats from concurrent access */ 84.404 ++ SYS_ARCH_PROTECT(lev); 84.405 ++ MEM_STATS_INC(illegal); 84.406 ++ SYS_ARCH_UNPROTECT(lev); 84.407 + return; 84.408 + } 84.409 ++ /* protect the heap from concurrent access */ 84.410 ++ LWIP_MEM_FREE_PROTECT(); 84.411 + /* Get the corresponding struct mem ... */ 84.412 + mem = (struct mem *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); 84.413 + /* ... which has to be in a used state ... */ 84.414 +@@ -303,13 +329,14 @@ mem_free(void *rmem) 84.415 + lfree = mem; 84.416 + } 84.417 + 84.418 +-#if MEM_STATS 84.419 +- lwip_stats.mem.used -= mem->next - ((u8_t *)mem - ram); 84.420 +-#endif /* MEM_STATS */ 84.421 ++ MEM_STATS_DEC_USED(used, mem->next - ((u8_t *)mem - ram)); 84.422 + 84.423 + /* finally, see if prev or next are free also */ 84.424 + plug_holes(mem); 84.425 +- sys_sem_signal(mem_sem); 84.426 ++#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 84.427 ++ mem_free_count = 1; 84.428 ++#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ 84.429 ++ LWIP_MEM_FREE_UNPROTECT(); 84.430 + } 84.431 + 84.432 + /** 84.433 +@@ -321,6 +348,8 @@ mem_free(void *rmem) 84.434 + * @param newsize required size after shrinking (needs to be smaller than or 84.435 + * equal to the previous size) 84.436 + * @return for compatibility reasons: is always == rmem, at the moment 84.437 ++ * or NULL if newsize is > old size, in which case rmem is NOT touched 84.438 ++ * or freed! 84.439 + */ 84.440 + void * 84.441 + mem_realloc(void *rmem, mem_size_t newsize) 84.442 +@@ -328,6 +357,8 @@ mem_realloc(void *rmem, mem_size_t newsi 84.443 + mem_size_t size; 84.444 + mem_size_t ptr, ptr2; 84.445 + struct mem *mem, *mem2; 84.446 ++ /* use the FREE_PROTECT here: it protects with sem OR SYS_ARCH_PROTECT */ 84.447 ++ LWIP_MEM_FREE_DECL_PROTECT(); 84.448 + 84.449 + /* Expand the size of the allocated memory region so that we can 84.450 + adjust for alignment. */ 84.451 +@@ -346,7 +377,12 @@ mem_realloc(void *rmem, mem_size_t newsi 84.452 + (u8_t *)rmem < (u8_t *)ram_end); 84.453 + 84.454 + if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { 84.455 ++ SYS_ARCH_DECL_PROTECT(lev); 84.456 + LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_realloc: illegal memory\n")); 84.457 ++ /* protect mem stats from concurrent access */ 84.458 ++ SYS_ARCH_PROTECT(lev); 84.459 ++ MEM_STATS_INC(illegal); 84.460 ++ SYS_ARCH_UNPROTECT(lev); 84.461 + return rmem; 84.462 + } 84.463 + /* Get the corresponding struct mem ... */ 84.464 +@@ -366,11 +402,9 @@ mem_realloc(void *rmem, mem_size_t newsi 84.465 + } 84.466 + 84.467 + /* protect the heap from concurrent access */ 84.468 +- sys_arch_sem_wait(mem_sem, 0); 84.469 ++ LWIP_MEM_FREE_PROTECT(); 84.470 + 84.471 +-#if MEM_STATS 84.472 +- lwip_stats.mem.used -= (size - newsize); 84.473 +-#endif /* MEM_STATS */ 84.474 ++ MEM_STATS_DEC_USED(used, (size - newsize)); 84.475 + 84.476 + mem2 = (struct mem *)&ram[mem->next]; 84.477 + if(mem2->used == 0) { 84.478 +@@ -426,7 +460,10 @@ mem_realloc(void *rmem, mem_size_t newsi 84.479 + -> don't do anyhting. 84.480 + -> the remaining space stays unused since it is too small 84.481 + } */ 84.482 +- sys_sem_signal(mem_sem); 84.483 ++#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 84.484 ++ mem_free_count = 1; 84.485 ++#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ 84.486 ++ LWIP_MEM_FREE_UNPROTECT(); 84.487 + return rmem; 84.488 + } 84.489 + 84.490 +@@ -444,6 +481,10 @@ mem_malloc(mem_size_t size) 84.491 + { 84.492 + mem_size_t ptr, ptr2; 84.493 + struct mem *mem, *mem2; 84.494 ++#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 84.495 ++ u8_t local_mem_free_count = 0; 84.496 ++#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ 84.497 ++ LWIP_MEM_ALLOC_DECL_PROTECT(); 84.498 + 84.499 + if (size == 0) { 84.500 + return NULL; 84.501 +@@ -464,88 +505,101 @@ mem_malloc(mem_size_t size) 84.502 + 84.503 + /* protect the heap from concurrent access */ 84.504 + sys_arch_sem_wait(mem_sem, 0); 84.505 ++ LWIP_MEM_ALLOC_PROTECT(); 84.506 ++#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 84.507 ++ /* run as long as a mem_free disturbed mem_malloc */ 84.508 ++ do { 84.509 ++ local_mem_free_count = 0; 84.510 ++#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ 84.511 ++ 84.512 ++ /* Scan through the heap searching for a free block that is big enough, 84.513 ++ * beginning with the lowest free block. 84.514 ++ */ 84.515 ++ for (ptr = (u8_t *)lfree - ram; ptr < MEM_SIZE_ALIGNED - size; 84.516 ++ ptr = ((struct mem *)&ram[ptr])->next) { 84.517 ++ mem = (struct mem *)&ram[ptr]; 84.518 ++#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 84.519 ++ mem_free_count = 0; 84.520 ++ LWIP_MEM_ALLOC_UNPROTECT(); 84.521 ++ /* allow mem_free to run */ 84.522 ++ LWIP_MEM_ALLOC_PROTECT(); 84.523 ++ if (mem_free_count != 0) { 84.524 ++ local_mem_free_count = mem_free_count; 84.525 ++ } 84.526 ++ mem_free_count = 0; 84.527 ++#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ 84.528 + 84.529 +- /* Scan through the heap searching for a free block that is big enough, 84.530 +- * beginning with the lowest free block. 84.531 +- */ 84.532 +- for (ptr = (u8_t *)lfree - ram; ptr < MEM_SIZE_ALIGNED - size; 84.533 +- ptr = ((struct mem *)&ram[ptr])->next) { 84.534 +- mem = (struct mem *)&ram[ptr]; 84.535 +- 84.536 +- if ((!mem->used) && 84.537 +- (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) { 84.538 +- /* mem is not used and at least perfect fit is possible: 84.539 +- * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */ 84.540 +- 84.541 +- if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)) { 84.542 +- /* (in addition to the above, we test if another struct mem (SIZEOF_STRUCT_MEM) containing 84.543 +- * at least MIN_SIZE_ALIGNED of data also fits in the 'user data space' of 'mem') 84.544 +- * -> split large block, create empty remainder, 84.545 +- * remainder must be large enough to contain MIN_SIZE_ALIGNED data: if 84.546 +- * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size, 84.547 +- * struct mem would fit in but no data between mem2 and mem2->next 84.548 +- * @todo we could leave out MIN_SIZE_ALIGNED. We would create an empty 84.549 +- * region that couldn't hold data, but when mem->next gets freed, 84.550 +- * the 2 regions would be combined, resulting in more free memory 84.551 +- */ 84.552 +- ptr2 = ptr + SIZEOF_STRUCT_MEM + size; 84.553 +- /* create mem2 struct */ 84.554 +- mem2 = (struct mem *)&ram[ptr2]; 84.555 +- mem2->used = 0; 84.556 +- mem2->next = mem->next; 84.557 +- mem2->prev = ptr; 84.558 +- /* and insert it between mem and mem->next */ 84.559 +- mem->next = ptr2; 84.560 +- mem->used = 1; 84.561 +- 84.562 +- if (mem2->next != MEM_SIZE_ALIGNED) { 84.563 +- ((struct mem *)&ram[mem2->next])->prev = ptr2; 84.564 +- } 84.565 +-#if MEM_STATS 84.566 +- lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM); 84.567 +- if (lwip_stats.mem.max < lwip_stats.mem.used) { 84.568 +- lwip_stats.mem.max = lwip_stats.mem.used; 84.569 ++ if ((!mem->used) && 84.570 ++ (mem->next - (ptr + SIZEOF_STRUCT_MEM)) >= size) { 84.571 ++ /* mem is not used and at least perfect fit is possible: 84.572 ++ * mem->next - (ptr + SIZEOF_STRUCT_MEM) gives us the 'user data size' of mem */ 84.573 ++ 84.574 ++ if (mem->next - (ptr + SIZEOF_STRUCT_MEM) >= (size + SIZEOF_STRUCT_MEM + MIN_SIZE_ALIGNED)) { 84.575 ++ /* (in addition to the above, we test if another struct mem (SIZEOF_STRUCT_MEM) containing 84.576 ++ * at least MIN_SIZE_ALIGNED of data also fits in the 'user data space' of 'mem') 84.577 ++ * -> split large block, create empty remainder, 84.578 ++ * remainder must be large enough to contain MIN_SIZE_ALIGNED data: if 84.579 ++ * mem->next - (ptr + (2*SIZEOF_STRUCT_MEM)) == size, 84.580 ++ * struct mem would fit in but no data between mem2 and mem2->next 84.581 ++ * @todo we could leave out MIN_SIZE_ALIGNED. We would create an empty 84.582 ++ * region that couldn't hold data, but when mem->next gets freed, 84.583 ++ * the 2 regions would be combined, resulting in more free memory 84.584 ++ */ 84.585 ++ ptr2 = ptr + SIZEOF_STRUCT_MEM + size; 84.586 ++ /* create mem2 struct */ 84.587 ++ mem2 = (struct mem *)&ram[ptr2]; 84.588 ++ mem2->used = 0; 84.589 ++ mem2->next = mem->next; 84.590 ++ mem2->prev = ptr; 84.591 ++ /* and insert it between mem and mem->next */ 84.592 ++ mem->next = ptr2; 84.593 ++ mem->used = 1; 84.594 ++ 84.595 ++ if (mem2->next != MEM_SIZE_ALIGNED) { 84.596 ++ ((struct mem *)&ram[mem2->next])->prev = ptr2; 84.597 ++ } 84.598 ++ MEM_STATS_INC_USED(used, (size + SIZEOF_STRUCT_MEM)); 84.599 ++ } else { 84.600 ++ /* (a mem2 struct does no fit into the user data space of mem and mem->next will always 84.601 ++ * be used at this point: if not we have 2 unused structs in a row, plug_holes should have 84.602 ++ * take care of this). 84.603 ++ * -> near fit or excact fit: do not split, no mem2 creation 84.604 ++ * also can't move mem->next directly behind mem, since mem->next 84.605 ++ * will always be used at this point! 84.606 ++ */ 84.607 ++ mem->used = 1; 84.608 ++ MEM_STATS_INC_USED(used, mem->next - ((u8_t *)mem - ram)); 84.609 + } 84.610 +-#endif /* MEM_STATS */ 84.611 +- } else { 84.612 +- /* (a mem2 struct does no fit into the user data space of mem and mem->next will always 84.613 +- * be used at this point: if not we have 2 unused structs in a row, plug_holes should have 84.614 +- * take care of this). 84.615 +- * -> near fit or excact fit: do not split, no mem2 creation 84.616 +- * also can't move mem->next directly behind mem, since mem->next 84.617 +- * will always be used at this point! 84.618 +- */ 84.619 +- mem->used = 1; 84.620 +-#if MEM_STATS 84.621 +- lwip_stats.mem.used += mem->next - ((u8_t *)mem - ram); 84.622 +- if (lwip_stats.mem.max < lwip_stats.mem.used) { 84.623 +- lwip_stats.mem.max = lwip_stats.mem.used; 84.624 +- } 84.625 +-#endif /* MEM_STATS */ 84.626 +- } 84.627 + 84.628 +- if (mem == lfree) { 84.629 +- /* Find next free block after mem and update lowest free pointer */ 84.630 +- while (lfree->used && lfree != ram_end) { 84.631 +- lfree = (struct mem *)&ram[lfree->next]; 84.632 ++ if (mem == lfree) { 84.633 ++ /* Find next free block after mem and update lowest free pointer */ 84.634 ++ while (lfree->used && lfree != ram_end) { 84.635 ++ LWIP_MEM_ALLOC_UNPROTECT(); 84.636 ++ /* prevent high interrupt latency... */ 84.637 ++ LWIP_MEM_ALLOC_PROTECT(); 84.638 ++ lfree = (struct mem *)&ram[lfree->next]; 84.639 ++ } 84.640 ++ LWIP_ASSERT("mem_malloc: !lfree->used", ((lfree == ram_end) || (!lfree->used))); 84.641 + } 84.642 +- LWIP_ASSERT("mem_malloc: !lfree->used", ((lfree == ram_end) || (!lfree->used))); 84.643 +- } 84.644 +- sys_sem_signal(mem_sem); 84.645 +- LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.", 84.646 +- (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end); 84.647 +- LWIP_ASSERT("mem_malloc: allocated memory properly aligned.", 84.648 +- (unsigned long)((u8_t *)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0); 84.649 +- LWIP_ASSERT("mem_malloc: sanity check alignment", 84.650 +- (((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0); 84.651 ++ LWIP_MEM_ALLOC_UNPROTECT(); 84.652 ++ sys_sem_signal(mem_sem); 84.653 ++ LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.", 84.654 ++ (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end); 84.655 ++ LWIP_ASSERT("mem_malloc: allocated memory properly aligned.", 84.656 ++ (unsigned long)((u8_t *)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0); 84.657 ++ LWIP_ASSERT("mem_malloc: sanity check alignment", 84.658 ++ (((mem_ptr_t)mem) & (MEM_ALIGNMENT-1)) == 0); 84.659 + 84.660 +- return (u8_t *)mem + SIZEOF_STRUCT_MEM; 84.661 ++ return (u8_t *)mem + SIZEOF_STRUCT_MEM; 84.662 ++ } 84.663 + } 84.664 +- } 84.665 ++#if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 84.666 ++ /* if we got interrupted by a mem_free, try again */ 84.667 ++ } while(local_mem_free_count != 0); 84.668 ++#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */ 84.669 + LWIP_DEBUGF(MEM_DEBUG | 2, ("mem_malloc: could not allocate %"S16_F" bytes\n", (s16_t)size)); 84.670 +-#if MEM_STATS 84.671 +- ++lwip_stats.mem.err; 84.672 +-#endif /* MEM_STATS */ 84.673 ++ MEM_STATS_INC(err); 84.674 ++ LWIP_MEM_ALLOC_UNPROTECT(); 84.675 + sys_sem_signal(mem_sem); 84.676 + return NULL; 84.677 + } 84.678 +Index: src/core/memp.c 84.679 +=================================================================== 84.680 +RCS file: /sources/lwip/lwip/src/core/memp.c,v 84.681 +retrieving revision 1.55 84.682 +retrieving revision 1.56 84.683 +diff -u -p -r1.55 -r1.56 84.684 +--- src/core/memp.c 25 Nov 2007 10:43:28 -0000 1.55 84.685 ++++ src/core/memp.c 27 Jun 2008 18:37:54 -0000 1.56 84.686 +@@ -252,13 +252,12 @@ memp_init(void) 84.687 + struct memp *memp; 84.688 + u16_t i, j; 84.689 + 84.690 +-#if MEMP_STATS 84.691 + for (i = 0; i < MEMP_MAX; ++i) { 84.692 +- lwip_stats.memp[i].used = lwip_stats.memp[i].max = 84.693 +- lwip_stats.memp[i].err = 0; 84.694 +- lwip_stats.memp[i].avail = memp_num[i]; 84.695 ++ MEMP_STATS_AVAIL(used, i, 0); 84.696 ++ MEMP_STATS_AVAIL(max, i, 0); 84.697 ++ MEMP_STATS_AVAIL(err, i, 0); 84.698 ++ MEMP_STATS_AVAIL(avail, i, memp_num[i]); 84.699 + } 84.700 +-#endif /* MEMP_STATS */ 84.701 + 84.702 + memp = LWIP_MEM_ALIGN(memp_memory); 84.703 + /* for every pool: */ 84.704 +@@ -315,20 +314,13 @@ memp_malloc_fn(memp_t type, const char* 84.705 + memp->file = file; 84.706 + memp->line = line; 84.707 + #endif /* MEMP_OVERFLOW_CHECK */ 84.708 +-#if MEMP_STATS 84.709 +- ++lwip_stats.memp[type].used; 84.710 +- if (lwip_stats.memp[type].used > lwip_stats.memp[type].max) { 84.711 +- lwip_stats.memp[type].max = lwip_stats.memp[type].used; 84.712 +- } 84.713 +-#endif /* MEMP_STATS */ 84.714 ++ MEMP_STATS_INC_USED(used, type); 84.715 + LWIP_ASSERT("memp_malloc: memp properly aligned", 84.716 + ((mem_ptr_t)memp % MEM_ALIGNMENT) == 0); 84.717 + memp = (struct memp*)((u8_t*)memp + MEMP_SIZE); 84.718 + } else { 84.719 + LWIP_DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %s\n", memp_desc[type])); 84.720 +-#if MEMP_STATS 84.721 +- ++lwip_stats.memp[type].err; 84.722 +-#endif /* MEMP_STATS */ 84.723 ++ MEMP_STATS_INC(err, type); 84.724 + } 84.725 + 84.726 + SYS_ARCH_UNPROTECT(old_level); 84.727 +@@ -365,9 +357,7 @@ memp_free(memp_t type, void *mem) 84.728 + #endif /* MEMP_OVERFLOW_CHECK >= 2 */ 84.729 + #endif /* MEMP_OVERFLOW_CHECK */ 84.730 + 84.731 +-#if MEMP_STATS 84.732 +- lwip_stats.memp[type].used--; 84.733 +-#endif /* MEMP_STATS */ 84.734 ++ MEMP_STATS_DEC(used, type); 84.735 + 84.736 + memp->next = memp_tab[type]; 84.737 + memp_tab[type] = memp; 84.738 +Index: src/core/netif.c 84.739 +=================================================================== 84.740 +RCS file: /sources/lwip/lwip/src/core/netif.c,v 84.741 +retrieving revision 1.65 84.742 +retrieving revision 1.68 84.743 +diff -u -p -r1.65 -r1.68 84.744 +--- src/core/netif.c 9 Oct 2007 20:00:55 -0000 1.65 84.745 ++++ src/core/netif.c 19 Jun 2008 16:27:18 -0000 1.68 84.746 +@@ -45,6 +45,12 @@ 84.747 + #include "lwip/snmp.h" 84.748 + #include "lwip/igmp.h" 84.749 + #include "netif/etharp.h" 84.750 ++#if ENABLE_LOOPBACK 84.751 ++#include "lwip/sys.h" 84.752 ++#if LWIP_NETIF_LOOPBACK_MULTITHREADING 84.753 ++#include "lwip/tcpip.h" 84.754 ++#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ 84.755 ++#endif /* ENABLE_LOOPBACK */ 84.756 + 84.757 + #if LWIP_NETIF_STATUS_CALLBACK 84.758 + #define NETIF_STATUS_CALLBACK(n) { if (n->status_callback) (n->status_callback)(n); } 84.759 +@@ -106,6 +112,10 @@ netif_add(struct netif *netif, struct ip 84.760 + #if LWIP_IGMP 84.761 + netif->igmp_mac_filter = NULL; 84.762 + #endif /* LWIP_IGMP */ 84.763 ++#if ENABLE_LOOPBACK 84.764 ++ netif->loop_first = NULL; 84.765 ++ netif->loop_last = NULL; 84.766 ++#endif /* ENABLE_LOOPBACK */ 84.767 + 84.768 + /* remember netif specific state information data */ 84.769 + netif->state = state; 84.770 +@@ -114,6 +124,9 @@ netif_add(struct netif *netif, struct ip 84.771 + #if LWIP_NETIF_HWADDRHINT 84.772 + netif->addr_hint = NULL; 84.773 + #endif /* LWIP_NETIF_HWADDRHINT*/ 84.774 ++#if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS 84.775 ++ netif->loop_cnt_current = 0; 84.776 ++#endif /* ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS */ 84.777 + 84.778 + netif_set_addr(netif, ipaddr, netmask, gw); 84.779 + 84.780 +@@ -493,7 +506,158 @@ u8_t netif_is_link_up(struct netif *neti 84.781 + */ 84.782 + void netif_set_link_callback(struct netif *netif, void (* link_callback)(struct netif *netif )) 84.783 + { 84.784 +- if ( netif ) 84.785 +- netif->link_callback = link_callback; 84.786 ++ if (netif) { 84.787 ++ netif->link_callback = link_callback; 84.788 ++ } 84.789 + } 84.790 + #endif /* LWIP_NETIF_LINK_CALLBACK */ 84.791 ++ 84.792 ++#if ENABLE_LOOPBACK 84.793 ++/** 84.794 ++ * Send an IP packet to be received on the same netif (loopif-like). 84.795 ++ * The pbuf is simply copied and handed back to netif->input. 84.796 ++ * In multithreaded mode, this is done directly since netif->input must put 84.797 ++ * the packet on a queue. 84.798 ++ * In callback mode, the packet is put on an internal queue and is fed to 84.799 ++ * netif->input by netif_poll(). 84.800 ++ * 84.801 ++ * @param netif the lwip network interface structure 84.802 ++ * @param p the (IP) packet to 'send' 84.803 ++ * @param ipaddr the ip address to send the packet to (not used) 84.804 ++ * @return ERR_OK if the packet has been sent 84.805 ++ * ERR_MEM if the pbuf used to copy the packet couldn't be allocated 84.806 ++ */ 84.807 ++err_t 84.808 ++netif_loop_output(struct netif *netif, struct pbuf *p, 84.809 ++ struct ip_addr *ipaddr) 84.810 ++{ 84.811 ++ struct pbuf *r; 84.812 ++ err_t err; 84.813 ++ struct pbuf *last; 84.814 ++#if LWIP_LOOPBACK_MAX_PBUFS 84.815 ++ u8_t clen = 0; 84.816 ++#endif /* LWIP_LOOPBACK_MAX_PBUFS */ 84.817 ++ SYS_ARCH_DECL_PROTECT(lev); 84.818 ++ LWIP_UNUSED_ARG(ipaddr); 84.819 ++ 84.820 ++ /* Allocate a new pbuf */ 84.821 ++ r = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM); 84.822 ++ if (r == NULL) { 84.823 ++ return ERR_MEM; 84.824 ++ } 84.825 ++#if LWIP_LOOPBACK_MAX_PBUFS 84.826 ++ clen = pbuf_clen(r); 84.827 ++ /* check for overflow or too many pbuf on queue */ 84.828 ++ if(((netif->loop_cnt_current + clen) < netif->loop_cnt_current) || 84.829 ++ ((netif->loop_cnt_current + clen) > LWIP_LOOPBACK_MAX_PBUFS)) { 84.830 ++ pbuf_free(r); 84.831 ++ r = NULL; 84.832 ++ return ERR_MEM; 84.833 ++ } 84.834 ++ netif->loop_cnt_current += clen; 84.835 ++#endif /* LWIP_LOOPBACK_MAX_PBUFS */ 84.836 ++ 84.837 ++ /* Copy the whole pbuf queue p into the single pbuf r */ 84.838 ++ if ((err = pbuf_copy(r, p)) != ERR_OK) { 84.839 ++ pbuf_free(r); 84.840 ++ r = NULL; 84.841 ++ return err; 84.842 ++ } 84.843 ++ 84.844 ++ /* Put the packet on a linked list which gets emptied through calling 84.845 ++ netif_poll(). */ 84.846 ++ 84.847 ++ /* let last point to the last pbuf in chain r */ 84.848 ++ for (last = r; last->next != NULL; last = last->next); 84.849 ++ 84.850 ++ SYS_ARCH_PROTECT(lev); 84.851 ++ if(netif->loop_first != NULL) { 84.852 ++ LWIP_ASSERT("if first != NULL, last must also be != NULL", netif->loop_last != NULL); 84.853 ++ netif->loop_last->next = r; 84.854 ++ netif->loop_last = last; 84.855 ++ } else { 84.856 ++ netif->loop_first = r; 84.857 ++ netif->loop_last = last; 84.858 ++ } 84.859 ++ SYS_ARCH_UNPROTECT(lev); 84.860 ++ 84.861 ++#if LWIP_NETIF_LOOPBACK_MULTITHREADING 84.862 ++ /* For multithreading environment, schedule a call to netif_poll */ 84.863 ++ tcpip_callback(netif_poll, netif); 84.864 ++#endif /* LWIP_NETIF_LOOPBACK_MULTITHREADING */ 84.865 ++ 84.866 ++ return ERR_OK; 84.867 ++} 84.868 ++ 84.869 ++/** 84.870 ++ * Call netif_poll() in the main loop of your application. This is to prevent 84.871 ++ * reentering non-reentrant functions like tcp_input(). Packets passed to 84.872 ++ * netif_loop_output() are put on a list that is passed to netif->input() by 84.873 ++ * netif_poll(). 84.874 ++ */ 84.875 ++void 84.876 ++netif_poll(struct netif *netif) 84.877 ++{ 84.878 ++ struct pbuf *in; 84.879 ++ SYS_ARCH_DECL_PROTECT(lev); 84.880 ++ 84.881 ++ do { 84.882 ++ /* Get a packet from the list. With SYS_LIGHTWEIGHT_PROT=1, this is protected */ 84.883 ++ SYS_ARCH_PROTECT(lev); 84.884 ++ in = netif->loop_first; 84.885 ++ if(in != NULL) { 84.886 ++ struct pbuf *in_end = in; 84.887 ++#if LWIP_LOOPBACK_MAX_PBUFS 84.888 ++ u8_t clen = pbuf_clen(in); 84.889 ++ /* adjust the number of pbufs on queue */ 84.890 ++ LWIP_ASSERT("netif->loop_cnt_current underflow", 84.891 ++ ((netif->loop_cnt_current - clen) < netif->loop_cnt_current)); 84.892 ++ netif->loop_cnt_current -= clen; 84.893 ++#endif /* LWIP_LOOPBACK_MAX_PBUFS */ 84.894 ++ while(in_end->len != in_end->tot_len) { 84.895 ++ LWIP_ASSERT("bogus pbuf: len != tot_len but next == NULL!", in_end->next != NULL); 84.896 ++ in_end = in_end->next; 84.897 ++ } 84.898 ++ /* 'in_end' now points to the last pbuf from 'in' */ 84.899 ++ if(in_end == netif->loop_last) { 84.900 ++ /* this was the last pbuf in the list */ 84.901 ++ netif->loop_first = netif->loop_last = NULL; 84.902 ++ } else { 84.903 ++ /* pop the pbuf off the list */ 84.904 ++ netif->loop_first = in_end->next; 84.905 ++ LWIP_ASSERT("should not be null since first != last!", netif->loop_first != NULL); 84.906 ++ } 84.907 ++ /* De-queue the pbuf from its successors on the 'loop_' list. */ 84.908 ++ in_end->next = NULL; 84.909 ++ } 84.910 ++ SYS_ARCH_UNPROTECT(lev); 84.911 ++ 84.912 ++ if(in != NULL) { 84.913 ++ /* loopback packets are always IP packets! */ 84.914 ++ if(ip_input(in, netif) != ERR_OK) { 84.915 ++ pbuf_free(in); 84.916 ++ } 84.917 ++ /* Don't reference the packet any more! */ 84.918 ++ in = NULL; 84.919 ++ } 84.920 ++ /* go on while there is a packet on the list */ 84.921 ++ } while(netif->loop_first != NULL); 84.922 ++} 84.923 ++ 84.924 ++#if !LWIP_NETIF_LOOPBACK_MULTITHREADING 84.925 ++/** 84.926 ++ * Calls netif_poll() for every netif on the netif_list. 84.927 ++ */ 84.928 ++void 84.929 ++netif_poll_all(void) 84.930 ++{ 84.931 ++ struct netif *netif = netif_list; 84.932 ++ /* loop through netifs */ 84.933 ++ while (netif != NULL) { 84.934 ++ netif_poll(netif); 84.935 ++ /* proceed to next network interface */ 84.936 ++ netif = netif->next; 84.937 ++ } 84.938 ++} 84.939 ++#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ 84.940 ++#endif /* ENABLE_LOOPBACK */ 84.941 +Index: src/core/pbuf.c 84.942 +=================================================================== 84.943 +RCS file: /sources/lwip/lwip/src/core/pbuf.c,v 84.944 +retrieving revision 1.127 84.945 +retrieving revision 1.128 84.946 +diff -u -p -r1.127 -r1.128 84.947 +--- src/core/pbuf.c 4 Mar 2008 16:37:46 -0000 1.127 84.948 ++++ src/core/pbuf.c 1 Apr 2008 19:05:40 -0000 1.128 84.949 +@@ -667,8 +667,8 @@ pbuf_dechain(struct pbuf *p) 84.950 + * 84.951 + * @note Only one packet is copied, no packet queue! 84.952 + * 84.953 +- * @param p_to pbuf source of the copy 84.954 +- * @param p_from pbuf destination of the copy 84.955 ++ * @param p_to pbuf destination of the copy 84.956 ++ * @param p_from pbuf source of the copy 84.957 + * 84.958 + * @return ERR_OK if pbuf was copied 84.959 + * ERR_ARG if one of the pbufs is NULL or p_to is not big 84.960 +Index: src/core/stats.c 84.961 +=================================================================== 84.962 +RCS file: /sources/lwip/lwip/src/core/stats.c,v 84.963 +retrieving revision 1.27 84.964 +retrieving revision 1.28 84.965 +diff -u -p -r1.27 -r1.28 84.966 +--- src/core/stats.c 4 Mar 2008 16:31:32 -0000 1.27 84.967 ++++ src/core/stats.c 27 Jun 2008 18:37:54 -0000 1.28 84.968 +@@ -54,7 +54,6 @@ stats_display_proto(struct stats_proto * 84.969 + { 84.970 + LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); 84.971 + LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); 84.972 +- LWIP_PLATFORM_DIAG(("rexmit: %"STAT_COUNTER_F"\n\t", proto->rexmit)); 84.973 + LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); 84.974 + LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); 84.975 + LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); 84.976 +@@ -68,6 +67,7 @@ stats_display_proto(struct stats_proto * 84.977 + LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); 84.978 + } 84.979 + 84.980 ++#if IGMP_STATS 84.981 + void 84.982 + stats_display_igmp(struct stats_igmp *igmp) 84.983 + { 84.984 +@@ -82,7 +82,9 @@ stats_display_igmp(struct stats_igmp *ig 84.985 + LWIP_PLATFORM_DIAG(("report_rxed: %"STAT_COUNTER_F"\n\t", igmp->report_rxed)); 84.986 + LWIP_PLATFORM_DIAG(("group_query_rxed: %"STAT_COUNTER_F"\n", igmp->group_query_rxed)); 84.987 + } 84.988 ++#endif /* IGMP_STATS */ 84.989 + 84.990 ++#if MEM_STATS || MEMP_STATS 84.991 + void 84.992 + stats_display_mem(struct stats_mem *mem, char *name) 84.993 + { 84.994 +@@ -93,48 +95,53 @@ stats_display_mem(struct stats_mem *mem, 84.995 + LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err)); 84.996 + } 84.997 + 84.998 ++#if MEMP_STATS 84.999 + void 84.1000 +-stats_display(void) 84.1001 ++stats_display_memp(struct stats_mem *mem, int index) 84.1002 + { 84.1003 +-#if MEMP_STATS 84.1004 +- s16_t i; 84.1005 + char * memp_names[] = { 84.1006 + #define LWIP_MEMPOOL(name,num,size,desc) desc, 84.1007 + #include "lwip/memp_std.h" 84.1008 + }; 84.1009 +-#endif 84.1010 +-#if LINK_STATS 84.1011 +- stats_display_proto(&lwip_stats.link, "LINK"); 84.1012 +-#endif 84.1013 +-#if ETHARP_STATS 84.1014 +- stats_display_proto(&lwip_stats.etharp, "ETHARP"); 84.1015 +-#endif 84.1016 +-#if IPFRAG_STATS 84.1017 +- stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG"); 84.1018 +-#endif 84.1019 +-#if IP_STATS 84.1020 +- stats_display_proto(&lwip_stats.ip, "IP"); 84.1021 +-#endif 84.1022 +-#if ICMP_STATS 84.1023 +- stats_display_proto(&lwip_stats.icmp, "ICMP"); 84.1024 +-#endif 84.1025 +-#if IGMP_STATS 84.1026 +- stats_display_igmp(&lwip_stats.igmp); 84.1027 +-#endif 84.1028 +-#if UDP_STATS 84.1029 +- stats_display_proto(&lwip_stats.udp, "UDP"); 84.1030 +-#endif 84.1031 +-#if TCP_STATS 84.1032 +- stats_display_proto(&lwip_stats.tcp, "TCP"); 84.1033 +-#endif 84.1034 +-#if MEM_STATS 84.1035 +- stats_display_mem(&lwip_stats.mem, "HEAP"); 84.1036 +-#endif 84.1037 +-#if MEMP_STATS 84.1038 ++ if(index < MEMP_MAX) { 84.1039 ++ stats_display_mem(mem, memp_names[index]); 84.1040 ++ } 84.1041 ++} 84.1042 ++#endif /* MEMP_STATS */ 84.1043 ++#endif /* MEM_STATS || MEMP_STATS */ 84.1044 ++ 84.1045 ++#if SYS_STATS 84.1046 ++void 84.1047 ++stats_display_sys(struct stats_sys *sys) 84.1048 ++{ 84.1049 ++ LWIP_PLATFORM_DIAG(("\nSYS\n\t")); 84.1050 ++ LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used)); 84.1051 ++ LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max)); 84.1052 ++ LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err)); 84.1053 ++ LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used)); 84.1054 ++ LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max)); 84.1055 ++ LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err)); 84.1056 ++} 84.1057 ++#endif /* SYS_STATS */ 84.1058 ++ 84.1059 ++void 84.1060 ++stats_display(void) 84.1061 ++{ 84.1062 ++ s16_t i; 84.1063 ++ 84.1064 ++ LINK_STATS_DISPLAY(); 84.1065 ++ ETHARP_STATS_DISPLAY(); 84.1066 ++ IPFRAG_STATS_DISPLAY(); 84.1067 ++ IP_STATS_DISPLAY(); 84.1068 ++ IGMP_STATS_DISPLAY(); 84.1069 ++ ICMP_STATS_DISPLAY(); 84.1070 ++ UDP_STATS_DISPLAY(); 84.1071 ++ TCP_STATS_DISPLAY(); 84.1072 ++ MEM_STATS_DISPLAY(); 84.1073 + for (i = 0; i < MEMP_MAX; i++) { 84.1074 +- stats_display_mem(&lwip_stats.memp[i], memp_names[i]); 84.1075 ++ MEMP_STATS_DISPLAY(i); 84.1076 + } 84.1077 +-#endif 84.1078 ++ SYS_STATS_DISPLAY(); 84.1079 + } 84.1080 + #endif /* LWIP_STATS_DISPLAY */ 84.1081 + 84.1082 +Index: src/core/sys.c 84.1083 +=================================================================== 84.1084 +RCS file: /sources/lwip/lwip/src/core/sys.c,v 84.1085 +retrieving revision 1.32 84.1086 +retrieving revision 1.33 84.1087 +diff -u -p -r1.32 -r1.33 84.1088 +--- src/core/sys.c 25 Nov 2007 13:57:05 -0000 1.32 84.1089 ++++ src/core/sys.c 16 Jul 2008 20:36:12 -0000 1.33 84.1090 +@@ -65,7 +65,7 @@ struct sswt_cb 84.1091 + void 84.1092 + sys_mbox_fetch(sys_mbox_t mbox, void **msg) 84.1093 + { 84.1094 +- u32_t time; 84.1095 ++ u32_t time_needed; 84.1096 + struct sys_timeouts *timeouts; 84.1097 + struct sys_timeo *tmptimeout; 84.1098 + sys_timeout_handler h; 84.1099 +@@ -76,18 +76,18 @@ sys_mbox_fetch(sys_mbox_t mbox, void **m 84.1100 + 84.1101 + if (!timeouts || !timeouts->next) { 84.1102 + UNLOCK_TCPIP_CORE(); 84.1103 +- time = sys_arch_mbox_fetch(mbox, msg, 0); 84.1104 ++ time_needed = sys_arch_mbox_fetch(mbox, msg, 0); 84.1105 + LOCK_TCPIP_CORE(); 84.1106 + } else { 84.1107 + if (timeouts->next->time > 0) { 84.1108 + UNLOCK_TCPIP_CORE(); 84.1109 +- time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time); 84.1110 ++ time_needed = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time); 84.1111 + LOCK_TCPIP_CORE(); 84.1112 + } else { 84.1113 +- time = SYS_ARCH_TIMEOUT; 84.1114 ++ time_needed = SYS_ARCH_TIMEOUT; 84.1115 + } 84.1116 + 84.1117 +- if (time == SYS_ARCH_TIMEOUT) { 84.1118 ++ if (time_needed == SYS_ARCH_TIMEOUT) { 84.1119 + /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message 84.1120 + could be fetched. We should now call the timeout handler and 84.1121 + deallocate the memory allocated for the timeout. */ 84.1122 +@@ -107,8 +107,8 @@ sys_mbox_fetch(sys_mbox_t mbox, void **m 84.1123 + /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout 84.1124 + occured. The time variable is set to the number of 84.1125 + milliseconds we waited for the message. */ 84.1126 +- if (time < timeouts->next->time) { 84.1127 +- timeouts->next->time -= time; 84.1128 ++ if (time_needed < timeouts->next->time) { 84.1129 ++ timeouts->next->time -= time_needed; 84.1130 + } else { 84.1131 + timeouts->next->time = 0; 84.1132 + } 84.1133 +@@ -125,7 +125,7 @@ sys_mbox_fetch(sys_mbox_t mbox, void **m 84.1134 + void 84.1135 + sys_sem_wait(sys_sem_t sem) 84.1136 + { 84.1137 +- u32_t time; 84.1138 ++ u32_t time_needed; 84.1139 + struct sys_timeouts *timeouts; 84.1140 + struct sys_timeo *tmptimeout; 84.1141 + sys_timeout_handler h; 84.1142 +@@ -139,12 +139,12 @@ sys_sem_wait(sys_sem_t sem) 84.1143 + sys_arch_sem_wait(sem, 0); 84.1144 + } else { 84.1145 + if (timeouts->next->time > 0) { 84.1146 +- time = sys_arch_sem_wait(sem, timeouts->next->time); 84.1147 ++ time_needed = sys_arch_sem_wait(sem, timeouts->next->time); 84.1148 + } else { 84.1149 +- time = SYS_ARCH_TIMEOUT; 84.1150 ++ time_needed = SYS_ARCH_TIMEOUT; 84.1151 + } 84.1152 + 84.1153 +- if (time == SYS_ARCH_TIMEOUT) { 84.1154 ++ if (time_needed == SYS_ARCH_TIMEOUT) { 84.1155 + /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message 84.1156 + could be fetched. We should now call the timeout handler and 84.1157 + deallocate the memory allocated for the timeout. */ 84.1158 +@@ -164,8 +164,8 @@ sys_sem_wait(sys_sem_t sem) 84.1159 + /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout 84.1160 + occured. The time variable is set to the number of 84.1161 + milliseconds we waited for the message. */ 84.1162 +- if (time < timeouts->next->time) { 84.1163 +- timeouts->next->time -= time; 84.1164 ++ if (time_needed < timeouts->next->time) { 84.1165 ++ timeouts->next->time -= time_needed; 84.1166 + } else { 84.1167 + timeouts->next->time = 0; 84.1168 + } 84.1169 +Index: src/core/tcp.c 84.1170 +=================================================================== 84.1171 +RCS file: /sources/lwip/lwip/src/core/tcp.c,v 84.1172 +retrieving revision 1.85 84.1173 +retrieving revision 1.86 84.1174 +diff -u -p -r1.85 -r1.86 84.1175 +--- src/core/tcp.c 22 Jan 2008 21:15:15 -0000 1.85 84.1176 ++++ src/core/tcp.c 26 Mar 2008 11:57:13 -0000 1.86 84.1177 +@@ -509,7 +509,8 @@ tcp_connect(struct tcp_pcb *pcb, struct 84.1178 + pcb->rcv_wnd = TCP_WND; 84.1179 + pcb->rcv_ann_wnd = TCP_WND; 84.1180 + pcb->snd_wnd = TCP_WND; 84.1181 +- /* The send MSS is updated when an MSS option is received. */ 84.1182 ++ /* As initial send MSS, we use TCP_MSS but limit it to 536. 84.1183 ++ The send MSS is updated when an MSS option is received. */ 84.1184 + pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS; 84.1185 + #if TCP_CALCULATE_EFF_SEND_MSS 84.1186 + pcb->mss = tcp_eff_send_mss(pcb->mss, ipaddr); 84.1187 +@@ -991,7 +992,8 @@ tcp_alloc(u8_t prio) 84.1188 + pcb->rcv_ann_wnd = TCP_WND; 84.1189 + pcb->tos = 0; 84.1190 + pcb->ttl = TCP_TTL; 84.1191 +- /* The send MSS is updated when an MSS option is received. */ 84.1192 ++ /* As initial send MSS, we use TCP_MSS but limit it to 536. 84.1193 ++ The send MSS is updated when an MSS option is received. */ 84.1194 + pcb->mss = (TCP_MSS > 536) ? 536 : TCP_MSS; 84.1195 + pcb->rto = 3000 / TCP_SLOW_INTERVAL; 84.1196 + pcb->sa = 0; 84.1197 +Index: src/core/tcp_in.c 84.1198 +=================================================================== 84.1199 +RCS file: /sources/lwip/lwip/src/core/tcp_in.c,v 84.1200 +retrieving revision 1.97 84.1201 +retrieving revision 1.100 84.1202 +diff -u -p -r1.97 -r1.100 84.1203 +--- src/core/tcp_in.c 22 Jan 2008 21:15:15 -0000 1.97 84.1204 ++++ src/core/tcp_in.c 24 Jun 2008 15:46:39 -0000 1.100 84.1205 +@@ -511,7 +511,7 @@ tcp_process(struct tcp_pcb *pcb) 84.1206 + } 84.1207 + } else { 84.1208 + if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, 84.1209 +- pcb->rcv_nxt+pcb->rcv_ann_wnd)) { 84.1210 ++ pcb->rcv_nxt+pcb->rcv_wnd)) { 84.1211 + acceptable = 1; 84.1212 + } 84.1213 + } 84.1214 +@@ -1038,7 +1038,7 @@ tcp_receive(struct tcp_pcb *pcb) 84.1215 + and below rcv_nxt + rcv_wnd) in order to be further 84.1216 + processed. */ 84.1217 + if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, 84.1218 +- pcb->rcv_nxt + pcb->rcv_ann_wnd - 1)){ 84.1219 ++ pcb->rcv_nxt + pcb->rcv_wnd - 1)){ 84.1220 + if (pcb->rcv_nxt == seqno) { 84.1221 + accepted_inseq = 1; 84.1222 + /* The incoming segment is the next in sequence. We check if 84.1223 +@@ -1195,14 +1195,14 @@ tcp_receive(struct tcp_pcb *pcb) 84.1224 + } else { 84.1225 + pcb->ooseq = cseg; 84.1226 + } 84.1227 +- } 84.1228 +- tcp_seg_free(next); 84.1229 +- if (cseg->next != NULL) { 84.1230 +- next = cseg->next; 84.1231 +- if (TCP_SEQ_GT(seqno + cseg->len, next->tcphdr->seqno)) { 84.1232 +- /* We need to trim the incoming segment. */ 84.1233 +- cseg->len = (u16_t)(next->tcphdr->seqno - seqno); 84.1234 +- pbuf_realloc(cseg->p, cseg->len); 84.1235 ++ tcp_seg_free(next); 84.1236 ++ if (cseg->next != NULL) { 84.1237 ++ next = cseg->next; 84.1238 ++ if (TCP_SEQ_GT(seqno + cseg->len, next->tcphdr->seqno)) { 84.1239 ++ /* We need to trim the incoming segment. */ 84.1240 ++ cseg->len = (u16_t)(next->tcphdr->seqno - seqno); 84.1241 ++ pbuf_realloc(cseg->p, cseg->len); 84.1242 ++ } 84.1243 + } 84.1244 + } 84.1245 + break; 84.1246 +@@ -1282,10 +1282,7 @@ tcp_receive(struct tcp_pcb *pcb) 84.1247 + 84.1248 + } 84.1249 + } else { 84.1250 +- if(!TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, 84.1251 +- pcb->rcv_nxt + pcb->rcv_ann_wnd-1)){ 84.1252 +- tcp_ack_now(pcb); 84.1253 +- } 84.1254 ++ tcp_ack_now(pcb); 84.1255 + } 84.1256 + } else { 84.1257 + /* Segments with length 0 is taken care of here. Segments that 84.1258 +@@ -1331,7 +1328,8 @@ tcp_parseopt(struct tcp_pcb *pcb) 84.1259 + opts[c + 1] == 0x04) { 84.1260 + /* An MSS option with the right option length. */ 84.1261 + mss = (opts[c + 2] << 8) | opts[c + 3]; 84.1262 +- pcb->mss = mss > TCP_MSS? TCP_MSS: mss; 84.1263 ++ /* Limit the mss to the configured TCP_MSS and prevent division by zero */ 84.1264 ++ pcb->mss = ((mss > TCP_MSS) || (mss == 0)) ? TCP_MSS : mss; 84.1265 + 84.1266 + /* And we are done processing options. */ 84.1267 + break; 84.1268 +Index: src/core/ipv4/autoip.c 84.1269 +=================================================================== 84.1270 +RCS file: /sources/lwip/lwip/src/core/ipv4/autoip.c,v 84.1271 +retrieving revision 1.16 84.1272 +retrieving revision 1.17 84.1273 +diff -u -p -r1.16 -r1.17 84.1274 +--- src/core/ipv4/autoip.c 26 Jan 2008 16:11:40 -0000 1.16 84.1275 ++++ src/core/ipv4/autoip.c 17 Jun 2008 20:16:23 -0000 1.17 84.1276 +@@ -395,8 +395,8 @@ autoip_arp_reply(struct netif *netif, st 84.1277 + /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without 84.1278 + * structure packing (not using structure copy which breaks strict-aliasing rules). 84.1279 + */ 84.1280 +- MEMCPY(&sipaddr, &hdr->sipaddr, sizeof(sipaddr)); 84.1281 +- MEMCPY(&dipaddr, &hdr->dipaddr, sizeof(dipaddr)); 84.1282 ++ SMEMCPY(&sipaddr, &hdr->sipaddr, sizeof(sipaddr)); 84.1283 ++ SMEMCPY(&dipaddr, &hdr->dipaddr, sizeof(dipaddr)); 84.1284 + 84.1285 + if ((netif->autoip->state == AUTOIP_STATE_PROBING) || 84.1286 + ((netif->autoip->state == AUTOIP_STATE_ANNOUNCING) && 84.1287 +Index: src/core/ipv4/inet_chksum.c 84.1288 +=================================================================== 84.1289 +RCS file: /sources/lwip/lwip/src/core/ipv4/inet_chksum.c,v 84.1290 +retrieving revision 1.4 84.1291 +retrieving revision 1.5 84.1292 +diff -u -p -r1.4 -r1.5 84.1293 +--- src/core/ipv4/inet_chksum.c 10 Mar 2008 16:12:31 -0000 1.4 84.1294 ++++ src/core/ipv4/inet_chksum.c 17 Jun 2008 20:06:25 -0000 1.5 84.1295 +@@ -41,8 +41,6 @@ 84.1296 + #include "lwip/inet_chksum.h" 84.1297 + #include "lwip/inet.h" 84.1298 + 84.1299 +-#include <string.h> 84.1300 +- 84.1301 + /* These are some reference implementations of the checksum algorithm, with the 84.1302 + * aim of being simple, correct and fully portable. Checksumming is the 84.1303 + * first thing you would want to optimize for your platform. If you create 84.1304 +@@ -65,6 +63,11 @@ 84.1305 + # define LWIP_CHKSUM_ALGORITHM 0 84.1306 + #endif 84.1307 + 84.1308 ++/** Like the name says... */ 84.1309 ++#define SWAP_BYTES_IN_WORD(w) ((w & 0xff) << 8) | ((w & 0xff00) >> 8) 84.1310 ++/** Split an u32_t in two u16_ts and add them up */ 84.1311 ++#define FOLD_U32T(u) ((u >> 16) + (u & 0x0000ffffUL)) 84.1312 ++ 84.1313 + #if (LWIP_CHKSUM_ALGORITHM == 1) /* Version #1 */ 84.1314 + /** 84.1315 + * lwip checksum 84.1316 +@@ -86,8 +89,7 @@ lwip_standard_chksum(void *dataptr, u16_ 84.1317 + acc = 0; 84.1318 + /* dataptr may be at odd or even addresses */ 84.1319 + octetptr = (u8_t*)dataptr; 84.1320 +- while (len > 1) 84.1321 +- { 84.1322 ++ while (len > 1) { 84.1323 + /* declare first octet as most significant 84.1324 + thus assume network order, ignoring host order */ 84.1325 + src = (*octetptr) << 8; 84.1326 +@@ -98,8 +100,7 @@ lwip_standard_chksum(void *dataptr, u16_ 84.1327 + acc += src; 84.1328 + len -= 2; 84.1329 + } 84.1330 +- if (len > 0) 84.1331 +- { 84.1332 ++ if (len > 0) { 84.1333 + /* accumulate remaining octet */ 84.1334 + src = (*octetptr) << 8; 84.1335 + acc += src; 84.1336 +@@ -154,19 +155,22 @@ lwip_standard_chksum(void *dataptr, int 84.1337 + } 84.1338 + 84.1339 + /* Consume left-over byte, if any */ 84.1340 +- if (len > 0) 84.1341 ++ if (len > 0) { 84.1342 + ((u8_t *)&t)[0] = *(u8_t *)ps;; 84.1343 ++ } 84.1344 + 84.1345 + /* Add end bytes */ 84.1346 + sum += t; 84.1347 + 84.1348 +- /* Fold 32-bit sum to 16 bits */ 84.1349 +- while ((sum >> 16) != 0) 84.1350 +- sum = (sum & 0xffff) + (sum >> 16); 84.1351 ++ /* Fold 32-bit sum to 16 bits 84.1352 ++ calling this twice is propably faster than if statements... */ 84.1353 ++ sum = FOLD_U32T(sum); 84.1354 ++ sum = FOLD_U32T(sum); 84.1355 + 84.1356 + /* Swap if alignment was odd */ 84.1357 +- if (odd) 84.1358 +- sum = ((sum & 0xff) << 8) | ((sum & 0xff00) >> 8); 84.1359 ++ if (odd) { 84.1360 ++ sum = SWAP_BYTES_IN_WORD(sum); 84.1361 ++ } 84.1362 + 84.1363 + return sum; 84.1364 + } 84.1365 +@@ -211,18 +215,20 @@ lwip_standard_chksum(void *dataptr, int 84.1366 + 84.1367 + while (len > 7) { 84.1368 + tmp = sum + *pl++; /* ping */ 84.1369 +- if (tmp < sum) 84.1370 ++ if (tmp < sum) { 84.1371 + tmp++; /* add back carry */ 84.1372 ++ } 84.1373 + 84.1374 + sum = tmp + *pl++; /* pong */ 84.1375 +- if (sum < tmp) 84.1376 ++ if (sum < tmp) { 84.1377 + sum++; /* add back carry */ 84.1378 ++ } 84.1379 + 84.1380 + len -= 8; 84.1381 + } 84.1382 + 84.1383 + /* make room in upper bits */ 84.1384 +- sum = (sum >> 16) + (sum & 0xffff); 84.1385 ++ sum = FOLD_U32T(sum); 84.1386 + 84.1387 + ps = (u16_t *)pl; 84.1388 + 84.1389 +@@ -233,16 +239,20 @@ lwip_standard_chksum(void *dataptr, int 84.1390 + } 84.1391 + 84.1392 + /* dangling tail byte remaining? */ 84.1393 +- if (len > 0) /* include odd byte */ 84.1394 ++ if (len > 0) { /* include odd byte */ 84.1395 + ((u8_t *)&t)[0] = *(u8_t *)ps; 84.1396 ++ } 84.1397 + 84.1398 + sum += t; /* add end bytes */ 84.1399 + 84.1400 +- while ((sum >> 16) != 0) /* combine halves */ 84.1401 +- sum = (sum >> 16) + (sum & 0xffff); 84.1402 ++ /* Fold 32-bit sum to 16 bits 84.1403 ++ calling this twice is propably faster than if statements... */ 84.1404 ++ sum = FOLD_U32T(sum); 84.1405 ++ sum = FOLD_U32T(sum); 84.1406 + 84.1407 +- if (odd) 84.1408 +- sum = ((sum & 0xff) << 8) | ((sum & 0xff00) >> 8); 84.1409 ++ if (odd) { 84.1410 ++ sum = SWAP_BYTES_IN_WORD(sum); 84.1411 ++ } 84.1412 + 84.1413 + return sum; 84.1414 + } 84.1415 +@@ -277,18 +287,18 @@ inet_chksum_pseudo(struct pbuf *p, 84.1416 + (void *)q, (void *)q->next)); 84.1417 + acc += LWIP_CHKSUM(q->payload, q->len); 84.1418 + /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/ 84.1419 +- while ((acc >> 16) != 0) { 84.1420 +- acc = (acc & 0xffffUL) + (acc >> 16); 84.1421 +- } 84.1422 ++ /* just executing this next line is probably faster that the if statement needed 84.1423 ++ to check whether we really need to execute it, and does no harm */ 84.1424 ++ acc = FOLD_U32T(acc); 84.1425 + if (q->len % 2 != 0) { 84.1426 + swapped = 1 - swapped; 84.1427 +- acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8); 84.1428 ++ acc = SWAP_BYTES_IN_WORD(acc); 84.1429 + } 84.1430 + /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/ 84.1431 + } 84.1432 + 84.1433 + if (swapped) { 84.1434 +- acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8); 84.1435 ++ acc = SWAP_BYTES_IN_WORD(acc); 84.1436 + } 84.1437 + acc += (src->addr & 0xffffUL); 84.1438 + acc += ((src->addr >> 16) & 0xffffUL); 84.1439 +@@ -297,9 +307,10 @@ inet_chksum_pseudo(struct pbuf *p, 84.1440 + acc += (u32_t)htons((u16_t)proto); 84.1441 + acc += (u32_t)htons(proto_len); 84.1442 + 84.1443 +- while ((acc >> 16) != 0) { 84.1444 +- acc = (acc & 0xffffUL) + (acc >> 16); 84.1445 +- } 84.1446 ++ /* Fold 32-bit sum to 16 bits 84.1447 ++ calling this twice is propably faster than if statements... */ 84.1448 ++ acc = FOLD_U32T(acc); 84.1449 ++ acc = FOLD_U32T(acc); 84.1450 + LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc)); 84.1451 + return (u16_t)~(acc & 0xffffUL); 84.1452 + } 84.1453 +@@ -340,18 +351,17 @@ inet_chksum_pseudo_partial(struct pbuf * 84.1454 + chksum_len -= chklen; 84.1455 + LWIP_ASSERT("delete me", chksum_len < 0x7fff); 84.1456 + /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%"X32_F" \n", acc));*/ 84.1457 +- while ((acc >> 16) != 0) { 84.1458 +- acc = (acc & 0xffffUL) + (acc >> 16); 84.1459 +- } 84.1460 ++ /* fold the upper bit down */ 84.1461 ++ acc = FOLD_U32T(acc); 84.1462 + if (q->len % 2 != 0) { 84.1463 + swapped = 1 - swapped; 84.1464 +- acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8); 84.1465 ++ acc = SWAP_BYTES_IN_WORD(acc); 84.1466 + } 84.1467 + /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%"X32_F" \n", acc));*/ 84.1468 + } 84.1469 + 84.1470 + if (swapped) { 84.1471 +- acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8); 84.1472 ++ acc = SWAP_BYTES_IN_WORD(acc); 84.1473 + } 84.1474 + acc += (src->addr & 0xffffUL); 84.1475 + acc += ((src->addr >> 16) & 0xffffUL); 84.1476 +@@ -360,9 +370,10 @@ inet_chksum_pseudo_partial(struct pbuf * 84.1477 + acc += (u32_t)htons((u16_t)proto); 84.1478 + acc += (u32_t)htons(proto_len); 84.1479 + 84.1480 +- while ((acc >> 16) != 0) { 84.1481 +- acc = (acc & 0xffffUL) + (acc >> 16); 84.1482 +- } 84.1483 ++ /* Fold 32-bit sum to 16 bits 84.1484 ++ calling this twice is propably faster than if statements... */ 84.1485 ++ acc = FOLD_U32T(acc); 84.1486 ++ acc = FOLD_U32T(acc); 84.1487 + LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%"X32_F"\n", acc)); 84.1488 + return (u16_t)~(acc & 0xffffUL); 84.1489 + } 84.1490 +@@ -380,13 +391,7 @@ inet_chksum_pseudo_partial(struct pbuf * 84.1491 + u16_t 84.1492 + inet_chksum(void *dataptr, u16_t len) 84.1493 + { 84.1494 +- u32_t acc; 84.1495 +- 84.1496 +- acc = LWIP_CHKSUM(dataptr, len); 84.1497 +- while ((acc >> 16) != 0) { 84.1498 +- acc = (acc & 0xffff) + (acc >> 16); 84.1499 +- } 84.1500 +- return (u16_t)~(acc & 0xffff); 84.1501 ++ return ~LWIP_CHKSUM(dataptr, len); 84.1502 + } 84.1503 + 84.1504 + /** 84.1505 +@@ -407,17 +412,15 @@ inet_chksum_pbuf(struct pbuf *p) 84.1506 + swapped = 0; 84.1507 + for(q = p; q != NULL; q = q->next) { 84.1508 + acc += LWIP_CHKSUM(q->payload, q->len); 84.1509 +- while ((acc >> 16) != 0) { 84.1510 +- acc = (acc & 0xffffUL) + (acc >> 16); 84.1511 +- } 84.1512 ++ acc = FOLD_U32T(acc); 84.1513 + if (q->len % 2 != 0) { 84.1514 + swapped = 1 - swapped; 84.1515 +- acc = (acc & 0x00ffUL << 8) | (acc & 0xff00UL >> 8); 84.1516 ++ acc = SWAP_BYTES_IN_WORD(acc); 84.1517 + } 84.1518 + } 84.1519 + 84.1520 + if (swapped) { 84.1521 +- acc = ((acc & 0x00ffUL) << 8) | ((acc & 0xff00UL) >> 8); 84.1522 ++ acc = SWAP_BYTES_IN_WORD(acc); 84.1523 + } 84.1524 + return (u16_t)~(acc & 0xffffUL); 84.1525 + } 84.1526 +Index: src/core/ipv4/ip.c 84.1527 +=================================================================== 84.1528 +RCS file: /sources/lwip/lwip/src/core/ipv4/ip.c,v 84.1529 +retrieving revision 1.66 84.1530 +retrieving revision 1.68 84.1531 +diff -u -p -r1.66 -r1.68 84.1532 +--- src/core/ipv4/ip.c 14 Jan 2008 20:53:23 -0000 1.66 84.1533 ++++ src/core/ipv4/ip.c 17 Jun 2008 19:39:22 -0000 1.68 84.1534 +@@ -531,9 +531,19 @@ ip_output_if(struct pbuf *p, struct ip_a 84.1535 + LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%"U16_F"\n", netif->name[0], netif->name[1], netif->num)); 84.1536 + ip_debug_print(p); 84.1537 + 84.1538 +- LWIP_DEBUGF(IP_DEBUG, ("netif->output()")); 84.1539 ++#if (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) 84.1540 ++ if (ip_addr_cmp(dest, &netif->ip_addr)) { 84.1541 ++ /* Packet to self, enqueue it for loopback */ 84.1542 ++ LWIP_DEBUGF(IP_DEBUG, ("netif_loop_output()")); 84.1543 ++ 84.1544 ++ return netif_loop_output(netif, p, dest); 84.1545 ++ } else 84.1546 ++#endif /* (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) */ 84.1547 ++ { 84.1548 ++ LWIP_DEBUGF(IP_DEBUG, ("netif->output()")); 84.1549 + 84.1550 +- return netif->output(netif, p, dest); 84.1551 ++ return netif->output(netif, p, dest); 84.1552 ++ } 84.1553 + } 84.1554 + 84.1555 + /** 84.1556 +Index: src/include/lwip/debug.h 84.1557 +=================================================================== 84.1558 +RCS file: /sources/lwip/lwip/src/include/lwip/debug.h,v 84.1559 +retrieving revision 1.37 84.1560 +retrieving revision 1.39 84.1561 +diff -u -p -r1.37 -r1.39 84.1562 +--- src/include/lwip/debug.h 22 Sep 2007 11:16:07 -0000 1.37 84.1563 ++++ src/include/lwip/debug.h 16 Jul 2008 20:36:22 -0000 1.39 84.1564 +@@ -61,26 +61,28 @@ 84.1565 + #define LWIP_DBG_HALT 0x08U 84.1566 + 84.1567 + #ifndef LWIP_NOASSERT 84.1568 +-#define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0) 84.1569 ++#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ 84.1570 ++ LWIP_PLATFORM_ASSERT(message); } while(0) 84.1571 + #else /* LWIP_NOASSERT */ 84.1572 +-#define LWIP_ASSERT(x,y) 84.1573 ++#define LWIP_ASSERT(message, assertion) 84.1574 + #endif /* LWIP_NOASSERT */ 84.1575 + 84.1576 +-/** print "m" message only if "e" is true, and execute "h" expression */ 84.1577 ++/** if "expression" isn't true, then print "message" and execute "handler" expression */ 84.1578 + #ifndef LWIP_ERROR 84.1579 +-#define LWIP_ERROR(m,e,h) do { if (!(e)) { LWIP_PLATFORM_ASSERT(m); h;}} while(0) 84.1580 ++#define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ 84.1581 ++ LWIP_PLATFORM_ASSERT(message); handler;}} while(0) 84.1582 + #endif /* LWIP_ERROR */ 84.1583 + 84.1584 + #ifdef LWIP_DEBUG 84.1585 + /** print debug message only if debug message type is enabled... 84.1586 + * AND is of correct type AND is at least LWIP_DBG_LEVEL 84.1587 + */ 84.1588 +-#define LWIP_DEBUGF(debug,x) do { \ 84.1589 ++#define LWIP_DEBUGF(debug, message) do { \ 84.1590 + if ( \ 84.1591 + ((debug) & LWIP_DBG_ON) && \ 84.1592 + ((debug) & LWIP_DBG_TYPES_ON) && \ 84.1593 + ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ 84.1594 +- LWIP_PLATFORM_DIAG(x); \ 84.1595 ++ LWIP_PLATFORM_DIAG(message); \ 84.1596 + if ((debug) & LWIP_DBG_HALT) { \ 84.1597 + while(1); \ 84.1598 + } \ 84.1599 +@@ -88,7 +90,7 @@ 84.1600 + } while(0) 84.1601 + 84.1602 + #else /* LWIP_DEBUG */ 84.1603 +-#define LWIP_DEBUGF(debug,x) 84.1604 ++#define LWIP_DEBUGF(debug, message) 84.1605 + #endif /* LWIP_DEBUG */ 84.1606 + 84.1607 + #endif /* __LWIP_DEBUG_H__ */ 84.1608 +Index: src/include/lwip/err.h 84.1609 +=================================================================== 84.1610 +RCS file: /sources/lwip/lwip/src/include/lwip/err.h,v 84.1611 +retrieving revision 1.13 84.1612 +retrieving revision 1.15 84.1613 +diff -u -p -r1.13 -r1.15 84.1614 +--- src/include/lwip/err.h 13 Dec 2007 23:06:50 -0000 1.13 84.1615 ++++ src/include/lwip/err.h 17 Jun 2008 20:27:32 -0000 1.15 84.1616 +@@ -33,37 +33,43 @@ 84.1617 + #define __LWIP_ERR_H__ 84.1618 + 84.1619 + #include "lwip/opt.h" 84.1620 ++#include "lwip/arch.h" 84.1621 + 84.1622 + #ifdef __cplusplus 84.1623 + extern "C" { 84.1624 + #endif 84.1625 + 84.1626 +-typedef s8_t err_t; 84.1627 ++/** Define LWIP_ERR_T in cc.h if you want to use 84.1628 ++ * a different type for your platform (must be signed). */ 84.1629 ++#ifdef LWIP_ERR_T 84.1630 ++typedef LWIP_ERR_T err_t; 84.1631 ++#else /* LWIP_ERR_T */ 84.1632 ++ typedef s8_t err_t; 84.1633 ++#endif /* LWIP_ERR_T*/ 84.1634 + 84.1635 + /* Definitions for error constants. */ 84.1636 + 84.1637 + #define ERR_OK 0 /* No error, everything OK. */ 84.1638 + #define ERR_MEM -1 /* Out of memory error. */ 84.1639 + #define ERR_BUF -2 /* Buffer error. */ 84.1640 +-#define ERR_RTE -3 /* Routing problem. */ 84.1641 ++#define ERR_TIMEOUT -3 /* Timeout. */ 84.1642 ++#define ERR_RTE -4 /* Routing problem. */ 84.1643 + 84.1644 + #define ERR_IS_FATAL(e) ((e) < ERR_RTE) 84.1645 + 84.1646 +-#define ERR_ABRT -4 /* Connection aborted. */ 84.1647 +-#define ERR_RST -5 /* Connection reset. */ 84.1648 +-#define ERR_CLSD -6 /* Connection closed. */ 84.1649 +-#define ERR_CONN -7 /* Not connected. */ 84.1650 ++#define ERR_ABRT -5 /* Connection aborted. */ 84.1651 ++#define ERR_RST -6 /* Connection reset. */ 84.1652 ++#define ERR_CLSD -7 /* Connection closed. */ 84.1653 ++#define ERR_CONN -8 /* Not connected. */ 84.1654 + 84.1655 +-#define ERR_VAL -8 /* Illegal value. */ 84.1656 ++#define ERR_VAL -9 /* Illegal value. */ 84.1657 + 84.1658 +-#define ERR_ARG -9 /* Illegal argument. */ 84.1659 ++#define ERR_ARG -10 /* Illegal argument. */ 84.1660 + 84.1661 +-#define ERR_USE -10 /* Address in use. */ 84.1662 ++#define ERR_USE -11 /* Address in use. */ 84.1663 + 84.1664 +-#define ERR_IF -11 /* Low-level netif error */ 84.1665 +-#define ERR_ISCONN -12 /* Already connected. */ 84.1666 +- 84.1667 +-#define ERR_TIMEOUT -13 /* Timeout. */ 84.1668 ++#define ERR_IF -12 /* Low-level netif error */ 84.1669 ++#define ERR_ISCONN -13 /* Already connected. */ 84.1670 + 84.1671 + #define ERR_INPROGRESS -14 /* Operation in progress */ 84.1672 + 84.1673 +Index: src/include/lwip/mem.h 84.1674 +=================================================================== 84.1675 +RCS file: /sources/lwip/lwip/src/include/lwip/mem.h,v 84.1676 +retrieving revision 1.21 84.1677 +retrieving revision 1.22 84.1678 +diff -u -p -r1.21 -r1.22 84.1679 +--- src/include/lwip/mem.h 4 Mar 2008 16:31:32 -0000 1.21 84.1680 ++++ src/include/lwip/mem.h 30 May 2008 11:37:15 -0000 1.22 84.1681 +@@ -50,16 +50,16 @@ typedef size_t mem_size_t; 84.1682 + * allow these defines to be overridden. 84.1683 + */ 84.1684 + #ifndef mem_free 84.1685 +-#define mem_free(x) free(x) 84.1686 ++#define mem_free free 84.1687 + #endif 84.1688 + #ifndef mem_malloc 84.1689 +-#define mem_malloc(x) malloc(x) 84.1690 ++#define mem_malloc malloc 84.1691 + #endif 84.1692 + #ifndef mem_calloc 84.1693 +-#define mem_calloc(x, y) calloc(x, y) 84.1694 ++#define mem_calloc calloc 84.1695 + #endif 84.1696 + #ifndef mem_realloc 84.1697 +-#define mem_realloc(x, size) (x) 84.1698 ++#define mem_realloc realloc 84.1699 + #endif 84.1700 + #else /* MEM_LIBC_MALLOC */ 84.1701 + 84.1702 +Index: src/include/lwip/netif.h 84.1703 +=================================================================== 84.1704 +RCS file: /sources/lwip/lwip/src/include/lwip/netif.h,v 84.1705 +retrieving revision 1.43 84.1706 +retrieving revision 1.46 84.1707 +diff -u -p -r1.43 -r1.46 84.1708 +--- src/include/lwip/netif.h 9 Oct 2007 19:59:59 -0000 1.43 84.1709 ++++ src/include/lwip/netif.h 19 Jun 2008 16:27:23 -0000 1.46 84.1710 +@@ -34,6 +34,8 @@ 84.1711 + 84.1712 + #include "lwip/opt.h" 84.1713 + 84.1714 ++#define ENABLE_LOOPBACK (LWIP_NETIF_LOOPBACK || LWIP_HAVE_LOOPIF) 84.1715 ++ 84.1716 + #include "lwip/err.h" 84.1717 + 84.1718 + #include "lwip/ip_addr.h" 84.1719 +@@ -165,6 +167,14 @@ struct netif { 84.1720 + #if LWIP_NETIF_HWADDRHINT 84.1721 + u8_t *addr_hint; 84.1722 + #endif /* LWIP_NETIF_HWADDRHINT */ 84.1723 ++#if ENABLE_LOOPBACK 84.1724 ++ /* List of packets to be queued for ourselves. */ 84.1725 ++ struct pbuf *loop_first; 84.1726 ++ struct pbuf *loop_last; 84.1727 ++#if LWIP_LOOPBACK_MAX_PBUFS 84.1728 ++ u16_t loop_cnt_current; 84.1729 ++#endif /* LWIP_LOOPBACK_MAX_PBUFS */ 84.1730 ++#endif /* ENABLE_LOOPBACK */ 84.1731 + }; 84.1732 + 84.1733 + #if LWIP_SNMP 84.1734 +@@ -242,4 +252,12 @@ void netif_set_link_callback(struct neti 84.1735 + } 84.1736 + #endif 84.1737 + 84.1738 ++#if ENABLE_LOOPBACK 84.1739 ++err_t netif_loop_output(struct netif *netif, struct pbuf *p, struct ip_addr *dest_ip); 84.1740 ++void netif_poll(struct netif *netif); 84.1741 ++#if !LWIP_NETIF_LOOPBACK_MULTITHREADING 84.1742 ++void netif_poll_all(void); 84.1743 ++#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ 84.1744 ++#endif /* ENABLE_LOOPBACK */ 84.1745 ++ 84.1746 + #endif /* __LWIP_NETIF_H__ */ 84.1747 +Index: src/include/lwip/opt.h 84.1748 +=================================================================== 84.1749 +RCS file: /sources/lwip/lwip/src/include/lwip/opt.h,v 84.1750 +retrieving revision 1.116 84.1751 +retrieving revision 1.122 84.1752 +diff -u -p -r1.116 -r1.122 84.1753 +--- src/include/lwip/opt.h 31 Jan 2008 18:19:29 -0000 1.116 84.1754 ++++ src/include/lwip/opt.h 30 Jun 2008 18:16:52 -0000 1.122 84.1755 +@@ -155,6 +155,27 @@ 84.1756 + #define MEMP_USE_CUSTOM_POOLS 0 84.1757 + #endif 84.1758 + 84.1759 ++/** 84.1760 ++ * Set this to 1 if you want to free PBUF_RAM pbufs (or call mem_free()) from 84.1761 ++ * interrupt context (or another context that doesn't allow waiting for a 84.1762 ++ * semaphore). 84.1763 ++ * If set to 1, mem_malloc will be protected by a semaphore and SYS_ARCH_PROTECT, 84.1764 ++ * while mem_free will only use SYS_ARCH_PROTECT. mem_malloc SYS_ARCH_UNPROTECTs 84.1765 ++ * with each loop so that mem_free can run. 84.1766 ++ * 84.1767 ++ * ATTENTION: As you can see from the above description, this leads to dis-/ 84.1768 ++ * enabling interrupts often, which can be slow! Also, on low memory, mem_malloc 84.1769 ++ * can need longer. 84.1770 ++ * 84.1771 ++ * If you don't want that, at least for NO_SYS=0, you can still use the following 84.1772 ++ * functions to enqueue a deallocation call which then runs in the tcpip_thread 84.1773 ++ * context: 84.1774 ++ * - pbuf_free_callback(p); 84.1775 ++ * - mem_free_callback(m); 84.1776 ++ */ 84.1777 ++#ifndef LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 84.1778 ++#define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 0 84.1779 ++#endif 84.1780 + 84.1781 + /* 84.1782 + ------------------------------------------------ 84.1783 +@@ -815,6 +836,39 @@ 84.1784 + #define LWIP_NETIF_HWADDRHINT 0 84.1785 + #endif 84.1786 + 84.1787 ++/** 84.1788 ++ * LWIP_NETIF_LOOPBACK==1: Support sending packets with a destination IP 84.1789 ++ * address equal to the netif IP address, looping them back up the stack. 84.1790 ++ */ 84.1791 ++#ifndef LWIP_NETIF_LOOPBACK 84.1792 ++#define LWIP_NETIF_LOOPBACK 0 84.1793 ++#endif 84.1794 ++ 84.1795 ++/** 84.1796 ++ * LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback 84.1797 ++ * sending for each netif (0 = disabled) 84.1798 ++ */ 84.1799 ++#ifndef LWIP_LOOPBACK_MAX_PBUFS 84.1800 ++#define LWIP_LOOPBACK_MAX_PBUFS 0 84.1801 ++#endif 84.1802 ++ 84.1803 ++/** 84.1804 ++ * LWIP_NETIF_LOOPBACK_MULTITHREADING: Indicates whether threading is enabled in 84.1805 ++ * the system, as netifs must change how they behave depending on this setting 84.1806 ++ * for the LWIP_NETIF_LOOPBACK option to work. 84.1807 ++ * Setting this is needed to avoid reentering non-reentrant functions like 84.1808 ++ * tcp_input(). 84.1809 ++ * LWIP_NETIF_LOOPBACK_MULTITHREADING==1: Indicates that the user is using a 84.1810 ++ * multithreaded environment like tcpip.c. In this case, netif->input() 84.1811 ++ * is called directly. 84.1812 ++ * LWIP_NETIF_LOOPBACK_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup. 84.1813 ++ * The packets are put on a list and netif_poll() must be called in 84.1814 ++ * the main application loop. 84.1815 ++ */ 84.1816 ++#ifndef LWIP_NETIF_LOOPBACK_MULTITHREADING 84.1817 ++#define LWIP_NETIF_LOOPBACK_MULTITHREADING (!NO_SYS) 84.1818 ++#endif 84.1819 ++ 84.1820 + /* 84.1821 + ------------------------------------ 84.1822 + ---------- LOOPIF options ---------- 84.1823 +@@ -827,20 +881,16 @@ 84.1824 + #define LWIP_HAVE_LOOPIF 0 84.1825 + #endif 84.1826 + 84.1827 ++/* 84.1828 ++ ------------------------------------ 84.1829 ++ ---------- SLIPIF options ---------- 84.1830 ++ ------------------------------------ 84.1831 ++*/ 84.1832 + /** 84.1833 +- * LWIP_LOOPIF_MULTITHREADING: Indicates whether threading is enabled in 84.1834 +- * the system, as LOOPIF must change how it behaves depending on this setting. 84.1835 +- * Setting this is needed to avoid reentering non-reentrant functions like 84.1836 +- * tcp_input(). 84.1837 +- * LWIP_LOOPIF_MULTITHREADING==1: Indicates that the user is using a 84.1838 +- * multithreaded environment like tcpip.c. In this case, netif->input() 84.1839 +- * is called directly. 84.1840 +- * LWIP_LOOPIF_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup. 84.1841 +- * The packets are put on a list and loopif_poll() must be called in 84.1842 +- * the main application loop. 84.1843 ++ * LWIP_HAVE_SLIPIF==1: Support slip interface and slipif.c 84.1844 + */ 84.1845 +-#ifndef LWIP_LOOPIF_MULTITHREADING 84.1846 +-#define LWIP_LOOPIF_MULTITHREADING 1 84.1847 ++#ifndef LWIP_HAVE_SLIPIF 84.1848 ++#define LWIP_HAVE_SLIPIF 0 84.1849 + #endif 84.1850 + 84.1851 + /* 84.1852 +Index: src/include/lwip/sio.h 84.1853 +=================================================================== 84.1854 +RCS file: /sources/lwip/lwip/src/include/lwip/sio.h,v 84.1855 +retrieving revision 1.7 84.1856 +retrieving revision 1.8 84.1857 +diff -u -p -r1.7 -r1.8 84.1858 +--- src/include/lwip/sio.h 6 Sep 2007 16:43:44 -0000 1.7 84.1859 ++++ src/include/lwip/sio.h 27 Mar 2008 18:06:02 -0000 1.8 84.1860 +@@ -32,16 +32,24 @@ 84.1861 + * It needs to be implemented by those platforms which need SLIP or PPP 84.1862 + */ 84.1863 + 84.1864 ++#ifndef __SIO_H__ 84.1865 ++#define __SIO_H__ 84.1866 ++ 84.1867 + #include "lwip/arch.h" 84.1868 + 84.1869 + #ifdef __cplusplus 84.1870 + extern "C" { 84.1871 + #endif 84.1872 + 84.1873 ++/* If you want to define sio_fd_t elsewhere or differently, 84.1874 ++ define this in your cc.h file. */ 84.1875 + #ifndef __sio_fd_t_defined 84.1876 + typedef void * sio_fd_t; 84.1877 + #endif 84.1878 + 84.1879 ++/* The following functions can be defined to something else in your cc.h file 84.1880 ++ or be implemented in your custom sio.c file. */ 84.1881 ++ 84.1882 + #ifndef sio_open 84.1883 + sio_fd_t sio_open(u8_t); 84.1884 + #endif 84.1885 +@@ -69,3 +77,5 @@ void sio_read_abort(sio_fd_t); 84.1886 + #ifdef __cplusplus 84.1887 + } 84.1888 + #endif 84.1889 ++ 84.1890 ++#endif /* __SIO_H__ */ 84.1891 +Index: src/include/lwip/sockets.h 84.1892 +=================================================================== 84.1893 +RCS file: /sources/lwip/lwip/src/include/lwip/sockets.h,v 84.1894 +retrieving revision 1.38 84.1895 +retrieving revision 1.39 84.1896 +diff -u -p -r1.38 -r1.39 84.1897 +--- src/include/lwip/sockets.h 2 Dec 2007 15:24:02 -0000 1.38 84.1898 ++++ src/include/lwip/sockets.h 26 Apr 2008 10:46:23 -0000 1.39 84.1899 +@@ -177,7 +177,22 @@ typedef struct ip_mreq { 84.1900 + } ip_mreq; 84.1901 + #endif /* LWIP_IGMP */ 84.1902 + 84.1903 +-/* Unimplemented for now... */ 84.1904 ++/* 84.1905 ++ * The Type of Service provides an indication of the abstract 84.1906 ++ * parameters of the quality of service desired. These parameters are 84.1907 ++ * to be used to guide the selection of the actual service parameters 84.1908 ++ * when transmitting a datagram through a particular network. Several 84.1909 ++ * networks offer service precedence, which somehow treats high 84.1910 ++ * precedence traffic as more important than other traffic (generally 84.1911 ++ * by accepting only traffic above a certain precedence at time of high 84.1912 ++ * load). The major choice is a three way tradeoff between low-delay, 84.1913 ++ * high-reliability, and high-throughput. 84.1914 ++ * The use of the Delay, Throughput, and Reliability indications may 84.1915 ++ * increase the cost (in some sense) of the service. In many networks 84.1916 ++ * better performance for one of these parameters is coupled with worse 84.1917 ++ * performance on another. Except for very unusual cases at most two 84.1918 ++ * of these three indications should be set. 84.1919 ++ */ 84.1920 + #define IPTOS_TOS_MASK 0x1E 84.1921 + #define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) 84.1922 + #define IPTOS_LOWDELAY 0x10 84.1923 +@@ -187,7 +202,13 @@ typedef struct ip_mreq { 84.1924 + #define IPTOS_MINCOST IPTOS_LOWCOST 84.1925 + 84.1926 + /* 84.1927 +- * Definitions for IP precedence (also in ip_tos) (Unimplemented) 84.1928 ++ * The Network Control precedence designation is intended to be used 84.1929 ++ * within a network only. The actual use and control of that 84.1930 ++ * designation is up to each network. The Internetwork Control 84.1931 ++ * designation is intended for use by gateway control originators only. 84.1932 ++ * If the actual use of these precedence designations is of concern to 84.1933 ++ * a particular network, it is the responsibility of that network to 84.1934 ++ * control the access to, and use of, those precedence designations. 84.1935 + */ 84.1936 + #define IPTOS_PREC_MASK 0xe0 84.1937 + #define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK) 84.1938 +Index: src/include/lwip/stats.h 84.1939 +=================================================================== 84.1940 +RCS file: /sources/lwip/lwip/src/include/lwip/stats.h,v 84.1941 +retrieving revision 1.19 84.1942 +retrieving revision 1.23 84.1943 +diff -u -p -r1.19 -r1.23 84.1944 +--- src/include/lwip/stats.h 28 Nov 2007 21:25:07 -0000 1.19 84.1945 ++++ src/include/lwip/stats.h 8 Jul 2008 09:15:57 -0000 1.23 84.1946 +@@ -57,7 +57,6 @@ extern "C" { 84.1947 + 84.1948 + struct stats_proto { 84.1949 + STAT_COUNTER xmit; /* Transmitted packets. */ 84.1950 +- STAT_COUNTER rexmit; /* Retransmitted packets. */ 84.1951 + STAT_COUNTER recv; /* Received packets. */ 84.1952 + STAT_COUNTER fw; /* Forwarded packets. */ 84.1953 + STAT_COUNTER drop; /* Dropped packets. */ 84.1954 +@@ -87,7 +86,8 @@ struct stats_mem { 84.1955 + mem_size_t avail; 84.1956 + mem_size_t used; 84.1957 + mem_size_t max; 84.1958 +- mem_size_t err; 84.1959 ++ STAT_COUNTER err; 84.1960 ++ STAT_COUNTER illegal; 84.1961 + }; 84.1962 + 84.1963 + struct stats_syselem { 84.1964 +@@ -142,64 +142,138 @@ extern struct stats_ lwip_stats; 84.1965 + #define stats_init() /* Compatibility define, not init needed. */ 84.1966 + 84.1967 + #define STATS_INC(x) ++lwip_stats.x 84.1968 ++#define STATS_DEC(x) --lwip_stats.x 84.1969 + #else 84.1970 + #define stats_init() 84.1971 + #define STATS_INC(x) 84.1972 ++#define STATS_DEC(x) 84.1973 + #endif /* LWIP_STATS */ 84.1974 + 84.1975 + #if TCP_STATS 84.1976 + #define TCP_STATS_INC(x) STATS_INC(x) 84.1977 ++#define TCP_STATS_DISPLAY() stats_display_proto(&lwip_stats.tcp, "TCP") 84.1978 + #else 84.1979 + #define TCP_STATS_INC(x) 84.1980 ++#define TCP_STATS_DISPLAY() 84.1981 + #endif 84.1982 + 84.1983 + #if UDP_STATS 84.1984 + #define UDP_STATS_INC(x) STATS_INC(x) 84.1985 ++#define UDP_STATS_DISPLAY() stats_display_proto(&lwip_stats.udp, "UDP") 84.1986 + #else 84.1987 + #define UDP_STATS_INC(x) 84.1988 ++#define UDP_STATS_DISPLAY() 84.1989 + #endif 84.1990 + 84.1991 + #if ICMP_STATS 84.1992 + #define ICMP_STATS_INC(x) STATS_INC(x) 84.1993 ++#define ICMP_STATS_DISPLAY() stats_display_proto(&lwip_stats.icmp, "ICMP") 84.1994 + #else 84.1995 + #define ICMP_STATS_INC(x) 84.1996 ++#define ICMP_STATS_DISPLAY() 84.1997 + #endif 84.1998 + 84.1999 + #if IGMP_STATS 84.2000 + #define IGMP_STATS_INC(x) STATS_INC(x) 84.2001 ++#define IGMP_STATS_DISPLAY() stats_display_igmp(&lwip_stats.igmp) 84.2002 + #else 84.2003 + #define IGMP_STATS_INC(x) 84.2004 ++#define IGMP_STATS_DISPLAY() 84.2005 + #endif 84.2006 + 84.2007 + #if IP_STATS 84.2008 + #define IP_STATS_INC(x) STATS_INC(x) 84.2009 ++#define IP_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip, "IP") 84.2010 + #else 84.2011 + #define IP_STATS_INC(x) 84.2012 ++#define IP_STATS_DISPLAY() 84.2013 + #endif 84.2014 + 84.2015 + #if IPFRAG_STATS 84.2016 + #define IPFRAG_STATS_INC(x) STATS_INC(x) 84.2017 ++#define IPFRAG_STATS_DISPLAY() stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG") 84.2018 + #else 84.2019 + #define IPFRAG_STATS_INC(x) 84.2020 ++#define IPFRAG_STATS_DISPLAY() 84.2021 + #endif 84.2022 + 84.2023 + #if ETHARP_STATS 84.2024 + #define ETHARP_STATS_INC(x) STATS_INC(x) 84.2025 ++#define ETHARP_STATS_DISPLAY() stats_display_proto(&lwip_stats.etharp, "ETHARP") 84.2026 + #else 84.2027 + #define ETHARP_STATS_INC(x) 84.2028 ++#define ETHARP_STATS_DISPLAY() 84.2029 + #endif 84.2030 + 84.2031 + #if LINK_STATS 84.2032 + #define LINK_STATS_INC(x) STATS_INC(x) 84.2033 ++#define LINK_STATS_DISPLAY() stats_display_proto(&lwip_stats.link, "LINK") 84.2034 + #else 84.2035 + #define LINK_STATS_INC(x) 84.2036 ++#define LINK_STATS_DISPLAY() 84.2037 ++#endif 84.2038 ++ 84.2039 ++#if MEM_STATS 84.2040 ++#define MEM_STATS_AVAIL(x, y) lwip_stats.mem.x = y 84.2041 ++#define MEM_STATS_INC(x) STATS_INC(mem.x) 84.2042 ++#define MEM_STATS_INC_USED(x, y) do { lwip_stats.mem.used += y; \ 84.2043 ++ if (lwip_stats.mem.max < lwip_stats.mem.used) { \ 84.2044 ++ lwip_stats.mem.max = lwip_stats.mem.used; \ 84.2045 ++ } \ 84.2046 ++ } while(0) 84.2047 ++#define MEM_STATS_DEC_USED(x, y) lwip_stats.mem.x -= y 84.2048 ++#define MEM_STATS_DISPLAY() stats_display_mem(&lwip_stats.mem, "HEAP") 84.2049 ++#else 84.2050 ++#define MEM_STATS_AVAIL(x, y) 84.2051 ++#define MEM_STATS_INC(x) 84.2052 ++#define MEM_STATS_INC_USED(x, y) 84.2053 ++#define MEM_STATS_DEC_USED(x, y) 84.2054 ++#define MEM_STATS_DISPLAY() 84.2055 ++#endif 84.2056 ++ 84.2057 ++#if MEMP_STATS 84.2058 ++#define MEMP_STATS_AVAIL(x, i, y) lwip_stats.memp[i].x = y 84.2059 ++#define MEMP_STATS_INC(x, i) STATS_INC(memp[i].x) 84.2060 ++#define MEMP_STATS_DEC(x, i) STATS_DEC(memp[i].x) 84.2061 ++#define MEMP_STATS_INC_USED(x, i) do { ++lwip_stats.memp[i].used; \ 84.2062 ++ if (lwip_stats.memp[i].max < lwip_stats.memp[i].used) { \ 84.2063 ++ lwip_stats.memp[i].max = lwip_stats.memp[i].used; \ 84.2064 ++ } \ 84.2065 ++ } while(0) 84.2066 ++#define MEMP_STATS_DISPLAY(i) stats_display_memp(&lwip_stats.memp[i], i) 84.2067 ++#else 84.2068 ++#define MEMP_STATS_AVAIL(x, i, y) 84.2069 ++#define MEMP_STATS_INC(x, i) 84.2070 ++#define MEMP_STATS_DEC(x, i) 84.2071 ++#define MEMP_STATS_INC_USED(x, i) 84.2072 ++#define MEMP_STATS_DISPLAY(i) 84.2073 ++#endif 84.2074 ++ 84.2075 ++#if SYS_STATS 84.2076 ++#define SYS_STATS_INC(x) STATS_INC(sys.x) 84.2077 ++#define SYS_STATS_DEC(x) STATS_DEC(sys.x) 84.2078 ++#define SYS_STATS_DISPLAY() stats_display_sys(&lwip_stats.sys) 84.2079 ++#else 84.2080 ++#define SYS_STATS_INC(x) 84.2081 ++#define SYS_STATS_DEC(x) 84.2082 ++#define SYS_STATS_DISPLAY() 84.2083 + #endif 84.2084 + 84.2085 + /* Display of statistics */ 84.2086 + #if LWIP_STATS_DISPLAY 84.2087 + void stats_display(void); 84.2088 ++void stats_display_proto(struct stats_proto *proto, char *name); 84.2089 ++void stats_display_igmp(struct stats_igmp *igmp); 84.2090 ++void stats_display_mem(struct stats_mem *mem, char *name); 84.2091 ++void stats_display_memp(struct stats_mem *mem, int index); 84.2092 ++void stats_display_sys(struct stats_sys *sys); 84.2093 + #else 84.2094 + #define stats_display() 84.2095 ++#define stats_display_proto(proto, name) 84.2096 ++#define stats_display_igmp(igmp) 84.2097 ++#define stats_display_mem(mem, name) 84.2098 ++#define stats_display_memp(mem, index) 84.2099 ++#define stats_display_sys(sys) 84.2100 + #endif /* LWIP_STATS_DISPLAY */ 84.2101 + 84.2102 + #ifdef __cplusplus 84.2103 +Index: src/include/lwip/tcpip.h 84.2104 +=================================================================== 84.2105 +RCS file: /sources/lwip/lwip/src/include/lwip/tcpip.h,v 84.2106 +retrieving revision 1.24 84.2107 +retrieving revision 1.27 84.2108 +diff -u -p -r1.24 -r1.27 84.2109 +--- src/include/lwip/tcpip.h 12 Jan 2008 11:52:22 -0000 1.24 84.2110 ++++ src/include/lwip/tcpip.h 27 Jun 2008 20:34:55 -0000 1.27 84.2111 +@@ -83,7 +83,11 @@ err_t tcpip_netifapi_lock(struct netifap 84.2112 + #endif /* LWIP_NETIF_API */ 84.2113 + 84.2114 + err_t tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block); 84.2115 +-#define tcpip_callback(f,ctx) tcpip_callback_with_block(f,ctx,1) 84.2116 ++#define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1) 84.2117 ++ 84.2118 ++/* free pbufs or heap memory from another context without blocking */ 84.2119 ++err_t pbuf_free_callback(struct pbuf *p); 84.2120 ++err_t mem_free_callback(void *m); 84.2121 + 84.2122 + err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg); 84.2123 + #define tcpip_untimeout(h, arg) tcpip_timeout(0xffffffff, h, arg) 84.2124 +Index: src/include/netif/loopif.h 84.2125 +=================================================================== 84.2126 +RCS file: /sources/lwip/lwip/src/include/netif/loopif.h,v 84.2127 +retrieving revision 1.7 84.2128 +retrieving revision 1.9 84.2129 +diff -u -p -r1.7 -r1.9 84.2130 +--- src/include/netif/loopif.h 10 May 2007 10:59:20 -0000 1.7 84.2131 ++++ src/include/netif/loopif.h 17 Jun 2008 20:12:22 -0000 1.9 84.2132 +@@ -32,6 +32,7 @@ 84.2133 + #ifndef __NETIF_LOOPIF_H__ 84.2134 + #define __NETIF_LOOPIF_H__ 84.2135 + 84.2136 ++#include "lwip/opt.h" 84.2137 + #include "lwip/netif.h" 84.2138 + #include "lwip/err.h" 84.2139 + 84.2140 +@@ -39,9 +40,9 @@ 84.2141 + extern "C" { 84.2142 + #endif 84.2143 + 84.2144 +-#if !LWIP_LOOPIF_MULTITHREADING 84.2145 +-void loopif_poll(struct netif *netif); 84.2146 +-#endif 84.2147 ++#if !LWIP_NETIF_LOOPBACK_MULTITHREADING 84.2148 ++#define loopif_poll netif_poll 84.2149 ++#endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */ 84.2150 + 84.2151 + err_t loopif_init(struct netif *netif); 84.2152 + 84.2153 +Index: src/netif/etharp.c 84.2154 +=================================================================== 84.2155 +RCS file: /sources/lwip/lwip/src/netif/etharp.c,v 84.2156 +retrieving revision 1.145 84.2157 +retrieving revision 1.148 84.2158 +diff -u -p -r1.145 -r1.148 84.2159 +--- src/netif/etharp.c 4 Mar 2008 13:41:24 -0000 1.145 84.2160 ++++ src/netif/etharp.c 19 Jun 2008 16:40:59 -0000 1.148 84.2161 +@@ -353,7 +353,7 @@ find_entry(struct ip_addr *ipaddr, u8_t 84.2162 + * 1) empty entry 84.2163 + * 2) oldest stable entry 84.2164 + * 3) oldest pending entry without queued packets 84.2165 +- * 4) oldest pending entry without queued packets 84.2166 ++ * 4) oldest pending entry with queued packets 84.2167 + * 84.2168 + * { ETHARP_TRY_HARD is set at this point } 84.2169 + */ 84.2170 +@@ -1130,7 +1130,14 @@ ethernet_input(struct pbuf *p, struct ne 84.2171 + 84.2172 + /* points to packet payload, which starts with an Ethernet header */ 84.2173 + ethhdr = p->payload; 84.2174 +- 84.2175 ++ LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, 84.2176 ++ ("ethernet_input: dest:%02x:%02x:%02x:%02x:%02x:%02x, src:%02x:%02x:%02x:%02x:%02x:%02x, type:%2hx\n", 84.2177 ++ (unsigned)ethhdr->dest.addr[0], (unsigned)ethhdr->dest.addr[1], (unsigned)ethhdr->dest.addr[2], 84.2178 ++ (unsigned)ethhdr->dest.addr[3], (unsigned)ethhdr->dest.addr[4], (unsigned)ethhdr->dest.addr[5], 84.2179 ++ (unsigned)ethhdr->src.addr[0], (unsigned)ethhdr->src.addr[1], (unsigned)ethhdr->src.addr[2], 84.2180 ++ (unsigned)ethhdr->src.addr[3], (unsigned)ethhdr->src.addr[4], (unsigned)ethhdr->src.addr[5], 84.2181 ++ (unsigned)htons(ethhdr->type))); 84.2182 ++ 84.2183 + switch (htons(ethhdr->type)) { 84.2184 + /* IP packet? */ 84.2185 + case ETHTYPE_IP: 84.2186 +@@ -1165,6 +1172,8 @@ ethernet_input(struct pbuf *p, struct ne 84.2187 + #endif /* PPPOE_SUPPORT */ 84.2188 + 84.2189 + default: 84.2190 ++ ETHARP_STATS_INC(etharp.proterr); 84.2191 ++ ETHARP_STATS_INC(etharp.drop); 84.2192 + pbuf_free(p); 84.2193 + p = NULL; 84.2194 + break; 84.2195 +Index: src/netif/loopif.c 84.2196 +=================================================================== 84.2197 +RCS file: /sources/lwip/lwip/src/netif/loopif.c,v 84.2198 +retrieving revision 1.26 84.2199 +retrieving revision 1.27 84.2200 +diff -u -p -r1.26 -r1.27 84.2201 +--- src/netif/loopif.c 31 Aug 2007 10:14:09 -0000 1.26 84.2202 ++++ src/netif/loopif.c 12 Jun 2008 20:10:10 -0000 1.27 84.2203 +@@ -40,149 +40,8 @@ 84.2204 + #if LWIP_HAVE_LOOPIF 84.2205 + 84.2206 + #include "netif/loopif.h" 84.2207 +-#include "lwip/pbuf.h" 84.2208 + #include "lwip/snmp.h" 84.2209 + 84.2210 +-#include <string.h> 84.2211 +- 84.2212 +-#if !LWIP_LOOPIF_MULTITHREADING 84.2213 +- 84.2214 +-#include "lwip/sys.h" 84.2215 +-#include "lwip/mem.h" 84.2216 +- 84.2217 +-/* helper struct for the linked list of pbufs */ 84.2218 +-struct loopif_private { 84.2219 +- struct pbuf *first; 84.2220 +- struct pbuf *last; 84.2221 +-}; 84.2222 +- 84.2223 +-/** 84.2224 +- * Call loopif_poll() in the main loop of your application. This is to prevent 84.2225 +- * reentering non-reentrant functions like tcp_input(). Packets passed to 84.2226 +- * loopif_output() are put on a list that is passed to netif->input() by 84.2227 +- * loopif_poll(). 84.2228 +- * 84.2229 +- * @param netif the lwip network interface structure for this loopif 84.2230 +- */ 84.2231 +-void 84.2232 +-loopif_poll(struct netif *netif) 84.2233 +-{ 84.2234 +- SYS_ARCH_DECL_PROTECT(lev); 84.2235 +- struct pbuf *in, *in_end; 84.2236 +- struct loopif_private *priv = (struct loopif_private*)netif->state; 84.2237 +- 84.2238 +- LWIP_ERROR("priv != NULL", (priv != NULL), return;); 84.2239 +- 84.2240 +- do { 84.2241 +- /* Get a packet from the list. With SYS_LIGHTWEIGHT_PROT=1, this is protected */ 84.2242 +- SYS_ARCH_PROTECT(lev); 84.2243 +- in = priv->first; 84.2244 +- if(in) { 84.2245 +- in_end = in; 84.2246 +- while(in_end->len != in_end->tot_len) { 84.2247 +- LWIP_ASSERT("bogus pbuf: len != tot_len but next == NULL!", in_end->next != NULL); 84.2248 +- in_end = in_end->next; 84.2249 +- } 84.2250 +- /* 'in_end' now points to the last pbuf from 'in' */ 84.2251 +- if(in_end == priv->last) { 84.2252 +- /* this was the last pbuf in the list */ 84.2253 +- priv->first = priv->last = NULL; 84.2254 +- } else { 84.2255 +- /* pop the pbuf off the list */ 84.2256 +- priv->first = in_end->next; 84.2257 +- LWIP_ASSERT("should not be null since first != last!", priv->first != NULL); 84.2258 +- } 84.2259 +- } 84.2260 +- SYS_ARCH_UNPROTECT(lev); 84.2261 +- 84.2262 +- if(in != NULL) { 84.2263 +- if(in_end->next != NULL) { 84.2264 +- /* De-queue the pbuf from its successors on the 'priv' list. */ 84.2265 +- in_end->next = NULL; 84.2266 +- } 84.2267 +- if(netif->input(in, netif) != ERR_OK) { 84.2268 +- pbuf_free(in); 84.2269 +- } 84.2270 +- /* Don't reference the packet any more! */ 84.2271 +- in = NULL; 84.2272 +- in_end = NULL; 84.2273 +- } 84.2274 +- /* go on while there is a packet on the list */ 84.2275 +- } while(priv->first != NULL); 84.2276 +-} 84.2277 +-#endif /* LWIP_LOOPIF_MULTITHREADING */ 84.2278 +- 84.2279 +-/** 84.2280 +- * Send an IP packet over the loopback interface. 84.2281 +- * The pbuf is simply copied and handed back to netif->input. 84.2282 +- * In multithreaded mode, this is done directly since netif->input must put 84.2283 +- * the packet on a queue. 84.2284 +- * In callback mode, the packet is put on an internal queue and is fed to 84.2285 +- * netif->input by loopif_poll(). 84.2286 +- * 84.2287 +- * @param netif the lwip network interface structure for this loopif 84.2288 +- * @param p the (IP) packet to 'send' 84.2289 +- * @param ipaddr the ip address to send the packet to (not used for loopif) 84.2290 +- * @return ERR_OK if the packet has been sent 84.2291 +- * ERR_MEM if the pbuf used to copy the packet couldn't be allocated 84.2292 +- */ 84.2293 +-static err_t 84.2294 +-loopif_output(struct netif *netif, struct pbuf *p, 84.2295 +- struct ip_addr *ipaddr) 84.2296 +-{ 84.2297 +-#if !LWIP_LOOPIF_MULTITHREADING 84.2298 +- SYS_ARCH_DECL_PROTECT(lev); 84.2299 +- struct loopif_private *priv; 84.2300 +- struct pbuf *last; 84.2301 +-#endif /* LWIP_LOOPIF_MULTITHREADING */ 84.2302 +- struct pbuf *r; 84.2303 +- err_t err; 84.2304 +- 84.2305 +- LWIP_UNUSED_ARG(ipaddr); 84.2306 +- 84.2307 +- /* Allocate a new pbuf */ 84.2308 +- r = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); 84.2309 +- if (r == NULL) { 84.2310 +- return ERR_MEM; 84.2311 +- } 84.2312 +- 84.2313 +- /* Copy the whole pbuf queue p into the single pbuf r */ 84.2314 +- if ((err = pbuf_copy(r, p)) != ERR_OK) { 84.2315 +- pbuf_free(r); 84.2316 +- r = NULL; 84.2317 +- return err; 84.2318 +- } 84.2319 +- 84.2320 +-#if LWIP_LOOPIF_MULTITHREADING 84.2321 +- /* Multithreading environment, netif->input() is supposed to put the packet 84.2322 +- into a mailbox, so we can safely call it here without risking to re-enter 84.2323 +- functions that are not reentrant (TCP!!!) */ 84.2324 +- if(netif->input(r, netif) != ERR_OK) { 84.2325 +- pbuf_free(r); 84.2326 +- r = NULL; 84.2327 +- } 84.2328 +-#else /* LWIP_LOOPIF_MULTITHREADING */ 84.2329 +- /* Raw API without threads: put the packet on a linked list which gets emptied 84.2330 +- through calling loopif_poll(). */ 84.2331 +- priv = (struct loopif_private*)netif->state; 84.2332 +- 84.2333 +- /* let last point to the last pbuf in chain r */ 84.2334 +- for (last = r; last->next != NULL; last = last->next); 84.2335 +- SYS_ARCH_PROTECT(lev); 84.2336 +- if(priv->first != NULL) { 84.2337 +- LWIP_ASSERT("if first != NULL, last must also be != NULL", priv->last != NULL); 84.2338 +- priv->last->next = r; 84.2339 +- priv->last = last; 84.2340 +- } else { 84.2341 +- priv->first = r; 84.2342 +- priv->last = last; 84.2343 +- } 84.2344 +- SYS_ARCH_UNPROTECT(lev); 84.2345 +-#endif /* LWIP_LOOPIF_MULTITHREADING */ 84.2346 +- 84.2347 +- return ERR_OK; 84.2348 +-} 84.2349 +- 84.2350 + /** 84.2351 + * Initialize a lwip network interface structure for a loopback interface 84.2352 + * 84.2353 +@@ -193,16 +52,6 @@ loopif_output(struct netif *netif, struc 84.2354 + err_t 84.2355 + loopif_init(struct netif *netif) 84.2356 + { 84.2357 +-#if !LWIP_LOOPIF_MULTITHREADING 84.2358 +- struct loopif_private *priv; 84.2359 +- 84.2360 +- priv = (struct loopif_private*)mem_malloc(sizeof(struct loopif_private)); 84.2361 +- if(priv == NULL) 84.2362 +- return ERR_MEM; 84.2363 +- priv->first = priv->last = NULL; 84.2364 +- netif->state = priv; 84.2365 +-#endif /* LWIP_LOOPIF_MULTITHREADING */ 84.2366 +- 84.2367 + /* initialize the snmp variables and counters inside the struct netif 84.2368 + * ifSpeed: no assumption can be made! 84.2369 + */ 84.2370 +@@ -210,7 +59,7 @@ loopif_init(struct netif *netif) 84.2371 + 84.2372 + netif->name[0] = 'l'; 84.2373 + netif->name[1] = 'o'; 84.2374 +- netif->output = loopif_output; 84.2375 ++ netif->output = netif_loop_output; 84.2376 + return ERR_OK; 84.2377 + } 84.2378 + 84.2379 +Index: src/netif/slipif.c 84.2380 +=================================================================== 84.2381 +RCS file: /sources/lwip/lwip/src/netif/slipif.c,v 84.2382 +retrieving revision 1.29 84.2383 +retrieving revision 1.30 84.2384 +diff -u -p -r1.29 -r1.30 84.2385 +--- src/netif/slipif.c 30 Nov 2007 17:22:21 -0000 1.29 84.2386 ++++ src/netif/slipif.c 17 Jun 2008 20:14:05 -0000 1.30 84.2387 +@@ -44,6 +44,9 @@ 84.2388 + 84.2389 + #include "netif/slipif.h" 84.2390 + #include "lwip/opt.h" 84.2391 ++ 84.2392 ++#if LWIP_HAVE_SLIPIF 84.2393 ++ 84.2394 + #include "lwip/def.h" 84.2395 + #include "lwip/pbuf.h" 84.2396 + #include "lwip/sys.h" 84.2397 +@@ -273,3 +276,4 @@ slipif_init(struct netif *netif) 84.2398 + sys_thread_new(SLIPIF_THREAD_NAME, slipif_loop, netif, SLIPIF_THREAD_STACKSIZE, SLIPIF_THREAD_PRIO); 84.2399 + return ERR_OK; 84.2400 + } 84.2401 ++#endif /* LWIP_HAVE_SLIPIF */
85.1 --- a/stubdom/newlib.patch Tue Jul 08 11:41:43 2008 +0900 85.2 +++ b/stubdom/newlib.patch Fri Jul 18 12:12:41 2008 +0900 85.3 @@ -201,3 +201,429 @@ diff -u -p -r1.1 memcpy.S 85.4 ret 85.5 85.6 85.7 +--- newlib/libc/machine/x86_64/x86_64mach.h.orig 2008-07-11 14:57:23.062269000 +0100 85.8 ++++ newlib/libc/machine/x86_64/x86_64mach.h 2008-07-11 14:58:01.262503000 +0100 85.9 +@@ -22,81 +22,81 @@ 85.10 + 85.11 + #define REG(x) CONCAT1(__REG_PREFIX__, x) 85.12 + 85.13 +-#define rax REG(rax) 85.14 +-#define rbx REG(rbx) 85.15 +-#define rcx REG(rcx) 85.16 +-#define rdx REG(rdx) 85.17 +-#define rsi REG(rsi) 85.18 +-#define rdi REG(rdi) 85.19 +-#define rbp REG(rbp) 85.20 +-#define rsp REG(rsp) 85.21 +- 85.22 +-#define r8 REG(r8) 85.23 +-#define r9 REG(r9) 85.24 +-#define r10 REG(r10) 85.25 +-#define r11 REG(r11) 85.26 +-#define r12 REG(r12) 85.27 +-#define r13 REG(r13) 85.28 +-#define r14 REG(r14) 85.29 +-#define r15 REG(r15) 85.30 +- 85.31 +-#define eax REG(eax) 85.32 +-#define ebx REG(ebx) 85.33 +-#define ecx REG(ecx) 85.34 +-#define edx REG(edx) 85.35 +-#define esi REG(esi) 85.36 +-#define edi REG(edi) 85.37 +-#define ebp REG(ebp) 85.38 +-#define esp REG(esp) 85.39 +- 85.40 +-#define st0 REG(st) 85.41 +-#define st1 REG(st(1)) 85.42 +-#define st2 REG(st(2)) 85.43 +-#define st3 REG(st(3)) 85.44 +-#define st4 REG(st(4)) 85.45 +-#define st5 REG(st(5)) 85.46 +-#define st6 REG(st(6)) 85.47 +-#define st7 REG(st(7)) 85.48 +- 85.49 +-#define ax REG(ax) 85.50 +-#define bx REG(bx) 85.51 +-#define cx REG(cx) 85.52 +-#define dx REG(dx) 85.53 +- 85.54 +-#define ah REG(ah) 85.55 +-#define bh REG(bh) 85.56 +-#define ch REG(ch) 85.57 +-#define dh REG(dh) 85.58 +- 85.59 +-#define al REG(al) 85.60 +-#define bl REG(bl) 85.61 +-#define cl REG(cl) 85.62 +-#define dl REG(dl) 85.63 +- 85.64 +-#define sil REG(sil) 85.65 +- 85.66 +-#define mm1 REG(mm1) 85.67 +-#define mm2 REG(mm2) 85.68 +-#define mm3 REG(mm3) 85.69 +-#define mm4 REG(mm4) 85.70 +-#define mm5 REG(mm5) 85.71 +-#define mm6 REG(mm6) 85.72 +-#define mm7 REG(mm7) 85.73 +- 85.74 +-#define xmm0 REG(xmm0) 85.75 +-#define xmm1 REG(xmm1) 85.76 +-#define xmm2 REG(xmm2) 85.77 +-#define xmm3 REG(xmm3) 85.78 +-#define xmm4 REG(xmm4) 85.79 +-#define xmm5 REG(xmm5) 85.80 +-#define xmm6 REG(xmm6) 85.81 +-#define xmm7 REG(xmm7) 85.82 +- 85.83 +-#define cr0 REG(cr0) 85.84 +-#define cr1 REG(cr1) 85.85 +-#define cr2 REG(cr2) 85.86 +-#define cr3 REG(cr3) 85.87 +-#define cr4 REG(cr4) 85.88 ++#define rax %rax 85.89 ++#define rbx %rbx 85.90 ++#define rcx %rcx 85.91 ++#define rdx %rdx 85.92 ++#define rsi %rsi 85.93 ++#define rdi %rdi 85.94 ++#define rbp %rbp 85.95 ++#define rsp %rsp 85.96 ++ 85.97 ++#define r8 %r8 85.98 ++#define r9 %r9 85.99 ++#define r10 %r10 85.100 ++#define r11 %r11 85.101 ++#define r12 %r12 85.102 ++#define r13 %r13 85.103 ++#define r14 %r14 85.104 ++#define r15 %r15 85.105 ++ 85.106 ++#define eax %eax 85.107 ++#define ebx %ebx 85.108 ++#define ecx %ecx 85.109 ++#define edx %edx 85.110 ++#define esi %esi 85.111 ++#define edi %edi 85.112 ++#define ebp %ebp 85.113 ++#define esp %esp 85.114 ++ 85.115 ++#define st0 %st 85.116 ++#define st1 %st(1) 85.117 ++#define st2 %st(2) 85.118 ++#define st3 %st(3) 85.119 ++#define st4 %st(4) 85.120 ++#define st5 %st(5) 85.121 ++#define st6 %st(6) 85.122 ++#define st7 %st(7) 85.123 ++ 85.124 ++#define ax %ax 85.125 ++#define bx %bx 85.126 ++#define cx %cx 85.127 ++#define dx %dx 85.128 ++ 85.129 ++#define ah %ah 85.130 ++#define bh %bh 85.131 ++#define ch %ch 85.132 ++#define dh %dh 85.133 ++ 85.134 ++#define al %al 85.135 ++#define bl %bl 85.136 ++#define cl %cl 85.137 ++#define dl %dl 85.138 ++ 85.139 ++#define sil %sil 85.140 ++ 85.141 ++#define mm1 %mm1 85.142 ++#define mm2 %mm2 85.143 ++#define mm3 %mm3 85.144 ++#define mm4 %mm4 85.145 ++#define mm5 %mm5 85.146 ++#define mm6 %mm6 85.147 ++#define mm7 %mm7 85.148 ++ 85.149 ++#define xmm0 %xmm0 85.150 ++#define xmm1 %xmm1 85.151 ++#define xmm2 %xmm2 85.152 ++#define xmm3 %xmm3 85.153 ++#define xmm4 %xmm4 85.154 ++#define xmm5 %xmm5 85.155 ++#define xmm6 %xmm6 85.156 ++#define xmm7 %xmm7 85.157 ++ 85.158 ++#define cr0 %cr0 85.159 ++#define cr1 %cr1 85.160 ++#define cr2 %cr2 85.161 ++#define cr3 %cr3 85.162 ++#define cr4 %cr4 85.163 + 85.164 + #ifdef _I386MACH_NEED_SOTYPE_FUNCTION 85.165 + #define SOTYPE_FUNCTION(sym) .type SYM(sym),@function 85.166 +--- newlib/libc/machine/x86_64/memcpy.S.orig 2008-07-11 15:12:27.494693000 +0100 85.167 ++++ newlib/libc/machine/x86_64/memcpy.S 2008-07-11 15:12:29.448706000 +0100 85.168 +@@ -60,14 +60,14 @@ 85.169 + movq 48 (rsi), r13 85.170 + movq 56 (rsi), r14 85.171 + 85.172 +- movntiq rax, (rdi) 85.173 +- movntiq r8 , 8 (rdi) 85.174 +- movntiq r9 , 16 (rdi) 85.175 +- movntiq r10, 24 (rdi) 85.176 +- movntiq r11, 32 (rdi) 85.177 +- movntiq r12, 40 (rdi) 85.178 +- movntiq r13, 48 (rdi) 85.179 +- movntiq r14, 56 (rdi) 85.180 ++ movnti rax, (rdi) 85.181 ++ movnti r8 , 8 (rdi) 85.182 ++ movnti r9 , 16 (rdi) 85.183 ++ movnti r10, 24 (rdi) 85.184 ++ movnti r11, 32 (rdi) 85.185 ++ movnti r12, 40 (rdi) 85.186 ++ movnti r13, 48 (rdi) 85.187 ++ movnti r14, 56 (rdi) 85.188 + 85.189 + movq 64 (rsi), rax 85.190 + movq 72 (rsi), r8 85.191 +@@ -78,14 +78,14 @@ 85.192 + movq 112 (rsi), r13 85.193 + movq 120 (rsi), r14 85.194 + 85.195 +- movntiq rax, 64 (rdi) 85.196 +- movntiq r8 , 72 (rdi) 85.197 +- movntiq r9 , 80 (rdi) 85.198 +- movntiq r10, 88 (rdi) 85.199 +- movntiq r11, 96 (rdi) 85.200 +- movntiq r12, 104 (rdi) 85.201 +- movntiq r13, 112 (rdi) 85.202 +- movntiq r14, 120 (rdi) 85.203 ++ movnti rax, 64 (rdi) 85.204 ++ movnti r8 , 72 (rdi) 85.205 ++ movnti r9 , 80 (rdi) 85.206 ++ movnti r10, 88 (rdi) 85.207 ++ movnti r11, 96 (rdi) 85.208 ++ movnti r12, 104 (rdi) 85.209 ++ movnti r13, 112 (rdi) 85.210 ++ movnti r14, 120 (rdi) 85.211 + 85.212 + leaq 128 (rsi), rsi 85.213 + leaq 128 (rdi), rdi 85.214 +--- newlib/libc/machine/i386/i386mach.h 2000-08-28 18:50:06.000000000 +0100 85.215 ++++ newlib/libc/machine/i386/i386mach.h 2008-07-11 15:17:13.874409000 +0100 85.216 +@@ -27,46 +27,46 @@ 85.217 + 85.218 + #define REG(x) CONCAT1(__REG_PREFIX__, x) 85.219 + 85.220 +-#define eax REG(eax) 85.221 +-#define ebx REG(ebx) 85.222 +-#define ecx REG(ecx) 85.223 +-#define edx REG(edx) 85.224 +-#define esi REG(esi) 85.225 +-#define edi REG(edi) 85.226 +-#define ebp REG(ebp) 85.227 +-#define esp REG(esp) 85.228 +- 85.229 +-#define st0 REG(st) 85.230 +-#define st1 REG(st(1)) 85.231 +-#define st2 REG(st(2)) 85.232 +-#define st3 REG(st(3)) 85.233 +-#define st4 REG(st(4)) 85.234 +-#define st5 REG(st(5)) 85.235 +-#define st6 REG(st(6)) 85.236 +-#define st7 REG(st(7)) 85.237 +- 85.238 +-#define ax REG(ax) 85.239 +-#define bx REG(bx) 85.240 +-#define cx REG(cx) 85.241 +-#define dx REG(dx) 85.242 +- 85.243 +-#define ah REG(ah) 85.244 +-#define bh REG(bh) 85.245 +-#define ch REG(ch) 85.246 +-#define dh REG(dh) 85.247 +- 85.248 +-#define al REG(al) 85.249 +-#define bl REG(bl) 85.250 +-#define cl REG(cl) 85.251 +-#define dl REG(dl) 85.252 +- 85.253 +-#define mm1 REG(mm1) 85.254 +-#define mm2 REG(mm2) 85.255 +-#define mm3 REG(mm3) 85.256 +-#define mm4 REG(mm4) 85.257 +-#define mm5 REG(mm5) 85.258 +-#define mm6 REG(mm6) 85.259 +-#define mm7 REG(mm7) 85.260 ++#define eax %eax 85.261 ++#define ebx %ebx 85.262 ++#define ecx %ecx 85.263 ++#define edx %edx 85.264 ++#define esi %esi 85.265 ++#define edi %edi 85.266 ++#define ebp %ebp 85.267 ++#define esp %esp 85.268 ++ 85.269 ++#define st0 %st 85.270 ++#define st1 %st(1) 85.271 ++#define st2 %st(2) 85.272 ++#define st3 %st(3) 85.273 ++#define st4 %st(4) 85.274 ++#define st5 %st(5) 85.275 ++#define st6 %st(6) 85.276 ++#define st7 %st(7) 85.277 ++ 85.278 ++#define ax %ax 85.279 ++#define bx %bx 85.280 ++#define cx %cx 85.281 ++#define dx %dx 85.282 ++ 85.283 ++#define ah %ah 85.284 ++#define bh %bh 85.285 ++#define ch %ch 85.286 ++#define dh %dh 85.287 ++ 85.288 ++#define al %al 85.289 ++#define bl %bl 85.290 ++#define cl %cl 85.291 ++#define dl %dl 85.292 ++ 85.293 ++#define mm1 %mm1 85.294 ++#define mm2 %mm2 85.295 ++#define mm3 %mm3 85.296 ++#define mm4 %mm4 85.297 ++#define mm5 %mm5 85.298 ++#define mm6 %mm6 85.299 ++#define mm7 %mm7 85.300 + 85.301 + #ifdef _I386MACH_NEED_SOTYPE_FUNCTION 85.302 + #define SOTYPE_FUNCTION(sym) .type SYM(sym),@function 85.303 +--- newlib/libc/machine/x86_64/memset.S 2007-08-28 22:56:49.000000000 +0100 85.304 ++++ newlib/libc/machine/x86_64/memset.S 2008-07-11 15:16:59.098320000 +0100 85.305 +@@ -40,22 +40,22 @@ 85.306 + 85.307 + .p2align 4 85.308 + loop: 85.309 +- movntiq rax, (rdi) 85.310 +- movntiq rax, 8 (rdi) 85.311 +- movntiq rax, 16 (rdi) 85.312 +- movntiq rax, 24 (rdi) 85.313 +- movntiq rax, 32 (rdi) 85.314 +- movntiq rax, 40 (rdi) 85.315 +- movntiq rax, 48 (rdi) 85.316 +- movntiq rax, 56 (rdi) 85.317 +- movntiq rax, 64 (rdi) 85.318 +- movntiq rax, 72 (rdi) 85.319 +- movntiq rax, 80 (rdi) 85.320 +- movntiq rax, 88 (rdi) 85.321 +- movntiq rax, 96 (rdi) 85.322 +- movntiq rax, 104 (rdi) 85.323 +- movntiq rax, 112 (rdi) 85.324 +- movntiq rax, 120 (rdi) 85.325 ++ movnti rax, (rdi) 85.326 ++ movnti rax, 8 (rdi) 85.327 ++ movnti rax, 16 (rdi) 85.328 ++ movnti rax, 24 (rdi) 85.329 ++ movnti rax, 32 (rdi) 85.330 ++ movnti rax, 40 (rdi) 85.331 ++ movnti rax, 48 (rdi) 85.332 ++ movnti rax, 56 (rdi) 85.333 ++ movnti rax, 64 (rdi) 85.334 ++ movnti rax, 72 (rdi) 85.335 ++ movnti rax, 80 (rdi) 85.336 ++ movnti rax, 88 (rdi) 85.337 ++ movnti rax, 96 (rdi) 85.338 ++ movnti rax, 104 (rdi) 85.339 ++ movnti rax, 112 (rdi) 85.340 ++ movnti rax, 120 (rdi) 85.341 + 85.342 + leaq 128 (rdi), rdi 85.343 + 85.344 +--- newlib/libm/machine/i386/i386mach.h.orig 2008-07-11 15:30:37.367227000 +0100 85.345 ++++ newlib/libm/machine/i386/i386mach.h 2008-07-11 15:30:55.232337000 +0100 85.346 +@@ -27,46 +27,46 @@ 85.347 + 85.348 + #define REG(x) CONCAT1(__REG_PREFIX__, x) 85.349 + 85.350 +-#define eax REG(eax) 85.351 +-#define ebx REG(ebx) 85.352 +-#define ecx REG(ecx) 85.353 +-#define edx REG(edx) 85.354 +-#define esi REG(esi) 85.355 +-#define edi REG(edi) 85.356 +-#define ebp REG(ebp) 85.357 +-#define esp REG(esp) 85.358 +- 85.359 +-#define st0 REG(st) 85.360 +-#define st1 REG(st(1)) 85.361 +-#define st2 REG(st(2)) 85.362 +-#define st3 REG(st(3)) 85.363 +-#define st4 REG(st(4)) 85.364 +-#define st5 REG(st(5)) 85.365 +-#define st6 REG(st(6)) 85.366 +-#define st7 REG(st(7)) 85.367 +- 85.368 +-#define ax REG(ax) 85.369 +-#define bx REG(bx) 85.370 +-#define cx REG(cx) 85.371 +-#define dx REG(dx) 85.372 +- 85.373 +-#define ah REG(ah) 85.374 +-#define bh REG(bh) 85.375 +-#define ch REG(ch) 85.376 +-#define dh REG(dh) 85.377 +- 85.378 +-#define al REG(al) 85.379 +-#define bl REG(bl) 85.380 +-#define cl REG(cl) 85.381 +-#define dl REG(dl) 85.382 +- 85.383 +-#define mm1 REG(mm1) 85.384 +-#define mm2 REG(mm2) 85.385 +-#define mm3 REG(mm3) 85.386 +-#define mm4 REG(mm4) 85.387 +-#define mm5 REG(mm5) 85.388 +-#define mm6 REG(mm6) 85.389 +-#define mm7 REG(mm7) 85.390 ++#define eax %eax 85.391 ++#define ebx %ebx 85.392 ++#define ecx %ecx 85.393 ++#define edx %edx 85.394 ++#define esi %esi 85.395 ++#define edi %edi 85.396 ++#define ebp %ebp 85.397 ++#define esp %esp 85.398 ++ 85.399 ++#define st0 %st 85.400 ++#define st1 %st(1) 85.401 ++#define st2 %st(2) 85.402 ++#define st3 %st(3) 85.403 ++#define st4 %st(4) 85.404 ++#define st5 %st(5) 85.405 ++#define st6 %st(6) 85.406 ++#define st7 %st(7) 85.407 ++ 85.408 ++#define ax %ax 85.409 ++#define bx %bx 85.410 ++#define cx %cx 85.411 ++#define dx %dx 85.412 ++ 85.413 ++#define ah %ah 85.414 ++#define bh %bh 85.415 ++#define ch %ch 85.416 ++#define dh %dh 85.417 ++ 85.418 ++#define al %al 85.419 ++#define bl %bl 85.420 ++#define cl %cl 85.421 ++#define dl %dl 85.422 ++ 85.423 ++#define mm1 %mm1 85.424 ++#define mm2 %mm2 85.425 ++#define mm3 %mm3 85.426 ++#define mm4 %mm4 85.427 ++#define mm5 %mm5 85.428 ++#define mm6 %mm6 85.429 ++#define mm7 %mm7 85.430 + 85.431 + #ifdef _I386MACH_NEED_SOTYPE_FUNCTION 85.432 + #define SOTYPE_FUNCTION(sym) .type SYM(sym),@function
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 86.2 +++ b/stubdom/pciutils.patch Fri Jul 18 12:12:41 2008 +0900 86.3 @@ -0,0 +1,299 @@ 86.4 +diff -urN pciutils-2.2.9.orig/lib/access.c pciutils-2.2.9/lib/access.c 86.5 +--- pciutils-2.2.9.orig/lib/access.c 2007-02-06 11:59:43.000000000 +0000 86.6 ++++ pciutils-2.2.9/lib/access.c 2008-06-30 19:07:09.713187000 +0100 86.7 +@@ -57,6 +57,11 @@ 86.8 + #else 86.9 + NULL, 86.10 + #endif 86.11 ++#ifdef PCI_OS_MINIOS 86.12 ++ &pm_minios, 86.13 ++#else 86.14 ++ NULL, 86.15 ++#endif 86.16 + }; 86.17 + 86.18 + struct pci_access * 86.19 +--- pciutils-2.2.9.orig/lib/pci.h 2006-09-09 13:46:06.000000000 +0100 86.20 ++++ pciutils-2.2.9/lib/pci.h 2008-06-30 18:56:15.350111000 +0100 86.21 +@@ -33,6 +33,7 @@ 86.22 + PCI_ACCESS_NBSD_LIBPCI, /* NetBSD libpci */ 86.23 + PCI_ACCESS_OBSD_DEVICE, /* OpenBSD /dev/pci */ 86.24 + PCI_ACCESS_DUMP, /* Dump file (params: filename) */ 86.25 ++ PCI_ACCESS_MINIOS, /* MiniOS */ 86.26 + PCI_ACCESS_MAX 86.27 + }; 86.28 + 86.29 +@@ -63,6 +64,7 @@ 86.30 + int fd_rw; /* proc: fd opened read-write */ 86.31 + struct pci_dev *cached_dev; /* proc: device the fd is for */ 86.32 + int fd_pos; /* proc: current position */ 86.33 ++ void *minios; 86.34 + }; 86.35 + 86.36 + /* Initialize PCI access */ 86.37 +--- pciutils-2.2.9.orig/lib/internal.h 2006-09-09 11:52:47.000000000 +0100 86.38 ++++ pciutils-2.2.9/lib/internal.h 2008-07-01 10:46:24.968202000 +0100 86.39 +@@ -37,4 +37,4 @@ 86.40 + 86.41 + extern struct pci_methods pm_intel_conf1, pm_intel_conf2, pm_linux_proc, 86.42 + pm_fbsd_device, pm_aix_device, pm_nbsd_libpci, pm_obsd_device, 86.43 +- pm_dump, pm_linux_sysfs; 86.44 ++ pm_dump, pm_linux_sysfs, pm_minios; 86.45 +--- pciutils-2.2.9.orig/lib/Makefile 2007-10-19 13:41:34.000000000 +0100 86.46 ++++ pciutils-2.2.9/lib/Makefile 2008-07-01 12:13:14.400525000 +0100 86.47 +@@ -46,6 +46,12 @@ 86.48 + PCILIB=libpciutils.a 86.49 + endif 86.50 + 86.51 ++ifdef PCI_OS_MINIOS 86.52 ++XEN_ROOT=../../.. 86.53 ++include $(XEN_ROOT)/Config.mk 86.54 ++OBJS += minios.o 86.55 ++endif 86.56 ++ 86.57 + all: $(PCILIB) $(PCILIBPC) 86.58 + 86.59 + $(PCILIB): $(OBJS) 86.60 +--- pciutils-2.2.9.orig/lib/types.h 2007-09-03 09:44:15.000000000 +0100 86.61 ++++ pciutils-2.2.9/lib/types.h 2008-07-01 12:17:08.396156000 +0100 86.62 +@@ -17,9 +17,13 @@ 86.63 + typedef DWORD u32; 86.64 + #elif defined(PCI_HAVE_STDINT_H) 86.65 + #include <stdint.h> 86.66 ++#ifdef PCI_OS_MINIOS 86.67 ++#include <types.h> 86.68 ++#else 86.69 + typedef uint8_t u8; 86.70 + typedef uint16_t u16; 86.71 + typedef uint32_t u32; 86.72 ++#endif 86.73 + #else 86.74 + typedef u_int8_t u8; 86.75 + typedef u_int16_t u16; 86.76 +--- pciutils-2.2.9.orig/lib/minios.c 1970-01-01 01:00:00.000000000 +0100 86.77 ++++ pciutils-2.2.9/lib/minios.c 2008-07-01 12:31:40.554260000 +0100 86.78 +@@ -0,0 +1,113 @@ 86.79 ++/* 86.80 ++ * The PCI Library -- MiniOS PCI frontend access 86.81 ++ * 86.82 ++ * Samuel Thibault <samuel.thibault@eu.citrix.com>, 2008 86.83 ++ * 86.84 ++ * Can be freely distributed and used under the terms of the GNU GPL. 86.85 ++ */ 86.86 ++ 86.87 ++#include <os.h> 86.88 ++#include <pcifront.h> 86.89 ++#include <xenbus.h> 86.90 ++#include "internal.h" 86.91 ++ 86.92 ++static int 86.93 ++minios_detect(struct pci_access *a) 86.94 ++{ 86.95 ++ return 1; 86.96 ++} 86.97 ++ 86.98 ++static void 86.99 ++minios_init(struct pci_access *a) 86.100 ++{ 86.101 ++ a->minios = init_pcifront(NULL); 86.102 ++ if (!a->minios) 86.103 ++ a->warning("minios_init open failed"); 86.104 ++} 86.105 ++ 86.106 ++static void 86.107 ++minios_cleanup(struct pci_access *a) 86.108 ++{ 86.109 ++ if (a->minios) 86.110 ++ shutdown_pcifront(a->minios); 86.111 ++} 86.112 ++ 86.113 ++static void 86.114 ++minios_scan(struct pci_access *a) 86.115 ++{ 86.116 ++ if (!a->minios) 86.117 ++ return; 86.118 ++ 86.119 ++ void func(unsigned int domain, unsigned int bus, unsigned int slot, unsigned int fun) 86.120 ++ { 86.121 ++ struct pci_dev *d = pci_alloc_dev(a); 86.122 ++ 86.123 ++ d->domain = domain; 86.124 ++ d->bus = bus; 86.125 ++ d->dev = slot; 86.126 ++ d->func = fun; 86.127 ++ 86.128 ++ pci_link_dev(a, d); 86.129 ++ } 86.130 ++ 86.131 ++ pcifront_scan(a->minios, func); 86.132 ++} 86.133 ++ 86.134 ++static int 86.135 ++minios_read(struct pci_dev *d, int pos, byte *buf, int len) 86.136 ++{ 86.137 ++ unsigned int val; 86.138 ++ switch (len) { 86.139 ++ case 1: 86.140 ++ if (pcifront_conf_read(d->access->minios, d->domain, d->bus, d->dev, d->func, pos, len, &val)) 86.141 ++ return 0; 86.142 ++ * buf = val; 86.143 ++ return 1; 86.144 ++ case 2: 86.145 ++ if (pcifront_conf_read(d->access->minios, d->domain, d->bus, d->dev, d->func, pos, len, &val)) 86.146 ++ return 0; 86.147 ++ *(u16 *) buf = cpu_to_le16((u16) val); 86.148 ++ return 1; 86.149 ++ case 4: 86.150 ++ if (pcifront_conf_read(d->access->minios, d->domain, d->bus, d->dev, d->func, pos, len, &val)) 86.151 ++ return 0; 86.152 ++ *(u32 *) buf = cpu_to_le32((u32) val); 86.153 ++ return 1; 86.154 ++ default: 86.155 ++ return pci_generic_block_read(d, pos, buf, len); 86.156 ++ } 86.157 ++} 86.158 ++ 86.159 ++static int 86.160 ++minios_write(struct pci_dev *d, int pos, byte *buf, int len) 86.161 ++{ 86.162 ++ unsigned int val; 86.163 ++ switch (len) { 86.164 ++ case 1: 86.165 ++ val = * buf; 86.166 ++ break; 86.167 ++ case 2: 86.168 ++ val = le16_to_cpu(*(u16 *) buf); 86.169 ++ break; 86.170 ++ case 4: 86.171 ++ val = le32_to_cpu(*(u32 *) buf); 86.172 ++ break; 86.173 ++ default: 86.174 ++ return pci_generic_block_write(d, pos, buf, len); 86.175 ++ } 86.176 ++ return !pcifront_conf_write(d->access->minios, d->domain, d->bus, d->dev, d->func, pos, len, val); 86.177 ++} 86.178 ++ 86.179 ++struct pci_methods pm_minios = { 86.180 ++ "MiniOS-device", 86.181 ++ NULL, /* config */ 86.182 ++ minios_detect, 86.183 ++ minios_init, 86.184 ++ minios_cleanup, 86.185 ++ minios_scan, 86.186 ++ pci_generic_fill_info, 86.187 ++ minios_read, 86.188 ++ minios_write, 86.189 ++ NULL, /* dev_init */ 86.190 ++ NULL /* dev_cleanup */ 86.191 ++}; 86.192 +--- pciutils-2.2.9/lib/generic.c 2007-02-06 12:00:05.000000000 +0000 86.193 ++++ pciutils-2.2.9-mine/lib/generic.c 2008-07-01 19:13:52.289949000 +0100 86.194 +@@ -74,6 +74,19 @@ 86.195 + pci_generic_scan_bus(a, busmap, 0); 86.196 + } 86.197 + 86.198 ++static u32 pci_size(u32 base, u32 maxbase, u32 mask) 86.199 ++{ 86.200 ++ u32 size = mask & maxbase; 86.201 ++ if (!size) 86.202 ++ return 0; 86.203 ++ size = (size & ~(size-1)) - 1; 86.204 ++ 86.205 ++ if (base == maxbase && ((base | size) & mask) != mask) 86.206 ++ return 0; 86.207 ++ 86.208 ++ return size + 1; 86.209 ++} 86.210 ++ 86.211 + int 86.212 + pci_generic_fill_info(struct pci_dev *d, int flags) 86.213 + { 86.214 +@@ -114,23 +127,61 @@ 86.215 + if (!x || x == (u32) ~0) 86.216 + continue; 86.217 + if ((x & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) 86.218 +- d->base_addr[i] = x; 86.219 +- else 86.220 ++ { 86.221 ++ d->base_addr[i] = x & PCI_BASE_ADDRESS_IO_MASK; 86.222 ++ if (flags & PCI_FILL_SIZES) 86.223 ++ { 86.224 ++ u32 size; 86.225 ++ pci_write_long(d, PCI_BASE_ADDRESS_0 + i*4, ~0); 86.226 ++ d->size[i] = pci_size(x, pci_read_long(d, PCI_BASE_ADDRESS_0 + i*4), PCI_BASE_ADDRESS_IO_MASK); 86.227 ++ pci_write_long(d, PCI_BASE_ADDRESS_0 + i*4, x); 86.228 ++ } 86.229 ++ } 86.230 ++ else 86.231 + { 86.232 + if ((x & PCI_BASE_ADDRESS_MEM_TYPE_MASK) != PCI_BASE_ADDRESS_MEM_TYPE_64) 86.233 +- d->base_addr[i] = x; 86.234 ++ { 86.235 ++ d->base_addr[i] = x & PCI_BASE_ADDRESS_MEM_MASK; 86.236 ++ if (flags & PCI_FILL_SIZES) 86.237 ++ { 86.238 ++ u32 size; 86.239 ++ pci_write_long(d, PCI_BASE_ADDRESS_0 + i*4, ~0); 86.240 ++ d->size[i] = pci_read_long(d, PCI_BASE_ADDRESS_0 + i*4); 86.241 ++ d->size[i] = pci_size(x, pci_read_long(d, PCI_BASE_ADDRESS_0 + i*4), PCI_BASE_ADDRESS_MEM_MASK); 86.242 ++ pci_write_long(d, PCI_BASE_ADDRESS_0 + i*4, x); 86.243 ++ } 86.244 ++ } 86.245 + else if (i >= cnt-1) 86.246 + a->warning("%04x:%02x:%02x.%d: Invalid 64-bit address seen for BAR %d.", d->domain, d->bus, d->dev, d->func, i); 86.247 + else 86.248 + { 86.249 + u32 y = pci_read_long(d, PCI_BASE_ADDRESS_0 + (++i)*4); 86.250 + #ifdef PCI_HAVE_64BIT_ADDRESS 86.251 +- d->base_addr[i-1] = x | (((pciaddr_t) y) << 32); 86.252 ++ d->base_addr[i-1] = (x | (((pciaddr_t) y) << 32)) & PCI_BASE_ADDRESS_MEM_MASK; 86.253 ++ if (flags & PCI_FILL_SIZES) 86.254 ++ { 86.255 ++ u32 size; 86.256 ++ pci_write_long(d, PCI_BASE_ADDRESS_0 + (i-1)*4, ~0); 86.257 ++ pci_write_long(d, PCI_BASE_ADDRESS_0 + i*4, ~0); 86.258 ++ d->size[i-1] = pci_size(y, pci_read_long(d, PCI_BASE_ADDRESS_0 + (i-1)*4) | 86.259 ++ pci_read_long(d, PCI_BASE_ADDRESS_0 + i*4), 0xffffffff ); 86.260 ++ pci_write_long(d, PCI_BASE_ADDRESS_0 + (i-1)*4, x); 86.261 ++ pci_write_long(d, PCI_BASE_ADDRESS_0 + i*4, y); 86.262 ++ } 86.263 + #else 86.264 + if (y) 86.265 + a->warning("%04x:%02x:%02x.%d 64-bit device address ignored.", d->domain, d->bus, d->dev, d->func); 86.266 + else 86.267 +- d->base_addr[i-1] = x; 86.268 ++ { 86.269 ++ d->base_addr[i-1] = x & PCI_BASE_ADDRESS_MEM_MASK; 86.270 ++ if (flags & PCI_FILL_SIZES) 86.271 ++ { 86.272 ++ u32 size; 86.273 ++ pci_write_long(d, PCI_BASE_ADDRESS_0 + (i-1)*4, ~0); 86.274 ++ d->size[i-1] = pci_size(x, pci_read_long(d, PCI_BASE_ADDRESS_0 + (i-1)*4), PCI_BASE_ADDRESS_MEM_MASK); 86.275 ++ pci_write_long(d, PCI_BASE_ADDRESS_0 + (i-1)*4, x); 86.276 ++ } 86.277 ++ } 86.278 + #endif 86.279 + } 86.280 + } 86.281 +@@ -154,10 +205,19 @@ 86.282 + { 86.283 + u32 u = pci_read_long(d, reg); 86.284 + if (u != 0xffffffff) 86.285 +- d->rom_base_addr = u; 86.286 ++ { 86.287 ++ d->rom_base_addr = u; 86.288 ++ if (flags & PCI_FILL_SIZES) 86.289 ++ { 86.290 ++ u32 size; 86.291 ++ pci_write_long(d, reg, ~0); 86.292 ++ d->rom_size = pci_read_long(d, reg); 86.293 ++ pci_write_long(d, reg, u); 86.294 ++ } 86.295 ++ } 86.296 + } 86.297 + } 86.298 +- return flags & ~PCI_FILL_SIZES; 86.299 ++ return flags; 86.300 + } 86.301 + 86.302 + static int
87.1 --- a/tools/Makefile Tue Jul 08 11:41:43 2008 +0900 87.2 +++ b/tools/Makefile Fri Jul 18 12:12:41 2008 +0900 87.3 @@ -22,7 +22,12 @@ SUBDIRS-y += libaio 87.4 SUBDIRS-y += blktap 87.5 SUBDIRS-y += libfsimage 87.6 SUBDIRS-$(LIBXENAPI_BINDINGS) += libxen 87.7 + 87.8 +ifeq (ioemu,$(CONFIG_QEMU)) 87.9 SUBDIRS-$(CONFIG_IOEMU) += ioemu 87.10 +else 87.11 +SUBDIRS-$(CONFIG_IOEMU) += ioemu-dir 87.12 +endif 87.13 87.14 # These don't cross-compile 87.15 ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH)) 87.16 @@ -62,3 +67,33 @@ subdir-all-ioemu subdir-install-ioemu: i 87.17 subdir-clean-ioemu: 87.18 $(MAKE) -C ioemu distclean 87.19 87.20 +ioemu-dir-find: 87.21 + set -ex; \ 87.22 + if test -d $(CONFIG_QEMU); then \ 87.23 + rm -f ioemu-dir; \ 87.24 + ln -sf $(CONFIG_QEMU) ioemu-dir; \ 87.25 + else \ 87.26 + if [ ! -d ioemu-remote ]; then \ 87.27 + rm -rf ioemu-remote ioemu-remote.tmp; \ 87.28 + mkdir ioemu-remote.tmp; rmdir ioemu-remote.tmp; \ 87.29 + $(GIT) clone $(CONFIG_QEMU) ioemu-remote.tmp; \ 87.30 + mv ioemu-remote.tmp ioemu-remote; \ 87.31 + fi; \ 87.32 + rm -f ioemu-dir; \ 87.33 + ln -sf ioemu-remote ioemu-dir; \ 87.34 + fi 87.35 + set -e; \ 87.36 + case "$(XEN_ROOT)" in \ 87.37 + /*) XEN_ROOT=$(XEN_ROOT) ;; \ 87.38 + *) XEN_ROOT=`pwd`/$(XEN_ROOT) ;; \ 87.39 + esac; \ 87.40 + export XEN_ROOT; \ 87.41 + cd ioemu-dir; \ 87.42 + ./xen-setup 87.43 + 87.44 +subdir-all-ioemu-dir subdir-install-ioemu-dir: ioemu-dir-find 87.45 + 87.46 +subdir-clean-ioemu-dir: 87.47 + if test -d ioemu-dir/.; then \ 87.48 + $(MAKE) -C ioemu-dir clean; \ 87.49 + fi
88.1 --- a/tools/blktap/drivers/Makefile Tue Jul 08 11:41:43 2008 +0900 88.2 +++ b/tools/blktap/drivers/Makefile Fri Jul 18 12:12:41 2008 +0900 88.3 @@ -36,11 +36,14 @@ BLK-OBJS-y += block-qcow.o 88.4 BLK-OBJS-y += block-qcow2.o 88.5 BLK-OBJS-y += aes.o 88.6 BLK-OBJS-y += tapaio.o 88.7 -BLK-OBJS-$(CONFIG_Linux) += blk_linux.c 88.8 +BLK-OBJS-$(CONFIG_Linux) += blk_linux.o 88.9 + 88.10 +BLKTAB-OBJS-y := blktapctrl.o 88.11 +BLKTAB-OBJS-$(CONFIG_Linux) += blktapctrl_linux.o 88.12 88.13 all: $(IBIN) qcow-util 88.14 88.15 -blktapctrl: blktapctrl.o 88.16 +blktapctrl: $(BLKTAB-OBJS-y) 88.17 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LDFLAGS_blktapctrl) 88.18 88.19 tapdisk: tapdisk.o $(BLK-OBJS-y)
89.1 --- a/tools/blktap/drivers/blktapctrl.c Tue Jul 08 11:41:43 2008 +0900 89.2 +++ b/tools/blktap/drivers/blktapctrl.c Fri Jul 18 12:12:41 2008 +0900 89.3 @@ -37,7 +37,6 @@ 89.4 #include <stdio.h> 89.5 #include <stdlib.h> 89.6 #include <sys/mman.h> 89.7 -#include <sys/stat.h> 89.8 #include <err.h> 89.9 #include <errno.h> 89.10 #include <sys/types.h> 89.11 @@ -55,6 +54,8 @@ 89.12 #include "blktaplib.h" 89.13 #include "blktapctrl.h" 89.14 #include "tapdisk.h" 89.15 +#include "list.h" 89.16 +#include "xs_api.h" /* for xs_fire_next_watch() */ 89.17 89.18 #define PIDFILE "/var/run/blktapctrl.pid" 89.19 89.20 @@ -75,6 +76,32 @@ static int write_msg(int fd, int msgtype 89.21 static int read_msg(int fd, int msgtype, void *ptr); 89.22 static driver_list_entry_t *active_disks[MAX_DISK_TYPES]; 89.23 89.24 + 89.25 +static unsigned long long tapdisk_get_size(blkif_t *blkif) 89.26 +{ 89.27 + image_t *img = (image_t *)blkif->prv; 89.28 + return img->size; 89.29 +} 89.30 + 89.31 +static unsigned long tapdisk_get_secsize(blkif_t *blkif) 89.32 +{ 89.33 + image_t *img = (image_t *)blkif->prv; 89.34 + return img->secsize; 89.35 +} 89.36 + 89.37 +static unsigned int tapdisk_get_info(blkif_t *blkif) 89.38 +{ 89.39 + image_t *img = (image_t *)blkif->prv; 89.40 + return img->info; 89.41 +} 89.42 + 89.43 +struct blkif_ops tapdisk_ops = { 89.44 + .get_size = tapdisk_get_size, 89.45 + .get_secsize = tapdisk_get_secsize, 89.46 + .get_info = tapdisk_get_info, 89.47 +}; 89.48 + 89.49 + 89.50 static void init_driver_list(void) 89.51 { 89.52 int i; 89.53 @@ -95,62 +122,6 @@ static void init_rng(void) 89.54 return; 89.55 } 89.56 89.57 -static void make_blktap_dev(char *devname, int major, int minor) 89.58 -{ 89.59 - struct stat st; 89.60 - 89.61 - if (lstat(devname, &st) != 0) { 89.62 - /*Need to create device*/ 89.63 - if (mkdir(BLKTAP_DEV_DIR, 0755) == 0) 89.64 - DPRINTF("Created %s directory\n",BLKTAP_DEV_DIR); 89.65 - if (mknod(devname, S_IFCHR|0600, 89.66 - makedev(major, minor)) == 0) 89.67 - DPRINTF("Created %s device\n",devname); 89.68 - } else { 89.69 - DPRINTF("%s device already exists\n",devname); 89.70 - /* it already exists, but is it the same major number */ 89.71 - if (((st.st_rdev>>8) & 0xff) != major) { 89.72 - DPRINTF("%s has old major %d\n", 89.73 - devname, 89.74 - (unsigned int)((st.st_rdev >> 8) & 0xff)); 89.75 - /* only try again if we succed in deleting it */ 89.76 - if (!unlink(devname)) 89.77 - make_blktap_dev(devname, major, minor); 89.78 - } 89.79 - } 89.80 -} 89.81 - 89.82 -static int get_new_dev(int *major, int *minor, blkif_t *blkif) 89.83 -{ 89.84 - domid_translate_t tr; 89.85 - int ret; 89.86 - char *devname; 89.87 - 89.88 - tr.domid = blkif->domid; 89.89 - tr.busid = blkif->be_id; 89.90 - ret = ioctl(ctlfd, BLKTAP_IOCTL_NEWINTF, tr ); 89.91 - 89.92 - if ( (ret <= 0)||(ret > MAX_TAP_DEV) ) { 89.93 - DPRINTF("Incorrect Dev ID [%d]\n",ret); 89.94 - return -1; 89.95 - } 89.96 - 89.97 - *minor = ret; 89.98 - *major = ioctl(ctlfd, BLKTAP_IOCTL_MAJOR, ret ); 89.99 - if (*major < 0) { 89.100 - DPRINTF("Incorrect Major ID [%d]\n",*major); 89.101 - return -1; 89.102 - } 89.103 - 89.104 - if (asprintf(&devname,"%s/%s%d",BLKTAP_DEV_DIR, BLKTAP_DEV_NAME, *minor) == -1) 89.105 - return -1; 89.106 - make_blktap_dev(devname,*major,*minor); 89.107 - DPRINTF("Received device id %d and major %d, " 89.108 - "sent domid %d and be_id %d\n", 89.109 - *minor, *major, tr.domid, tr.busid); 89.110 - return 0; 89.111 -} 89.112 - 89.113 static int get_tapdisk_pid(blkif_t *blkif) 89.114 { 89.115 int ret; 89.116 @@ -626,7 +597,7 @@ fail: 89.117 return ret; 89.118 } 89.119 89.120 -int blktapctrl_new_blkif(blkif_t *blkif) 89.121 +static int blktapctrl_new_blkif(blkif_t *blkif) 89.122 { 89.123 blkif_info_t *blk; 89.124 int major, minor, fd_read, fd_write, type, new; 89.125 @@ -637,7 +608,7 @@ int blktapctrl_new_blkif(blkif_t *blkif) 89.126 89.127 DPRINTF("Received a poll for a new vbd\n"); 89.128 if ( ((blk=blkif->info) != NULL) && (blk->params != NULL) ) { 89.129 - if (get_new_dev(&major, &minor, blkif)<0) 89.130 + if (blktap_interface_create(ctlfd, &major, &minor, blkif) < 0) 89.131 return -1; 89.132 89.133 if (test_path(blk->params, &ptr, &type, &exist) != 0) { 89.134 @@ -698,7 +669,7 @@ fail: 89.135 return -EINVAL; 89.136 } 89.137 89.138 -int map_new_blktapctrl(blkif_t *blkif) 89.139 +static int map_new_blktapctrl(blkif_t *blkif) 89.140 { 89.141 DPRINTF("Received a poll for a new devmap\n"); 89.142 if (write_msg(blkif->fds[WRITE], CTLMSG_NEWDEV, blkif, NULL) <= 0) { 89.143 @@ -715,7 +686,7 @@ int map_new_blktapctrl(blkif_t *blkif) 89.144 return blkif->minor - 1; 89.145 } 89.146 89.147 -int unmap_blktapctrl(blkif_t *blkif) 89.148 +static int unmap_blktapctrl(blkif_t *blkif) 89.149 { 89.150 DPRINTF("Unmapping vbd\n"); 89.151 89.152 @@ -829,21 +800,11 @@ int main(int argc, char *argv[]) 89.153 register_new_devmap_hook(map_new_blktapctrl); 89.154 register_new_unmap_hook(unmap_blktapctrl); 89.155 89.156 - /* Attach to blktap0 */ 89.157 - if (asprintf(&devname,"%s/%s0", BLKTAP_DEV_DIR, BLKTAP_DEV_NAME) == -1) 89.158 - goto open_failed; 89.159 - if ((ret = xc_find_device_number("blktap0")) < 0) { 89.160 - DPRINTF("couldn't find device number for 'blktap0'\n"); 89.161 + ctlfd = blktap_interface_open(); 89.162 + if (ctlfd < 0) { 89.163 + DPRINTF("couldn't open blktap interface\n"); 89.164 goto open_failed; 89.165 } 89.166 - blktap_major = major(ret); 89.167 - make_blktap_dev(devname,blktap_major,0); 89.168 - ctlfd = open(devname, O_RDWR); 89.169 - if (ctlfd == -1) { 89.170 - DPRINTF("blktap0 open failed\n"); 89.171 - goto open_failed; 89.172 - } 89.173 - 89.174 89.175 retry: 89.176 /* Set up store connection and watch. */
90.1 --- a/tools/blktap/drivers/blktapctrl.h Tue Jul 08 11:41:43 2008 +0900 90.2 +++ b/tools/blktap/drivers/blktapctrl.h Fri Jul 18 12:12:41 2008 +0900 90.3 @@ -30,26 +30,7 @@ 90.4 */ 90.5 90.6 90.7 -static inline unsigned long long tapdisk_get_size(blkif_t *blkif) 90.8 -{ 90.9 - image_t *img = (image_t *)blkif->prv; 90.10 - return img->size; 90.11 -} 90.12 - 90.13 -static inline unsigned long tapdisk_get_secsize(blkif_t *blkif) 90.14 -{ 90.15 - image_t *img = (image_t *)blkif->prv; 90.16 - return img->secsize; 90.17 -} 90.18 +int blktap_interface_open(void); 90.19 90.20 -static inline unsigned int tapdisk_get_info(blkif_t *blkif) 90.21 -{ 90.22 - image_t *img = (image_t *)blkif->prv; 90.23 - return img->info; 90.24 -} 90.25 +int blktap_interface_create(int ctlfd, int *major, int *minor, blkif_t *blkif); 90.26 90.27 -struct blkif_ops tapdisk_ops = { 90.28 - .get_size = tapdisk_get_size, 90.29 - .get_secsize = tapdisk_get_secsize, 90.30 - .get_info = tapdisk_get_info, 90.31 -};
91.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 91.2 +++ b/tools/blktap/drivers/blktapctrl_linux.c Fri Jul 18 12:12:41 2008 +0900 91.3 @@ -0,0 +1,109 @@ 91.4 + 91.5 +#include <stdio.h> 91.6 +#include <fcntl.h> 91.7 +#include <sys/stat.h> 91.8 +#include <sys/ioctl.h> 91.9 + 91.10 +#include "tapdisk.h" 91.11 +#include "blktaplib.h" 91.12 +#include "blktapctrl.h" 91.13 + 91.14 +static void make_blktap_dev(char *devname, int major, int minor) 91.15 +{ 91.16 + struct stat st; 91.17 + 91.18 + if (lstat(devname, &st) != 0) { 91.19 + /*Need to create device*/ 91.20 + if (mkdir(BLKTAP_DEV_DIR, 0755) == 0) 91.21 + DPRINTF("Created %s directory\n",BLKTAP_DEV_DIR); 91.22 + if (mknod(devname, S_IFCHR|0600, 91.23 + makedev(major, minor)) == 0) 91.24 + DPRINTF("Created %s device\n",devname); 91.25 + } else { 91.26 + DPRINTF("%s device already exists\n",devname); 91.27 + /* it already exists, but is it the same major number */ 91.28 + if (((st.st_rdev>>8) & 0xff) != major) { 91.29 + DPRINTF("%s has old major %d\n", 91.30 + devname, 91.31 + (unsigned int)((st.st_rdev >> 8) & 0xff)); 91.32 + /* only try again if we succed in deleting it */ 91.33 + if (!unlink(devname)) 91.34 + make_blktap_dev(devname, major, minor); 91.35 + } 91.36 + } 91.37 +} 91.38 + 91.39 +int blktap_interface_create(int ctlfd, int *major, int *minor, blkif_t *blkif) 91.40 +{ 91.41 + domid_translate_t tr; 91.42 + domid_translate_ext_t tr_ext; 91.43 + int ret; 91.44 + char *devname; 91.45 + 91.46 + if (blkif->be_id >= (1<<28)) { 91.47 + /* new-style backend-id, so use the extended structure */ 91.48 + tr_ext.domid = blkif->domid; 91.49 + tr_ext.busid = blkif->be_id; 91.50 + ret = ioctl(ctlfd, BLKTAP_IOCTL_NEWINTF_EXT, &tr_ext); 91.51 + DPRINTF("Sent domid %d and be_id %d\n", tr_ext.domid, 91.52 + tr_ext.busid); 91.53 + } 91.54 + else { 91.55 + /* old-style backend-id; use the old structure */ 91.56 + tr.domid = blkif->domid; 91.57 + tr.busid = (unsigned short)blkif->be_id; 91.58 + ret = ioctl(ctlfd, BLKTAP_IOCTL_NEWINTF, tr); 91.59 + DPRINTF("Sent domid %d and be_id %d\n", tr.domid, tr.busid); 91.60 + } 91.61 + 91.62 + if ( (ret <= 0)||(ret > MAX_TAP_DEV) ) { 91.63 + DPRINTF("Incorrect Dev ID [%d]\n",ret); 91.64 + return -1; 91.65 + } 91.66 + 91.67 + *minor = ret; 91.68 + *major = ioctl(ctlfd, BLKTAP_IOCTL_MAJOR, ret ); 91.69 + if (*major < 0) { 91.70 + DPRINTF("Incorrect Major ID [%d]\n",*major); 91.71 + return -1; 91.72 + } 91.73 + 91.74 + if (asprintf(&devname,"%s/%s%d",BLKTAP_DEV_DIR, BLKTAP_DEV_NAME, *minor) == -1) 91.75 + return -1; 91.76 + make_blktap_dev(devname,*major,*minor); 91.77 + DPRINTF("Received device id %d and major %d\n", 91.78 + *minor, *major); 91.79 + return 0; 91.80 +} 91.81 + 91.82 + 91.83 +int blktap_interface_open(void) 91.84 +{ 91.85 + char *devname; 91.86 + int ret; 91.87 + int ctlfd; 91.88 + 91.89 + /* Attach to blktap0 */ 91.90 + if (asprintf(&devname,"%s/%s0", BLKTAP_DEV_DIR, BLKTAP_DEV_NAME) == -1) 91.91 + goto open_failed; 91.92 + 91.93 + ret = xc_find_device_number("blktap0"); 91.94 + if (ret < 0) { 91.95 + DPRINTF("couldn't find device number for 'blktap0'\n"); 91.96 + goto open_failed; 91.97 + } 91.98 + 91.99 + blktap_major = major(ret); 91.100 + make_blktap_dev(devname,blktap_major, 0); 91.101 + 91.102 + ctlfd = open(devname, O_RDWR); 91.103 + if (ctlfd == -1) { 91.104 + DPRINTF("blktap0 open failed\n"); 91.105 + goto open_failed; 91.106 + } 91.107 + 91.108 + return ctlfd; 91.109 + 91.110 +open_failed: 91.111 + return -1; 91.112 +}
92.1 --- a/tools/blktap/drivers/block-aio.c Tue Jul 08 11:41:43 2008 +0900 92.2 +++ b/tools/blktap/drivers/block-aio.c Fri Jul 18 12:12:41 2008 +0900 92.3 @@ -118,7 +118,7 @@ static inline void init_fds(struct disk_ 92.4 } 92.5 92.6 /* Open the disk file and initialize aio state. */ 92.7 -int tdaio_open (struct disk_driver *dd, const char *name, td_flag_t flags) 92.8 +static int tdaio_open (struct disk_driver *dd, const char *name, td_flag_t flags) 92.9 { 92.10 int i, fd, ret = 0, o_flags; 92.11 struct td_state *s = dd->td_state; 92.12 @@ -161,7 +161,7 @@ done: 92.13 return ret; 92.14 } 92.15 92.16 -int tdaio_queue_read(struct disk_driver *dd, uint64_t sector, 92.17 +static int tdaio_queue_read(struct disk_driver *dd, uint64_t sector, 92.18 int nb_sectors, char *buf, td_callback_t cb, 92.19 int id, void *private) 92.20 { 92.21 @@ -174,7 +174,7 @@ int tdaio_queue_read(struct disk_driver 92.22 cb, id, sector, private); 92.23 } 92.24 92.25 -int tdaio_queue_write(struct disk_driver *dd, uint64_t sector, 92.26 +static int tdaio_queue_write(struct disk_driver *dd, uint64_t sector, 92.27 int nb_sectors, char *buf, td_callback_t cb, 92.28 int id, void *private) 92.29 { 92.30 @@ -187,14 +187,14 @@ int tdaio_queue_write(struct disk_driver 92.31 cb, id, sector, private); 92.32 } 92.33 92.34 -int tdaio_submit(struct disk_driver *dd) 92.35 +static int tdaio_submit(struct disk_driver *dd) 92.36 { 92.37 struct tdaio_state *prv = (struct tdaio_state *)dd->private; 92.38 92.39 return tap_aio_submit(&prv->aio); 92.40 } 92.41 92.42 -int tdaio_close(struct disk_driver *dd) 92.43 +static int tdaio_close(struct disk_driver *dd) 92.44 { 92.45 struct tdaio_state *prv = (struct tdaio_state *)dd->private; 92.46 92.47 @@ -204,7 +204,7 @@ int tdaio_close(struct disk_driver *dd) 92.48 return 0; 92.49 } 92.50 92.51 -int tdaio_do_callbacks(struct disk_driver *dd, int sid) 92.52 +static int tdaio_do_callbacks(struct disk_driver *dd, int sid) 92.53 { 92.54 int i, nr_events, rsp = 0; 92.55 struct io_event *ep; 92.56 @@ -234,12 +234,12 @@ repeat: 92.57 return rsp; 92.58 } 92.59 92.60 -int tdaio_get_parent_id(struct disk_driver *dd, struct disk_id *id) 92.61 +static int tdaio_get_parent_id(struct disk_driver *dd, struct disk_id *id) 92.62 { 92.63 return TD_NO_PARENT; 92.64 } 92.65 92.66 -int tdaio_validate_parent(struct disk_driver *dd, 92.67 +static int tdaio_validate_parent(struct disk_driver *dd, 92.68 struct disk_driver *parent, td_flag_t flags) 92.69 { 92.70 return -EINVAL;
93.1 --- a/tools/blktap/drivers/block-qcow.c Tue Jul 08 11:41:43 2008 +0900 93.2 +++ b/tools/blktap/drivers/block-qcow.c Fri Jul 18 12:12:41 2008 +0900 93.3 @@ -720,7 +720,7 @@ static inline void init_fds(struct disk_ 93.4 } 93.5 93.6 /* Open the disk file and initialize qcow state. */ 93.7 -int tdqcow_open (struct disk_driver *dd, const char *name, td_flag_t flags) 93.8 +static int tdqcow_open (struct disk_driver *dd, const char *name, td_flag_t flags) 93.9 { 93.10 int fd, len, i, shift, ret, size, l1_table_size, o_flags; 93.11 int max_aio_reqs; 93.12 @@ -937,7 +937,7 @@ fail: 93.13 return -1; 93.14 } 93.15 93.16 -int tdqcow_queue_read(struct disk_driver *dd, uint64_t sector, 93.17 +static int tdqcow_queue_read(struct disk_driver *dd, uint64_t sector, 93.18 int nb_sectors, char *buf, td_callback_t cb, 93.19 int id, void *private) 93.20 { 93.21 @@ -999,7 +999,7 @@ done: 93.22 return rsp; 93.23 } 93.24 93.25 -int tdqcow_queue_write(struct disk_driver *dd, uint64_t sector, 93.26 +static int tdqcow_queue_write(struct disk_driver *dd, uint64_t sector, 93.27 int nb_sectors, char *buf, td_callback_t cb, 93.28 int id, void *private) 93.29 { 93.30 @@ -1057,14 +1057,14 @@ int tdqcow_queue_write(struct disk_drive 93.31 return 0; 93.32 } 93.33 93.34 -int tdqcow_submit(struct disk_driver *dd) 93.35 +static int tdqcow_submit(struct disk_driver *dd) 93.36 { 93.37 struct tdqcow_state *prv = (struct tdqcow_state *)dd->private; 93.38 93.39 return tap_aio_submit(&prv->aio); 93.40 } 93.41 93.42 -int tdqcow_close(struct disk_driver *dd) 93.43 +static int tdqcow_close(struct disk_driver *dd) 93.44 { 93.45 struct tdqcow_state *s = (struct tdqcow_state *)dd->private; 93.46 uint32_t cksum, out; 93.47 @@ -1092,7 +1092,7 @@ int tdqcow_close(struct disk_driver *dd) 93.48 return 0; 93.49 } 93.50 93.51 -int tdqcow_do_callbacks(struct disk_driver *dd, int sid) 93.52 +static int tdqcow_do_callbacks(struct disk_driver *dd, int sid) 93.53 { 93.54 int ret, i, nr_events, rsp = 0,*ptr; 93.55 struct io_event *ep; 93.56 @@ -1276,7 +1276,7 @@ int qcow_create(const char *filename, ui 93.57 return 0; 93.58 } 93.59 93.60 -int qcow_make_empty(struct tdqcow_state *s) 93.61 +static int qcow_make_empty(struct tdqcow_state *s) 93.62 { 93.63 uint32_t l1_length = s->l1_size * sizeof(uint64_t); 93.64 93.65 @@ -1296,14 +1296,14 @@ int qcow_make_empty(struct tdqcow_state 93.66 return 0; 93.67 } 93.68 93.69 -int qcow_get_cluster_size(struct tdqcow_state *s) 93.70 +static int qcow_get_cluster_size(struct tdqcow_state *s) 93.71 { 93.72 return s->cluster_size; 93.73 } 93.74 93.75 /* XXX: put compressed sectors first, then all the cluster aligned 93.76 tables to avoid losing bytes in alignment */ 93.77 -int qcow_compress_cluster(struct tdqcow_state *s, int64_t sector_num, 93.78 +static int qcow_compress_cluster(struct tdqcow_state *s, int64_t sector_num, 93.79 const uint8_t *buf) 93.80 { 93.81 z_stream strm; 93.82 @@ -1358,7 +1358,7 @@ int qcow_compress_cluster(struct tdqcow_ 93.83 return 0; 93.84 } 93.85 93.86 -int tdqcow_get_parent_id(struct disk_driver *dd, struct disk_id *id) 93.87 +static int tdqcow_get_parent_id(struct disk_driver *dd, struct disk_id *id) 93.88 { 93.89 off_t off; 93.90 char *buf, *filename; 93.91 @@ -1392,7 +1392,7 @@ int tdqcow_get_parent_id(struct disk_dri 93.92 return err; 93.93 } 93.94 93.95 -int tdqcow_validate_parent(struct disk_driver *child, 93.96 +static int tdqcow_validate_parent(struct disk_driver *child, 93.97 struct disk_driver *parent, td_flag_t flags) 93.98 { 93.99 struct stat stats;
94.1 --- a/tools/blktap/drivers/block-ram.c Tue Jul 08 11:41:43 2008 +0900 94.2 +++ b/tools/blktap/drivers/block-ram.c Fri Jul 18 12:12:41 2008 +0900 94.3 @@ -127,7 +127,7 @@ static inline void init_fds(struct disk_ 94.4 } 94.5 94.6 /* Open the disk file and initialize ram state. */ 94.7 -int tdram_open (struct disk_driver *dd, const char *name, td_flag_t flags) 94.8 +static int tdram_open (struct disk_driver *dd, const char *name, td_flag_t flags) 94.9 { 94.10 char *p; 94.11 uint64_t size; 94.12 @@ -220,7 +220,7 @@ done: 94.13 return ret; 94.14 } 94.15 94.16 - int tdram_queue_read(struct disk_driver *dd, uint64_t sector, 94.17 +static int tdram_queue_read(struct disk_driver *dd, uint64_t sector, 94.18 int nb_sectors, char *buf, td_callback_t cb, 94.19 int id, void *private) 94.20 { 94.21 @@ -234,7 +234,7 @@ done: 94.22 return cb(dd, 0, sector, nb_sectors, id, private); 94.23 } 94.24 94.25 -int tdram_queue_write(struct disk_driver *dd, uint64_t sector, 94.26 +static int tdram_queue_write(struct disk_driver *dd, uint64_t sector, 94.27 int nb_sectors, char *buf, td_callback_t cb, 94.28 int id, void *private) 94.29 { 94.30 @@ -250,12 +250,12 @@ int tdram_queue_write(struct disk_driver 94.31 return cb(dd, 0, sector, nb_sectors, id, private); 94.32 } 94.33 94.34 -int tdram_submit(struct disk_driver *dd) 94.35 +static int tdram_submit(struct disk_driver *dd) 94.36 { 94.37 return 0; 94.38 } 94.39 94.40 -int tdram_close(struct disk_driver *dd) 94.41 +static int tdram_close(struct disk_driver *dd) 94.42 { 94.43 struct tdram_state *prv = (struct tdram_state *)dd->private; 94.44 94.45 @@ -264,18 +264,18 @@ int tdram_close(struct disk_driver *dd) 94.46 return 0; 94.47 } 94.48 94.49 -int tdram_do_callbacks(struct disk_driver *dd, int sid) 94.50 +static int tdram_do_callbacks(struct disk_driver *dd, int sid) 94.51 { 94.52 /* always ask for a kick */ 94.53 return 1; 94.54 } 94.55 94.56 -int tdram_get_parent_id(struct disk_driver *dd, struct disk_id *id) 94.57 +static int tdram_get_parent_id(struct disk_driver *dd, struct disk_id *id) 94.58 { 94.59 return TD_NO_PARENT; 94.60 } 94.61 94.62 -int tdram_validate_parent(struct disk_driver *dd, 94.63 +static int tdram_validate_parent(struct disk_driver *dd, 94.64 struct disk_driver *parent, td_flag_t flags) 94.65 { 94.66 return -EINVAL;
95.1 --- a/tools/blktap/drivers/block-sync.c Tue Jul 08 11:41:43 2008 +0900 95.2 +++ b/tools/blktap/drivers/block-sync.c Fri Jul 18 12:12:41 2008 +0900 95.3 @@ -109,7 +109,7 @@ static inline void init_fds(struct disk_ 95.4 } 95.5 95.6 /* Open the disk file and initialize aio state. */ 95.7 -int tdsync_open (struct disk_driver *dd, const char *name, td_flag_t flags) 95.8 +static int tdsync_open (struct disk_driver *dd, const char *name, td_flag_t flags) 95.9 { 95.10 int i, fd, ret = 0, o_flags; 95.11 struct td_state *s = dd->td_state; 95.12 @@ -129,7 +129,7 @@ int tdsync_open (struct disk_driver *dd, 95.13 95.14 /* Maybe O_DIRECT isn't supported. */ 95.15 o_flags &= ~O_DIRECT; 95.16 - fd = open(name, O_RDWR | O_LARGEFILE); 95.17 + fd = open(name, o_flags); 95.18 if (fd != -1) DPRINTF("WARNING: Accessing image without" 95.19 "O_DIRECT! (%s)\n", name); 95.20 95.21 @@ -149,7 +149,7 @@ done: 95.22 return ret; 95.23 } 95.24 95.25 - int tdsync_queue_read(struct disk_driver *dd, uint64_t sector, 95.26 +static int tdsync_queue_read(struct disk_driver *dd, uint64_t sector, 95.27 int nb_sectors, char *buf, td_callback_t cb, 95.28 int id, void *private) 95.29 { 95.30 @@ -172,7 +172,7 @@ done: 95.31 return cb(dd, (ret < 0) ? ret: 0, sector, nb_sectors, id, private); 95.32 } 95.33 95.34 - int tdsync_queue_write(struct disk_driver *dd, uint64_t sector, 95.35 +static int tdsync_queue_write(struct disk_driver *dd, uint64_t sector, 95.36 int nb_sectors, char *buf, td_callback_t cb, 95.37 int id, void *private) 95.38 { 95.39 @@ -195,12 +195,12 @@ done: 95.40 return cb(dd, (ret < 0) ? ret : 0, sector, nb_sectors, id, private); 95.41 } 95.42 95.43 -int tdsync_submit(struct disk_driver *dd) 95.44 +static int tdsync_submit(struct disk_driver *dd) 95.45 { 95.46 return 0; 95.47 } 95.48 95.49 -int tdsync_close(struct disk_driver *dd) 95.50 +static int tdsync_close(struct disk_driver *dd) 95.51 { 95.52 struct tdsync_state *prv = (struct tdsync_state *)dd->private; 95.53 95.54 @@ -211,18 +211,18 @@ int tdsync_close(struct disk_driver *dd) 95.55 return 0; 95.56 } 95.57 95.58 -int tdsync_do_callbacks(struct disk_driver *dd, int sid) 95.59 +static int tdsync_do_callbacks(struct disk_driver *dd, int sid) 95.60 { 95.61 /* always ask for a kick */ 95.62 return 1; 95.63 } 95.64 95.65 -int tdsync_get_parent_id(struct disk_driver *dd, struct disk_id *id) 95.66 +static int tdsync_get_parent_id(struct disk_driver *dd, struct disk_id *id) 95.67 { 95.68 return TD_NO_PARENT; 95.69 } 95.70 95.71 -int tdsync_validate_parent(struct disk_driver *dd, 95.72 +static int tdsync_validate_parent(struct disk_driver *dd, 95.73 struct disk_driver *parent, td_flag_t flags) 95.74 { 95.75 return -EINVAL;
96.1 --- a/tools/blktap/drivers/img2qcow.c Tue Jul 08 11:41:43 2008 +0900 96.2 +++ b/tools/blktap/drivers/img2qcow.c Fri Jul 18 12:12:41 2008 +0900 96.3 @@ -61,8 +61,8 @@ static int returned_events = 0, submit_e 96.4 static uint64_t prev = 0; 96.5 static char output[25]; 96.6 96.7 -void print_bytes(void *ptr, int length) { 96.8 - 96.9 +static void print_bytes(void *ptr, int length) 96.10 +{ 96.11 int i,k; 96.12 unsigned char *p = ptr; 96.13 96.14 @@ -77,7 +77,7 @@ void print_bytes(void *ptr, int length) 96.15 return; 96.16 } 96.17 96.18 -void debug_output(uint64_t progress, uint64_t size) 96.19 +static void debug_output(uint64_t progress, uint64_t size) 96.20 { 96.21 uint64_t blocks = size/20; 96.22
97.1 --- a/tools/blktap/drivers/qcow-create.c Tue Jul 08 11:41:43 2008 +0900 97.2 +++ b/tools/blktap/drivers/qcow-create.c Fri Jul 18 12:12:41 2008 +0900 97.3 @@ -48,7 +48,7 @@ 97.4 97.5 #define MAX_NAME_LEN 1000 97.6 97.7 -void help(void) 97.8 +static void help(void) 97.9 { 97.10 fprintf(stderr, "Qcow-utils: v1.0.0\n"); 97.11 fprintf(stderr,
98.1 --- a/tools/blktap/drivers/qcow2raw.c Tue Jul 08 11:41:43 2008 +0900 98.2 +++ b/tools/blktap/drivers/qcow2raw.c Fri Jul 18 12:12:41 2008 +0900 98.3 @@ -65,8 +65,8 @@ struct disk_driver ddqcow, ddaio; 98.4 static uint64_t prev = 0, written = 0; 98.5 static char output[25]; 98.6 98.7 -void print_bytes(void *ptr, int length) { 98.8 - 98.9 +static void print_bytes(void *ptr, int length) 98.10 +{ 98.11 int i,k; 98.12 unsigned char *p = ptr; 98.13 98.14 @@ -81,7 +81,7 @@ void print_bytes(void *ptr, int length) 98.15 return; 98.16 } 98.17 98.18 -void debug_output(uint64_t progress, uint64_t size) 98.19 +static void debug_output(uint64_t progress, uint64_t size) 98.20 { 98.21 /*Output progress every 5% */ 98.22 uint64_t blocks = size/20;
99.1 --- a/tools/blktap/drivers/tapdisk.c Tue Jul 08 11:41:43 2008 +0900 99.2 +++ b/tools/blktap/drivers/tapdisk.c Fri Jul 18 12:12:41 2008 +0900 99.3 @@ -53,14 +53,14 @@ int do_cow_read(struct disk_driver *dd, 99.4 #define td_for_each_disk(tds, drv) \ 99.5 for (drv = tds->disks; drv != NULL; drv = drv->next) 99.6 99.7 -void usage(void) 99.8 +static void usage(void) 99.9 { 99.10 fprintf(stderr, "blktap-utils: v1.0.0\n"); 99.11 fprintf(stderr, "usage: tapdisk <READ fifo> <WRITE fifo>\n"); 99.12 exit(-1); 99.13 } 99.14 99.15 -void daemonize(void) 99.16 +static void daemonize(void) 99.17 { 99.18 int i; 99.19 99.20 @@ -121,7 +121,7 @@ static void unmap_disk(struct td_state * 99.21 return; 99.22 } 99.23 99.24 -void sig_handler(int sig) 99.25 +static void sig_handler(int sig) 99.26 { 99.27 /*Received signal to close. If no disks are active, we close app.*/ 99.28 99.29 @@ -512,7 +512,7 @@ static inline void kick_responses(struct 99.30 } 99.31 } 99.32 99.33 -void io_done(struct disk_driver *dd, int sid) 99.34 +static void io_done(struct disk_driver *dd, int sid) 99.35 { 99.36 struct tap_disk *drv = dd->drv; 99.37 99.38 @@ -537,7 +537,7 @@ segment_start(blkif_request_t *req, int 99.39 } 99.40 99.41 uint64_t sends, responds; 99.42 -int send_responses(struct disk_driver *dd, int res, 99.43 +static int send_responses(struct disk_driver *dd, int res, 99.44 uint64_t sector, int nr_secs, int idx, void *private) 99.45 { 99.46 pending_req_t *preq;
100.1 --- a/tools/blktap/lib/blktaplib.h Tue Jul 08 11:41:43 2008 +0900 100.2 +++ b/tools/blktap/lib/blktaplib.h Fri Jul 18 12:12:41 2008 +0900 100.3 @@ -57,6 +57,7 @@ 100.4 #define BLKTAP_IOCTL_MAJOR 7 100.5 #define BLKTAP_QUERY_ALLOC_REQS 8 100.6 #define BLKTAP_IOCTL_FREEINTF 9 100.7 +#define BLKTAP_IOCTL_NEWINTF_EXT 50 100.8 #define BLKTAP_IOCTL_PRINT_IDXS 100 100.9 100.10 /* blktap switching modes: (Set with BLKTAP_IOCTL_SETMODE) */ 100.11 @@ -161,8 +162,13 @@ typedef struct tapdev_info { 100.12 100.13 typedef struct domid_translate { 100.14 unsigned short domid; 100.15 + unsigned short busid; 100.16 +} domid_translate_t ; 100.17 + 100.18 +typedef struct domid_translate_ext { 100.19 + unsigned short domid; 100.20 uint32_t busid; 100.21 -} domid_translate_t ; 100.22 +} domid_translate_ext_t ; 100.23 100.24 typedef struct image { 100.25 unsigned long long size; 100.26 @@ -207,7 +213,6 @@ typedef struct msg_pid { 100.27 /* xenstore/xenbus: */ 100.28 #define DOMNAME "Domain-0" 100.29 int setup_probe_watch(struct xs_handle *h); 100.30 -int xs_fire_next_watch(struct xs_handle *h); 100.31 100.32 100.33 /* Abitrary values, must match the underlying driver... */
101.1 --- a/tools/blktap/lib/xenbus.c Tue Jul 08 11:41:43 2008 +0900 101.2 +++ b/tools/blktap/lib/xenbus.c Fri Jul 18 12:12:41 2008 +0900 101.3 @@ -354,7 +354,7 @@ static void ueblktap_probe(struct xs_han 101.4 *are created, we initalise the state and attach a disk. 101.5 */ 101.6 101.7 -int add_blockdevice_probe_watch(struct xs_handle *h, const char *domid) 101.8 +static int add_blockdevice_probe_watch(struct xs_handle *h, const char *domid) 101.9 { 101.10 char *path; 101.11 struct xenbus_watch *vbd_watch; 101.12 @@ -377,7 +377,7 @@ int add_blockdevice_probe_watch(struct x 101.13 } 101.14 101.15 /* Asynch callback to check for /local/domain/<DOMID>/name */ 101.16 -void check_dom(struct xs_handle *h, struct xenbus_watch *w, 101.17 +static void check_dom(struct xs_handle *h, struct xenbus_watch *w, 101.18 const char *bepath_im) 101.19 { 101.20 char *domid; 101.21 @@ -392,7 +392,7 @@ void check_dom(struct xs_handle *h, stru 101.22 } 101.23 101.24 /* We must wait for xend to register /local/domain/<DOMID> */ 101.25 -int watch_for_domid(struct xs_handle *h) 101.26 +static int watch_for_domid(struct xs_handle *h) 101.27 { 101.28 struct xenbus_watch *domid_watch; 101.29 char *path = NULL;
102.1 --- a/tools/console/daemon/io.c Tue Jul 08 11:41:43 2008 +0900 102.2 +++ b/tools/console/daemon/io.c Fri Jul 18 12:12:41 2008 +0900 102.3 @@ -471,7 +471,7 @@ out: 102.4 } 102.5 102.6 /* Takes tuples of names, scanf-style args, and void **, NULL terminated. */ 102.7 -int xs_gather(struct xs_handle *xs, const char *dir, ...) 102.8 +static int xs_gather(struct xs_handle *xs, const char *dir, ...) 102.9 { 102.10 va_list ap; 102.11 const char *name;
103.1 --- a/tools/examples/network-bridge Tue Jul 08 11:41:43 2008 +0900 103.2 +++ b/tools/examples/network-bridge Fri Jul 18 12:12:41 2008 +0900 103.3 @@ -60,7 +60,18 @@ is_network_root () { 103.4 local rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' /etc/mtab) 103.5 local rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab) 103.6 103.7 - [[ "$rootfs" =~ "^nfs" ]] || [[ "$rootopts" =~ "_netdev" ]] && return 0 || return 1 103.8 + [[ "$rootfs" =~ "^nfs" ]] || [[ "$rootopts" =~ "_netdev" ]] && has_nfsroot=1 || has_nfsroot=0 103.9 + if [ $has_nfsroot -eq 1 ]; then 103.10 + local bparms=$(cat /proc/cmdline) 103.11 + for p in $bparms; do 103.12 + local ipaddr=$(echo $p | awk /nfsroot=/'{ print substr($1,9,index($1,":")-9) }') 103.13 + if [ "$ipaddr" != "" ]; then 103.14 + local nfsdev=$(ip route get $ipaddr | awk /$ipaddr/'{ print $3 }') 103.15 + [[ "$nfsdev" == "$netdev" ]] && return 0 || return 1 103.16 + fi 103.17 + done 103.18 + fi 103.19 + return 1 103.20 } 103.21 103.22 find_alt_device () {
104.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 104.2 +++ b/tools/examples/vscsi Fri Jul 18 12:12:41 2008 +0900 104.3 @@ -0,0 +1,22 @@ 104.4 +#!/bin/sh 104.5 +# 104.6 +# Copyright (c) 2007, FUJITSU Limited 104.7 +# Based on the block scripts code. 104.8 +# 104.9 + 104.10 +dir=$(dirname "$0") 104.11 +. "$dir/xen-hotplug-common.sh" 104.12 + 104.13 +findCommand "$@" 104.14 + 104.15 +case "$command" in 104.16 + add) 104.17 + success 104.18 + ;; 104.19 + remove) 104.20 + # TODO 104.21 + exit 0 104.22 + ;; 104.23 +esac 104.24 + 104.25 +exit 0
105.1 --- a/tools/examples/vtpm-common.sh Tue Jul 08 11:41:43 2008 +0900 105.2 +++ b/tools/examples/vtpm-common.sh Fri Jul 18 12:12:41 2008 +0900 105.3 @@ -310,11 +310,11 @@ function vtpm_remove_instance () { 105.4 105.5 instance="0" 105.6 105.7 - if [ "$uuid != "" ]; then 105.8 + if [ "$uuid" != "" ]; then 105.9 instance=$(vtpmdb_find_instance $uuid) 105.10 fi 105.11 105.12 - if [ "$instance == "0" ]; then 105.13 + if [ "$instance" == "0" ]; then 105.14 domname=$(xenstore_read "$XENBUS_PATH"/domain) 105.15 instance=$(vtpmdb_find_instance $domname) 105.16 fi
106.1 --- a/tools/examples/xen-backend.agent Tue Jul 08 11:41:43 2008 +0900 106.2 +++ b/tools/examples/xen-backend.agent Fri Jul 18 12:12:41 2008 +0900 106.3 @@ -19,6 +19,9 @@ case "$XENBUS_TYPE" in 106.4 vif) 106.5 [ -n "$script" ] && $script "$ACTION" 106.6 ;; 106.7 + vscsi) 106.8 + /etc/xen/scripts/vscsi "$ACTION" 106.9 + ;; 106.10 esac 106.11 106.12 case "$ACTION" in
107.1 --- a/tools/examples/xen-backend.rules Tue Jul 08 11:41:43 2008 +0900 107.2 +++ b/tools/examples/xen-backend.rules Fri Jul 18 12:12:41 2008 +0900 107.3 @@ -3,6 +3,7 @@ SUBSYSTEM=="xen-backend", KERNEL=="vbd*" 107.4 SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}" 107.5 SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} online" 107.6 SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="offline", RUN+="$env{script} offline" 107.7 +SUBSYSTEM=="xen-backend", KERNEL=="vscsi*", RUN+="/etc/xen/scripts/vscsi $env{ACTION}" 107.8 SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/etc/xen/scripts/xen-hotplug-cleanup" 107.9 KERNEL=="evtchn", NAME="xen/%k" 107.10 KERNEL=="blktap[0-9]*", NAME="xen/%k"
108.1 --- a/tools/examples/xmexample.hvm Tue Jul 08 11:41:43 2008 +0900 108.2 +++ b/tools/examples/xmexample.hvm Fri Jul 18 12:12:41 2008 +0900 108.3 @@ -282,3 +282,26 @@ serial='pty' 108.4 # '0' -> the bit must be '0' 108.5 # 'x' -> we don't care (do not check) 108.6 # 's' -> the bit must be the same as on the host that started this VM 108.7 + 108.8 + 108.9 +#----------------------------------------------------------------------------- 108.10 +# Configure PVSCSI devices: 108.11 +# 108.12 +#vscsi=[ 'PDEV, VDEV' ] 108.13 +# 108.14 +# PDEV gives physical SCSI device to be attached to specified guest 108.15 +# domain by one of the following identifier format. 108.16 +# - XX:XX:XX:XX (4-tuples with decimal notation which shows 108.17 +# "host:channel:target:lun") 108.18 +# - /dev/sdxx or sdx 108.19 +# - /dev/stxx or stx 108.20 +# - /dev/sgxx or sgx 108.21 +# - result of 'scsi_id -gu -s'. 108.22 +# ex. # scsi_id -gu -s /block/sdb 108.23 +# 36000b5d0006a0000006a0257004c0000 108.24 +# 108.25 +# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as 108.26 +# which the specified guest domain recognize. 108.27 +# 108.28 + 108.29 +#vscsi = [ '/dev/sdx, 0:0:0:0' ]
109.1 --- a/tools/examples/xmexample.vti Tue Jul 08 11:41:43 2008 +0900 109.2 +++ b/tools/examples/xmexample.vti Fri Jul 18 12:12:41 2008 +0900 109.3 @@ -161,3 +161,25 @@ serial='pty' 109.4 # 'windows' - All Windows variants (Windows Server 2003/2008) 109.5 # 109.6 #guest_os_type='default' 109.7 + 109.8 +#----------------------------------------------------------------------------- 109.9 +# Configure PVSCSI devices: 109.10 +# 109.11 +#vscsi=[ 'PDEV, VDEV' ] 109.12 +# 109.13 +# PDEV gives physical SCSI device to be attached to specified guest 109.14 +# domain by one of the following identifier format. 109.15 +# - XX:XX:XX:XX (4-tuples with decimal notation which shows 109.16 +# "host:channel:target:lun") 109.17 +# - /dev/sdxx or sdx 109.18 +# - /dev/stxx or stx 109.19 +# - /dev/sgxx or sgx 109.20 +# - result of 'scsi_id -gu -s'. 109.21 +# ex. # scsi_id -gu -s /block/sdb 109.22 +# 36000b5d0006a0000006a0257004c0000 109.23 +# 109.24 +# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as 109.25 +# which the specified guest domain recognize. 109.26 +# 109.27 + 109.28 +#vscsi = [ '/dev/sdx, 0:0:0:0' ]
110.1 --- a/tools/examples/xmexample1 Tue Jul 08 11:41:43 2008 +0900 110.2 +++ b/tools/examples/xmexample1 Fri Jul 18 12:12:41 2008 +0900 110.3 @@ -185,4 +185,27 @@ extra = "4" 110.4 #on_reboot = 'restart' 110.5 #on_crash = 'restart' 110.6 110.7 +#----------------------------------------------------------------------------- 110.8 +# Configure PVSCSI devices: 110.9 +# 110.10 +#vscsi=[ 'PDEV, VDEV' ] 110.11 +# 110.12 +# PDEV gives physical SCSI device to be attached to specified guest 110.13 +# domain by one of the following identifier format. 110.14 +# - XX:XX:XX:XX (4-tuples with decimal notation which shows 110.15 +# "host:channel:target:lun") 110.16 +# - /dev/sdxx or sdx 110.17 +# - /dev/stxx or stx 110.18 +# - /dev/sgxx or sgx 110.19 +# - result of 'scsi_id -gu -s'. 110.20 +# ex. # scsi_id -gu -s /block/sdb 110.21 +# 36000b5d0006a0000006a0257004c0000 110.22 +# 110.23 +# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as 110.24 +# which the specified guest domain recognize. 110.25 +# 110.26 + 110.27 +#vscsi = [ '/dev/sdx, 0:0:0:0' ] 110.28 + 110.29 #============================================================================ 110.30 +
111.1 --- a/tools/examples/xmexample2 Tue Jul 08 11:41:43 2008 +0900 111.2 +++ b/tools/examples/xmexample2 Fri Jul 18 12:12:41 2008 +0900 111.3 @@ -221,4 +221,26 @@ extra = "4 VMID=%d usr=/dev/sda6" % vmid 111.4 #on_reboot = 'restart' 111.5 #on_crash = 'restart' 111.6 111.7 +#----------------------------------------------------------------------------- 111.8 +# Configure PVSCSI devices: 111.9 +# 111.10 +#vscsi=[ 'PDEV, VDEV' ] 111.11 +# 111.12 +# PDEV gives physical SCSI device to be attached to specified guest 111.13 +# domain by one of the following identifier format. 111.14 +# - XX:XX:XX:XX (4-tuples with decimal notation which shows 111.15 +# "host:channel:target:lun") 111.16 +# - /dev/sdxx or sdx 111.17 +# - /dev/stxx or stx 111.18 +# - /dev/sgxx or sgx 111.19 +# - result of 'scsi_id -gu -s'. 111.20 +# ex. # scsi_id -gu -s /block/sdb 111.21 +# 36000b5d0006a0000006a0257004c0000 111.22 +# 111.23 +# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as 111.24 +# which the specified guest domain recognize. 111.25 +# 111.26 + 111.27 +#vscsi = [ '/dev/sdx, 0:0:0:0' ] 111.28 + 111.29 #============================================================================
112.1 --- a/tools/firmware/hvmloader/acpi/build.c Tue Jul 08 11:41:43 2008 +0900 112.2 +++ b/tools/firmware/hvmloader/acpi/build.c Fri Jul 18 12:12:41 2008 +0900 112.3 @@ -70,12 +70,7 @@ static int hpet_exists(unsigned long hpe 112.4 112.5 static int construct_bios_info_table(uint8_t *buf) 112.6 { 112.7 - struct bios_info { 112.8 - uint8_t com1_present:1; 112.9 - uint8_t com2_present:1; 112.10 - uint8_t hpet_present:1; 112.11 - uint32_t pci_min, pci_len; 112.12 - } *bios_info = (struct bios_info *)buf; 112.13 + struct bios_info *bios_info = (struct bios_info *)buf; 112.14 112.15 memset(bios_info, 0, sizeof(*bios_info)); 112.16 112.17 @@ -86,6 +81,7 @@ static int construct_bios_info_table(uin 112.18 112.19 bios_info->pci_min = PCI_MEMBASE; 112.20 bios_info->pci_len = PCI_MEMSIZE; 112.21 + bios_info->xen_pfiob = 0xdead; 112.22 112.23 return align16(sizeof(*bios_info)); 112.24 }
113.1 --- a/tools/firmware/hvmloader/config.h Tue Jul 08 11:41:43 2008 +0900 113.2 +++ b/tools/firmware/hvmloader/config.h Fri Jul 18 12:12:41 2008 +0900 113.3 @@ -31,4 +31,15 @@ 113.4 #define ROMBIOS_PHYSICAL_ADDRESS 0x000F0000 113.5 #define SCRATCH_PHYSICAL_ADDRESS 0x00010000 113.6 113.7 +/* Xen Platform Device */ 113.8 +#define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */ 113.9 + 113.10 +struct bios_info { 113.11 + uint8_t com1_present:1; 113.12 + uint8_t com2_present:1; 113.13 + uint8_t hpet_present:1; 113.14 + uint32_t pci_min, pci_len; 113.15 + uint16_t xen_pfiob; 113.16 +}; 113.17 + 113.18 #endif /* __HVMLOADER_CONFIG_H__ */
114.1 --- a/tools/firmware/hvmloader/hvmloader.c Tue Jul 08 11:41:43 2008 +0900 114.2 +++ b/tools/firmware/hvmloader/hvmloader.c Fri Jul 18 12:12:41 2008 +0900 114.3 @@ -99,10 +99,6 @@ asm ( 114.4 " .text \n" 114.5 ); 114.6 114.7 -void smp_initialise(void); 114.8 -void create_mp_tables(void); 114.9 -int hvm_write_smbios_tables(void); 114.10 - 114.11 static enum { VGA_none, VGA_std, VGA_cirrus } virtual_vga = VGA_none; 114.12 114.13 static void 114.14 @@ -434,6 +430,23 @@ static void cmos_write_memory_size(void) 114.15 cmos_outb(0x35, (uint8_t)( alt_mem >> 8)); 114.16 } 114.17 114.18 +static void init_xen_platform_io_base(void) 114.19 +{ 114.20 + struct bios_info *bios_info = (struct bios_info *)ACPI_PHYSICAL_ADDRESS; 114.21 + uint32_t devfn, bar_data; 114.22 + uint16_t vendor_id, device_id; 114.23 + 114.24 + for ( devfn = 0; devfn < 128; devfn++ ) 114.25 + { 114.26 + vendor_id = pci_readw(devfn, PCI_VENDOR_ID); 114.27 + device_id = pci_readw(devfn, PCI_DEVICE_ID); 114.28 + if ( (vendor_id != 0x5853) || (device_id != 0x0001) ) 114.29 + continue; 114.30 + bar_data = pci_readl(devfn, PCI_BASE_ADDRESS_0); 114.31 + bios_info->xen_pfiob = bar_data & PCI_BASE_ADDRESS_IO_MASK; 114.32 + } 114.33 +} 114.34 + 114.35 int main(void) 114.36 { 114.37 int acpi_sz = 0, vgabios_sz = 0, etherboot_sz = 0, rombios_sz, smbios_sz; 114.38 @@ -527,6 +540,8 @@ int main(void) 114.39 ROMBIOS_PHYSICAL_ADDRESS, 114.40 ROMBIOS_PHYSICAL_ADDRESS + rombios_sz - 1); 114.41 114.42 + init_xen_platform_io_base(); 114.43 + 114.44 printf("Invoking ROMBIOS ...\n"); 114.45 return 0; 114.46 }
115.1 --- a/tools/firmware/hvmloader/mp_tables.c Tue Jul 08 11:41:43 2008 +0900 115.2 +++ b/tools/firmware/hvmloader/mp_tables.c Fri Jul 18 12:12:41 2008 +0900 115.3 @@ -69,8 +69,6 @@ 115.4 115.5 #include "util.h" 115.6 115.7 -extern int get_vcpu_nr(void); /* for the guest's VCPU count */ 115.8 - 115.9 /* 115.10 * The following structures are defined in the MuliProcessor Specifiation v1.4 115.11 */ 115.12 @@ -152,7 +150,7 @@ struct mp_local_intr_entry { 115.13 }; 115.14 115.15 115.16 -void fill_mp_config_table(struct mp_config_table *mpct, int length) 115.17 +static void fill_mp_config_table(struct mp_config_table *mpct, int length) 115.18 { 115.19 int vcpu_nr, i; 115.20 uint8_t checksum; 115.21 @@ -199,7 +197,7 @@ void fill_mp_config_table(struct mp_conf 115.22 } 115.23 115.24 /* fills in an MP processor entry for VCPU 'vcpu_id' */ 115.25 -void fill_mp_proc_entry(struct mp_proc_entry *mppe, int vcpu_id) 115.26 +static void fill_mp_proc_entry(struct mp_proc_entry *mppe, int vcpu_id) 115.27 { 115.28 mppe->type = ENTRY_TYPE_PROCESSOR; 115.29 mppe->lapic_id = LAPIC_ID(vcpu_id); 115.30 @@ -213,7 +211,7 @@ void fill_mp_proc_entry(struct mp_proc_e 115.31 115.32 115.33 /* fills in an MP bus entry of type 'type' and bus ID 'bus_id' */ 115.34 -void fill_mp_bus_entry(struct mp_bus_entry *mpbe, int bus_id, const char *type) 115.35 +static void fill_mp_bus_entry(struct mp_bus_entry *mpbe, int bus_id, const char *type) 115.36 { 115.37 int i; 115.38 115.39 @@ -225,7 +223,7 @@ void fill_mp_bus_entry(struct mp_bus_ent 115.40 115.41 115.42 /* fills in an MP IOAPIC entry for IOAPIC 'ioapic_id' */ 115.43 -void fill_mp_ioapic_entry(struct mp_ioapic_entry *mpie) 115.44 +static void fill_mp_ioapic_entry(struct mp_ioapic_entry *mpie) 115.45 { 115.46 mpie->type = ENTRY_TYPE_IOAPIC; 115.47 mpie->ioapic_id = IOAPIC_ID; 115.48 @@ -236,7 +234,7 @@ void fill_mp_ioapic_entry(struct mp_ioap 115.49 115.50 115.51 /* fills in an IO interrupt entry for IOAPIC 'ioapic_id' */ 115.52 -void fill_mp_io_intr_entry( 115.53 +static void fill_mp_io_intr_entry( 115.54 struct mp_io_intr_entry *mpiie, 115.55 int src_bus_id, int src_bus_irq, int ioapic_id, int dst_ioapic_intin) 115.56 { 115.57 @@ -251,7 +249,7 @@ void fill_mp_io_intr_entry( 115.58 115.59 115.60 /* fill in the mp floating processor structure */ 115.61 -void fill_mpfps(struct mp_floating_pointer_struct *mpfps, uint32_t mpct) 115.62 +static void fill_mpfps(struct mp_floating_pointer_struct *mpfps, uint32_t mpct) 115.63 { 115.64 int i; 115.65 uint8_t checksum; 115.66 @@ -283,7 +281,7 @@ void fill_mpfps(struct mp_floating_point 115.67 * The '___HVMMP' signature is created by the ROMBIOS and designates a chunk 115.68 * of space inside the ROMBIOS that is safe for us to write our MP table info 115.69 */ 115.70 -void* get_mp_table_start(void) 115.71 +static void *get_mp_table_start(void) 115.72 { 115.73 char *bios_mem; 115.74 115.75 @@ -300,7 +298,7 @@ void* get_mp_table_start(void) 115.76 115.77 115.78 /* recalculate the new ROMBIOS checksum after adding MP tables */ 115.79 -void reset_bios_checksum(void) 115.80 +static void reset_bios_checksum(void) 115.81 { 115.82 uint32_t i; 115.83 uint8_t checksum; 115.84 @@ -312,7 +310,6 @@ void reset_bios_checksum(void) 115.85 *((uint8_t *)(ROMBIOS_BEGIN + ROMBIOS_MAXOFFSET)) = -checksum; 115.86 } 115.87 115.88 - 115.89 /* create_mp_tables - creates MP tables for the guest based upon config data */ 115.90 void create_mp_tables(void) 115.91 {
116.1 --- a/tools/firmware/hvmloader/smp.c Tue Jul 08 11:41:43 2008 +0900 116.2 +++ b/tools/firmware/hvmloader/smp.c Fri Jul 18 12:12:41 2008 +0900 116.3 @@ -69,8 +69,7 @@ asm ( 116.4 " .text \n" 116.5 ); 116.6 116.7 -extern void cacheattr_init(void); 116.8 - 116.9 +void ap_start(void); /* non-static avoids unused-function compiler warning */ 116.10 /*static*/ void ap_start(void) 116.11 { 116.12 printf(" - CPU%d ... ", ap_cpuid);
117.1 --- a/tools/firmware/hvmloader/util.h Tue Jul 08 11:41:43 2008 +0900 117.2 +++ b/tools/firmware/hvmloader/util.h Fri Jul 18 12:12:41 2008 +0900 117.3 @@ -137,6 +137,12 @@ uint32_t e820_malloc(uint32_t size); 117.4 /* Prepare the 32bit BIOS */ 117.5 void highbios_setup(void); 117.6 117.7 +/* Miscellaneous. */ 117.8 +void cacheattr_init(void); 117.9 +void create_mp_tables(void); 117.10 +int hvm_write_smbios_tables(void); 117.11 +void smp_initialise(void); 117.12 + 117.13 #define isdigit(c) ((c) >= '0' && (c) <= '9') 117.14 117.15 #endif /* __HVMLOADER_UTIL_H__ */
118.1 --- a/tools/firmware/rombios/32bit/tcgbios/tcgbios.c Tue Jul 08 11:41:43 2008 +0900 118.2 +++ b/tools/firmware/rombios/32bit/tcgbios/tcgbios.c Fri Jul 18 12:12:41 2008 +0900 118.3 @@ -581,7 +581,7 @@ static char wake_event_1[] = "Wake Ev 118.4 * data : additional parameter; used as parameter for 10.4.3 118.5 * 'action index' 118.6 */ 118.7 -void tcpa_add_measurement(uint32_t pcrIndex, 118.8 +static void tcpa_add_measurement(uint32_t pcrIndex, 118.9 uint16_t event_type, 118.10 uint32_t data) 118.11 { 118.12 @@ -863,7 +863,7 @@ uint32_t tcpa_initialize_tpm(uint32_t ph 118.13 } 118.14 118.15 118.16 -uint16_t TCG_IsShutdownPreBootInterface(void) 118.17 +static uint16_t TCG_IsShutdownPreBootInterface(void) 118.18 { 118.19 return tcpa_acpi.flags & STATUS_FLAG_SHUTDOWN; 118.20 }
119.1 --- a/tools/firmware/rombios/32bit/tcgbios/tpm_drivers.c Tue Jul 08 11:41:43 2008 +0900 119.2 +++ b/tools/firmware/rombios/32bit/tcgbios/tpm_drivers.c Fri Jul 18 12:12:41 2008 +0900 119.3 @@ -75,7 +75,7 @@ static uint32_t tis_activate(uint32_t ba 119.4 return rc; 119.5 } 119.6 119.7 -uint32_t tis_ready(uint32_t baseaddr) 119.8 +static uint32_t tis_ready(uint32_t baseaddr) 119.9 { 119.10 uint32_t rc = 0; 119.11 uint8_t *tis_addr = (uint8_t*)baseaddr; 119.12 @@ -86,7 +86,7 @@ uint32_t tis_ready(uint32_t baseaddr) 119.13 return rc; 119.14 } 119.15 119.16 -uint32_t tis_senddata(uint32_t baseaddr, unsigned char *data, uint32_t len) 119.17 +static uint32_t tis_senddata(uint32_t baseaddr, unsigned char *data, uint32_t len) 119.18 { 119.19 uint32_t rc = 0; 119.20 uint8_t *tis_addr = (uint8_t*)baseaddr; 119.21 @@ -127,7 +127,7 @@ uint32_t tis_senddata(uint32_t baseaddr, 119.22 return rc; 119.23 } 119.24 119.25 -uint32_t tis_readresp(uint32_t baseaddr, unsigned char *buffer, uint32_t len) 119.26 +static uint32_t tis_readresp(uint32_t baseaddr, unsigned char *buffer, uint32_t len) 119.27 { 119.28 uint32_t rc = 0; 119.29 uint32_t offset = 0; 119.30 @@ -147,7 +147,7 @@ uint32_t tis_readresp(uint32_t baseaddr, 119.31 } 119.32 119.33 119.34 -uint32_t tis_waitdatavalid(uint32_t baseaddr) 119.35 +static uint32_t tis_waitdatavalid(uint32_t baseaddr) 119.36 { 119.37 uint8_t *tis_addr = (uint8_t*)baseaddr; 119.38 uint32_t rc = 0; 119.39 @@ -157,7 +157,7 @@ uint32_t tis_waitdatavalid(uint32_t base 119.40 return rc; 119.41 } 119.42 119.43 -uint32_t tis_waitrespready(uint32_t baseaddr, uint32_t timeout) 119.44 +static uint32_t tis_waitrespready(uint32_t baseaddr, uint32_t timeout) 119.45 { 119.46 uint32_t rc = 0; 119.47 uint8_t *tis_addr = (uint8_t*)baseaddr; 119.48 @@ -170,7 +170,7 @@ uint32_t tis_waitrespready(uint32_t base 119.49 } 119.50 119.51 /* if device is not there, return '0', '1' otherwise */ 119.52 -uint32_t tis_probe(uint32_t baseaddr) 119.53 +static uint32_t tis_probe(uint32_t baseaddr) 119.54 { 119.55 uint32_t rc = 0; 119.56 uint8_t *tis_addr = (uint8_t*)baseaddr;
120.1 --- a/tools/firmware/rombios/32bit/util.c Tue Jul 08 11:41:43 2008 +0900 120.2 +++ b/tools/firmware/rombios/32bit/util.c Fri Jul 18 12:12:41 2008 +0900 120.3 @@ -388,12 +388,6 @@ int printf(const char *fmt, ...) 120.4 return 0; 120.5 } 120.6 120.7 -int vprintf(const char *fmt, va_list ap) 120.8 -{ 120.9 - _doprint(putchar, fmt, ap); 120.10 - return 0; 120.11 -} 120.12 - 120.13 void mssleep(uint32_t waittime) 120.14 { 120.15 uint32_t i;
121.1 --- a/tools/firmware/rombios/rombios.c Tue Jul 08 11:41:43 2008 +0900 121.2 +++ b/tools/firmware/rombios/rombios.c Fri Jul 18 12:12:41 2008 +0900 121.3 @@ -26,6 +26,9 @@ 121.4 121.5 // ROM BIOS for use with Bochs/Plex x86 emulation environment 121.6 121.7 +#define uint8_t unsigned char 121.8 +#define uint16_t unsigned short 121.9 +#define uint32_t unsigned long 121.10 #include "../hvmloader/config.h" 121.11 121.12 #define HVMASSIST 121.13 @@ -1459,6 +1462,23 @@ copy_e820_table() 121.14 base_mem = read_dword(0x9000, 0x2d0 + 8); 121.15 write_word(0x40, 0x13, base_mem >> 10); 121.16 } 121.17 + 121.18 +void 121.19 +disable_rom_write_access() 121.20 +{ 121.21 + Bit16u off = (Bit16u)&((struct bios_info *)0)->xen_pfiob; 121.22 +ASM_START 121.23 + mov si,.disable_rom_write_access.off[bp] 121.24 + push ds 121.25 + mov ax,#(ACPI_PHYSICAL_ADDRESS >> 4) 121.26 + mov ds,ax 121.27 + mov dx,[si] 121.28 + pop ds 121.29 + mov ax,#PFFLAG_ROM_LOCK 121.30 + out dx,al 121.31 +ASM_END 121.32 +} 121.33 + 121.34 #endif /* HVMASSIST */ 121.35 121.36 #if BX_DEBUG_SERIAL 121.37 @@ -10155,6 +10175,10 @@ post_default_ints: 121.38 call tcpa_post_part2 121.39 #endif 121.40 121.41 +#ifdef HVMASSIST 121.42 + call _disable_rom_write_access 121.43 +#endif 121.44 + 121.45 ;; Start the boot sequence. See the comments in int19_relocated 121.46 ;; for why we use INT 18h instead of INT 19h here. 121.47 int #0x18
122.1 --- a/tools/firmware/vgabios/ChangeLog Tue Jul 08 11:41:43 2008 +0900 122.2 +++ b/tools/firmware/vgabios/ChangeLog Fri Jul 18 12:12:41 2008 +0900 122.3 @@ -1,3 +1,207 @@ 122.4 +2008-05-11 08:40 vruppert 122.5 + 122.6 + * biossums.c (1.6): 122.7 + 122.8 + - fixed a warning 122.9 + 122.10 +2008-03-02 08:47 vruppert 122.11 + 122.12 + * vbe.c (1.60): 122.13 + 122.14 + - added debug message for unsupported VBE modes 122.15 + 122.16 +2008-02-24 09:18 vruppert 122.17 + 122.18 + * vbe.c (1.59): 122.19 + 122.20 + - in LFB modes the number of banks must be set to 1 122.21 + 122.22 +2008-01-27 10:44 vruppert 122.23 + 122.24 + * Makefile (1.21), biossums.c (1.5), vgabios.c (1.67): 122.25 + 122.26 + - added PCI data structure for the Cirrus VGABIOS images 122.27 + - added support for the PCI data structure in biossums 122.28 + - updated year in copyright 122.29 + 122.30 +2008-01-26 11:46 vruppert 122.31 + 122.32 + * BUGS (1.4), Makefile (1.20), README (1.14), TODO (1.13), vbe_display_api.txt (1.14): 122.33 + 122.34 + - whitespace cleanup 122.35 + 122.36 +2006-11-26 10:43 vruppert 122.37 + 122.38 + * Makefile (1.19): 122.39 + 122.40 + - disable the generation of linemarkers by the preprocessor, since the latest 122.41 + versions of bcc don't like them 122.42 + 122.43 +2006-09-02 13:15 vruppert 122.44 + 122.45 + * biossums.c (1.4): 122.46 + 122.47 + - the biossums utility no longer modifies VGABIOS images with proper checksum 122.48 + and size 122.49 + 122.50 +2006-08-19 14:28 vruppert 122.51 + 122.52 + * Changelog (1.26), README (1.13), TODO (1.12): 122.53 + 122.54 + - updates for 0.6a release 122.55 + 122.56 +2006-08-19 09:39 vruppert 122.57 + 122.58 + * vbe.c (1.58): 122.59 + 122.60 + - improved VGA compatible setup for VBE modes (disable CGA and Hercules 122.61 + compatible memory layout) 122.62 + 122.63 +2006-08-18 20:39 vruppert 122.64 + 122.65 + * vbe.c (1.57): 122.66 + 122.67 + - improved VGA compatible setup for >=8bpp VBE modes (CRTC doubleword mode and 122.68 + GRDC shift register setting added) 122.69 + - now using symbolic name for CRTC address register 122.70 + 122.71 +2006-08-15 20:42 vruppert 122.72 + 122.73 + * vbe.c (1.56), vbetables-gen.c (1.4): 122.74 + 122.75 + - init 4bpp VBE modes by a temporary switch to VGA mode 0x6A 122.76 + - all 4bpp VBE modes now enabled 122.77 + 122.78 +2006-08-14 20:24 vruppert 122.79 + 122.80 + * vbe.c (1.55): 122.81 + 122.82 + - VGA compatible setup for VBE modes improved (Bochs hack can be removed now) 122.83 + 122.84 +2006-08-12 07:51 vruppert 122.85 + 122.86 + * .cvsignore (1.1): 122.87 + 122.88 + - .cvsignore added for auto-generated file 122.89 + 122.90 +2006-08-12 07:47 vruppert 122.91 + 122.92 + * vbe.c (1.54), vbe.h (1.27), vbe_display_api.txt (1.13), vbetables-gen.c (1.3): 122.93 + 122.94 + - cleaned up VBE memory size definitions (removed duplicate defines, main 122.95 + definition now in vbetables-gen.c) 122.96 + 122.97 +2006-08-09 21:28 vruppert 122.98 + 122.99 + * vbetables.h (1.30): 122.100 + 122.101 + - removed auto-generated file 122.102 + 122.103 +2006-08-09 21:26 vruppert 122.104 + 122.105 + * vbe.c (1.53), vbe.h (1.26), vbe_display_api.txt (1.12), vbetables-gen.c (1.2), 122.106 + vbetables.h (1.29): 122.107 + 122.108 + - VBE video memory increased to 8 MB 122.109 + - VBE dispi ID changed to B0C4 122.110 + - documentation update 122.111 + 122.112 +2006-07-11 08:03 vruppert 122.113 + 122.114 + * Makefile (1.18), vbetables-gen.c (1.1), vbetables.h (1.28): 122.115 + 122.116 + - generate vbetables.h dynamicly 122.117 + * initial patch from the qemu project by Fabrice Bellard 122.118 + * only add modes that fit in video memory (still 4 MB) 122.119 + * several other fixes (e.g. 4 bpp specific stuff, number of pages) 122.120 + 122.121 +2006-07-10 07:47 vruppert 122.122 + 122.123 + * vgabios.c (1.66): 122.124 + 122.125 + - biosfn_scroll(): check variable 'i' for underflowing when scrolling downwards 122.126 + to avoid screen corruption 122.127 + 122.128 +2006-07-10 07:47 vruppert 122.129 + 122.130 + * vbe.c (1.52): 122.131 + 122.132 + - VBE set bank functions failure handling added 122.133 + - VBE get/set logical scan line length fixes for the 4bpp mode 122.134 + 122.135 +2006-07-08 13:27 vruppert 122.136 + 122.137 + * vbe.c (1.51), vbetables.h (1.27): 122.138 + 122.139 + - added special case for the 4 bpp when setting VBE display start 122.140 + - VBE mode table fixes 122.141 + 122.142 +2006-07-07 13:30 vruppert 122.143 + 122.144 + * clext.c (1.12): 122.145 + 122.146 + - bank pointer must be set to 0 after a mode set 122.147 + 122.148 +2006-06-21 16:58 vruppert 122.149 + 122.150 + * vbe.c (1.50), vbetables.h (1.26): 122.151 + 122.152 + - improved VBE display capabilities check (X resulution checked now) 122.153 + - removed obsolete defines (LFB always available, always generate dynamic list) 122.154 + - CR/LF to LF fixes 122.155 + 122.156 +2006-06-18 15:22 vruppert 122.157 + 122.158 + * clext.c (1.11), vbe.c (1.49), vbe.h (1.25), vbetables.h (1.25), vgabios.c 122.159 + (1.65): 122.160 + 122.161 + - applied patch from the qemu project (Fabrice Bellard) 122.162 + * Cirrus SVGA now supports the "no clear" bit when switching to Cirrus or 122.163 + VESA mode 122.164 + * Bochs VBE protected mode interface improved 122.165 + * save/restore video state support for Bochs VBE and standard VGA added 122.166 + * Bochs VBE prepared for more modi 122.167 + 122.168 +2006-03-25 10:19 vruppert 122.169 + 122.170 + * clext.c (1.10), vgabios.c (1.64), vgatables.h (1.10): 122.171 + 122.172 + - applied patch from Fabrice Bellard 122.173 + * added minimal support for the video parameter table (VPT) 122.174 + * added Cirrus SVGA mode 0x7b (1600x1200x8) 122.175 + 122.176 +2005-12-26 19:50 vruppert 122.177 + 122.178 + * vbe.c (1.48), vgabios.c (1.63): 122.179 + 122.180 + - Bochs VBE protected mode interface added (based on a patch by malc@pulsesoft.com) 122.181 + 122.182 +2005-12-26 19:50 vruppert 122.183 + 122.184 + * biossums.c (1.3): 122.185 + 122.186 + - biossums utility now supports VGABIOS sizes up to 64 kBytes 122.187 + 122.188 +2005-09-21 18:45 vruppert 122.189 + 122.190 + * vgatables.h (1.9): 122.191 + 122.192 + - mode 0x11: all color planes must be enabled in this 2-color VGA mode 122.193 + 122.194 +2005-08-30 18:41 vruppert 122.195 + 122.196 + * biossums.c (1.2): 122.197 + 122.198 + - missing license text added in biossums.c 122.199 + 122.200 +2005-07-02 18:39 vruppert 122.201 + 122.202 + * vgabios.c (1.62): 122.203 + 122.204 + - BIOS configuration word usually reports initial mode 80x25 color text 122.205 + - vgabios function 0x0e (write teletype): linefeed (0x0a) only increments the 122.206 + cursor row value 122.207 + 122.208 2005-05-24 16:50 vruppert 122.209 122.210 * vbe.c (1.47), vgabios.c (1.61):
123.1 --- a/tools/firmware/vgabios/Makefile Tue Jul 08 11:41:43 2008 +0900 123.2 +++ b/tools/firmware/vgabios/Makefile Fri Jul 18 12:12:41 2008 +0900 123.3 @@ -21,7 +21,7 @@ cirrus-bios: vgabios-cirrus.bin vgabios- 123.4 123.5 .PHONY: clean 123.6 clean: 123.7 - rm -f biossums *.o *.s *.ld86 \ 123.8 + rm -f biossums vbetables-gen vbetables.h *.o *.s *.ld86 \ 123.9 temp.awk.* vgabios*.orig _vgabios_* _vgabios-debug_* core vgabios*.bin vgabios*.txt $(RELEASE).bin *.bak 123.10 rm -f VGABIOS-lgpl-latest*.bin 123.11 123.12 @@ -37,7 +37,7 @@ release: 123.13 tar czvf ../$(RELEASE).tgz --exclude CVS -C .. $(RELEASE)/ 123.14 123.15 vgabios.bin: biossums vgabios.c vgabios.h vgafonts.h vgatables.h vbe.h vbe.c vbetables.h 123.16 - $(GCC) -E -P vgabios.c $(VGABIOS_VERS) $(VGABIOS_DATE) > _vgabios_.c 123.17 + $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DVBE $(VGABIOS_DATE) > _vgabios_.c 123.18 $(BCC) -o vgabios.s -C-c -D__i86__ -S -0 _vgabios_.c 123.19 sed -e 's/^\.text//' -e 's/^\.data//' vgabios.s > _vgabios_.s 123.20 $(AS86) _vgabios_.s -b vgabios.bin -u -w- -g -0 -j -O -l vgabios.txt 123.21 @@ -47,7 +47,7 @@ vgabios.bin: biossums vgabios.c vgabios. 123.22 ls -l VGABIOS-lgpl-latest.bin 123.23 123.24 vgabios.debug.bin: biossums vgabios.c vgabios.h vgafonts.h vgatables.h vbe.h vbe.c vbetables.h 123.25 - $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DDEBUG $(VGABIOS_DATE) > _vgabios-debug_.c 123.26 + $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DVBE -DDEBUG $(VGABIOS_DATE) > _vgabios-debug_.c 123.27 $(BCC) -o vgabios-debug.s -C-c -D__i86__ -S -0 _vgabios-debug_.c 123.28 sed -e 's/^\.text//' -e 's/^\.data//' vgabios-debug.s > _vgabios-debug_.s 123.29 $(AS86) _vgabios-debug_.s -b vgabios.debug.bin -u -w- -g -0 -j -O -l vgabios.debug.txt 123.30 @@ -57,7 +57,7 @@ vgabios.debug.bin: biossums vgabios.c vg 123.31 ls -l VGABIOS-lgpl-latest.debug.bin 123.32 123.33 vgabios-cirrus.bin: biossums vgabios.c vgabios.h vgafonts.h vgatables.h clext.c 123.34 - $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DCIRRUS $(VGABIOS_DATE) > _vgabios-cirrus_.c 123.35 + $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DCIRRUS -DPCIBIOS $(VGABIOS_DATE) > _vgabios-cirrus_.c 123.36 $(BCC) -o vgabios-cirrus.s -C-c -D__i86__ -S -0 _vgabios-cirrus_.c 123.37 sed -e 's/^\.text//' -e 's/^\.data//' vgabios-cirrus.s > _vgabios-cirrus_.s 123.38 $(AS86) _vgabios-cirrus_.s -b vgabios-cirrus.bin -u -w- -g -0 -j -O -l vgabios-cirrus.txt 123.39 @@ -67,7 +67,7 @@ vgabios-cirrus.bin: biossums vgabios.c v 123.40 ls -l VGABIOS-lgpl-latest.cirrus.bin 123.41 123.42 vgabios-cirrus.debug.bin: biossums vgabios.c vgabios.h vgafonts.h vgatables.h clext.c 123.43 - $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DCIRRUS -DCIRRUS_DEBUG $(VGABIOS_DATE) > _vgabios-cirrus-debug_.c 123.44 + $(GCC) -E -P vgabios.c $(VGABIOS_VERS) -DCIRRUS -DCIRRUS_DEBUG -DPCIBIOS $(VGABIOS_DATE) > _vgabios-cirrus-debug_.c 123.45 $(BCC) -o vgabios-cirrus-debug.s -C-c -D__i86__ -S -0 _vgabios-cirrus-debug_.c 123.46 sed -e 's/^\.text//' -e 's/^\.data//' vgabios-cirrus-debug.s > _vgabios-cirrus-debug_.s 123.47 $(AS86) _vgabios-cirrus-debug_.s -b vgabios-cirrus.debug.bin -u -w- -g -0 -j -O -l vgabios-cirrus.debug.txt 123.48 @@ -78,3 +78,9 @@ vgabios-cirrus.debug.bin: biossums vgabi 123.49 123.50 biossums: biossums.c 123.51 $(CC) -o biossums biossums.c 123.52 + 123.53 +vbetables-gen: vbetables-gen.c 123.54 + $(CC) -o vbetables-gen vbetables-gen.c 123.55 + 123.56 +vbetables.h: vbetables-gen 123.57 + ./vbetables-gen > $@
124.1 --- a/tools/firmware/vgabios/README Tue Jul 08 11:41:43 2008 +0900 124.2 +++ b/tools/firmware/vgabios/README Fri Jul 18 12:12:41 2008 +0900 124.3 @@ -90,6 +90,34 @@ For any information on qemu, visit the w 124.4 124.5 History 124.6 ------- 124.7 +vgabios-0.6b : May 30 2008 124.8 + - Volker 124.9 + . added PCI data structure for the Cirrus VGABIOS images 124.10 + . minor bugfixes in biossums utility, VBE support and makefile 124.11 + 124.12 +vgabios-0.6a : Aug 19 2006 124.13 + - Volker 124.14 + . added minimal support for the video parameter table (VPT) 124.15 + . Cirrus SVGA now supports the "no clear" bit in Cirrus and VESA mode 124.16 + . Bochs VBE protected mode interface improved 124.17 + . save/restore video state support for Bochs VBE and standard VGA added 124.18 + . generate vbetables.h dynamicly 124.19 + . VBE video memory increased to 8 MB (VBE dispi ID changed to B0C4) 124.20 + . lots of 4bpp VBE fixes (all 4bpp VBE modes now enabled) 124.21 + . VGA compatible setup for VBE modes added 124.22 + 124.23 +vgabios-0.5d : Dec 29 2005 124.24 + - Volker 124.25 + . Bochs VBE protected mode interface added (based on a patch by malc@pulsesoft.com) 124.26 + . biossums utility now supports VGABIOS sizes up to 64 kBytes 124.27 + . VGA mode 0x11: all color planes must be enabled in this 2-color VGA mode 124.28 + 124.29 +vgabios-0.5c : Jul 07 2005 124.30 + - Volker 124.31 + . BIOS configuration word usually reports initial mode 80x25 color text 124.32 + . vgabios function 0x0e (write teletype): linefeed (0x0a) only increments the 124.33 + cursor row value 124.34 + 124.35 vgabios-0.5b : May 24 2005 124.36 - Volker 124.37 . fixed return value for the default case in the VBE section (non-debug mode)
125.1 --- a/tools/firmware/vgabios/TODO Tue Jul 08 11:41:43 2008 +0900 125.2 +++ b/tools/firmware/vgabios/TODO Fri Jul 18 12:12:41 2008 +0900 125.3 @@ -6,13 +6,11 @@ General 125.4 - Add new functionalities and modify static functionality table 125.5 - Performance : 16 bits IO 125.6 125.7 -v0.6 125.8 - - Reimplement the tables so it is compatible with the video save pointer table 125.9 +v0.7 125.10 - Implement the remaining functions (don't know if all are needed): 125.11 - chargen ax=1120, ax=1121, ax=1122, ax=1123, ax=1124 125.12 - display switch interface ah=12 bl=35 125.13 - video refresh control ah=12 bl=36 125.14 - - save/restore state ah=1c 125.15 - Graphic modes 125.16 125.17 v1.0
126.1 --- a/tools/firmware/vgabios/biossums.c Tue Jul 08 11:41:43 2008 +0900 126.2 +++ b/tools/firmware/vgabios/biossums.c Fri Jul 18 12:12:41 2008 +0900 126.3 @@ -1,25 +1,35 @@ 126.4 /* biossums.c --- written by Eike W. for the Bochs BIOS */ 126.5 /* adapted for the LGPL'd VGABIOS by vruppert */ 126.6 126.7 +/* This library is free software; you can redistribute it and/or 126.8 + * modify it under the terms of the GNU Lesser General Public 126.9 + * License as published by the Free Software Foundation; either 126.10 + * version 2 of the License, or (at your option) any later version. 126.11 + * 126.12 + * This library is distributed in the hope that it will be useful, 126.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 126.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 126.15 + * Lesser General Public License for more details. 126.16 + * 126.17 + * You should have received a copy of the GNU Lesser General Public 126.18 + * License along with this library; if not, write to the Free Software 126.19 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 126.20 + */ 126.21 #include <stdlib.h> 126.22 #include <stdio.h> 126.23 +#include <string.h> 126.24 126.25 typedef unsigned char byte; 126.26 126.27 void check( int value, char* message ); 126.28 126.29 -#define LEN_BIOS_DATA 0x8000 126.30 -#define MAX_OFFSET (LEN_BIOS_DATA - 1) 126.31 - 126.32 - 126.33 -#define BIOS_OFFSET 0x7FFF 126.34 +#define MAX_BIOS_DATA 0x10000 126.35 126.36 long chksum_bios_get_offset( byte* data, long offset ); 126.37 byte chksum_bios_calc_value( byte* data, long offset ); 126.38 byte chksum_bios_get_value( byte* data, long offset ); 126.39 void chksum_bios_set_value( byte* data, long offset, byte value ); 126.40 126.41 - 126.42 #define PMID_LEN 20 126.43 #define PMID_CHKSUM 19 126.44 126.45 @@ -28,33 +38,55 @@ byte chksum_pmid_calc_value( byte* data, 126.46 byte chksum_pmid_get_value( byte* data, long offset ); 126.47 void chksum_pmid_set_value( byte* data, long offset, byte value ); 126.48 126.49 +#define PCIR_LEN 24 126.50 126.51 -byte bios_data[LEN_BIOS_DATA]; 126.52 +long chksum_pcir_get_offset( byte* data, long offset ); 126.53 + 126.54 + 126.55 +byte bios_data[MAX_BIOS_DATA]; 126.56 +long bios_len; 126.57 126.58 126.59 -int main( int argc, char* argv[] ) { 126.60 - 126.61 +int main(int argc, char* argv[]) 126.62 +{ 126.63 FILE* stream; 126.64 - long offset, tmp_offset; 126.65 - byte cur_val = 0, new_val = 0; 126.66 - int hits; 126.67 + long offset, tmp_offset, pcir_offset; 126.68 + byte bios_len_byte, cur_val = 0, new_val = 0; 126.69 + int hits, modified; 126.70 126.71 - 126.72 - if( argc != 2 ) { 126.73 + if (argc != 2) { 126.74 printf( "Error. Need a file-name as an argument.\n" ); 126.75 exit( EXIT_FAILURE ); 126.76 } 126.77 126.78 - if(( stream = fopen( argv[1], "rb" )) == NULL ) { 126.79 - printf( "Error opening %s for reading.\n", argv[1] ); 126.80 - exit( EXIT_FAILURE ); 126.81 + if ((stream = fopen(argv[1], "rb")) == NULL) { 126.82 + printf("Error opening %s for reading.\n", argv[1]); 126.83 + exit(EXIT_FAILURE); 126.84 + } 126.85 + memset(bios_data, 0, MAX_BIOS_DATA); 126.86 + bios_len = fread(bios_data, 1, MAX_BIOS_DATA, stream); 126.87 + if (bios_len > MAX_BIOS_DATA) { 126.88 + printf("Error reading max. 65536 Bytes from %s.\n", argv[1]); 126.89 + fclose(stream); 126.90 + exit(EXIT_FAILURE); 126.91 } 126.92 - if( fread( bios_data, 1, LEN_BIOS_DATA, stream ) >= LEN_BIOS_DATA ) { 126.93 - printf( "Error reading max. 32767 Bytes from %s.\n", argv[1] ); 126.94 - fclose( stream ); 126.95 - exit( EXIT_FAILURE ); 126.96 + fclose(stream); 126.97 + modified = 0; 126.98 + if (bios_len < 0x8000) { 126.99 + bios_len = 0x8000; 126.100 + modified = 1; 126.101 + } else if ((bios_len & 0x1FF) != 0) { 126.102 + bios_len = (bios_len + 0x200) & ~0x1FF; 126.103 + modified = 1; 126.104 } 126.105 - fclose( stream ); 126.106 + bios_len_byte = (byte)(bios_len / 512); 126.107 + if (bios_len_byte != bios_data[2]) { 126.108 + if (modified == 0) { 126.109 + bios_len += 0x200; 126.110 + } 126.111 + bios_data[2] = (byte)(bios_len / 512); 126.112 + modified = 1; 126.113 + } 126.114 126.115 hits = 0; 126.116 offset = 0L; 126.117 @@ -67,44 +99,76 @@ int main( int argc, char* argv[] ) { 126.118 printf( "Calculated checksum: 0x%02X ", new_val ); 126.119 hits++; 126.120 } 126.121 - if( hits == 1 && cur_val != new_val ) { 126.122 - printf( "Setting checksum." ); 126.123 + if ((hits == 1) && (cur_val != new_val)) { 126.124 + printf("Setting checksum."); 126.125 chksum_pmid_set_value( bios_data, offset, new_val ); 126.126 + if (modified == 0) { 126.127 + bios_len += 0x200; 126.128 + bios_data[2]++; 126.129 + } 126.130 + modified = 1; 126.131 } 126.132 - if( hits >= 2 ) { 126.133 + if (hits >= 2) { 126.134 printf( "Multiple PMID entries! No checksum set." ); 126.135 } 126.136 - if( hits ) { 126.137 - printf( "\n" ); 126.138 + if (hits) { 126.139 + printf("\n"); 126.140 } 126.141 126.142 + offset = 0L; 126.143 + pcir_offset = chksum_pcir_get_offset( bios_data, offset ); 126.144 + if (pcir_offset != -1L) { 126.145 + if (bios_data[pcir_offset + 16] != bios_data[2]) { 126.146 + bios_data[pcir_offset + 16] = bios_data[2]; 126.147 + if (modified == 0) { 126.148 + bios_len += 0x200; 126.149 + bios_data[2]++; 126.150 + bios_data[pcir_offset + 16]++; 126.151 + } 126.152 + modified = 1; 126.153 + } 126.154 + } 126.155 126.156 offset = 0L; 126.157 - offset = chksum_bios_get_offset( bios_data, offset ); 126.158 - cur_val = chksum_bios_get_value( bios_data, offset ); 126.159 - new_val = chksum_bios_calc_value( bios_data, offset ); 126.160 - printf( "\nBios checksum at: 0x%4lX\n", offset ); 126.161 - printf( "Current checksum: 0x%02X\n", cur_val ); 126.162 - printf( "Calculated checksum: 0x%02X ", new_val ); 126.163 - if( cur_val != new_val ) { 126.164 - printf( "Setting checksum." ); 126.165 - chksum_bios_set_value( bios_data, offset, new_val ); 126.166 - } 126.167 - printf( "\n" ); 126.168 - 126.169 + do { 126.170 + offset = chksum_bios_get_offset(bios_data, offset); 126.171 + cur_val = chksum_bios_get_value(bios_data, offset); 126.172 + new_val = chksum_bios_calc_value(bios_data, offset); 126.173 + if ((cur_val != new_val) && (modified == 0)) { 126.174 + bios_len += 0x200; 126.175 + bios_data[2]++; 126.176 + if (pcir_offset != -1L) { 126.177 + bios_data[pcir_offset + 16]++; 126.178 + } 126.179 + modified = 1; 126.180 + } else { 126.181 + printf("\nBios checksum at: 0x%4lX\n", offset); 126.182 + printf("Current checksum: 0x%02X\n", cur_val); 126.183 + printf("Calculated checksum: 0x%02X ", new_val); 126.184 + if (cur_val != new_val) { 126.185 + printf("Setting checksum."); 126.186 + chksum_bios_set_value(bios_data, offset, new_val); 126.187 + cur_val = new_val; 126.188 + modified = 1; 126.189 + } 126.190 + printf( "\n" ); 126.191 + } 126.192 + } while (cur_val != new_val); 126.193 126.194 - if(( stream = fopen( argv[1], "wb" )) == NULL ) { 126.195 - printf( "Error opening %s for writing.\n", argv[1] ); 126.196 - exit( EXIT_FAILURE ); 126.197 + if (modified == 1) { 126.198 + if ((stream = fopen( argv[1], "wb")) == NULL) { 126.199 + printf("Error opening %s for writing.\n", argv[1]); 126.200 + exit(EXIT_FAILURE); 126.201 + } 126.202 + if (fwrite(bios_data, 1, bios_len, stream) < bios_len) { 126.203 + printf("Error writing %d KBytes to %s.\n", bios_len / 1024, argv[1]); 126.204 + fclose(stream); 126.205 + exit(EXIT_FAILURE); 126.206 + } 126.207 + fclose(stream); 126.208 } 126.209 - if( fwrite( bios_data, 1, LEN_BIOS_DATA, stream ) < LEN_BIOS_DATA ) { 126.210 - printf( "Error writing 32KBytes to %s.\n", argv[1] ); 126.211 - fclose( stream ); 126.212 - exit( EXIT_FAILURE ); 126.213 - } 126.214 - fclose( stream ); 126.215 126.216 - return( EXIT_SUCCESS ); 126.217 + return (EXIT_SUCCESS); 126.218 } 126.219 126.220 126.221 @@ -119,7 +183,7 @@ void check( int okay, char* message ) { 126.222 126.223 long chksum_bios_get_offset( byte* data, long offset ) { 126.224 126.225 - return( BIOS_OFFSET ); 126.226 + return (bios_len - 1); 126.227 } 126.228 126.229 126.230 @@ -129,7 +193,7 @@ byte chksum_bios_calc_value( byte* data, 126.231 byte sum; 126.232 126.233 sum = 0; 126.234 - for( i = 0; i < MAX_OFFSET; i++ ) { 126.235 + for( i = 0; i < offset; i++ ) { 126.236 sum = sum + *( data + i ); 126.237 } 126.238 sum = -sum; /* iso ensures -s + s == 0 on unsigned types */ 126.239 @@ -139,13 +203,13 @@ byte chksum_bios_calc_value( byte* data, 126.240 126.241 byte chksum_bios_get_value( byte* data, long offset ) { 126.242 126.243 - return( *( data + BIOS_OFFSET ) ); 126.244 + return( *( data + offset ) ); 126.245 } 126.246 126.247 126.248 void chksum_bios_set_value( byte* data, long offset, byte value ) { 126.249 126.250 - *( data + BIOS_OFFSET ) = value; 126.251 + *( data + offset ) = value; 126.252 } 126.253 126.254 126.255 @@ -156,7 +220,7 @@ byte chksum_pmid_calc_value( byte* data, 126.256 byte sum; 126.257 126.258 len = PMID_LEN; 126.259 - check( offset + len <= MAX_OFFSET, "PMID entry length out of bounds" ); 126.260 + check((offset + len) <= (bios_len - 1), "PMID entry length out of bounds" ); 126.261 sum = 0; 126.262 for( i = 0; i < len; i++ ) { 126.263 if( i != PMID_CHKSUM ) { 126.264 @@ -172,7 +236,7 @@ long chksum_pmid_get_offset( byte* data, 126.265 126.266 long result = -1L; 126.267 126.268 - while( offset + PMID_LEN < MAX_OFFSET ) { 126.269 + while ((offset + PMID_LEN) < (bios_len - 1)) { 126.270 offset = offset + 1; 126.271 if( *( data + offset + 0 ) == 'P' && \ 126.272 *( data + offset + 1 ) == 'M' && \ 126.273 @@ -188,13 +252,31 @@ long chksum_pmid_get_offset( byte* data, 126.274 126.275 byte chksum_pmid_get_value( byte* data, long offset ) { 126.276 126.277 - check( offset + PMID_CHKSUM <= MAX_OFFSET, "PMID checksum out of bounds" ); 126.278 + check((offset + PMID_CHKSUM) <= (bios_len - 1), "PMID checksum out of bounds" ); 126.279 return( *( data + offset + PMID_CHKSUM ) ); 126.280 } 126.281 126.282 126.283 void chksum_pmid_set_value( byte* data, long offset, byte value ) { 126.284 126.285 - check( offset + PMID_CHKSUM <= MAX_OFFSET, "PMID checksum out of bounds" ); 126.286 + check((offset + PMID_CHKSUM) <= (bios_len - 1), "PMID checksum out of bounds" ); 126.287 *( data + offset + PMID_CHKSUM ) = value; 126.288 } 126.289 + 126.290 + 126.291 +long chksum_pcir_get_offset( byte* data, long offset ) { 126.292 + 126.293 + long result = -1L; 126.294 + 126.295 + while ((offset + PCIR_LEN) < (bios_len - 1)) { 126.296 + offset = offset + 1; 126.297 + if( *( data + offset + 0 ) == 'P' && \ 126.298 + *( data + offset + 1 ) == 'C' && \ 126.299 + *( data + offset + 2 ) == 'I' && \ 126.300 + *( data + offset + 3 ) == 'R' ) { 126.301 + result = offset; 126.302 + break; 126.303 + } 126.304 + } 126.305 + return( result ); 126.306 +}
127.1 --- a/tools/firmware/vgabios/clext.c Tue Jul 08 11:41:43 2008 +0900 127.2 +++ b/tools/firmware/vgabios/clext.c Fri Jul 18 12:12:41 2008 +0900 127.3 @@ -239,6 +239,21 @@ 0x001a,0x321b,0x001d, 127.4 0xffff 127.5 }; 127.6 127.7 +/* 1600x1200x8 */ 127.8 +unsigned short cseq_1600x1200x8[] = { 127.9 +0x0300,0x2101,0x0f02,0x0003,0x0e04,0x1107, 127.10 +0x760b,0x760c,0x760d,0x760e, 127.11 +0x0412,0x0013,0x2017, 127.12 +0x341b,0x341c,0x341d,0x341e, 127.13 +0xffff 127.14 +}; 127.15 +unsigned short ccrtc_1600x1200x8[] = { 127.16 +0x2911,0xc300,0x9f01,0x9f02,0x8603,0x8304,0x9405,0x2406,0xf707, 127.17 +0x6009,0x000c,0x000d, 127.18 +0x0310,0xff12,0xa013,0x4014,0xff15,0x2416,0xc317,0xff18, 127.19 +0x001a,0x221b,0x001d, 127.20 +0xffff 127.21 +}; 127.22 127.23 cirrus_mode_t cirrus_modes[] = 127.24 { 127.25 @@ -292,6 +307,10 @@ cirrus_mode_t cirrus_modes[] = 127.26 cseq_1280x1024x16,cgraph_svgacolor,ccrtc_1280x1024x16,16, 127.27 6,5,11,6,5,5,0,0,0}, 127.28 127.29 + {0x7b,1600,1200,8,0x00, 127.30 + cseq_1600x1200x8,cgraph_svgacolor,ccrtc_1600x1200x8,8, 127.31 + 4,0,0,0,0,0,0,0,0}, 127.32 + 127.33 {0xfe,0,0,0,0,cseq_vga,cgraph_vga,ccrtc_vga,0, 127.34 0xff,0,0,0,0,0,0,0,0}, 127.35 {0xff,0,0,0,0,0,0,0,0, 127.36 @@ -1561,6 +1580,10 @@ cirrus_clear_vram_1: 127.37 cmp ah, bl 127.38 jne cirrus_clear_vram_1 127.39 127.40 + xor ah,ah 127.41 + mov dx, #0x3ce 127.42 + out dx, ax 127.43 + 127.44 pop es 127.45 popa 127.46 ret 127.47 @@ -1652,6 +1675,7 @@ cirrus_vesa_handlers: 127.48 dw cirrus_vesa_10h 127.49 127.50 127.51 + 127.52 ASM_END 127.53 127.54 #ifdef CIRRUS_VESA3_PMINFO
128.1 --- a/tools/firmware/vgabios/vbe.c Tue Jul 08 11:41:43 2008 +0900 128.2 +++ b/tools/firmware/vgabios/vbe.c Fri Jul 18 12:12:41 2008 +0900 128.3 @@ -30,19 +30,15 @@ 128.4 128.5 128.6 // defines available 128.7 -// enable LFB support 128.8 -#define VBE_HAVE_LFB 128.9 128.10 // disable VESA/VBE2 check in vbe info 128.11 //#define VBE2_NO_VESA_CHECK 128.12 128.13 -// dynamicly generate a mode_info list 128.14 -#define DYN_LIST 128.15 - 128.16 128.17 #include "vbe.h" 128.18 #include "vbetables.h" 128.19 128.20 +#define VBE_TOTAL_VIDEO_MEMORY_DIV_64K (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB*1024/64) 128.21 128.22 // The current OEM Software Revision of this VBE Bios 128.23 #define VBE_OEM_SOFTWARE_REV 0x0002; 128.24 @@ -52,10 +48,6 @@ extern char vbebios_vendor_name; 128.25 extern char vbebios_product_name; 128.26 extern char vbebios_product_revision; 128.27 128.28 -#ifndef DYN_LIST 128.29 -extern Bit16u vbebios_mode_list; 128.30 -#endif 128.31 - 128.32 ASM_START 128.33 // FIXME: 'merge' these (c) etc strings with the vgabios.c strings? 128.34 _vbebios_copyright: 128.35 @@ -71,7 +63,7 @@ ASM_START 128.36 .byte 0x00 128.37 128.38 _vbebios_product_revision: 128.39 -.ascii "$Id: vbe.c,v 1.47 2005/05/24 16:50:50 vruppert Exp $" 128.40 +.ascii "$Id: vbe.c,v 1.60 2008/03/02 07:47:21 vruppert Exp $" 128.41 .byte 0x00 128.42 128.43 _vbebios_info_string: 128.44 @@ -88,35 +80,143 @@ ASM_START 128.45 128.46 #if defined(USE_BX_INFO) || defined(DEBUG) 128.47 msg_vbe_init: 128.48 -.ascii "VBE Bios $Id: vbe.c,v 1.47 2005/05/24 16:50:50 vruppert Exp $" 128.49 +.ascii "VBE Bios $Id: vbe.c,v 1.60 2008/03/02 07:47:21 vruppert Exp $" 128.50 .byte 0x0a,0x0d, 0x00 128.51 #endif 128.52 128.53 -#ifndef DYN_LIST 128.54 -// FIXME: for each new mode add a statement here 128.55 -// at least until dynamic list creation is working 128.56 -_vbebios_mode_list: 128.57 + .align 2 128.58 +vesa_pm_start: 128.59 + dw vesa_pm_set_window - vesa_pm_start 128.60 + dw vesa_pm_set_display_start - vesa_pm_start 128.61 + dw vesa_pm_unimplemented - vesa_pm_start 128.62 + dw vesa_pm_io_ports_table - vesa_pm_start 128.63 +vesa_pm_io_ports_table: 128.64 + dw VBE_DISPI_IOPORT_INDEX 128.65 + dw VBE_DISPI_IOPORT_INDEX + 1 128.66 + dw VBE_DISPI_IOPORT_DATA 128.67 + dw VBE_DISPI_IOPORT_DATA + 1 128.68 + dw 0xffff 128.69 + dw 0xffff 128.70 + 128.71 + USE32 128.72 +vesa_pm_set_window: 128.73 + cmp bx, #0x00 128.74 + je vesa_pm_set_display_window1 128.75 + mov ax, #0x0100 128.76 + ret 128.77 +vesa_pm_set_display_window1: 128.78 + mov ax, dx 128.79 + push dx 128.80 + push ax 128.81 + mov dx, # VBE_DISPI_IOPORT_INDEX 128.82 + mov ax, # VBE_DISPI_INDEX_BANK 128.83 + out dx, ax 128.84 + pop ax 128.85 + mov dx, # VBE_DISPI_IOPORT_DATA 128.86 + out dx, ax 128.87 + in ax, dx 128.88 + pop dx 128.89 + cmp dx, ax 128.90 + jne illegal_window 128.91 + mov ax, #0x004f 128.92 + ret 128.93 +illegal_window: 128.94 + mov ax, #0x014f 128.95 + ret 128.96 + 128.97 +vesa_pm_set_display_start: 128.98 + cmp bl, #0x80 128.99 + je vesa_pm_set_display_start1 128.100 + cmp bl, #0x00 128.101 + je vesa_pm_set_display_start1 128.102 + mov ax, #0x0100 128.103 + ret 128.104 +vesa_pm_set_display_start1: 128.105 +; convert offset to (X, Y) coordinate 128.106 +; (would be simpler to change Bochs VBE API...) 128.107 + push eax 128.108 + push ecx 128.109 + push edx 128.110 + push esi 128.111 + push edi 128.112 + shl edx, #16 128.113 + and ecx, #0xffff 128.114 + or ecx, edx 128.115 + shl ecx, #2 128.116 + mov eax, ecx 128.117 128.118 -.word VBE_VESA_MODE_640X400X8 128.119 -.word VBE_VESA_MODE_640X480X8 128.120 -.word VBE_VESA_MODE_800X600X4 128.121 -.word VBE_VESA_MODE_800X600X8 128.122 -.word VBE_VESA_MODE_1024X768X8 128.123 -.word VBE_VESA_MODE_640X480X1555 128.124 -.word VBE_VESA_MODE_640X480X565 128.125 -.word VBE_VESA_MODE_640X480X888 128.126 -.word VBE_VESA_MODE_800X600X1555 128.127 -.word VBE_VESA_MODE_800X600X565 128.128 -.word VBE_VESA_MODE_800X600X888 128.129 -.word VBE_VESA_MODE_1024X768X1555 128.130 -.word VBE_VESA_MODE_1024X768X565 128.131 -.word VBE_VESA_MODE_1024X768X888 128.132 -.word VBE_OWN_MODE_640X480X8888 128.133 -.word VBE_OWN_MODE_800X600X8888 128.134 -.word VBE_OWN_MODE_1024X768X8888 128.135 -.word VBE_OWN_MODE_320X200X8 128.136 -.word VBE_VESA_MODE_END_OF_LIST 128.137 -#endif 128.138 + push eax 128.139 + mov dx, # VBE_DISPI_IOPORT_INDEX 128.140 + mov ax, # VBE_DISPI_INDEX_VIRT_WIDTH 128.141 + out dx, ax 128.142 + mov dx, # VBE_DISPI_IOPORT_DATA 128.143 + in ax, dx 128.144 + movzx ecx, ax 128.145 + 128.146 + mov dx, # VBE_DISPI_IOPORT_INDEX 128.147 + mov ax, # VBE_DISPI_INDEX_BPP 128.148 + out dx, ax 128.149 + mov dx, # VBE_DISPI_IOPORT_DATA 128.150 + in ax, dx 128.151 + movzx esi, ax 128.152 + pop eax 128.153 + 128.154 + cmp esi, #4 128.155 + jz bpp4_mode 128.156 + add esi, #7 128.157 + shr esi, #3 128.158 + imul ecx, esi 128.159 + xor edx, edx 128.160 + div ecx 128.161 + mov edi, eax 128.162 + mov eax, edx 128.163 + xor edx, edx 128.164 + div esi 128.165 + jmp set_xy_regs 128.166 + 128.167 +bpp4_mode: 128.168 + shr ecx, #1 128.169 + xor edx, edx 128.170 + div ecx 128.171 + mov edi, eax 128.172 + mov eax, edx 128.173 + shl eax, #1 128.174 + 128.175 +set_xy_regs: 128.176 + push dx 128.177 + push ax 128.178 + mov dx, # VBE_DISPI_IOPORT_INDEX 128.179 + mov ax, # VBE_DISPI_INDEX_X_OFFSET 128.180 + out dx, ax 128.181 + pop ax 128.182 + mov dx, # VBE_DISPI_IOPORT_DATA 128.183 + out dx, ax 128.184 + pop dx 128.185 + 128.186 + mov ax, di 128.187 + push dx 128.188 + push ax 128.189 + mov dx, # VBE_DISPI_IOPORT_INDEX 128.190 + mov ax, # VBE_DISPI_INDEX_Y_OFFSET 128.191 + out dx, ax 128.192 + pop ax 128.193 + mov dx, # VBE_DISPI_IOPORT_DATA 128.194 + out dx, ax 128.195 + pop dx 128.196 + 128.197 + pop edi 128.198 + pop esi 128.199 + pop edx 128.200 + pop ecx 128.201 + pop eax 128.202 + mov ax, #0x004f 128.203 + ret 128.204 + 128.205 +vesa_pm_unimplemented: 128.206 + mov ax, #0x014f 128.207 + ret 128.208 + USE16 128.209 +vesa_pm_end: 128.210 128.211 ; DISPI ioport functions 128.212 128.213 @@ -158,20 +258,6 @@ ASM_START 128.214 mov dx, # VBE_DISPI_IOPORT_DATA 128.215 mov ax, 4[bp] ; xres 128.216 out dx, ax 128.217 - push ax 128.218 - mov dx, #0x03d4 128.219 - mov ax, #0x0011 128.220 - out dx, ax 128.221 - mov dx, #0x03d4 128.222 - pop ax 128.223 - push ax 128.224 - shr ax, #3 128.225 - dec ax 128.226 - mov ah, al 128.227 - mov al, #0x01 128.228 - out dx, ax 128.229 - pop ax 128.230 - call vga_set_virt_width 128.231 128.232 pop dx 128.233 pop ax 128.234 @@ -211,6 +297,28 @@ get_bpp_noinc: 128.235 pop dx 128.236 ret 128.237 128.238 +; get display capabilities 128.239 + 128.240 +_dispi_get_max_xres: 128.241 + push dx 128.242 + push bx 128.243 + call dispi_get_enable 128.244 + mov bx, ax 128.245 + or ax, # VBE_DISPI_GETCAPS 128.246 + call _dispi_set_enable 128.247 + mov dx, # VBE_DISPI_IOPORT_INDEX 128.248 + mov ax, # VBE_DISPI_INDEX_XRES 128.249 + out dx, ax 128.250 + mov dx, # VBE_DISPI_IOPORT_DATA 128.251 + in ax, dx 128.252 + push ax 128.253 + mov ax, bx 128.254 + call _dispi_set_enable 128.255 + pop ax 128.256 + pop bx 128.257 + pop dx 128.258 + ret 128.259 + 128.260 _dispi_get_max_bpp: 128.261 push dx 128.262 push bx 128.263 @@ -283,13 +391,20 @@ ASM_START 128.264 je dispi_set_bank_farcall_get 128.265 or bx,bx 128.266 jnz dispi_set_bank_farcall_error 128.267 + mov ax,dx 128.268 push dx 128.269 + push ax 128.270 mov ax,# VBE_DISPI_INDEX_BANK 128.271 mov dx,# VBE_DISPI_IOPORT_INDEX 128.272 out dx,ax 128.273 pop ax 128.274 mov dx,# VBE_DISPI_IOPORT_DATA 128.275 out dx,ax 128.276 + in ax,dx 128.277 + pop dx 128.278 + cmp dx,ax 128.279 + jne dispi_set_bank_farcall_error 128.280 + mov ax, #0x004f 128.281 retf 128.282 dispi_set_bank_farcall_get: 128.283 mov ax,# VBE_DISPI_INDEX_BANK 128.284 @@ -358,10 +473,10 @@ vga_set_virt_width: 128.285 call dispi_get_bpp 128.286 cmp al, #0x04 128.287 ja set_width_svga 128.288 - shr bx, #2 128.289 + shr bx, #1 128.290 set_width_svga: 128.291 - shr bx, #2 128.292 - mov dx, #0x03d4 128.293 + shr bx, #3 128.294 + mov dx, # VGAREG_VGA_CRTC_ADDRESS 128.295 mov ah, bl 128.296 mov al, #0x13 128.297 out dx, ax 128.298 @@ -402,6 +517,134 @@ dispi_get_virt_height: 128.299 in ax, dx 128.300 pop dx 128.301 ret 128.302 + 128.303 +_vga_compat_setup: 128.304 + push ax 128.305 + push dx 128.306 + 128.307 + ; set CRT X resolution 128.308 + mov dx, # VBE_DISPI_IOPORT_INDEX 128.309 + mov ax, # VBE_DISPI_INDEX_XRES 128.310 + out dx, ax 128.311 + mov dx, # VBE_DISPI_IOPORT_DATA 128.312 + in ax, dx 128.313 + push ax 128.314 + mov dx, # VGAREG_VGA_CRTC_ADDRESS 128.315 + mov ax, #0x0011 128.316 + out dx, ax 128.317 + pop ax 128.318 + push ax 128.319 + shr ax, #3 128.320 + dec ax 128.321 + mov ah, al 128.322 + mov al, #0x01 128.323 + out dx, ax 128.324 + pop ax 128.325 + call vga_set_virt_width 128.326 + 128.327 + ; set CRT Y resolution 128.328 + mov dx, # VBE_DISPI_IOPORT_INDEX 128.329 + mov ax, # VBE_DISPI_INDEX_YRES 128.330 + out dx, ax 128.331 + mov dx, # VBE_DISPI_IOPORT_DATA 128.332 + in ax, dx 128.333 + dec ax 128.334 + push ax 128.335 + mov dx, # VGAREG_VGA_CRTC_ADDRESS 128.336 + mov ah, al 128.337 + mov al, #0x12 128.338 + out dx, ax 128.339 + pop ax 128.340 + mov al, #0x07 128.341 + out dx, al 128.342 + inc dx 128.343 + in al, dx 128.344 + and al, #0xbd 128.345 + test ah, #0x01 128.346 + jz bit8_clear 128.347 + or al, #0x02 128.348 +bit8_clear: 128.349 + test ah, #0x02 128.350 + jz bit9_clear 128.351 + or al, #0x40 128.352 +bit9_clear: 128.353 + out dx, al 128.354 + 128.355 + ; other settings 128.356 + mov dx, # VGAREG_VGA_CRTC_ADDRESS 128.357 + mov ax, #0x0009 128.358 + out dx, ax 128.359 + mov al, #0x17 128.360 + out dx, al 128.361 + mov dx, # VGAREG_VGA_CRTC_DATA 128.362 + in al, dx 128.363 + or al, #0x03 128.364 + out dx, al 128.365 + mov dx, # VGAREG_ACTL_RESET 128.366 + in al, dx 128.367 + mov dx, # VGAREG_ACTL_ADDRESS 128.368 + mov al, #0x10 128.369 + out dx, al 128.370 + mov dx, # VGAREG_ACTL_READ_DATA 128.371 + in al, dx 128.372 + or al, #0x01 128.373 + mov dx, # VGAREG_ACTL_ADDRESS 128.374 + out dx, al 128.375 + mov al, #0x20 128.376 + out dx, al 128.377 + mov dx, # VGAREG_GRDC_ADDRESS 128.378 + mov ax, #0x0506 128.379 + out dx, ax 128.380 + mov dx, # VGAREG_SEQU_ADDRESS 128.381 + mov ax, #0x0f02 128.382 + out dx, ax 128.383 + 128.384 + ; settings for >= 8bpp 128.385 + mov dx, # VBE_DISPI_IOPORT_INDEX 128.386 + mov ax, # VBE_DISPI_INDEX_BPP 128.387 + out dx, ax 128.388 + mov dx, # VBE_DISPI_IOPORT_DATA 128.389 + in ax, dx 128.390 + cmp al, #0x08 128.391 + jb vga_compat_end 128.392 + mov dx, # VGAREG_VGA_CRTC_ADDRESS 128.393 + mov al, #0x14 128.394 + out dx, al 128.395 + mov dx, # VGAREG_VGA_CRTC_DATA 128.396 + in al, dx 128.397 + or al, #0x40 128.398 + out dx, al 128.399 + mov dx, # VGAREG_ACTL_RESET 128.400 + in al, dx 128.401 + mov dx, # VGAREG_ACTL_ADDRESS 128.402 + mov al, #0x10 128.403 + out dx, al 128.404 + mov dx, # VGAREG_ACTL_READ_DATA 128.405 + in al, dx 128.406 + or al, #0x40 128.407 + mov dx, # VGAREG_ACTL_ADDRESS 128.408 + out dx, al 128.409 + mov al, #0x20 128.410 + out dx, al 128.411 + mov dx, # VGAREG_SEQU_ADDRESS 128.412 + mov al, #0x04 128.413 + out dx, al 128.414 + mov dx, # VGAREG_SEQU_DATA 128.415 + in al, dx 128.416 + or al, #0x08 128.417 + out dx, al 128.418 + mov dx, # VGAREG_GRDC_ADDRESS 128.419 + mov al, #0x05 128.420 + out dx, al 128.421 + mov dx, # VGAREG_GRDC_DATA 128.422 + in al, dx 128.423 + and al, #0x9f 128.424 + or al, #0x40 128.425 + out dx, al 128.426 + 128.427 +vga_compat_end: 128.428 + pop dx 128.429 + pop ax 128.430 ASM_END 128.431 128.432 128.433 @@ -472,7 +715,7 @@ vbe_init: 128.434 mov [bx], al 128.435 pop bx 128.436 pop ds 128.437 - mov ax, # VBE_DISPI_ID3 128.438 + mov ax, # VBE_DISPI_ID4 128.439 call dispi_set_id 128.440 no_vbe_interface: 128.441 #if defined(USE_BX_INFO) || defined(DEBUG) 128.442 @@ -573,15 +816,9 @@ Bit16u *AX;Bit16u ES;Bit16u DI; 128.443 vbe_info_block.Capabilities[2] = 0; 128.444 vbe_info_block.Capabilities[3] = 0; 128.445 128.446 -#ifdef DYN_LIST 128.447 // VBE Video Mode Pointer (dynamicly generated from the mode_info_list) 128.448 vbe_info_block.VideoModePtr_Seg= ES ; 128.449 vbe_info_block.VideoModePtr_Off= DI + 34; 128.450 -#else 128.451 - // VBE Video Mode Pointer (staticly in rom) 128.452 - vbe_info_block.VideoModePtr_Seg = 0xc000; 128.453 - vbe_info_block.VideoModePtr_Off = &vbebios_mode_list; 128.454 -#endif 128.455 128.456 // VBE Total Memory (in 64b blocks) 128.457 vbe_info_block.TotalMemory = VBE_TOTAL_VIDEO_MEMORY_DIV_64K; 128.458 @@ -606,23 +843,26 @@ Bit16u *AX;Bit16u ES;Bit16u DI; 128.459 memcpyb(ES, DI, ss, &vbe_info_block, 256); 128.460 } 128.461 128.462 -#ifdef DYN_LIST 128.463 do 128.464 { 128.465 - if (cur_info->info.BitsPerPixel <= dispi_get_max_bpp()) { 128.466 + if ((cur_info->info.XResolution <= dispi_get_max_xres()) && 128.467 + (cur_info->info.BitsPerPixel <= dispi_get_max_bpp())) { 128.468 #ifdef DEBUG 128.469 printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode); 128.470 #endif 128.471 write_word(ES, DI + cur_ptr, cur_info->mode); 128.472 cur_mode++; 128.473 cur_ptr+=2; 128.474 + } else { 128.475 +#ifdef DEBUG 128.476 + printf("VBE mode %x (xres=%x / bpp=%02x) not supported by display\n", cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel); 128.477 +#endif 128.478 } 128.479 cur_info++; 128.480 } while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST); 128.481 128.482 // Add vesa mode list terminator 128.483 write_word(ES, DI + cur_ptr, cur_info->mode); 128.484 -#endif 128.485 128.486 result = 0x4f; 128.487 128.488 @@ -666,6 +906,9 @@ Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u D 128.489 #endif 128.490 memsetb(ss, &info, 0, sizeof(ModeInfoBlock)); 128.491 memcpyb(ss, &info, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact)); 128.492 + if (using_lfb) { 128.493 + info.NumberOfBanks = 1; 128.494 + } 128.495 if (info.WinAAttributes & VBE_WINDOW_ATTRIBUTE_RELOCATABLE) { 128.496 info.WinFuncPtr = 0xC0000000UL; 128.497 *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall); 128.498 @@ -747,7 +990,7 @@ Bit16u *AX;Bit16u BX; Bit16u ES;Bit16u D 128.499 // first disable current mode (when switching between vesa modi) 128.500 dispi_set_enable(VBE_DISPI_DISABLED); 128.501 128.502 - if (cur_info->mode == VBE_VESA_MODE_800X600X4) 128.503 + if (cur_info->info.BitsPerPixel == 4) 128.504 { 128.505 biosfn_set_video_mode(0x6a); 128.506 } 128.507 @@ -757,6 +1000,7 @@ Bit16u *AX;Bit16u BX; Bit16u ES;Bit16u D 128.508 dispi_set_yres(cur_info->info.YResolution); 128.509 dispi_set_bank(0); 128.510 dispi_set_enable(VBE_DISPI_ENABLED | no_clear | lfb_flag); 128.511 + vga_compat_setup(); 128.512 128.513 write_word(BIOSMEM_SEG,BIOSMEM_VBE_MODE,BX); 128.514 write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL,(0x60 | no_clear)); 128.515 @@ -812,6 +1056,64 @@ vbe_03_ok: 128.516 ASM_END 128.517 128.518 128.519 +Bit16u vbe_biosfn_read_video_state_size() 128.520 +{ 128.521 + return 9 * 2; 128.522 +} 128.523 + 128.524 +void vbe_biosfn_save_video_state(ES, BX) 128.525 + Bit16u ES; Bit16u BX; 128.526 +{ 128.527 + Bit16u enable, i; 128.528 + 128.529 + outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 128.530 + enable = inw(VBE_DISPI_IOPORT_DATA); 128.531 + write_word(ES, BX, enable); 128.532 + BX += 2; 128.533 + if (!(enable & VBE_DISPI_ENABLED)) 128.534 + return; 128.535 + for(i = VBE_DISPI_INDEX_XRES; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) { 128.536 + if (i != VBE_DISPI_INDEX_ENABLE) { 128.537 + outw(VBE_DISPI_IOPORT_INDEX, i); 128.538 + write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA)); 128.539 + BX += 2; 128.540 + } 128.541 + } 128.542 +} 128.543 + 128.544 + 128.545 +void vbe_biosfn_restore_video_state(ES, BX) 128.546 + Bit16u ES; Bit16u BX; 128.547 +{ 128.548 + Bit16u enable, i; 128.549 + 128.550 + enable = read_word(ES, BX); 128.551 + BX += 2; 128.552 + 128.553 + if (!(enable & VBE_DISPI_ENABLED)) { 128.554 + outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 128.555 + outw(VBE_DISPI_IOPORT_DATA, enable); 128.556 + } else { 128.557 + outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES); 128.558 + outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 128.559 + BX += 2; 128.560 + outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES); 128.561 + outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 128.562 + BX += 2; 128.563 + outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP); 128.564 + outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 128.565 + BX += 2; 128.566 + outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE); 128.567 + outw(VBE_DISPI_IOPORT_DATA, enable); 128.568 + 128.569 + for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++) { 128.570 + outw(VBE_DISPI_IOPORT_INDEX, i); 128.571 + outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX)); 128.572 + BX += 2; 128.573 + } 128.574 + } 128.575 +} 128.576 + 128.577 /** Function 04h - Save/Restore State 128.578 * 128.579 * Input: 128.580 @@ -826,11 +1128,49 @@ ASM_END 128.581 * BX = Number of 64-byte blocks to hold the state buffer (if DL=00h) 128.582 * 128.583 */ 128.584 -void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX) 128.585 +void vbe_biosfn_save_restore_state(AX, CX, DX, ES, BX) 128.586 +Bit16u *AX; Bit16u CX; Bit16u DX; Bit16u ES; Bit16u *BX; 128.587 { 128.588 + Bit16u ss=get_SS(); 128.589 + Bit16u result, val; 128.590 + 128.591 + result = 0x4f; 128.592 + switch(GET_DL()) { 128.593 + case 0x00: 128.594 + val = biosfn_read_video_state_size2(CX); 128.595 +#ifdef DEBUG 128.596 + printf("VGA state size=%x\n", val); 128.597 +#endif 128.598 + if (CX & 8) 128.599 + val += vbe_biosfn_read_video_state_size(); 128.600 + write_word(ss, BX, val); 128.601 + break; 128.602 + case 0x01: 128.603 + val = read_word(ss, BX); 128.604 + val = biosfn_save_video_state(CX, ES, val);