From nobody Thu Jul 23 21:11:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784535568240848.7918750967989; Mon, 20 Jul 2026 01:19:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366242.1616131 (Exim 4.92) (envelope-from ) id 1wljD4-0005eb-V6; Mon, 20 Jul 2026 08:18:46 +0000 Received: by outflank-mailman (output) from mailman id 1366242.1616131; Mon, 20 Jul 2026 08:18:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wljD4-0005eS-RR; Mon, 20 Jul 2026 08:18:46 +0000 Received: by outflank-mailman (input) for mailman id 1366242; Mon, 20 Jul 2026 08:18:46 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wljD3-0005an-ES for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 08:18:45 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wljD2-000Q5E-RK for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 10:18:44 +0200 Received: from [10.42.69.4] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5dd9de-bab6-0a2a0a5309dd-0a2a4504e28c-34 for ; Mon, 20 Jul 2026 10:18:44 +0200 Received: from [195.135.223.130] (helo=smtp-out1.suse.de) by tlsNG-ebf023.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5dd9e4-b57f-0a2a45040019-c387df8290ac-3 for ; Mon, 20 Jul 2026 10:18:44 +0200 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C0DB179E47; Mon, 20 Jul 2026 08:18:41 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5BB48779AA; Mon, 20 Jul 2026 08:18:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 3AwQFeHZXWpBXgAAD6G6ig (envelope-from ); Mon, 20 Jul 2026 08:18:41 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=fail header.s=susede1 header.d=suse.com header.i="@suse.com"; dkim=fail header.s=susede1 header.d=suse.com header.i="@suse.com" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784535522; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cNBgcQqFBVXL2663TfGLBiU57c1Js/fPnDLW3L6CWA4=; b=W3ruMhhq1vZp+T1rPuWou1XHxgLyKsewPH/82I6JGx3vyUo9WWO+3/9EFzWX0znnhQad3p b9WDM0JaeGWFPAcotv7+yLAgY8pt/TAqOqIf+wk2P4BUl0mYaC8mRrf51WUzcl4h3FDrNX /T7euxfNY4ZN8yVKwJ0I9ZzQFBuQQhA= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=liQqSIgr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784535521; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cNBgcQqFBVXL2663TfGLBiU57c1Js/fPnDLW3L6CWA4=; b=liQqSIgr4J+qlBYp2QEuN9TWPJVrodziEsAbFU32CMO4ZLMrdQS051AumlhmJtpVtzF/xG o8er1xbJv54wlF8VzWKc5Qsyv8y9RWal/oV11Gsb+Lhm7+01JwnS+bogQsK4dBoFV0xF2x ZYpuT+l8FTAInBp0TAw1satnv00t/zM= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Samuel Thibault Subject: [PATCH v2 1/5] stubdom: remove support for grub-pv Date: Mon, 20 Jul 2026 10:18:28 +0200 Message-ID: <20260720081833.4122182-2-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260720081833.4122182-1-jgross@suse.com> References: <20260720081833.4122182-1-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Rspamd-Action: no action X-Spam-Level: X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_TRACE(0.00)[suse.com:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: C0DB179E47 X-Spam-Score: -3.51 X-purgate-ID: tlsNG-ebf023/1784535524-C12DC8F0-A5E02CB7/0/0 X-purgate-type: clean X-purgate-size: 354672 X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZM-MESSAGEID: 1784535569430158500 The Mini-OS based grub-pv is not being built by default since Xen 4.16. Additionally it can be replaced in most cases by the more modern pvgrub (part of grub upstream), while grub-pv is based on legacy grub 0.97. In case someone is really depending on grub-pv, an old build from a previous Xen version can be used without any problem, as only stable hypercall interfaces are used by it. Remove grub-pv from the build system. Signed-off-by: Juergen Gross --- V2: - moved grub install hook from patch 2 here (Jan Beulich) --- Makefile | 6 - config/Stubdom.mk.in | 3 - stubdom/.gitignore | 1 - stubdom/Makefile | 54 - stubdom/configure | 65 - stubdom/configure.ac | 2 - stubdom/grub.patches/00cvs | 1022 ----- stubdom/grub.patches/10graphics.diff | 2297 ----------- stubdom/grub.patches/11graphics-keyboard.diff | 13 - stubdom/grub.patches/20print_func.diff | 52 - stubdom/grub.patches/30savedefault.diff | 186 - .../grub.patches/40ext3_256byte_inode.diff | 114 - stubdom/grub.patches/50fs_fulldisk.diff | 72 - stubdom/grub.patches/60ext4.diff | 474 --- stubdom/grub.patches/61btrfs.diff | 3499 ----------------- stubdom/grub.patches/70compiler_warnings.diff | 45 - stubdom/grub.patches/99minios | 1570 -------- stubdom/grub/Makefile | 88 - stubdom/grub/boot-x86_32.S | 112 - stubdom/grub/boot-x86_64.S | 108 - stubdom/grub/config.h | 12 - stubdom/grub/kexec.c | 434 -- stubdom/grub/mini-os.c | 771 ---- stubdom/grub/mini-os.h | 7 - stubdom/grub/minios.cfg | 4 - stubdom/grub/osdep.h | 30 - 26 files changed, 11041 deletions(-) delete mode 100644 stubdom/grub.patches/00cvs delete mode 100644 stubdom/grub.patches/10graphics.diff delete mode 100644 stubdom/grub.patches/11graphics-keyboard.diff delete mode 100644 stubdom/grub.patches/20print_func.diff delete mode 100644 stubdom/grub.patches/30savedefault.diff delete mode 100644 stubdom/grub.patches/40ext3_256byte_inode.diff delete mode 100644 stubdom/grub.patches/50fs_fulldisk.diff delete mode 100644 stubdom/grub.patches/60ext4.diff delete mode 100644 stubdom/grub.patches/61btrfs.diff delete mode 100644 stubdom/grub.patches/70compiler_warnings.diff delete mode 100644 stubdom/grub.patches/99minios delete mode 100644 stubdom/grub/Makefile delete mode 100644 stubdom/grub/boot-x86_32.S delete mode 100644 stubdom/grub/boot-x86_64.S delete mode 100644 stubdom/grub/config.h delete mode 100644 stubdom/grub/kexec.c delete mode 100644 stubdom/grub/mini-os.c delete mode 100644 stubdom/grub/mini-os.h delete mode 100644 stubdom/grub/minios.cfg delete mode 100644 stubdom/grub/osdep.h diff --git a/Makefile b/Makefile index 67b71ac3d4..ea432e21b0 100644 --- a/Makefile +++ b/Makefile @@ -71,9 +71,6 @@ build-tools-oxenstored: build-tools-public-headers .PHONY: build-stubdom build-stubdom: mini-os-dir build-tools-public-headers $(MAKE) -C stubdom build -ifeq (x86_64,$(XEN_TARGET_ARCH)) - XEN_TARGET_ARCH=3Dx86_32 $(MAKE) -C stubdom pv-grub-if-enabled -endif =20 define do-subtree $(1)/%: FORCE @@ -149,9 +146,6 @@ install-tools: install-tools-public-headers .PHONY: install-stubdom install-stubdom: mini-os-dir install-tools-public-headers $(MAKE) -C stubdom install -ifeq (x86_64,$(XEN_TARGET_ARCH)) - XEN_TARGET_ARCH=3Dx86_32 $(MAKE) -C stubdom install-grub-if-enabled -endif =20 .PHONY: tools/firmware/seabios-dir-force-update tools/firmware/seabios-dir-force-update: diff --git a/config/Stubdom.mk.in b/config/Stubdom.mk.in index b399d77740..0d70d03941 100644 --- a/config/Stubdom.mk.in +++ b/config/Stubdom.mk.in @@ -23,9 +23,6 @@ NEWLIB_URL :=3D @NEWLIB_URL@ LWIP_VERSION :=3D @LWIP_VERSION@ LWIP_URL :=3D @LWIP_URL@ =20 -GRUB_VERSION :=3D @GRUB_VERSION@ -GRUB_URL :=3D @GRUB_URL@ - GMP_VERSION :=3D @GMP_VERSION@ GMP_URL :=3D @GMP_URL@ =20 diff --git a/stubdom/.gitignore b/stubdom/.gitignore index 1b69656d45..08f2e9b432 100644 --- a/stubdom/.gitignore +++ b/stubdom/.gitignore @@ -9,7 +9,6 @@ /cross-root-* /gcc-* /gmp-* -/grub-* /include /libs-* /libxencall-* diff --git a/stubdom/Makefile b/stubdom/Makefile index acd5e56f16..850e8544ca 100644 --- a/stubdom/Makefile +++ b/stubdom/Makefile @@ -361,32 +361,6 @@ vtpmmgr-minios-config.mk: $(CURDIR)/vtpmmgr/minios.cfg vtpmmgr: cross-polarssl vtpmmgr-minios-config.mk XEN_TARGET_ARCH=3D"$(XEN_TARGET_ARCH)" CPPFLAGS=3D"$(TARGET_CPPFLAGS) $(s= hell cat vtpmmgr-minios-config.mk)" CFLAGS=3D"$(TARGET_CFLAGS)" $(MAKE) -C = $@ =20 -###### -# Grub -###### - -grub-$(GRUB_VERSION).tar.gz: - $(FETCHER) $@ $(GRUB_URL)/$@ - -grub-upstream: grub-$(GRUB_VERSION).tar.gz - tar xzf $< - mv grub-$(GRUB_VERSION) $@ - for i in grub.patches/* ; do \ - patch -d $@ -p1 < $$i || exit 1; \ - done - -grub/minios.gen.cfg: APP_LIBS =3D guest ctrl toollog -grub/minios.gen.cfg: grub/minios.cfg Makefile - $(GEN_config) >$@ - -grub-$(XEN_TARGET_ARCH)-minios-config.mk: grub/minios.gen.cfg - MINIOS_CONFIG=3D"$(CURDIR)/$<" CONFIG_FILE=3D"$(CURDIR)/$@" $(MAKE) DESTD= IR=3D -C $(MINI_OS) config - -.PHONY: grub -grub: cross-polarssl grub-upstream $(CROSS_ROOT) grub-$(XEN_TARGET_ARCH)-m= inios-config.mk - mkdir -p grub-$(XEN_TARGET_ARCH) - CPPFLAGS=3D"$(TARGET_CPPFLAGS) $(shell cat grub-$(XEN_TARGET_ARCH)-minios= -config.mk)" CFLAGS=3D"$(TARGET_CFLAGS)" $(MAKE) DESTDIR=3D -C $@ OBJ_DIR= =3D$(CURDIR)/grub-$(XEN_TARGET_ARCH) - ########## # xenstore ########## @@ -429,17 +403,6 @@ vtpm-stubdom: mini-os-$(XEN_TARGET_ARCH)-vtpm vtpm vtpmmgr-stubdom: mini-os-$(XEN_TARGET_ARCH)-vtpmmgr vtpmmgr DEF_CPPFLAGS=3D"$(TARGET_CPPFLAGS)" DEF_CFLAGS=3D"$(TARGET_CFLAGS)" DEF_L= DFLAGS=3D"$(TARGET_LDFLAGS)" MINIOS_CONFIG=3D"$(CURDIR)/vtpmmgr/minios.cfg"= $(MAKE) -C $(MINI_OS) OBJ_DIR=3D$(CURDIR)/$< APP_OBJS=3D"$(CURDIR)/vtpmmgr= /vtpmmgr.a" APP_LDLIBS=3D"-lm -lpolarssl" =20 -.PHONY: pv-grub -pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxenguest grub - DEF_CPPFLAGS=3D"$(TARGET_CPPFLAGS)" DEF_CFLAGS=3D"$(TARGET_CFLAGS)" DEF_L= DFLAGS=3D"$(TARGET_LDFLAGS)" MINIOS_CONFIG=3D"$(CURDIR)/grub/minios.gen.cfg= " $(MAKE) DESTDIR=3D -C $(MINI_OS) OBJ_DIR=3D$(CURDIR)/$< APP_OBJS=3D$(CURD= IR)/grub-$(XEN_TARGET_ARCH)/main.a - -.PHONY: pv-grub-if-enabled -ifneq ($(filter grub,$(STUBDOM_TARGETS)),) -pv-grub-if-enabled: pv-grub -else -pv-grub-if-enabled: -endif - XENSTORE_DEPS :=3D libxenevtchn libxengnttab libxenmanage =20 .PHONY: xenstore-stubdom @@ -460,16 +423,6 @@ else install: endif =20 -install-grub: pv-grub - $(INSTALL_DIR) "$(DESTDIR)$(XENFIRMWAREDIR)" - $(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-grub/mini-os.gz "$(DESTDIR)$(X= ENFIRMWAREDIR)/pv-grub-$(XEN_TARGET_ARCH).gz" - -ifneq ($(filter grub,$(STUBDOM_TARGETS)),) -install-grub-if-enabled: install-grub -else -install-grub-if-enabled: -endif - install-xenstore: xenstore-stubdom $(INSTALL_DIR) "$(DESTDIR)$(XENFIRMWAREDIR)" $(INSTALL_DATA) mini-os-$(XEN_TARGET_ARCH)-xenstore/mini-os.gz "$(DESTDIR= )$(XENFIRMWAREDIR)/xenstore-stubdom.gz" @@ -500,9 +453,6 @@ else uninstall: endif =20 -uninstall-grub: - rm -f $(DESTDIR)$(XENFIRMWAREDIR)/pv-grub-$(XEN_TARGET_ARCH).gz - uninstall-xenstore: rm -f $(DESTDIR)$(XENFIRMWAREDIR)/xenstore-stubdom.gz =20 @@ -523,14 +473,12 @@ uninstall-vtpmmgr: .PHONY: clean clean: $(foreach lib,$(STUB_LIBS),clean-libxen$(lib)) clean: - rm -fr mini-os-$(XEN_TARGET_ARCH)-grub rm -fr mini-os-$(XEN_TARGET_ARCH)-xenstore rm -fr mini-os-$(XEN_TARGET_ARCH)-xenstorepvh rm -fr mini-os-$(XEN_TARGET_ARCH)-vtpm rm -fr mini-os-$(XEN_TARGET_ARCH)-vtpmmgr $(MAKE) -C vtpm clean $(MAKE) -C vtpmmgr clean - rm -fr grub-$(XEN_TARGET_ARCH) rm -f *-minios-config.mk rm -f *.gen.cfg rm -fr pkg-config @@ -559,7 +507,6 @@ patchclean: crossclean rm -fr polarssl-$(XEN_TARGET_ARCH) rm -fr tpm_emulator-$(XEN_TARGET_ARCH) rm -fr lwip-$(XEN_TARGET_ARCH) - rm -fr grub-upstream =20 # clean downloads .PHONY: downloadclean @@ -569,7 +516,6 @@ downloadclean: patchclean rm -f gmp-$(GMP_VERSION).tar.bz2 rm -f tpm_emulator-$(TPMEMU_VERSION).tar.gz rm -f pciutils-$(LIBPCI_VERSION).tar.bz2 - rm -f grub-$(GRUB_VERSION).tar.gz rm -f lwip-$(LWIP_VERSION).tar.gz rm -f polarssl-$(POLARSSL_VERSION)-gpl.tgz =20 diff --git a/stubdom/configure b/stubdom/configure index 8a0a798bd2..689ff4d6ed 100755 --- a/stubdom/configure +++ b/stubdom/configure @@ -630,8 +630,6 @@ POLARSSL_VERSION POLARSSL_URL GMP_VERSION GMP_URL -GRUB_VERSION -GRUB_URL LWIP_VERSION LWIP_URL NEWLIB_VERSION @@ -660,7 +658,6 @@ extfiles debug xenstorepvh xenstore -grub host_os host_vendor host_cpu @@ -711,7 +708,6 @@ SHELL' ac_subst_files=3D'' ac_user_opts=3D' enable_option_checking -enable_pv_grub enable_xenstore_stubdom enable_xenstorepvh_stubdom enable_vtpm_stubdom @@ -732,7 +728,6 @@ ZLIB_URL LIBPCI_URL NEWLIB_URL LWIP_URL -GRUB_URL GMP_URL POLARSSL_URL TPMEMU_URL' @@ -1358,7 +1353,6 @@ Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE= =3Dno) --enable-FEATURE[=3DARG] include FEATURE [ARG=3Dyes] - --enable-pv-grub Build and install pv-grub (default is DISABLED) --disable-xenstore-stubdom Build and install xenstore-stubdom (default is ENABLED) @@ -1385,7 +1379,6 @@ Some influential environment variables: LIBPCI_URL Download url for libpci NEWLIB_URL Download url for newlib LWIP_URL Download url for lwip - GRUB_URL Download url for grub GMP_URL Download url for libgmp POLARSSL_URL Download url for polarssl @@ -2403,47 +2396,6 @@ case $host_os in *\ *) host_os=3D`echo "$host_os" | = sed 's/ /-/g'`;; esac =20 # Enable/disable stub domains =20 -# Check whether --enable-pv-grub was given. -if test ${enable_pv_grub+y} -then : - enableval=3D$enable_pv_grub; - -if test "x$enableval" =3D "xyes" -then : - - -grub=3Dy -STUBDOM_TARGETS=3D"$STUBDOM_TARGETS grub" -STUBDOM_BUILD=3D"$STUBDOM_BUILD pv-grub" -STUBDOM_INSTALL=3D"$STUBDOM_INSTALL install-grub" -STUBDOM_UNINSTALL=3D"$STUBDOM_UNINSTALL install-grub" - - -else $as_nop - -if test "x$enableval" =3D "xno" -then : - - -grub=3Dn - - -fi - -fi - - -else $as_nop - - -grub=3Dn - - -fi - - - - # Check whether --enable-xenstore-stubdom was given. if test ${enable_xenstore_stubdom+y} then : @@ -4137,23 +4089,6 @@ LWIP_VERSION=3D"1.3.0" =20 =20 =20 -if test "x$GRUB_URL" =3D "x" -then : - - if test "x$extfiles" =3D "xy" -then : - GRUB_URL=3D\$\(XEN_EXTFILES_URL\) -else $as_nop - GRUB_URL=3D"https://alpha.gnu.org/gnu/grub" -fi - -fi -GRUB_VERSION=3D"0.97" - - - - - if test "x$GMP_URL" =3D "x" then : =20 diff --git a/stubdom/configure.ac b/stubdom/configure.ac index 33f170144e..6ff3ab0ee9 100644 --- a/stubdom/configure.ac +++ b/stubdom/configure.ac @@ -18,7 +18,6 @@ m4_include([../m4/depends.m4]) m4_include([../m4/fetcher.m4]) =20 # Enable/disable stub domains -AX_STUBDOM_DEFAULT_DISABLE([pv-grub], [grub]) AX_STUBDOM_DEFAULT_ENABLE([xenstore-stubdom], [xenstore]) AX_STUBDOM_DEFAULT_ENABLE([xenstorepvh-stubdom], [xenstorepvh]) AX_STUBDOM_CONDITIONAL([vtpm-stubdom], [vtpm]) @@ -43,7 +42,6 @@ AX_STUBDOM_LIB([ZLIB], [zlib], [1.2.3]) AX_STUBDOM_LIB([LIBPCI], [libpci], [2.2.9], [https://mirrors.edge.kernel.o= rg/pub/software/utils/pciutils]) AX_STUBDOM_LIB([NEWLIB], [newlib], [1.16.0], [https://sourceware.org/ftp/n= ewlib]) AX_STUBDOM_LIB([LWIP], [lwip], [1.3.0], [https://download.savannah.gnu.org= /releases/lwip]) -AX_STUBDOM_LIB([GRUB], [grub], [0.97], [https://alpha.gnu.org/gnu/grub]) AX_STUBDOM_LIB([GMP], [libgmp], [4.3.2], [https://gmplib.org/download/gmp/= archive]) AX_STUBDOM_LIB([POLARSSL], [polarssl], [1.1.4]) AX_STUBDOM_LIB([TPMEMU], [berlios tpm emulator], [0.7.4]) diff --git a/stubdom/grub.patches/00cvs b/stubdom/grub.patches/00cvs deleted file mode 100644 index 47d66f3a3b..0000000000 --- a/stubdom/grub.patches/00cvs +++ /dev/null @@ -1,1022 +0,0 @@ -diff -uprN grub-0.97/acinclude.m4 grub/acinclude.m4 ---- grub-0.97/acinclude.m4 2004-04-27 21:48:06.000000000 +0100 -+++ grub/acinclude.m4 2007-11-05 01:29:46.000000000 +0000 -@@ -57,7 +57,7 @@ else - fi - grub_cv_prog_objcopy_absolute=3Dyes - for link_addr in 2000 8000 7C00; do -- if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$= link_addr conftest.o -o conftest.exec]); then : -+ if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} ${LDFLAGS} -nostdlib -Wl,-N -Wl,-= Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then : - else - AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr]) - fi -diff -uprN grub-0.97/ChangeLog grub/ChangeLog ---- grub-0.97/ChangeLog 2005-05-08 03:47:02.000000000 +0100 -+++ grub/ChangeLog 2008-05-20 12:04:18.000000000 +0100 -@@ -1,3 +1,127 @@ -+2008-05-20 Robert Millan -+ -+ * netboot/cs89x0.c: Fix license violation. -+ * netboot/cs89x0.h: Likewise. -+ -+2008-04-10 Pavel Roskin -+ -+ * configure.ac: Always use "_cv_" in cache variables for -+ compatibility with Autoconf 2.62. -+ -+2008-03-28 Robert Millan -+ -+ Surpass 1 TiB disk addressing limit. Note: there are no plans to handle -+ the 2 TiB disk limit in GRUB Legacy, since that would need considerable -+ rework. If you have >2TiB disks, use GRUB 2 instead. -+ -+ * grub/asmstub.c (biosdisk): Add unsigned qualifier to `sector'. -+ * stage2/bios.c (biosdisk): Likewise. -+ * stage2/disk_io.c (rawread, devread, rawwrite, devwrite): Likewise. -+ * stage2/shared.h (rawread, devread, rawwrite, devwrite): Likewise. -+ * lib/device.c (get_drive_geometry): Replace BLKGETSIZE with -+ BLKGETSIZE64. -+ -+2007-10-29 Pavel Roskin -+ -+ * configure.ac: Test if '--build-id=3Dnone' is supported by the -+ linker and add it to LDFLAGS if possible. Build ID causes -+ objcopy to generate huge binary files. -+ * aclocal.m4 (grub_PROG_OBJCOPY_ABSOLUTE): Use LDFLAGS when -+ linking, so that build ID doesn't break the test. -+ * stage1/Makefile.am: Preserve LDFLAGS, use stage1_exec_LDFLAGS. -+ -+2007-02-22 Pavel Roskin -+ -+ * stage2/iso9660.h: Remove unnecessary packed attributes. -+ -+2007-02-22 Robert Millan -+ -+ * util/mkbimage: Update my email address, and remove my name from -+ some places where unnecessary credit is given. -+ -+2006-09-10 Pavel Roskin -+ -+ * netboot/natsemi.c: Fix compile error with gcc 4.1.1. Cast -+ cannot make a variable volatile - it should be declared as such. -+ * netboot/sis900.c: Likewise. -+ -+2006-09-08 Pavel Roskin -+ -+ * netboot/etherboot.h: Remove incorrect extern declarations of -+ the variables later declared static. Move BOOTP_DATA_ADDR ... -+ * netboot/main.c: ... here. Eliminate end_of_rfc1533 - it's -+ write-only. -+ -+2006-06-24 Yoshinori K. Okuji -+ -+ * docs/grub.texi: Changed the license term to the GNU Free -+ Documentation License 1.2. -+ -+ * docs/multiboot.texi: Reformatted to show the license term -+ and the version number explicitly. -+=09 -+ * docs/fdl.texi: New file. -+=09 -+ * docs/Makefile.am (grub_TEXINFOS): Added fdl.texi. -+ -+2006-06-24 Robert Millan -+ -+ * lib/device.c (write_to_partition): /dev/ataraid/ and /dev/rd/ -+ partitions have a "p" prefix. Add it. -+ -+2006-06-24 Robert Millan -+ -+ * lib/device.c (get_i2o_disk_name): New function. -+ (init_device_map) [__linux__]: Add support for I2O devices. -+ -+2006-05-02 Pavel Roskin -+ -+ * stage2/stage2.c (run_menu): Fix "savedefault" to save only top -+ level menu positions. Remember current position when calling a -+ submenu. Don't recalculate it when booting from a submenu. -+ -+ * grub/main.c (main): Make sure the boot drive number doesn't -+ exceed 255. -+ -+2006-05-02 Vesa Jaaskelainen -+ -+ * stage2/shared.h (vbe_mode): Back ported aligment fix from GRUB 2 -+ to GRUB Legacy. Problem reported by Gerardo Richarte. -+ -+2006-04-23 Robert Millan -+ -+ * grub/asmstub.c (get_diskinfo): Optimize sysctl routine. -+ -+2006-04-20 Robert Millan -+ -+ Fixes for kernel of FreeBSD: -+ * grub/asmstub.c (get_diskinfo): Toggle "kern.geom.debugflags" sysctl -+ before opening a device for writing. -+ * util/grub-install.in: Devices don't have this "r" prefix anymore. -+ -+2006-04-16 Yoshinori K. Okuji -+ -+ * docs/multiboot.texi: Correct the offset of address -+ fields. Reported by Jeroen Dekkers. -+ -+2006-03-21 Yoshinori K. Okuji -+ -+ * stage2/builtins.c (setup_func): Specify the size of DEVICE to -+ grub_strncat instead of a strange number 256. Reported by Vitaly -+ Fertman . -+ -+2005-09-29 Yoshinori K. Okuji -+ -+ * docs/multiboot.texi: Fix a bug in the byte order of -+ boot_device. I hope this won't affect any OS image. -+ Increased the version number to 0.6.94. -+ -+2005-09-28 Yoshinori K. Okuji -+ -+ * stage2/boot.c (load_image): Even if an OS image is an ELF -+ object, use the a.out kludge if MULTIBOOT_AOUT_KLUDGE is -+ specified. -+ - 2005-05-08 Yoshinori K. Okuji -=20 - * configure.ac (AC_INIT): Upgraded to 0.97. -diff -uprN grub-0.97/configure grub/configure ---- grub-0.97/configure 2005-05-08 03:48:12.000000000 +0100 -+++ grub/configure 2007-11-05 01:29:46.000000000 +0000 -@@ -3694,6 +3694,64 @@ if test "x$undef_flag" =3D xyes; then - CPPFLAGS=3D"$CPPFLAGS -Wundef" - fi -=20 -+# Check if build ID can be disabled in the linker -+echo "$as_me:$LINENO: checking whether linker accepts \`--build-id=3Dnone= '" >&5 -+echo $ECHO_N "checking whether linker accepts \`--build-id=3Dnone'... $EC= HO_C" >&6 -+save_LDFLAGS=3D"$LDFLAGS" -+LDFLAGS=3D"$LDFLAGS -Wl,--build-id=3Dnone" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+int -+main () -+{ -+ -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=3D$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? =3D $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try=3D'test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=3D$? -+ echo "$as_me:$LINENO: \$? =3D $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try=3D'test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=3D$? -+ echo "$as_me:$LINENO: \$? =3D $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ build_id_flag=3Dyes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+build_id_flag=3Dno -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+echo "$as_me:$LINENO: result: $build_id_flag" >&5 -+echo "${ECHO_T}$build_id_flag" >&6 -+LDFLAGS=3D"$save_LDFLAGS" -+if test "x$build_id_flag" =3D xyes; then -+ LDFLAGS=3D"$LDFLAGS -Wl,--build-id=3Dnone" -+fi -+ - if test "x$with_binutils" !=3D x; then - # Extract the first word of "objcopy", so it can be a program name with= args. - set dummy objcopy; ac_word=3D$2 -@@ -3892,7 +3950,7 @@ echo "$as_me: error: ${CC-cc} cannot com - fi - grub_cv_prog_objcopy_absolute=3Dyes - for link_addr in 2000 8000 7C00; do -- if { ac_try=3D'${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link= _addr conftest.o -o conftest.exec' -+ if { ac_try=3D'${CC-cc} ${CFLAGS} ${LDFLAGS} -nostdlib -Wl,-N -Wl,-Ttex= t -Wl,$link_addr conftest.o -o conftest.exec' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=3D$? -diff -uprN grub-0.97/configure.ac grub/configure.ac ---- grub-0.97/configure.ac 2005-05-08 03:36:03.000000000 +0100 -+++ grub/configure.ac 2008-04-10 23:26:50.000000000 +0100 -@@ -86,13 +86,13 @@ if test "x$ac_cv_prog_gcc" =3D xyes; then - fi - STAGE1_CFLAGS=3D"-O2" - GRUB_CFLAGS=3D"-O2" -- AC_CACHE_CHECK([whether optimization for size works], size_flag, [ -+ AC_CACHE_CHECK([whether optimization for size works], grub_cv_cc_Os, [ - saved_CFLAGS=3D$CFLAGS - CFLAGS=3D"-Os -g" -- AC_TRY_COMPILE(, , size_flag=3Dyes, size_flag=3Dno) -+ AC_TRY_COMPILE(, , grub_cv_cc_Os=3Dyes, grub_cv_cc_Os=3Dno) - CFLAGS=3D$saved_CFLAGS - ]) -- if test "x$size_flag" =3D xyes; then -+ if test "x$grub_cv_cc_Os" =3D xyes; then - STAGE2_CFLAGS=3D"-Os" - else - STAGE2_CFLAGS=3D"-O2 -fno-strength-reduce -fno-unroll-loops" -@@ -100,16 +100,16 @@ if test "x$ac_cv_prog_gcc" =3D xyes; then - # OpenBSD has a GCC extension for protecting applications from - # stack smashing attacks, but GRUB doesn't want this feature. - AC_CACHE_CHECK([whether gcc has -fno-stack-protector], -- no_stack_protector_flag, [ -+ grub_cv_cc_no_stack_protector, [ - saved_CFLAGS=3D$CFLAGS - CFLAGS=3D"-fno-stack-protector" - AC_TRY_COMPILE(, - , -- no_stack_protector_flag=3Dyes, -- no_stack_protector_flag=3Dno) -+ grub_cv_cc_no_stack_protector=3Dyes, -+ grub_cv_cc_no_stack_protector=3Dno) - CFLAGS=3D$saved_CFLAGS - ]) -- if test "x$no_stack_protector_flag" =3D xyes; then -+ if test "x$grub_cv_cc_no_stack_protector" =3D xyes; then - STAGE2_CFLAGS=3D"$STAGE2_CFLAGS -fno-stack-protector" - fi - fi -@@ -123,33 +123,44 @@ AC_SUBST(GRUB_CFLAGS) - CPPFLAGS=3D"$CPPFLAGS -Wall -Wmissing-prototypes -Wunused -Wshadow" - CPPFLAGS=3D"$CPPFLAGS -Wpointer-arith" -=20 --AC_CACHE_CHECK([whether -Wundef works], undef_flag, [ -+AC_CACHE_CHECK([whether -Wundef works], grub_cv_cc_Wundef, [ - saved_CPPFLAGS=3D"$CPPFLAGS" - CPPFLAGS=3D"-Wundef" -- AC_TRY_COMPILE(, , undef_flag=3Dyes, undef_flag=3Dno) -+ AC_TRY_COMPILE(, , grub_cv_cc_Wundef=3Dyes, grub_cv_cc_Wundef=3Dno) - CPPFLAGS=3D"$saved_CPPFLAGS" - ]) -=20 - # The options `-falign-*' are supported by gcc 3.0 or later. - # Probably it is sufficient to only check for -falign-loops. --AC_CACHE_CHECK([whether -falign-loops works], [falign_loop_flag], [ -+AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [ - saved_CPPFLAGS=3D"$CPPFLAGS" - CPPFLAGS=3D"-falign-loops=3D1" -- AC_TRY_COMPILE(, , [falign_loop_flag=3Dyes], [falign_loop_flag=3Dno]) -+ AC_TRY_COMPILE(, , [grub_cv_cc_falign_loop=3Dyes], [grub_cv_cc_falign_l= oop=3Dno]) - CPPFLAGS=3D"$saved_CPPFLAGS" - ]) -=20 - # Force no alignment to save space. --if test "x$falign_loop_flag" =3D xyes; then -+if test "x$grub_cv_cc_falign_loop" =3D xyes; then - CPPFLAGS=3D"$CPPFLAGS -falign-jumps=3D1 -falign-loops=3D1 -falign-funct= ions=3D1" - else - CPPFLAGS=3D"$CPPFLAGS -malign-jumps=3D1 -malign-loops=3D1 -malign-funct= ions=3D1" - fi -=20 --if test "x$undef_flag" =3D xyes; then -+if test "x$grub_cv_cc_Wundef" =3D xyes; then - CPPFLAGS=3D"$CPPFLAGS -Wundef" - fi -=20 -+# Check if build ID can be disabled in the linker -+AC_MSG_CHECKING([whether linker accepts `--build-id=3Dnone']) -+save_LDFLAGS=3D"$LDFLAGS" -+LDFLAGS=3D"$LDFLAGS -Wl,--build-id=3Dnone" -+AC_TRY_LINK(, , build_id_flag=3Dyes, build_id_flag=3Dno) -+AC_MSG_RESULT([$build_id_flag]) -+LDFLAGS=3D"$save_LDFLAGS" -+if test "x$build_id_flag" =3D xyes; then -+ LDFLAGS=3D"$LDFLAGS -Wl,--build-id=3Dnone" -+fi -+ - if test "x$with_binutils" !=3D x; then - dnl AC_PATH_TOOL(OBJCOPY, objcopy, , "$with_binutils:$PATH") - AC_PATH_PROG(OBJCOPY, objcopy, , "$with_binutils:$PATH") -diff -uprN grub-0.97/grub/asmstub.c grub/grub/asmstub.c ---- grub-0.97/grub/asmstub.c 2005-02-16 20:45:14.000000000 +0000 -+++ grub/grub/asmstub.c 2008-03-28 13:22:28.000000000 +0000 -@@ -55,6 +55,10 @@ int grub_stage2 (void); - # endif /* ! BLKFLSBUF */ - #endif /* __linux__ */ -=20 -+#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__) -+# include -+#endif -+ - /* We want to prevent any circularararity in our stubs, as well as - libc name clashes. */ - #define WITHOUT_LIBC_STUBS 1 -@@ -777,7 +781,39 @@ get_diskinfo (int drive, struct geometry -=20 - /* Open read/write, or read-only if that failed. */ - if (! read_only) -- disks[drive].flags =3D open (devname, O_RDWR); -+ { -+/* By default, kernel of FreeBSD does not allow overwriting MBR */ -+#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__) -+#define GEOM_SYSCTL "kern.geom.debugflags" -+ int old_flags, flags; -+ size_t sizeof_int =3D sizeof (int); -+ -+ if (sysctlbyname (GEOM_SYSCTL, &old_flags, &sizeof_int, NULL, 0) !=3D = 0) -+ grub_printf ("failed to get " GEOM_SYSCTL "sysctl: %s\n", strerror (= errno)); -+ -+ if ((old_flags & 0x10) =3D=3D 0) -+ { -+ /* "allow foot shooting", see geom(4) */ -+ flags =3D old_flags | 0x10; -+ -+ if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &flags, sizeof (int)) != =3D 0) -+ { -+ flags =3D old_flags; -+ grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerror (e= rrno)); -+ } -+ } -+ else -+ flags =3D old_flags; -+#endif -+ disks[drive].flags =3D open (devname, O_RDWR); -+#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__) -+ if (flags !=3D old_flags) -+ { -+ if (sysctlbyname (GEOM_SYSCTL, NULL, NULL, &old_flags, sizeof (int= )) !=3D 0) -+ grub_printf ("failed to set " GEOM_SYSCTL "sysctl: %s\n", strerr= or (errno)); -+ } -+#endif -+ } -=20 - if (disks[drive].flags =3D=3D -1) - { -@@ -926,7 +962,7 @@ hex_dump (void *buf, size_t size) -=20 - int - biosdisk (int subfunc, int drive, struct geometry *geometry, -- int sector, int nsec, int segment) -+ unsigned int sector, int nsec, int segment) - { - char *buf; - int fd =3D geometry->flags; -diff -uprN grub-0.97/grub/main.c grub/grub/main.c ---- grub-0.97/grub/main.c 2003-07-09 12:45:36.000000000 +0100 -+++ grub/grub/main.c 2006-05-05 22:43:46.000000000 +0100 -@@ -32,6 +32,7 @@ int grub_stage2 (void); - #define WITHOUT_LIBC_STUBS 1 - #include - #include -+#include -=20 - char *program_name =3D 0; - int use_config_file =3D 1; -@@ -192,6 +193,12 @@ main (int argc, char **argv) - perror ("strtoul"); - exit (1); - } -+ if (boot_drive >=3D NUM_DISKS) -+ { -+ fprintf (stderr, "boot_drive should be from 0 to %d\n", -+ NUM_DISKS - 1); -+ exit (1); -+ } - break; -=20 - case OPT_NO_CONFIG_FILE: -diff -uprN grub-0.97/lib/device.c grub/lib/device.c ---- grub-0.97/lib/device.c 2005-03-28 00:14:25.000000000 +0100 -+++ grub/lib/device.c 2008-03-28 13:22:28.000000000 +0000 -@@ -69,9 +69,9 @@ struct hd_geometry - # ifndef CDROM_GET_CAPABILITY - # define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */ - # endif /* ! CDROM_GET_CAPABILITY */ --# ifndef BLKGETSIZE --# define BLKGETSIZE _IO(0x12,96) /* return device size */ --# endif /* ! BLKGETSIZE */ -+# ifndef BLKGETSIZE64 -+# define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size */ -+# endif /* ! BLKGETSIZE64 */ - #endif /* __linux__ */ -=20 - /* Use __FreeBSD_kernel__ instead of __FreeBSD__ for compatibility with -@@ -152,19 +152,19 @@ get_drive_geometry (struct geometry *geo - /* Linux */ - { - struct hd_geometry hdg; -- unsigned long nr; -+ unsigned long long nr; - =20 - if (ioctl (fd, HDIO_GETGEO, &hdg)) - goto fail; -=20 -- if (ioctl (fd, BLKGETSIZE, &nr)) -+ if (ioctl (fd, BLKGETSIZE64, &nr)) - goto fail; - =20 - /* Got the geometry, so save it. */ - geom->cylinders =3D hdg.cylinders; - geom->heads =3D hdg.heads; - geom->sectors =3D hdg.sectors; -- geom->total_sectors =3D nr; -+ geom->total_sectors =3D nr / 512; - =20 - goto success; - } -@@ -407,6 +407,12 @@ get_ataraid_disk_name (char *name, int u - { - sprintf (name, "/dev/ataraid/d%c", unit + '0'); - } -+ -+static void -+get_i2o_disk_name (char *name, char unit) -+{ -+ sprintf (name, "/dev/i2o/hd%c", unit); -+} - #endif -=20 - /* Check if DEVICE can be read. If an error occurs, return zero, -@@ -801,6 +807,29 @@ init_device_map (char ***map, const char - } - } - } -+ =20 -+ /* This is for I2O - we have /dev/i2o/hd */ -+ { -+ int unit; -+ -+ for (unit =3D 'a'; unit < 'f'; unit++) -+ { -+ char name[24]; -+ =20 -+ get_i2o_disk_name (name, unit); -+ if (check_device (name)) -+ { -+ (*map)[num_hd + 0x80] =3D strdup (name); -+ assert ((*map)[num_hd + 0x80]); -+ =20 -+ /* If the device map file is opened, write the map. */ -+ if (fp) -+ fprintf (fp, "(hd%d)\t%s\n", num_hd, name); -+ =20 -+ num_hd++; -+ } -+ } -+ } - #endif /* __linux__ */ - =20 - /* OK, close the device map file if opened. */ -@@ -861,6 +890,12 @@ write_to_partition (char **map, int driv - if (strcmp (dev + strlen(dev) - 5, "/disc") =3D=3D 0) - strcpy (dev + strlen(dev) - 5, "/part"); - } -+ else -+ { -+ if ((strncmp (dev, "/dev/ataraid/", 13) =3D=3D 0) || -+ (strncmp (dev, "/dev/rd/", 8) =3D=3D 0)) -+ strcpy (dev + strlen(dev), "p"); -+ } - sprintf (dev + strlen(dev), "%d", ((partition >> 16) & 0xFF) + 1); - =20 - /* Open the partition. */ -diff -uprN grub-0.97/netboot/3c509.c grub/netboot/3c509.c ---- grub-0.97/netboot/3c509.c 2003-07-09 12:45:37.000000000 +0100 -+++ grub/netboot/3c509.c 2002-01-02 21:56:40.000000000 +0000 -@@ -18,7 +18,7 @@ Author: Martin Renters. -=20 - 3c509 support added by Serge Babkin (babkin@hq.icb.chel.su) -=20 --$Id: 3c509.c,v 1.4 2002/01/02 21:56:40 okuji Exp $ -+$Id: 3c509.c 609 2002-01-02 21:56:40Z okuji $ -=20 - *************************************************************************= **/ -=20 -diff -uprN grub-0.97/netboot/cs89x0.c grub/netboot/cs89x0.c ---- grub-0.97/netboot/cs89x0.c 2003-07-09 12:45:37.000000000 +0100 -+++ grub/netboot/cs89x0.c 2008-05-20 12:04:18.000000000 +0100 -@@ -1,3 +1,21 @@ -+/** -+ Per an email message from Russ Nelson on -+ 18 March 2008 this file is now licensed under GPL Version 2. -+ -+ From: Russ Nelson -+ Date: Tue, 18 Mar 2008 12:42:00 -0400 -+ Subject: Re: [Etherboot-developers] cs89x0 driver in etherboot -+ -- quote from email -+ As copyright holder, if I say it doesn't conflict with the GPL, -+ then it doesn't conflict with the GPL. -+ -+ However, there's no point in causing people's brains to overheat, -+ so yes, I grant permission for the code to be relicensed under the -+ GPLv2. Please make sure that this change in licensing makes its -+ way upstream. -russ -+ -- quote from email -+**/ -+ - /* cs89x0.c: A Crystal Semiconductor CS89[02]0 driver for etherboot. */ - /* - Permission is granted to distribute the enclosed cs89x0.[ch] driver -diff -uprN grub-0.97/netboot/cs89x0.h grub/netboot/cs89x0.h ---- grub-0.97/netboot/cs89x0.h 2003-07-09 12:45:37.000000000 +0100 -+++ grub/netboot/cs89x0.h 2008-05-20 12:04:18.000000000 +0100 -@@ -1,3 +1,21 @@ -+/** -+ Per an email message from Russ Nelson on -+ 18 March 2008 this file is now licensed under GPL Version 2. -+ -+ From: Russ Nelson -+ Date: Tue, 18 Mar 2008 12:42:00 -0400 -+ Subject: Re: [Etherboot-developers] cs89x0 driver in etherboot -+ -- quote from email -+ As copyright holder, if I say it doesn't conflict with the GPL, -+ then it doesn't conflict with the GPL. -+ -+ However, there's no point in causing people's brains to overheat, -+ so yes, I grant permission for the code to be relicensed under the -+ GPLv2. Please make sure that this change in licensing makes its -+ way upstream. -russ -+ -- quote from email -+**/ -+ - /* Copyright, 1988-1992, Russell Nelson, Crynwr Software -=20 - This program is free software; you can redistribute it and/or modify -diff -uprN grub-0.97/netboot/etherboot.h grub/netboot/etherboot.h ---- grub-0.97/netboot/etherboot.h 2003-07-09 12:45:37.000000000 +0100 -+++ grub/netboot/etherboot.h 2006-09-08 13:56:22.000000000 +0100 -@@ -531,9 +531,6 @@ extern int ip_abort; - extern int network_ready; - extern struct rom_info rom; - extern struct arptable_t arptable[MAX_ARP]; --extern struct bootpd_t bootp_data; --#define BOOTP_DATA_ADDR (&bootp_data) --extern unsigned char *end_of_rfc1533; -=20 - /* config.c */ - extern struct nic nic; -diff -uprN grub-0.97/netboot/main.c grub/netboot/main.c ---- grub-0.97/netboot/main.c 2004-05-20 23:19:33.000000000 +0100 -+++ grub/netboot/main.c 2006-09-08 13:56:22.000000000 +0100 -@@ -56,7 +56,8 @@ static int vendorext_isvalid; - static unsigned long netmask; - static struct bootpd_t bootp_data; - static unsigned long xid; --static unsigned char *end_of_rfc1533 =3D NULL; -+ -+#define BOOTP_DATA_ADDR (&bootp_data) -=20 - #ifndef NO_DHCP_SUPPORT - #endif /* NO_DHCP_SUPPORT */ -@@ -967,7 +968,6 @@ decode_rfc1533 (unsigned char *p, int bl - =20 - if (block =3D=3D 0) - { -- end_of_rfc1533 =3D NULL; - vendorext_isvalid =3D 0; - =20 - if (grub_memcmp (p, rfc1533_cookie, 4)) -@@ -1021,7 +1021,7 @@ decode_rfc1533 (unsigned char *p, int bl - } - else if (c =3D=3D RFC1533_END) - { -- end_of_rfc1533 =3D endp =3D p; -+ endp =3D p; - continue; - } - else if (c =3D=3D RFC1533_NETMASK) -diff -uprN grub-0.97/netboot/natsemi.c grub/netboot/natsemi.c ---- grub-0.97/netboot/natsemi.c 2003-07-09 12:45:38.000000000 +0100 -+++ grub/netboot/natsemi.c 2006-09-10 08:26:10.000000000 +0100 -@@ -608,7 +608,7 @@ natsemi_transmit(struct nic *nic, - const char *p) /* Packet */ - { - u32 status, to, nstype; -- u32 tx_status; -+ volatile u32 tx_status; - =20 - /* Stop the transmitter */ - outl(TxOff, ioaddr + ChipCmd); -@@ -647,7 +647,7 @@ natsemi_transmit(struct nic *nic, -=20 - to =3D currticks() + TX_TIMEOUT; -=20 -- while ((((volatile u32) tx_status=3Dtxd.cmdsts) & OWN) && (currticks(= ) < to)) -+ while (((tx_status=3Dtxd.cmdsts) & OWN) && (currticks() < to)) - /* wait */ ; -=20 - if (currticks() >=3D to) { -diff -uprN grub-0.97/netboot/sis900.c grub/netboot/sis900.c ---- grub-0.97/netboot/sis900.c 2003-07-09 12:45:38.000000000 +0100 -+++ grub/netboot/sis900.c 2006-09-10 08:26:10.000000000 +0100 -@@ -901,7 +901,7 @@ sis900_transmit(struct nic *nic, - const char *p) /* Packet */ - { - u32 status, to, nstype; -- u32 tx_status; -+ volatile u32 tx_status; - =20 - /* Stop the transmitter */ - outl(TxDIS, ioaddr + cr); -@@ -940,7 +940,7 @@ sis900_transmit(struct nic *nic, -=20 - to =3D currticks() + TX_TIMEOUT; -=20 -- while ((((volatile u32) tx_status=3Dtxd.cmdsts) & OWN) && (currticks(= ) < to)) -+ while (((tx_status=3Dtxd.cmdsts) & OWN) && (currticks() < to)) - /* wait */ ; -=20 - if (currticks() >=3D to) { -diff -uprN grub-0.97/netboot/sk_g16.c grub/netboot/sk_g16.c ---- grub-0.97/netboot/sk_g16.c 2003-07-09 12:45:38.000000000 +0100 -+++ grub/netboot/sk_g16.c 2002-01-02 21:56:40.000000000 +0000 -@@ -13,12 +13,12 @@ Changes to make it work with Etherboot b - * - * Module : sk_g16.c - * -- * Version : $Revision: 1.4 $ -+ * Version : $Revision: 609 $ - * - * Author : Patrick J.D. Weichmann - * - * Date Created : 94/05/26 -- * Last Updated : $Date: 2002/01/02 21:56:40 $ -+ * Last Updated : $Date: 2002-01-02 21:56:40 +0000 (mer 02 jan 2002) $ - * - * Description : Schneider & Koch G16 Ethernet Device Driver for - * Linux Kernel >=3D 1.1.22 -diff -uprN grub-0.97/netboot/sk_g16.h grub/netboot/sk_g16.h ---- grub-0.97/netboot/sk_g16.h 2003-07-09 12:45:38.000000000 +0100 -+++ grub/netboot/sk_g16.h 2000-07-29 20:22:54.000000000 +0100 -@@ -4,7 +4,7 @@ - * of the GNU Public License, incorporated herein by reference. - * - * Module : sk_g16.h -- * Version : $Revision: 1.3 $ -+ * Version : $Revision: 388 $ - * - * Author : M.Hipp (mhipp@student.uni-tuebingen.de) - * changes by : Patrick J.D. Weichmann -@@ -15,8 +15,8 @@ - * the am7990 (LANCE) chip used for writing a - * network device driver which uses this chip - * -- * $Log: sk_g16.h,v $ -- * Revision 1.3 2000/07/29 19:22:54 okuji -+ * $Log$ -+ * Revision 1.3 2000-07-29 19:22:54 okuji - * update the network support to etherboot-4.6.4. - * - -*/ -diff -uprN grub-0.97/stage1/Makefile.am grub/stage1/Makefile.am ---- grub-0.97/stage1/Makefile.am 2004-07-16 12:44:56.000000000 +0100 -+++ grub/stage1/Makefile.am 2007-11-05 01:29:46.000000000 +0000 -@@ -5,7 +5,7 @@ CLEANFILES =3D $(nodist_pkglib_DATA) -=20 - # We can't use builtins or standard includes. - AM_CCASFLAGS =3D $(STAGE1_CFLAGS) -fno-builtin -nostdinc --LDFLAGS =3D -nostdlib -Wl,-N,-Ttext,7C00 -+stage1_exec_LDFLAGS =3D -nostdlib -Wl,-N,-Ttext,7C00 -=20 - noinst_PROGRAMS =3D stage1.exec - stage1_exec_SOURCES =3D stage1.S stage1.h -diff -uprN grub-0.97/stage1/Makefile.in grub/stage1/Makefile.in ---- grub-0.97/stage1/Makefile.in 2005-05-08 03:42:36.000000000 +0100 -+++ grub/stage1/Makefile.in 2007-11-05 01:29:46.000000000 +0000 -@@ -110,7 +110,7 @@ INSTALL_DATA =3D @INSTALL_DATA@ - INSTALL_PROGRAM =3D @INSTALL_PROGRAM@ - INSTALL_SCRIPT =3D @INSTALL_SCRIPT@ - INSTALL_STRIP_PROGRAM =3D @INSTALL_STRIP_PROGRAM@ --LDFLAGS =3D -nostdlib -Wl,-N,-Ttext,7C00 -+LDFLAGS =3D @LDFLAGS@ - LIBOBJS =3D @LIBOBJS@ - LIBS =3D @LIBS@ - LTLIBOBJS =3D @LTLIBOBJS@ -@@ -188,6 +188,7 @@ CLEANFILES =3D $(nodist_pkglib_DATA) -=20 - # We can't use builtins or standard includes. - AM_CCASFLAGS =3D $(STAGE1_CFLAGS) -fno-builtin -nostdinc -+stage1_exec_LDFLAGS =3D -nostdlib -Wl,-N,-Ttext,7C00 - stage1_exec_SOURCES =3D stage1.S stage1.h - SUFFIXES =3D .exec - all: all-am -diff -uprN grub-0.97/stage2/bios.c grub/stage2/bios.c ---- grub-0.97/stage2/bios.c 2004-03-27 16:34:04.000000000 +0000 -+++ grub/stage2/bios.c 2008-03-28 13:22:28.000000000 +0000 -@@ -47,7 +47,7 @@ extern int get_diskinfo_floppy (int driv - return the error number. Otherwise, return 0. */ - int - biosdisk (int read, int drive, struct geometry *geometry, -- int sector, int nsec, int segment) -+ unsigned int sector, int nsec, int segment) - { - int err; - =20 -diff -uprN grub-0.97/stage2/boot.c grub/stage2/boot.c ---- grub-0.97/stage2/boot.c 2004-03-30 12:44:08.000000000 +0100 -+++ grub/stage2/boot.c 2005-09-28 22:47:55.000000000 +0100 -@@ -1,7 +1,7 @@ - /* boot.c - load and bootstrap a kernel */ - /* - * GRUB -- GRand Unified Bootloader -- * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation= , Inc. -+ * Copyright (C) 1999,2000,2001,2002,2003,2004,2005 Free Software Found= ation, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by -@@ -96,7 +96,7 @@ load_image (char *kernel, char *arg, ker - lh =3D (struct linux_kernel_header *) buffer; - =20 - /* ELF loading supported if multiboot, FreeBSD and NetBSD. */ -- if ((type =3D=3D KERNEL_TYPE_MULTIBOOT -+ if (((type =3D=3D KERNEL_TYPE_MULTIBOOT && ! (flags & MULTIBOOT_AOUT_KL= UDGE)) - || pu.elf->e_ident[EI_OSABI] =3D=3D ELFOSABI_FREEBSD - || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") =3D=3D 0 - || suggested_type =3D=3D KERNEL_TYPE_NETBSD) -diff -uprN grub-0.97/stage2/builtins.c grub/stage2/builtins.c ---- grub-0.97/stage2/builtins.c 2005-02-15 21:58:23.000000000 +0000 -+++ grub/stage2/builtins.c 2006-03-21 20:51:58.000000000 +0000 -@@ -3830,15 +3830,15 @@ setup_func (char *arg, int flags) - { - char tmp[16]; - grub_sprintf (tmp, ",%d", (partition >> 16) & 0xFF); -- grub_strncat (device, tmp, 256); -+ grub_strncat (device, tmp, sizeof (device)); - } - if ((partition & 0x00FF00) !=3D 0x00FF00) - { - char tmp[16]; - grub_sprintf (tmp, ",%c", 'a' + ((partition >> 8) & 0xFF)); -- grub_strncat (device, tmp, 256); -+ grub_strncat (device, tmp, sizeof (device)); - } -- grub_strncat (device, ")", 256); -+ grub_strncat (device, ")", sizeof (device)); - } - =20 - int embed_stage1_5 (char *stage1_5, int drive, int partition) -diff -uprN grub-0.97/stage2/disk_io.c grub/stage2/disk_io.c ---- grub-0.97/stage2/disk_io.c 2004-05-23 17:35:24.000000000 +0100 -+++ grub/stage2/disk_io.c 2008-03-28 13:22:28.000000000 +0000 -@@ -137,7 +137,7 @@ log2 (unsigned long word) - } -=20 - int --rawread (int drive, int sector, int byte_offset, int byte_len, char *buf) -+rawread (int drive, unsigned int sector, int byte_offset, int byte_len, c= har *buf) - { - int slen, sectors_per_vtrack; - int sector_size_bits =3D log2 (buf_geom.sector_size); -@@ -261,7 +261,7 @@ rawread (int drive, int sector, int byte - */ - if (disk_read_func) - { -- int sector_num =3D sector; -+ unsigned int sector_num =3D sector; - int length =3D buf_geom.sector_size - byte_offset; - if (length > size) - length =3D size; -@@ -291,7 +291,7 @@ rawread (int drive, int sector, int byte -=20 -=20 - int --devread (int sector, int byte_offset, int byte_len, char *buf) -+devread (unsigned int sector, int byte_offset, int byte_len, char *buf) - { - /* - * Check partition boundaries -@@ -330,7 +330,7 @@ devread (int sector, int byte_offset, in -=20 - #ifndef STAGE1_5 - int --rawwrite (int drive, int sector, char *buf) -+rawwrite (int drive, unsigned int sector, char *buf) - { - if (sector =3D=3D 0) - { -@@ -363,7 +363,7 @@ rawwrite (int drive, int sector, char *b - } -=20 - int --devwrite (int sector, int sector_count, char *buf) -+devwrite (unsigned int sector, int sector_count, char *buf) - { - #if defined(GRUB_UTIL) && defined(__linux__) - if (current_partition !=3D 0xFFFFFF -diff -uprN grub-0.97/stage2/fsys_ffs.c grub/stage2/fsys_ffs.c ---- grub-0.97/stage2/fsys_ffs.c 2003-07-09 12:45:52.000000000 +0100 -+++ grub/stage2/fsys_ffs.c 2001-11-12 06:57:29.000000000 +0000 -@@ -50,7 +50,7 @@ - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:49 rpd -- * $Id: fsys_ffs.c,v 1.10 2001/11/12 06:57:29 okuji Exp $ -+ * $Id: fsys_ffs.c 594 2001-11-12 06:57:29Z okuji $ - */ -=20 - #ifdef FSYS_FFS -diff -uprN grub-0.97/stage2/fsys_ufs2.c grub/stage2/fsys_ufs2.c ---- grub-0.97/stage2/fsys_ufs2.c 2004-06-19 13:17:52.000000000 +0100 -+++ grub/stage2/fsys_ufs2.c 2004-06-19 13:17:52.000000000 +0100 -@@ -51,7 +51,7 @@ - * the rights to redistribute these changes. - * - * from: Mach, Revision 2.2 92/04/04 11:35:49 rpd -- * $Id: fsys_ufs2.c,v 1.2 2004/06/19 12:17:52 okuji Exp $ -+ * $Id: fsys_ufs2.c 841 2004-06-19 12:17:52Z okuji $ - */ -=20 - #ifdef FSYS_UFS2 -diff -uprN grub-0.97/stage2/imgact_aout.h grub/stage2/imgact_aout.h ---- grub-0.97/stage2/imgact_aout.h 2003-07-09 12:45:53.000000000 +0100 -+++ grub/stage2/imgact_aout.h 1999-06-24 01:03:29.000000000 +0100 -@@ -32,7 +32,7 @@ - * SUCH DAMAGE. - * - * from: @(#)exec.h 8.1 (Berkeley) 6/11/93 -- * $Id: imgact_aout.h,v 1.1 1999/06/24 00:03:22 okuji Exp $ -+ * $Id: imgact_aout.h 98 1999-06-24 00:03:29Z okuji $ - */ - /* - * 11/23/95 - Kludge to get "ntohl" null macro added. -- ESB -diff -uprN grub-0.97/stage2/iso9660.h grub/stage2/iso9660.h ---- grub-0.97/stage2/iso9660.h 2004-03-27 16:02:38.000000000 +0000 -+++ grub/stage2/iso9660.h 2007-02-22 23:40:25.000000000 +0000 -@@ -73,11 +73,11 @@ typedef union { -=20 - typedef struct __iso_16bit { - u_int16_t l, b; --} iso_16bit_t __attribute__ ((packed)); -+} iso_16bit_t; -=20 - typedef struct __iso_32bit { - u_int32_t l, b; --} iso_32bit_t __attribute__ ((packed)); -+} iso_32bit_t; -=20 - typedef u_int8_t iso_date_t[7]; -=20 -diff -uprN grub-0.97/stage2/shared.h grub/stage2/shared.h ---- grub-0.97/stage2/shared.h 2004-06-19 17:40:09.000000000 +0100 -+++ grub/stage2/shared.h 2008-03-28 13:22:28.000000000 +0000 -@@ -499,7 +499,11 @@ struct vbe_mode - unsigned char linear_reserved_field_position; - unsigned long max_pixel_clock; -=20 -- unsigned char reserved3[189]; -+ /* Reserved field to make structure to be 256 bytes long, VESA BIOS=20 -+ Extension 3.0 Specification says to reserve 189 bytes here but=20 -+ that doesn't make structure to be 256 bytes. So additional one is=20 -+ added here. */ -+ unsigned char reserved3[189 + 1]; - } __attribute__ ((packed)); -=20 -=20 -@@ -807,7 +811,7 @@ int checkkey (void); - /* Low-level disk I/O */ - int get_diskinfo (int drive, struct geometry *geometry); - int biosdisk (int subfunc, int drive, struct geometry *geometry, -- int sector, int nsec, int segment); -+ unsigned int sector, int nsec, int segment); - void stop_floppy (void); -=20 - /* Command-line interface functions. */ -@@ -920,10 +924,10 @@ int gunzip_test_header (void); - int gunzip_read (char *buf, int len); - #endif /* NO_DECOMPRESSION */ -=20 --int rawread (int drive, int sector, int byte_offset, int byte_len, char *= buf); --int devread (int sector, int byte_offset, int byte_len, char *buf); --int rawwrite (int drive, int sector, char *buf); --int devwrite (int sector, int sector_len, char *buf); -+int rawread (int drive, unsigned int sector, int byte_offset, int byte_le= n, char *buf); -+int devread (unsigned int sector, int byte_offset, int byte_len, char *bu= f); -+int rawwrite (int drive, unsigned int sector, char *buf); -+int devwrite (unsigned int sector, int sector_len, char *buf); -=20 - /* Parse a device string and initialize the global parameters. */ - char *set_device (char *device); -diff -uprN grub-0.97/stage2/stage2.c grub/stage2/stage2.c ---- grub-0.97/stage2/stage2.c 2005-03-19 17:51:57.000000000 +0000 -+++ grub/stage2/stage2.c 2006-05-05 23:06:31.000000000 +0100 -@@ -651,7 +651,10 @@ restart: - *(new_heap++) =3D 0; -=20 - if (config_entries) -- run_menu (heap, NULL, new_num_entries, new_heap, 0); -+ { -+ current_entryno =3D first_entry + entryno; -+ run_menu (heap, NULL, new_num_entries, new_heap, 0); -+ } - else - { - cls (); -@@ -727,7 +730,8 @@ restart: - cur_entry =3D get_entry (config_entries, first_entry + entryno, 1); -=20 - /* Set CURRENT_ENTRYNO for the command "savedefault". */ -- current_entryno =3D first_entry + entryno; -+ if (config_entries) -+ current_entryno =3D first_entry + entryno; - =20 - if (run_script (cur_entry, heap)) - { -diff -uprN grub-0.97/stage2/tparm.c grub/stage2/tparm.c ---- grub-0.97/stage2/tparm.c 2003-07-09 12:45:53.000000000 +0100 -+++ grub/stage2/tparm.c 2002-11-29 20:39:24.000000000 +0000 -@@ -63,7 +63,7 @@ typedef char grub_bool; - #define MAX_FORMAT_LEN 256 - #define max(a,b) ((a) > (b) ? (a) : (b)) -=20 --//MODULE_ID("$Id: tparm.c,v 1.1 2002/11/29 20:39:24 okuji Exp $") -+//MODULE_ID("$Id: tparm.c 708 2002-11-29 20:39:24Z okuji $") -=20 - /* - * char * -diff -uprN grub-0.97/stamp-h.in grub/stamp-h.in ---- grub-0.97/stamp-h.in 1970-01-01 01:00:00.000000000 +0100 -+++ grub/stamp-h.in 1999-09-13 14:32:31.000000000 +0100 -@@ -0,0 +1 @@ -+timestamp -diff -uprN grub-0.97/THANKS grub/THANKS ---- grub-0.97/THANKS 2005-05-08 03:17:43.000000000 +0100 -+++ grub/THANKS 2006-03-21 20:51:58.000000000 +0000 -@@ -121,3 +121,4 @@ Vesa Jaaskelainen - Yury V. Umanets - Yuri Zaporogets -+Vitaly Fertman -diff -uprN grub-0.97/util/grub-install.in grub/util/grub-install.in ---- grub-0.97/util/grub-install.in 2004-07-24 19:57:31.000000000 +0100 -+++ grub/util/grub-install.in 2006-04-20 14:46:46.000000000 +0100 -@@ -112,8 +112,8 @@ convert () { - tmp_disk=3D`echo "$1" | sed 's%\([sh]d[0-9]*\).*%\1%'` - tmp_part=3D`echo "$1" | sed "s%$tmp_disk%%"` ;; - freebsd* | kfreebsd*-gnu) -- tmp_disk=3D`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%r\1%' \ -- | sed 's%r\{0,1\}\(da[0-9]*\).*$%r\1%'` -+ tmp_disk=3D`echo "$1" | sed 's%r\{0,1\}\([saw]d[0-9]*\).*$%\1%' \ -+ | sed 's%r\{0,1\}\(da[0-9]*\).*$%\1%'` - tmp_part=3D`echo "$1" \ - | sed "s%.*/r\{0,1\}[saw]d[0-9]\(s[0-9]*[a-h]\)%\1%" \ - | sed "s%.*/r\{0,1\}da[0-9]\(s[0-9]*[a-h]\)%\1%"` -diff -uprN grub-0.97/util/mkbimage grub/util/mkbimage ---- grub-0.97/util/mkbimage 2004-07-24 19:57:31.000000000 +0100 -+++ grub/util/mkbimage 2007-02-22 16:01:03.000000000 +0000 -@@ -1,7 +1,7 @@ - #!/bin/sh - # MaKe a Bootable IMAGE --- 1.44, 2.88 and El Torito no-emulation mode - # C) 2001,2002,2003 Thierry Laronde --# C) 2001,2002,2003 Robert Millan -+# C) 2001,2002,2003 Robert Millan -=20 -=20 - # This program is free software; you can redistribute it and/or modify -@@ -19,7 +19,7 @@ - # program's maintainer or write to: The Free Software Foundation, - # Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA. -=20 --# $Id: mkbimage,v 1.19 2004/07/21 14:43:04 robertmh Exp $ -+# $Id: mkbimage 1233 2007-02-22 16:01:03Z robertmh $ -=20 - # Global variables - tarfile=3D -@@ -58,7 +58,7 @@ stage2_os_name=3D -=20 - # Name by which this script was invoked. - program=3D`echo "$0" | sed -e 's/[^\/]*\///g'` --version_number=3D'$Revision: 1.19 $' -+version_number=3D'$Revision: 1233 $' -=20 - usage=3D" - Usage: $program [-hVF] [-t TYPE] [-d DIRECTORY] [-s FS_TYPE] -f TAR_FILE -@@ -94,15 +94,13 @@ Options: - display Version information and exit -=20 - Copyright (c) 2001,2002,2003 Thierry Laronde .=20 --Copyright (c) 2001,2002 Robert Millan . - GPLed." -=20 - version=3D"mkbimage $version_number -=20 --Written by Thierry Laronde and Robert Millan. -+Written by Thierry Laronde. -=20 - Copyright (c) 2001,2002,2003 Thierry Laronde . --Copyright (c) 2001,2002,2003 Robert Millan . -=20 - This is free software under the GPL version 2 or later; see the source fo= r=20 - copying conditions. There is NO warranty, not even for MERCHANTABILITY o= r=20 diff --git a/stubdom/grub.patches/10graphics.diff b/stubdom/grub.patches/10= graphics.diff deleted file mode 100644 index 5ee2852fd7..0000000000 --- a/stubdom/grub.patches/10graphics.diff +++ /dev/null @@ -1,2297 +0,0 @@ -diff -Naur grub-0.97.orig/configure.ac grub-0.97/configure.ac ---- grub-0.97.orig/configure.ac 2005-05-07 23:36:03.000000000 -0300 -+++ grub-0.97/configure.ac 2005-06-12 20:56:49.000000000 -0300 -@@ -595,6 +595,11 @@ - [ --enable-diskless enable diskless support]) - AM_CONDITIONAL(DISKLESS_SUPPORT, test "x$enable_diskless" =3D xyes) -=20 -+dnl Graphical splashscreen support -+AC_ARG_ENABLE(graphics, -+ [ --disable-graphics disable graphics terminal support]) -+AM_CONDITIONAL(GRAPHICS_SUPPORT, test "x$enable_graphics" !=3D xno) -+ - dnl Hercules terminal - AC_ARG_ENABLE(hercules, - [ --disable-hercules disable hercules terminal support]) -diff -Naur grub-0.97.orig/stage2/asm.S grub-0.97/stage2/asm.S ---- grub-0.97.orig/stage2/asm.S 2004-06-19 13:55:22.000000000 -0300 -+++ grub-0.97/stage2/asm.S 2005-06-13 14:05:31.000000000 -0300 -@@ -2216,7 +2216,304 @@ - pop %ebx - pop %ebp - ret -- =09 -+ -+ -+/* graphics mode functions */ -+#ifdef SUPPORT_GRAPHICS -+VARIABLE(cursorX) -+.word 0 -+VARIABLE(cursorY) -+.word 0 -+VARIABLE(cursorCount) -+.word 0 -+VARIABLE(cursorBuf) -+.byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -+ -+ -+/* -+ * set_int1c_handler(void) -+ */ -+ENTRY(set_int1c_handler) -+ pushl %edi -+ -+ /* save the original int1c handler */ -+ movl $0x70, %edi -+ movw (%edi), %ax -+ movw %ax, ABS(int1c_offset) -+ movw 2(%edi), %ax -+ movw %ax, ABS(int1c_segment) -+ -+ /* save the new int1c handler */ -+ movw $ABS(int1c_handler), %ax -+ movw %ax, (%edi) -+ xorw %ax, %ax -+ movw %ax, 2(%edi) -+ -+ popl %edi -+ ret -+ -+ -+/* -+ * unset_int1c_handler(void) -+ */ -+ENTRY(unset_int1c_handler) -+ pushl %edi -+ -+ /* check if int1c_handler is set */ -+ movl $0x70, %edi -+ movw $ABS(int1c_handler), %ax -+ cmpw %ax, (%edi) -+ jne int1c_1 -+ xorw %ax, %ax -+ cmpw %ax, 2(%edi) -+ jne int1c_1 -+ -+ /* restore the original */ -+ movw ABS(int1c_offset), %ax -+ movw %ax, (%edi) -+ movw ABS(int1c_segment), %ax -+ movw %ax, 2(%edi) -+ -+int1c_1: -+ popl %edi -+ ret -+ -+ -+/* -+ * blinks graphics cursor -+ */ -+ .code16 -+write_data: -+ movw $0, %ax -+ movw %ax, %ds -+ -+ mov $0xA000, %ax /* video in es:di */ -+ mov %ax, %es -+ mov $80, %ax -+ movw $ABS(cursorY), %si -+ mov %ds:(%si), %bx -+ mul %bx -+ movw $ABS(cursorX), %si -+ mov %ds:(%si), %bx -+ shr $3, %bx /* %bx /=3D 8 */ -+ add %bx, %ax -+ mov %ax, %di -+ -+ movw $ABS(cursorBuf), %si /* fontBuf in ds:si */ -+ -+ /* prepare for data moving */ -+ mov $16, %dx /* altura da fonte */ -+ mov $80, %bx /* bytes por linha */ -+ -+write_loop: -+ movb %ds:(%si), %al -+ xorb $0xff, %al -+ movb %al, %ds:(%si) /* invert cursorBuf */ -+ movb %al, %es:(%di) /* write to video */ -+ add %bx, %di -+ inc %si -+ dec %dx -+ jg write_loop -+ ret -+ -+int1c_handler: -+ pusha -+ mov $0, %ax -+ mov %ax, %ds -+ mov $ABS(cursorCount), %si -+ mov %ds:(%si), %ax -+ inc %ax -+ mov %ax, %ds:(%si) -+ cmp $9, %ax -+ jne int1c_done -+ -+ mov $0, %ax -+ mov %ax, %ds:(%si) -+ call write_data -+ -+int1c_done: -+ popa -+ iret -+ /* call previous int1c handler */ -+ /* ljmp */ -+ .byte 0xea -+int1c_offset: .word 0 -+int1c_segment: .word 0 -+ .code32 -+ -+ -+/* -+ * unsigned char set_videomode(unsigned char mode) -+ * BIOS call "INT 10H Function 0h" to set video mode -+ * Call with %ah =3D 0x0 -+ * %al =3D video mode -+ * Returns old videomode. -+ */ -+ENTRY(set_videomode) -+ pushl %ebp -+ movl %esp,%ebp -+ pushl %ebx -+ pushl %ecx -+ -+ movb 8(%ebp), %cl -+ -+ call EXT_C(prot_to_real) -+ .code16 -+ -+ xorb %al, %al -+ movb $0xf, %ah -+ int $0x10 /* Get Current Video mode */ -+ movb %al, %ch -+ xorb %ah, %ah -+ movb %cl, %al -+ int $0x10 /* Set Video mode */ -+ -+ DATA32 call EXT_C(real_to_prot) -+ .code32 -+ -+ xorl %eax, %eax -+ movb %ch, %al -+ -+ popl %ecx -+ popl %ebx -+ popl %ebp -+ ret -+ -+ -+/* -+ * int get_videomode() -+ * BIOS call "INT 10H Function 0Fh" to get current video mode -+ * Call with %al =3D 0x0 -+ * %ah =3D 0xF -+ * Returns current videomode. -+ */ -+ENTRY(get_videomode) -+ pushl %ebp -+ movl %esp,%ebp -+ pushl %ebx -+ pushl %ecx -+ -+ call EXT_C(prot_to_real) -+ .code16 -+ -+ xorb %al, %al -+ movb $0xF, %ah -+ int $0x10 /* Get Current Video mode */ -+ movb %al, %cl /* For now we only want display mode */ -+ -+ DATA32 call EXT_C(real_to_prot) -+ .code32 -+ -+ xorl %eax, %eax -+ movb %cl, %al -+ -+ popl %ecx -+ popl %ebx -+ popl %ebp -+ ret -+ -+ -+/* -+ * unsigned char * graphics_get_font() -+ * BIOS call "INT 10H Function 11h" to set font -+ * Call with %ah =3D 0x11 -+ */ -+ENTRY(graphics_get_font) -+ push %ebp -+ push %ebx -+ push %ecx -+ push %edx -+ -+ call EXT_C(prot_to_real) -+ .code16 -+ -+ movw $0x1130, %ax -+ movb $6, %bh /* font 8x16 */ -+ int $0x10 -+ movw %bp, %dx -+ movw %es, %cx -+ -+ DATA32 call EXT_C(real_to_prot) -+ .code32 -+ -+ xorl %eax, %eax -+ movw %cx, %ax -+ shll $4, %eax -+ movw %dx, %ax -+ -+ pop %edx -+ pop %ecx -+ pop %ebx -+ pop %ebp -+ ret -+ -+ -+/* -+ * graphics_set_palette(index, red, green, blue) -+ * BIOS call "INT 10H Function 10h" to set individual dac register -+ * Call with %ah =3D 0x10 -+ * %bx =3D register number -+ * %ch =3D new value for green (0-63) -+ * %cl =3D new value for blue (0-63) -+ * %dh =3D new value for red (0-63) -+ */ -+ -+ENTRY(graphics_set_palette) -+ push %ebp -+ push %eax -+ push %ebx -+ push %ecx -+ push %edx -+ -+ movw $0x3c8, %bx /* address write mode register */ -+ -+ /* wait vertical retrace */ -+ movw $0x3da, %dx -+l1b: -+ inb %dx, %al /* wait vertical active display */ -+ test $8, %al -+ jnz l1b -+ -+l2b: -+ inb %dx, %al /* wait vertical retrace */ -+ test $8, %al -+ jnz l2b -+ -+ mov %bx, %dx -+ movb 0x18(%esp), %al /* index */ -+ outb %al, %dx -+ inc %dx -+ -+ movb 0x1c(%esp), %al /* red */ -+ outb %al, %dx -+ -+ movb 0x20(%esp), %al /* green */ -+ outb %al, %dx -+ -+ movb 0x24(%esp), %al /* blue */ -+ outb %al, %dx -+ -+ movw 0x18(%esp), %bx -+ -+ call EXT_C(prot_to_real) -+ .code16 -+ -+ movb %bl, %bh -+ movw $0x1000, %ax -+ int $0x10 -+ -+ DATA32 call EXT_C(real_to_prot) -+ .code32 -+ -+ pop %edx -+ pop %ecx -+ pop %ebx -+ pop %eax -+ pop %ebp -+ ret -+#endif /* SUPPORT_GRAPHICS */ -+ -+ - /* - * getrtsecs() - * if a seconds value can be read, read it and return it (BCD), -diff -Naur grub-0.97.orig/stage2/builtins.c grub-0.97/stage2/builtins.c ---- grub-0.97.orig/stage2/builtins.c 2005-02-15 19:58:23.000000000 -0200 -+++ grub-0.97/stage2/builtins.c 2005-06-13 18:44:03.000000000 -0300 -@@ -28,6 +28,10 @@ - #include - #include -=20 -+#ifdef SUPPORT_GRAPHICS -+# include -+#endif -+ - #ifdef SUPPORT_NETBOOT - # define GRUB 1 - # include -@@ -237,12 +241,22 @@ - static int - boot_func (char *arg, int flags) - { -+ struct term_entry *prev_term =3D current_term; - /* Clear the int15 handler if we can boot the kernel successfully. - This assumes that the boot code never fails only if KERNEL_TYPE is - not KERNEL_TYPE_NONE. Is this assumption is bad? */ - if (kernel_type !=3D KERNEL_TYPE_NONE) - unset_int15_handler (); -=20 -+ /* if our terminal needed initialization, we should shut it down -+ * before booting the kernel, but we want to save what it was so -+ * we can come back if needed */ -+ if (current_term->shutdown)=20 -+ { -+ current_term->shutdown(); -+ current_term =3D term_table; /* assumption: console is first */ -+ } -+ - #ifdef SUPPORT_NETBOOT - /* Shut down the networking. */ - cleanup_net (); -@@ -306,6 +320,13 @@ - return 1; - } -=20 -+ /* if we get back here, we should go back to what our term was before */ -+ current_term =3D prev_term; -+ if (current_term->startup) -+ /* if our terminal fails to initialize, fall back to console since -+ * it should always work */ -+ if (current_term->startup() =3D=3D 0) -+ current_term =3D term_table; /* we know that console is first */ - return 0; - } -=20 -@@ -852,6 +873,251 @@ - }; - #endif /* SUPPORT_NETBOOT */ -=20 -+#ifdef SUPPORT_GRAPHICS -+=0C -+static int splashimage_func(char *arg, int flags) { -+ int i; -+ =20 -+ /* filename can only be 256 characters due to our buffer size */ -+ if (grub_strlen(arg) > 256) { -+ grub_printf("Splash image filename too large\n"); -+ grub_printf("Press any key to continue..."); -+ getkey(); -+ return 1; -+ } -+ -+ /* get rid of TERM_NEED_INIT from the graphics terminal. */ -+ for (i =3D 0; term_table[i].name; i++) { -+ if (grub_strcmp (term_table[i].name, "graphics") =3D=3D 0) { -+ term_table[i].flags &=3D ~TERM_NEED_INIT; -+ break; -+ } -+ } -+ -+ graphics_set_splash(arg); -+ -+ if (flags =3D=3D BUILTIN_CMDLINE && graphics_inited) { -+ graphics_end(); -+ if (graphics_init() =3D=3D 0) { -+ /* Fallback to default term */ -+ current_term =3D term_table; -+ max_lines =3D current_term->max_lines; -+ if (current_term->cls) -+ current_term->cls(); -+ grub_printf("Failed to set splash image and/or graphics mode\n"); -+ return 1; -+ } -+ graphics_cls(); -+ } -+ -+ if (flags =3D=3D BUILTIN_MENU) -+ current_term =3D term_table + i; -+ -+ return 0; -+} -+ -+static struct builtin builtin_splashimage =3D -+{ -+ "splashimage", -+ splashimage_func, -+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST, -+ "splashimage FILE", -+ "Load FILE as the background image when in graphics mode." -+}; -+ -+=0C -+/* shade */ -+static int -+shade_func(char *arg, int flags) -+{ -+ int new_shade; -+ -+ if (!arg || safe_parse_maxint(&arg, &new_shade) =3D=3D 0) -+ return (1); -+ -+ if (shade !=3D new_shade) { -+ shade =3D new_shade; -+ if (flags =3D=3D BUILTIN_CMDLINE && graphics_inited) { -+ graphics_end(); -+ graphics_init(); -+ graphics_cls(); -+ } -+ } -+ -+ return 0; -+} -+ -+static struct builtin builtin_shade =3D -+{ -+ "shade", -+ shade_func, -+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST, -+ "shade INTEGER", -+ "If set to 0, disables the use of shaded text, else enables it." -+}; -+ -+=0C -+/* foreground */ -+static int -+foreground_func(char *arg, int flags) -+{ -+ if (grub_strlen(arg) =3D=3D 6) { -+ int r =3D ((hex(arg[0]) << 4) | hex(arg[1])) >> 2; -+ int g =3D ((hex(arg[2]) << 4) | hex(arg[3])) >> 2; -+ int b =3D ((hex(arg[4]) << 4) | hex(arg[5])) >> 2; -+ -+ foreground =3D (r << 16) | (g << 8) | b; -+ if (graphics_inited) -+ graphics_set_palette(15, r, g, b); -+ -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct builtin builtin_foreground =3D -+{ -+ "foreground", -+ foreground_func, -+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST, -+ "foreground RRGGBB", -+ "Sets the foreground color when in graphics mode." -+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal." -+}; -+ -+=0C -+/* background */ -+static int -+background_func(char *arg, int flags) -+{ -+ if (grub_strlen(arg) =3D=3D 6) { -+ int r =3D ((hex(arg[0]) << 4) | hex(arg[1])) >> 2; -+ int g =3D ((hex(arg[2]) << 4) | hex(arg[3])) >> 2; -+ int b =3D ((hex(arg[4]) << 4) | hex(arg[5])) >> 2; -+ -+ background =3D (r << 16) | (g << 8) | b; -+ if (graphics_inited) -+ graphics_set_palette(0, r, g, b); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct builtin builtin_background =3D -+{ -+ "background", -+ background_func, -+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST, -+ "background RRGGBB", -+ "Sets the background color when in graphics mode." -+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal." -+}; -+ -+=0C -+/* border */ -+static int -+border_func(char *arg, int flags) -+{ -+ if (grub_strlen(arg) =3D=3D 6) { -+ int r =3D ((hex(arg[0]) << 4) | hex(arg[1])) >> 2; -+ int g =3D ((hex(arg[2]) << 4) | hex(arg[3])) >> 2; -+ int b =3D ((hex(arg[4]) << 4) | hex(arg[5])) >> 2; -+ -+ window_border =3D (r << 16) | (g << 8) | b; -+ if (graphics_inited) -+ graphics_set_palette(0x11, r, g, b); -+ -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct builtin builtin_border =3D -+{ -+ "border", -+ border_func, -+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST, -+ "border RRGGBB", -+ "Sets the border video color when in graphics mode." -+ "RR is red, GG is green, and BB blue. Numbers must be in hexadecimal." -+}; -+ -+=0C -+/* viewport */ -+static int -+viewport_func (char *arg, int flags) -+{ -+ int i; -+ int x0 =3D 0, y0 =3D 0, x1 =3D 80, y1 =3D 30; -+ int *pos[4] =3D { &x0, &y0, &x1, &y1 }; -+ -+ if (!arg) -+ return (1); -+ for (i =3D 0; i < 4; i++) { -+ if (!*arg) -+ return (1); -+ while (*arg && (*arg =3D=3D ' ' || *arg =3D=3D '\t')) -+ ++arg; -+ if (!safe_parse_maxint(&arg, pos[i])) -+ return (1); -+ while (*arg && (*arg !=3D ' ' && *arg !=3D '\t')) -+ ++arg; -+ } -+ -+ /* minimum size is 65 colums and 16 rows */ -+ if (x0 > x1 - 66 || y0 > y1 - 16 || x0 < 0 || y0 < 0 || x1 > 80 || y1= > 30) -+ return 1; -+ -+ view_x0 =3D x0; -+ view_y0 =3D y0; -+ view_x1 =3D x1; -+ view_y1 =3D y1; -+ -+ if (flags =3D=3D BUILTIN_CMDLINE && graphics_inited) { -+ graphics_end(); -+ graphics_init(); -+ graphics_cls(); -+ } -+ -+ return 0; -+} -+ -+static struct builtin builtin_viewport =3D -+{ -+ "viewport", -+ viewport_func, -+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_HELP_LIST, -+ "viewport x0 y0 x1 y1", -+ "Changes grub internals to output text in the window defined by" -+ " four parameters. The x and y parameters are 0 based. This option" -+ " only works with the graphics interface." -+}; -+ -+#endif /* SUPPORT_GRAPHICS */ -+ -+=0C -+/* clear */ -+static int=20 -+clear_func()=20 -+{ -+ if (current_term->cls) -+ current_term->cls(); -+ -+ return 0; -+} -+ -+static struct builtin builtin_clear =3D -+{ -+ "clear", -+ clear_func, -+ BUILTIN_CMDLINE | BUILTIN_HELP_LIST, -+ "clear", -+ "Clear the screen" -+}; -+ - =0C - /* displayapm */ - static int -@@ -1454,14 +1720,20 @@ -=20 - =0C - /* help */ --#define MAX_SHORT_DOC_LEN 39 --#define MAX_LONG_DOC_LEN 66 -- - static int - help_func (char *arg, int flags) - { -- int all =3D 0; -- =20 -+ int all =3D 0, max_short_doc_len, max_long_doc_len; -+ max_short_doc_len =3D 39; -+ max_long_doc_len =3D 66; -+#ifdef SUPPORT_GRAPHICS -+ if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - = 1) =3D=3D 0) -+ { -+ max_short_doc_len =3D (view_x1 - view_x0 + 1) / 2 - 1; -+ max_long_doc_len =3D (view_x1 - view_x0) - 14; -+ } -+#endif -+ - if (grub_memcmp (arg, "--all", sizeof ("--all") - 1) =3D=3D 0) - { - all =3D 1; -@@ -1491,13 +1763,13 @@ -=20 - len =3D grub_strlen ((*builtin)->short_doc); - /* If the length of SHORT_DOC is too long, truncate it. */ -- if (len > MAX_SHORT_DOC_LEN - 1) -- len =3D MAX_SHORT_DOC_LEN - 1; -+ if (len > max_short_doc_len - 1) -+ len =3D max_short_doc_len - 1; -=20 - for (i =3D 0; i < len; i++) - grub_putchar ((*builtin)->short_doc[i]); -=20 -- for (; i < MAX_SHORT_DOC_LEN; i++) -+ for (; i < max_short_doc_len; i++) - grub_putchar (' '); -=20 - if (! left) -@@ -1546,10 +1818,10 @@ - int i; -=20 - /* If LEN is too long, fold DOC. */ -- if (len > MAX_LONG_DOC_LEN) -+ if (len > max_long_doc_len) - { - /* Fold this line at the position of a space. */ -- for (len =3D MAX_LONG_DOC_LEN; len > 0; len--) -+ for (len =3D max_long_doc_len; len > 0; len--) - if (doc[len - 1] =3D=3D ' ') - break; - } -@@ -4085,7 +4357,7 @@ - }; -=20 - =0C --#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) -+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPO= RT_GRAPHICS) - /* terminal */ - static int - terminal_func (char *arg, int flags) -@@ -4244,17 +4516,29 @@ - end: - current_term =3D term_table + default_term; - current_term->flags =3D term_flags; -- =20 -+ - if (lines) - max_lines =3D lines; - else -- /* 24 would be a good default value. */ -- max_lines =3D 24; -- =20 -+ max_lines =3D current_term->max_lines; -+ - /* If the interface is currently the command-line, - restart it to repaint the screen. */ -- if (current_term !=3D prev_term && (flags & BUILTIN_CMDLINE)) -+ if ((current_term !=3D prev_term) && (flags & BUILTIN_CMDLINE)){ -+ if (prev_term->shutdown) -+ prev_term->shutdown(); -+ if (current_term->startup) { -+ /* If startup fails, return to previous term */ -+ if (current_term->startup() =3D=3D 0) { -+ current_term =3D prev_term; -+ max_lines =3D current_term->max_lines; -+ if (current_term->cls) { -+ current_term->cls(); -+ } -+ } -+ } - grub_longjmp (restart_cmdline_env, 0); -+ } - =20 - return 0; - } -@@ -4264,7 +4548,7 @@ - "terminal", - terminal_func, - BUILTIN_MENU | BUILTIN_CMDLINE | BUILTIN_HELP_LIST, -- "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=3DSECS] [--lines= =3DLINES] [--silent] [console] [serial] [hercules]", -+ "terminal [--dumb] [--no-echo] [--no-edit] [--timeout=3DSECS] [--lines= =3DLINES] [--silent] [console] [serial] [hercules] [graphics]", - "Select a terminal. When multiple terminals are specified, wait until" - " you push any key to continue. If both console and serial are specifie= d," - " the terminal to which you input a key first will be selected. If no" -@@ -4276,7 +4560,7 @@ - " seconds. The option --lines specifies the maximum number of lines." - " The option --silent is used to suppress messages." - }; --#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */ -+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */ -=20 - =0C - #ifdef SUPPORT_SERIAL -@@ -4795,13 +5079,20 @@ - /* The table of builtin commands. Sorted in dictionary order. */ - struct builtin *builtin_table[] =3D - { -+#ifdef SUPPORT_GRAPHICS -+ &builtin_background, -+#endif - &builtin_blocklist, - &builtin_boot, - #ifdef SUPPORT_NETBOOT - &builtin_bootp, - #endif /* SUPPORT_NETBOOT */ -+#ifdef SUPPORT_GRAPHICS -+ &builtin_border, -+#endif - &builtin_cat, - &builtin_chainloader, -+ &builtin_clear, - &builtin_cmp, - &builtin_color, - &builtin_configfile, -@@ -4821,6 +5112,9 @@ - &builtin_embed, - &builtin_fallback, - &builtin_find, -+#ifdef SUPPORT_GRAPHICS -+ &builtin_foreground, -+#endif - &builtin_fstest, - &builtin_geometry, - &builtin_halt, -@@ -4864,9 +5158,13 @@ - #endif /* SUPPORT_SERIAL */ - &builtin_setkey, - &builtin_setup, --#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) -+#ifdef SUPPORT_GRAPHICS -+ &builtin_shade, -+ &builtin_splashimage, -+#endif /* SUPPORT_GRAPHICS */ -+#if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPO= RT_GRAPHICS) - &builtin_terminal, --#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES */ -+#endif /* SUPPORT_SERIAL || SUPPORT_HERCULES || SUPPORT_GRAPHICS */ - #ifdef SUPPORT_SERIAL - &builtin_terminfo, - #endif /* SUPPORT_SERIAL */ -@@ -4880,5 +5178,8 @@ - &builtin_unhide, - &builtin_uppermem, - &builtin_vbeprobe, -+#ifdef SUPPORT_GRAPHICS -+ &builtin_viewport, -+#endif - 0 - }; -diff -Naur grub-0.97.orig/stage2/char_io.c grub-0.97/stage2/char_io.c ---- grub-0.97.orig/stage2/char_io.c 2005-02-01 18:51:23.000000000 -0200 -+++ grub-0.97/stage2/char_io.c 2005-06-12 20:56:49.000000000 -0300 -@@ -29,12 +29,17 @@ - # include - #endif -=20 -+#ifdef SUPPORT_GRAPHICS -+# include -+#endif -+ - #ifndef STAGE1_5 - struct term_entry term_table[] =3D - { - { - "console", - 0, -+ 24, - console_putchar, - console_checkkey, - console_getkey, -@@ -43,13 +48,16 @@ - console_cls, - console_setcolorstate, - console_setcolor, -- console_setcursor -+ console_setcursor, -+ 0,=20 -+ 0 - }, - #ifdef SUPPORT_SERIAL - { - "serial", - /* A serial device must be initialized. */ - TERM_NEED_INIT, -+ 24, - serial_putchar, - serial_checkkey, - serial_getkey, -@@ -58,6 +66,8 @@ - serial_cls, - serial_setcolorstate, - 0, -+ 0, -+ 0,=20 - 0 - }, - #endif /* SUPPORT_SERIAL */ -@@ -65,6 +75,7 @@ - { - "hercules", - 0, -+ 24, - hercules_putchar, - console_checkkey, - console_getkey, -@@ -73,11 +84,30 @@ - hercules_cls, - hercules_setcolorstate, - hercules_setcolor, -- hercules_setcursor -+ hercules_setcursor, -+ 0, -+ 0 - }, =20 - #endif /* SUPPORT_HERCULES */ -+#ifdef SUPPORT_GRAPHICS -+ { "graphics", -+ TERM_NEED_INIT, /* flags */ -+ 30, /* number of lines */ -+ graphics_putchar, /* putchar */ -+ console_checkkey, /* checkkey */ -+ console_getkey, /* getkey */ -+ graphics_getxy, /* getxy */ -+ graphics_gotoxy, /* gotoxy */ -+ graphics_cls, /* cls */ -+ graphics_setcolorstate, /* setcolorstate */ -+ graphics_setcolor, /* setcolor */ -+ graphics_setcursor, /* nocursor */ -+ graphics_init, /* initialize */ -+ graphics_end /* shutdown */ -+ }, -+#endif /* SUPPORT_GRAPHICS */ - /* This must be the last entry. */ -- { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } -+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - }; -=20 - /* This must be console. */ -@@ -305,9 +335,10 @@ -=20 - /* XXX: These should be defined in shared.h, but I leave these here, - until this code is freezed. */ --#define CMDLINE_WIDTH 78 - #define CMDLINE_MARGIN 10 -- =20 -+ -+ /* command-line limits */ -+ int cmdline_width =3D 78, col_start =3D 0; - int xpos, lpos, c, section; - /* The length of PROMPT. */ - int plen; -@@ -338,7 +369,7 @@ - =20 - /* If the cursor is in the first section, display the first section - instead of the second. */ -- if (section =3D=3D 1 && plen + lpos < CMDLINE_WIDTH) -+ if (section =3D=3D 1 && plen + lpos < cmdline_width) - cl_refresh (1, 0); - else if (xpos - count < 1) - cl_refresh (1, 0); -@@ -354,7 +385,7 @@ - grub_putchar ('\b'); - } - else -- gotoxy (xpos, getxy () & 0xFF); -+ gotoxy (xpos + col_start, getxy () & 0xFF); - } - } -=20 -@@ -364,7 +395,7 @@ - lpos +=3D count; -=20 - /* If the cursor goes outside, scroll the screen to the right. */ -- if (xpos + count >=3D CMDLINE_WIDTH) -+ if (xpos + count >=3D cmdline_width) - cl_refresh (1, 0); - else - { -@@ -383,7 +414,7 @@ - } - } - else -- gotoxy (xpos, getxy () & 0xFF); -+ gotoxy (xpos + col_start, getxy () & 0xFF); - } - } -=20 -@@ -398,14 +429,14 @@ - if (full) - { - /* Recompute the section number. */ -- if (lpos + plen < CMDLINE_WIDTH) -+ if (lpos + plen < cmdline_width) - section =3D 0; - else -- section =3D ((lpos + plen - CMDLINE_WIDTH) -- / (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN) + 1); -+ section =3D ((lpos + plen - cmdline_width) -+ / (cmdline_width - 1 - CMDLINE_MARGIN) + 1); -=20 - /* From the start to the end. */ -- len =3D CMDLINE_WIDTH; -+ len =3D cmdline_width; - pos =3D 0; - grub_putchar ('\r'); -=20 -@@ -445,8 +476,8 @@ - if (! full) - offset =3D xpos - 1; - =20 -- start =3D ((section - 1) * (CMDLINE_WIDTH - 1 - CMDLINE_MARGIN) -- + CMDLINE_WIDTH - plen - CMDLINE_MARGIN); -+ start =3D ((section - 1) * (cmdline_width - 1 - CMDLINE_MARGIN) -+ + cmdline_width - plen - CMDLINE_MARGIN); - xpos =3D lpos + 1 - start; - start +=3D offset; - } -@@ -471,7 +502,7 @@ - =20 - /* If the cursor is at the last position, put `>' or a space, - depending on if there are more characters in BUF. */ -- if (pos =3D=3D CMDLINE_WIDTH) -+ if (pos =3D=3D cmdline_width) - { - if (start + len < llen) - grub_putchar ('>'); -@@ -488,7 +519,7 @@ - grub_putchar ('\b'); - } - else -- gotoxy (xpos, getxy () & 0xFF); -+ gotoxy (xpos + col_start, getxy () & 0xFF); - } -=20 - /* Initialize the command-line. */ -@@ -518,10 +549,10 @@ - =20 - llen +=3D l; - lpos +=3D l; -- if (xpos + l >=3D CMDLINE_WIDTH) -+ if (xpos + l >=3D cmdline_width) - cl_refresh (1, 0); -- else if (xpos + l + llen - lpos > CMDLINE_WIDTH) -- cl_refresh (0, CMDLINE_WIDTH - xpos); -+ else if (xpos + l + llen - lpos > cmdline_width) -+ cl_refresh (0, cmdline_width - xpos); - else - cl_refresh (0, l + llen - lpos); - } -@@ -533,12 +564,22 @@ - grub_memmove (buf + lpos, buf + lpos + count, llen - count + 1); - llen -=3D count; - =20 -- if (xpos + llen + count - lpos > CMDLINE_WIDTH) -- cl_refresh (0, CMDLINE_WIDTH - xpos); -+ if (xpos + llen + count - lpos > cmdline_width) -+ cl_refresh (0, cmdline_width - xpos); - else - cl_refresh (0, llen + count - lpos); - } -=20 -+ max_lines =3D current_term->max_lines; -+#ifdef SUPPORT_GRAPHICS -+ if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - = 1) =3D=3D 0) -+ { -+ cmdline_width =3D (view_x1 - view_x0) - 2; -+ col_start =3D view_x0; -+ max_lines =3D view_y1 - view_y0; -+ } -+#endif -+ - plen =3D grub_strlen (prompt); - llen =3D grub_strlen (cmdline); -=20 -@@ -1006,6 +1047,48 @@ - } - #endif /* ! STAGE1_5 */ -=20 -+#ifndef STAGE1_5 -+/* Internal pager. */ -+int -+do_more (void) -+{ -+ if (count_lines >=3D 0) -+ { -+ count_lines++; -+ if (count_lines >=3D max_lines - 2) -+ { -+ int tmp; -+ -+ /* It's important to disable the feature temporarily, because -+ the following grub_printf call will print newlines. */ -+ count_lines =3D -1; -+ -+ grub_printf("\n"); -+ if (current_term->setcolorstate) -+ current_term->setcolorstate (COLOR_STATE_HIGHLIGHT); -+ -+ grub_printf ("[Hit return to continue]"); -+ -+ if (current_term->setcolorstate) -+ current_term->setcolorstate (COLOR_STATE_NORMAL); -+ -+ -+ do -+ { -+ tmp =3D ASCII_CHAR (getkey ()); -+ } -+ while (tmp !=3D '\n' && tmp !=3D '\r'); -+ grub_printf ("\r \r"); -+ -+ /* Restart to count lines. */ -+ count_lines =3D 0; -+ return 1; -+ } -+ } -+ return 0; -+} -+#endif -+ - /* Display an ASCII character. */ - void - grub_putchar (int c) -@@ -1034,38 +1117,11 @@ -=20 - if (c =3D=3D '\n') - { -+ int flag; - /* Internal `more'-like feature. */ -- if (count_lines >=3D 0) -- { -- count_lines++; -- if (count_lines >=3D max_lines - 2) -- { -- int tmp; -- =20 -- /* It's important to disable the feature temporarily, because -- the following grub_printf call will print newlines. */ -- count_lines =3D -1; -- -- if (current_term->setcolorstate) -- current_term->setcolorstate (COLOR_STATE_HIGHLIGHT); -- =20 -- grub_printf ("\n[Hit return to continue]"); -- -- if (current_term->setcolorstate) -- current_term->setcolorstate (COLOR_STATE_NORMAL); -- =20 -- do -- { -- tmp =3D ASCII_CHAR (getkey ()); -- } -- while (tmp !=3D '\n' && tmp !=3D '\r'); -- grub_printf ("\r \r"); -- =20 -- /* Restart to count lines. */ -- count_lines =3D 0; -- return; -- } -- } -+ flag =3D do_more (); -+ if (flag) -+ return; - } -=20 - current_term->putchar (c); -@@ -1090,7 +1146,7 @@ - cls (void) - { - /* If the terminal is dumb, there is no way to clean the terminal. */ -- if (current_term->flags & TERM_DUMB) -+ if (current_term->flags & TERM_DUMB)=20 - grub_putchar ('\n'); - else - current_term->cls (); -@@ -1217,6 +1273,16 @@ - return ! errnum; - } -=20 -+void -+grub_memcpy(void *dest, const void *src, int len) -+{ -+ int i; -+ register char *d =3D (char*)dest, *s =3D (char*)src; -+ -+ for (i =3D 0; i < len; i++) -+ d[i] =3D s[i]; -+} -+ - void * - grub_memmove (void *to, const void *from, int len) - { -diff -Naur grub-0.97.orig/stage2/cmdline.c grub-0.97/stage2/cmdline.c ---- grub-0.97.orig/stage2/cmdline.c 2004-08-16 20:23:01.000000000 -0300 -+++ grub-0.97/stage2/cmdline.c 2005-06-12 20:56:49.000000000 -0300 -@@ -50,10 +50,11 @@ - void - print_cmdline_message (int forever) - { -- printf (" [ Minimal BASH-like line editing is supported. For the first= word, TAB\n" -- " lists possible command completions. Anywhere else TAB lists the p= ossible\n" -- " completions of a device/filename.%s ]\n", -- (forever ? "" : " ESC at any time exits.")); -+ grub_printf(" [ Minimal BASH-like line editing is supported. Fo= r\n" -+ " the first word, TAB lists possible comman= d\n" -+ " completions. Anywhere else TAB lists the possibl= e\n" -+ " completions of a device/filename.%s ]\n", -+ (forever ? "" : " ESC at any time\n exits.")); - } -=20 - /* Find the builtin whose command name is COMMAND and return the -diff -Naur grub-0.97.orig/stage2/graphics.c grub-0.97/stage2/graphics.c ---- grub-0.97.orig/stage2/graphics.c 1969-12-31 21:00:00.000000000 -0300 -+++ grub-0.97/stage2/graphics.c 2005-06-13 19:13:31.000000000 -0300 -@@ -0,0 +1,584 @@ -+/* -+ * graphics.c - graphics mode support for GRUB -+ * Implemented as a terminal type by Jeremy Katz based -+ * on a patch by Paulo C=EF=BF=BDsar Pereira de Andrade -+ * Options and enhancements made by Herton Ronaldo Krzesinski -+ * -+ * -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2001,2002 Red Hat, Inc. -+ * Portions copyright (C) 2000 Conectiva, Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; If not, see -+ */ -+ -+#ifdef SUPPORT_GRAPHICS -+ -+#include -+#include -+#include -+ -+int saved_videomode; -+unsigned char *font8x16; -+ -+int graphics_inited =3D 0; -+static char splashimage[256]; -+ -+int shade =3D 1, no_cursor =3D 0; -+ -+#define VSHADOW VSHADOW1 -+unsigned char VSHADOW1[38400]; -+unsigned char VSHADOW2[38400]; -+unsigned char VSHADOW4[38400]; -+unsigned char VSHADOW8[38400]; -+ -+/* define the default viewable area */ -+int view_x0 =3D 0; -+int view_y0 =3D 0; -+int view_x1 =3D 80; -+int view_y1 =3D 30; -+ -+/* text buffer has to be kept around so that we can write things as we -+ * scroll and the like */ -+unsigned short text[80 * 30]; -+ -+/* graphics options */ -+int foreground =3D (63 << 16) | (63 << 8) | (63), background =3D 0, windo= w_border =3D 0; -+ -+/* current position */ -+static int fontx =3D 0; -+static int fonty =3D 0; -+ -+/* global state so that we don't try to recursively scroll or cursor */ -+static int no_scroll =3D 0; -+ -+/* color state */ -+static int graphics_standard_color =3D A_NORMAL; -+static int graphics_normal_color =3D A_NORMAL; -+static int graphics_highlight_color =3D A_REVERSE; -+static int graphics_current_color =3D A_NORMAL; -+static color_state graphics_color_state =3D COLOR_STATE_STANDARD; -+ -+static inline void outb(unsigned short port, unsigned char val) -+{ -+ __asm __volatile ("outb %0,%1"::"a" (val), "d" (port)); -+} -+ -+static void MapMask(int value) { -+ outb(0x3c4, 2); -+ outb(0x3c5, value); -+} -+ -+/* bit mask register */ -+static void BitMask(int value) { -+ outb(0x3ce, 8); -+ outb(0x3cf, value); -+} -+ -+/* move the graphics cursor location to col, row */ -+static void graphics_setxy(int col, int row) { -+ if (col >=3D view_x0 && col < view_x1) { -+ fontx =3D col; -+ cursorX =3D col << 3; -+ } -+ if (row >=3D view_y0 && row < view_y1) { -+ fonty =3D row; -+ cursorY =3D row << 4; -+ } -+} -+ -+/* scroll the screen */ -+static void graphics_scroll() { -+ int i, j, k; -+ -+ /* we don't want to scroll recursively... that would be bad */ -+ if (no_scroll) -+ return; -+ no_scroll =3D 1; -+ -+ /* disable pager temporarily */ -+ k =3D count_lines; -+ count_lines =3D -1; -+ =20 -+ /* move everything up a line */ -+ for (j =3D view_y0 + 1; j < view_y1; j++) { -+ graphics_gotoxy(view_x0, j - 1); -+ for (i =3D view_x0; i < view_x1; i++) { -+ graphics_putchar(text[j * 80 + i]); -+ } -+ } -+ -+ /* last line should be blank */ -+ graphics_gotoxy(view_x0, view_y1 - 1); -+ for (i =3D view_x0; i < view_x1; i++) -+ graphics_putchar(' '); -+ graphics_setxy(view_x0, view_y1 - 1); -+ -+ count_lines =3D k; -+ -+ no_scroll =3D 0; -+} -+ -+/* Set the splash image */ -+void graphics_set_splash(char *splashfile) { -+ grub_strcpy(splashimage, splashfile); -+} -+ -+/* Get the current splash image */ -+char *graphics_get_splash(void) { -+ return splashimage; -+} -+ -+/*=20 -+ * Initialize a vga16 graphics display with the palette based off of -+ * the image in splashimage. If the image doesn't exist, leave graphics -+ * mode. The mode initiated is 12h. From "Ralf Brown's Interrupt List": -+ * text/ text pixel pixel colors disply scrn system -+ * grph resol box resolution pages addr -+ * 12h G 80x30 8x16 640x480 16/256K . A000 VGA,ATI VIP -+ * G 80x30 8x16 640x480 16/64 . A000 ATI EGA Wonder -+ * G . . 640x480 16 . . UltraVision+256K E= GA -+ */ -+int graphics_init() -+{ -+ if (!graphics_inited) { -+ saved_videomode =3D set_videomode(0x12); -+ if (get_videomode() !=3D 0x12) { -+ set_videomode(saved_videomode); -+ return 0; -+ } -+ graphics_inited =3D 1; -+ } -+ else -+ return 1; -+ -+ font8x16 =3D (unsigned char*)graphics_get_font(); -+ -+ /* make sure that the highlight color is set correctly */ -+ graphics_highlight_color =3D ((graphics_normal_color >> 4) |=20 -+ ((graphics_normal_color & 0xf) << 4)); -+ -+ graphics_cls(); -+ -+ if (!read_image(splashimage)) { -+ grub_printf("Failed to read splash image (%s)\n", splashimage); -+ grub_printf("Press any key to continue..."); -+ getkey(); -+ set_videomode(saved_videomode); -+ graphics_inited =3D 0; -+ return 0; -+ } -+ -+ set_int1c_handler(); -+ -+ return 1; -+} -+ -+/* Leave graphics mode */ -+void graphics_end(void) -+{ -+ if (graphics_inited) { -+ unset_int1c_handler(); -+ set_videomode(saved_videomode); -+ graphics_inited =3D 0; -+ no_cursor =3D 0; -+ } -+} -+ -+/* Print ch on the screen. Handle any needed scrolling or the like */ -+void graphics_putchar(int ch) { -+ ch &=3D 0xff; -+ -+ graphics_cursor(0); -+ -+ if (ch =3D=3D '\n') { -+ if (fonty + 1 < view_y1) -+ graphics_setxy(fontx, fonty + 1); -+ else -+ graphics_scroll(); -+ graphics_cursor(1); -+ return; -+ } else if (ch =3D=3D '\r') { -+ graphics_setxy(view_x0, fonty); -+ graphics_cursor(1); -+ return; -+ } -+ -+ graphics_cursor(0); -+ -+ text[fonty * 80 + fontx] =3D ch; -+ text[fonty * 80 + fontx] &=3D 0x00ff; -+ if (graphics_current_color & 0xf0) -+ text[fonty * 80 + fontx] |=3D 0x100; -+ -+ graphics_cursor(0); -+ -+ if ((fontx + 1) >=3D view_x1) { -+ graphics_setxy(view_x0, fonty); -+ if (fonty + 1 < view_y1) -+ graphics_setxy(view_x0, fonty + 1); -+ else -+ graphics_scroll(); -+ graphics_cursor(1); -+ do_more (); -+ graphics_cursor(0); -+ } else { -+ graphics_setxy(fontx + 1, fonty); -+ } -+ -+ graphics_cursor(1); -+} -+ -+/* get the current location of the cursor */ -+int graphics_getxy(void) { -+ return (fontx << 8) | fonty; -+} -+ -+void graphics_gotoxy(int x, int y) { -+ graphics_cursor(0); -+ -+ graphics_setxy(x, y); -+ -+ graphics_cursor(1); -+} -+ -+void graphics_cls(void) { -+ int i; -+ unsigned char *mem, *s1, *s2, *s4, *s8; -+ -+ graphics_cursor(0); -+ graphics_gotoxy(view_x0, view_y0); -+ -+ mem =3D (unsigned char*)VIDEOMEM; -+ s1 =3D (unsigned char*)VSHADOW1; -+ s2 =3D (unsigned char*)VSHADOW2; -+ s4 =3D (unsigned char*)VSHADOW4; -+ s8 =3D (unsigned char*)VSHADOW8; -+ -+ for (i =3D 0; i < 80 * 30; i++) -+ text[i] =3D ' '; -+ graphics_cursor(1); -+ -+ BitMask(0xff); -+ -+ /* plane 1 */ -+ MapMask(1); -+ grub_memcpy(mem, s1, 38400); -+ -+ /* plane 2 */ -+ MapMask(2); -+ grub_memcpy(mem, s2, 38400); -+ -+ /* plane 3 */ -+ MapMask(4); -+ grub_memcpy(mem, s4, 38400); -+ -+ /* plane 4 */ -+ MapMask(8); -+ grub_memcpy(mem, s8, 38400); -+ -+ MapMask(15); -+ -+ if (no_cursor) { -+ no_cursor =3D 0; -+ set_int1c_handler(); -+ } -+} -+ -+void graphics_setcolorstate (color_state state) { -+ switch (state) { -+ case COLOR_STATE_STANDARD: -+ graphics_current_color =3D graphics_standard_color; -+ break; -+ case COLOR_STATE_NORMAL: -+ graphics_current_color =3D graphics_normal_color; -+ break; -+ case COLOR_STATE_HIGHLIGHT: -+ graphics_current_color =3D graphics_highlight_color; -+ break; -+ default: -+ graphics_current_color =3D graphics_standard_color; -+ break; -+ } -+ -+ graphics_color_state =3D state; -+} -+ -+void graphics_setcolor (int normal_color, int highlight_color) { -+ graphics_normal_color =3D normal_color; -+ graphics_highlight_color =3D highlight_color; -+ -+ graphics_setcolorstate (graphics_color_state); -+} -+ -+int graphics_setcursor (int on) { -+ if (!no_cursor && !on) { -+ no_cursor =3D 1; -+ unset_int1c_handler(); -+ graphics_cursor(0); -+ } -+ else if(no_cursor && on) { -+ no_cursor =3D 0; -+ set_int1c_handler(); -+ graphics_cursor(1); -+ } -+ return 0; -+} -+ -+/* Read in the splashscreen image and set the palette up appropriately. -+ * Format of splashscreen is an xpm (can be gzipped) with 16 colors and -+ * 640x480. */ -+int read_image(char *s) -+{ -+ char buf[32], pal[16], c; -+ unsigned char base, mask, *s1, *s2, *s4, *s8; -+ unsigned i, len, idx, colors, x, y, width, height; -+ -+ if (!grub_open(s)) -+ return 0; -+ -+ /* read header */ -+ if (!grub_read((char*)&buf, 10) || grub_memcmp(buf, "/* XPM */\n", 10= )) { -+ grub_close(); -+ return 0; -+ } -+ =20 -+ /* parse info */ -+ while (grub_read(&c, 1)) { -+ if (c =3D=3D '"') -+ break; -+ } -+ -+ while (grub_read(&c, 1) && (c =3D=3D ' ' || c =3D=3D '\t')) -+ ; -+ -+ i =3D 0; -+ width =3D c - '0'; -+ while (grub_read(&c, 1)) { -+ if (c >=3D '0' && c <=3D '9') -+ width =3D width * 10 + c - '0'; -+ else -+ break; -+ } -+ while (grub_read(&c, 1) && (c =3D=3D ' ' || c =3D=3D '\t')) -+ ; -+ -+ height =3D c - '0'; -+ while (grub_read(&c, 1)) { -+ if (c >=3D '0' && c <=3D '9') -+ height =3D height * 10 + c - '0'; -+ else -+ break; -+ } -+ while (grub_read(&c, 1) && (c =3D=3D ' ' || c =3D=3D '\t')) -+ ; -+ -+ colors =3D c - '0'; -+ while (grub_read(&c, 1)) { -+ if (c >=3D '0' && c <=3D '9') -+ colors =3D colors * 10 + c - '0'; -+ else -+ break; -+ } -+ -+ base =3D 0; -+ while (grub_read(&c, 1) && c !=3D '"') -+ ; -+ -+ /* palette */ -+ for (i =3D 0, idx =3D 1; i < colors; i++) { -+ len =3D 0; -+ -+ while (grub_read(&c, 1) && c !=3D '"') -+ ; -+ grub_read(&c, 1); /* char */ -+ base =3D c; -+ grub_read(buf, 4); /* \t c # */ -+ -+ while (grub_read(&c, 1) && c !=3D '"') { -+ if (len < sizeof(buf)) -+ buf[len++] =3D c; -+ } -+ -+ if (len =3D=3D 6 && idx < 15) { -+ int r =3D ((hex(buf[0]) << 4) | hex(buf[1])) >> 2; -+ int g =3D ((hex(buf[2]) << 4) | hex(buf[3])) >> 2; -+ int b =3D ((hex(buf[4]) << 4) | hex(buf[5])) >> 2; -+ -+ pal[idx] =3D base; -+ graphics_set_palette(idx, r, g, b); -+ ++idx; -+ } -+ } -+ -+ x =3D y =3D len =3D 0; -+ -+ s1 =3D (unsigned char*)VSHADOW1; -+ s2 =3D (unsigned char*)VSHADOW2; -+ s4 =3D (unsigned char*)VSHADOW4; -+ s8 =3D (unsigned char*)VSHADOW8; -+ -+ for (i =3D 0; i < 38400; i++) -+ s1[i] =3D s2[i] =3D s4[i] =3D s8[i] =3D 0; -+ -+ /* parse xpm data */ -+ while (y < height) { -+ while (1) { -+ if (!grub_read(&c, 1)) { -+ grub_close(); -+ return 0; -+ } -+ if (c =3D=3D '"') -+ break; -+ } -+ -+ while (grub_read(&c, 1) && c !=3D '"') { -+ for (i =3D 1; i < 15; i++) -+ if (pal[i] =3D=3D c) { -+ c =3D i; -+ break; -+ } -+ -+ mask =3D 0x80 >> (x & 7); -+ if (c & 1) -+ s1[len + (x >> 3)] |=3D mask; -+ if (c & 2) -+ s2[len + (x >> 3)] |=3D mask; -+ if (c & 4) -+ s4[len + (x >> 3)] |=3D mask; -+ if (c & 8) -+ s8[len + (x >> 3)] |=3D mask; -+ -+ if (++x >=3D 640) { -+ x =3D 0; -+ -+ if (y < 480) -+ len +=3D 80; -+ ++y; -+ } -+ } -+ } -+ -+ grub_close(); -+ -+ graphics_set_palette(0, (background >> 16), (background >> 8) & 63,=20 -+ background & 63); -+ graphics_set_palette(15, (foreground >> 16), (foreground >> 8) & 63,=20 -+ foreground & 63); -+ graphics_set_palette(0x11, (window_border >> 16), (window_border >> 8= ) & 63,=20 -+ window_border & 63); -+ -+ return 1; -+} -+ -+/* Convert a character which is a hex digit to the appropriate integer */ -+int hex(int v) -+{ -+ if (v >=3D 'A' && v <=3D 'F') -+ return (v - 'A' + 10); -+ if (v >=3D 'a' && v <=3D 'f') -+ return (v - 'a' + 10); -+ return (v - '0'); -+} -+ -+void graphics_cursor(int set) { -+ unsigned char *pat, *mem, *ptr, chr[16 << 2]; -+ int i, ch, invert, offset; -+ -+ if (set && (no_cursor || no_scroll)) -+ return; -+ -+ offset =3D cursorY * 80 + fontx; -+ ch =3D text[fonty * 80 + fontx] & 0xff; -+ invert =3D (text[fonty * 80 + fontx] & 0xff00) !=3D 0; -+ pat =3D font8x16 + (ch << 4); -+ -+ mem =3D (unsigned char*)VIDEOMEM + offset; -+ -+ if (!set) { -+ for (i =3D 0; i < 16; i++) { -+ unsigned char mask =3D pat[i]; -+ -+ if (!invert) { -+ chr[i ] =3D ((unsigned char*)VSHADOW1)[offset]; -+ chr[16 + i] =3D ((unsigned char*)VSHADOW2)[offset]; -+ chr[32 + i] =3D ((unsigned char*)VSHADOW4)[offset]; -+ chr[48 + i] =3D ((unsigned char*)VSHADOW8)[offset]; -+ -+ if (shade) { -+ if (ch =3D=3D DISP_VERT || ch =3D=3D DISP_LL || -+ ch =3D=3D DISP_UR || ch =3D=3D DISP_LR) { -+ unsigned char pmask =3D ~(pat[i] >> 1); -+ -+ chr[i ] &=3D pmask; -+ chr[16 + i] &=3D pmask; -+ chr[32 + i] &=3D pmask; -+ chr[48 + i] &=3D pmask; -+ } -+ if (i > 0 && ch !=3D DISP_VERT) { -+ unsigned char pmask =3D ~(pat[i - 1] >> 1); -+ -+ chr[i ] &=3D pmask; -+ chr[16 + i] &=3D pmask; -+ chr[32 + i] &=3D pmask; -+ chr[48 + i] &=3D pmask; -+ if (ch =3D=3D DISP_HORIZ || ch =3D=3D DISP_UR || = ch =3D=3D DISP_LR) { -+ pmask =3D ~pat[i - 1]; -+ -+ chr[i ] &=3D pmask; -+ chr[16 + i] &=3D pmask; -+ chr[32 + i] &=3D pmask; -+ chr[48 + i] &=3D pmask; -+ } -+ } -+ } -+ chr[i ] |=3D mask; -+ chr[16 + i] |=3D mask; -+ chr[32 + i] |=3D mask; -+ chr[48 + i] |=3D mask; -+ -+ offset +=3D 80; -+ } -+ else { -+ chr[i ] =3D mask; -+ chr[16 + i] =3D mask; -+ chr[32 + i] =3D mask; -+ chr[48 + i] =3D mask; -+ } -+ } -+ } -+ else { -+ MapMask(15); -+ ptr =3D mem; -+ for (i =3D 0; i < 16; i++, ptr +=3D 80) { -+ cursorBuf[i] =3D pat[i]; -+ *ptr =3D ~pat[i]; -+ } -+ return; -+ } -+ -+ offset =3D 0; -+ for (i =3D 1; i < 16; i <<=3D 1, offset +=3D 16) { -+ int j; -+ -+ MapMask(i); -+ ptr =3D mem; -+ for (j =3D 0; j < 16; j++, ptr +=3D 80) -+ *ptr =3D chr[j + offset]; -+ } -+ -+ MapMask(15); -+} -+ -+#endif /* SUPPORT_GRAPHICS */ -diff -Naur grub-0.97.orig/stage2/graphics.h grub-0.97/stage2/graphics.h ---- grub-0.97.orig/stage2/graphics.h 1969-12-31 21:00:00.000000000 -0300 -+++ grub-0.97/stage2/graphics.h 2005-06-12 20:56:49.000000000 -0300 -@@ -0,0 +1,43 @@ -+/* graphics.h - graphics console interface */ -+/* -+ * GRUB -- GRand Unified Bootloader -+ * Copyright (C) 2002 Free Software Foundation, Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; If not, see -+ */ -+ -+#ifndef GRAPHICS_H -+#define GRAPHICS_H -+ -+/* magic constant */ -+#define VIDEOMEM 0xA0000 -+ -+/* function prototypes */ -+char *graphics_get_splash(void); -+ -+int read_image(char *s); -+void graphics_cursor(int set); -+ -+/* function prototypes for asm functions */ -+void * graphics_get_font(); -+void graphics_set_palette(int idx, int red, int green, int blue); -+void set_int1c_handler(); -+void unset_int1c_handler(); -+ -+extern short cursorX, cursorY; -+extern char cursorBuf[16]; -+extern int shade; -+extern int view_x0, view_y0, view_x1, view_y1; -+ -+#endif /* GRAPHICS_H */ -diff -Naur grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am ---- grub-0.97.orig/stage2/Makefile.am 2005-02-02 18:37:35.000000000 -0200 -+++ grub-0.97/stage2/Makefile.am 2005-06-12 20:56:49.000000000 -0300 -@@ -7,7 +7,7 @@ - fat.h filesys.h freebsd.h fs.h hercules.h i386-elf.h \ - imgact_aout.h iso9660.h jfs.h mb_header.h mb_info.h md5.h \ - nbi.h pc_slice.h serial.h shared.h smp-imps.h term.h \ -- terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h -+ terminfo.h tparm.h nbi.h ufs2.h vstafs.h xfs.h graphics.h - EXTRA_DIST =3D setjmp.S apm.S $(noinst_SCRIPTS) -=20 - # For . -@@ -19,7 +19,7 @@ - disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \ - fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \ - fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \ -- terminfo.c tparm.c -+ terminfo.c tparm.c graphics.c - libgrub_a_CFLAGS =3D $(GRUB_CFLAGS) -I$(top_srcdir)/lib \ - -DGRUB_UTIL=3D1 -DFSYS_EXT2FS=3D1 -DFSYS_FAT=3D1 -DFSYS_FFS=3D1 \ - -DFSYS_ISO9660=3D1 -DFSYS_JFS=3D1 -DFSYS_MINIX=3D1 -DFSYS_REISERFS=3D1 \ -@@ -79,8 +79,14 @@ - HERCULES_FLAGS =3D - endif -=20 -+if GRAPHICS_SUPPORT -+GRAPHICS_FLAGS =3D -DSUPPORT_GRAPHICS=3D1 -+else -+GRAPHICS_FLAGS =3D -+endif -+ - STAGE2_COMPILE =3D $(STAGE2_CFLAGS) -fno-builtin -nostdinc \ -- $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) -+ $(NETBOOT_FLAGS) $(SERIAL_FLAGS) $(HERCULES_FLAGS) $(GRAPHICS_FLAGS) -=20 - STAGE1_5_LINK =3D -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000 - STAGE1_5_COMPILE =3D $(STAGE2_COMPILE) -DNO_DECOMPRESSION=3D1 -DSTAGE1_5= =3D1 -@@ -90,7 +96,8 @@ - cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \ - fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \ - fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \ -- hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c -+ hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \ -+ graphics.c - pre_stage2_exec_CFLAGS =3D $(STAGE2_COMPILE) $(FSYS_CFLAGS) - pre_stage2_exec_CCASFLAGS =3D $(STAGE2_COMPILE) $(FSYS_CFLAGS) - pre_stage2_exec_LDFLAGS =3D $(PRE_STAGE2_LINK) -diff -Naur grub-0.97.orig/stage2/shared.h grub-0.97/stage2/shared.h ---- grub-0.97.orig/stage2/shared.h 2004-06-19 13:40:09.000000000 -0300 -+++ grub-0.97/stage2/shared.h 2005-06-12 20:56:49.000000000 -0300 -@@ -792,6 +792,11 @@ - /* Set the cursor position. */ - void gotoxy (int x, int y); -=20 -+/* Internal pager -+ Returns 1 =3D if pager was used -+ 0 =3D if pager wasn't used */ -+int do_more (void); -+ - /* Displays an ASCII character. IBM displays will translate some - characters to special graphical ones (see the DISP_* constants). */ - void grub_putchar (int c); -@@ -871,6 +876,7 @@ - int grub_tolower (int c); - int grub_isspace (int c); - int grub_strncat (char *s1, const char *s2, int n); -+void grub_memcpy(void *dest, const void *src, int len); - void *grub_memmove (void *to, const void *from, int len); - void *grub_memset (void *start, int c, int len); - int grub_strncat (char *s1, const char *s2, int n); -diff -Naur grub-0.97.orig/stage2/stage2.c grub-0.97/stage2/stage2.c ---- grub-0.97.orig/stage2/stage2.c 2005-03-19 14:51:57.000000000 -0300 -+++ grub-0.97/stage2/stage2.c 2005-06-13 22:38:08.000000000 -0300 -@@ -20,6 +20,12 @@ - #include - #include -=20 -+#ifdef SUPPORT_GRAPHICS -+# include -+#endif -+ -+int col_start, col_end, row_start, box_size; -+ - grub_jmp_buf restart_env; -=20 - #if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS) -@@ -105,13 +111,13 @@ - if (highlight && current_term->setcolorstate) - current_term->setcolorstate (COLOR_STATE_HIGHLIGHT); -=20 -- gotoxy (2, y); -+ gotoxy (2 + col_start, y); - grub_putchar (' '); -- for (x =3D 3; x < 75; x++) -+ for (x =3D 3 + col_start; x < (col_end - 5); x++) - { -- if (*entry && x <=3D 72) -+ if (*entry && x <=3D (col_end - 8)) - { -- if (x =3D=3D 72) -+ if (x =3D=3D (col_end - 8)) - grub_putchar (DISP_RIGHT); - else - grub_putchar (*entry++); -@@ -119,7 +125,7 @@ - else - grub_putchar (' '); - } -- gotoxy (74, y); -+ gotoxy ((col_end - 6), y); -=20 - if (current_term->setcolorstate) - current_term->setcolorstate (COLOR_STATE_STANDARD); -@@ -131,7 +137,7 @@ - { - int i; - =20 -- gotoxy (77, y + 1); -+ gotoxy ((col_end - 3), y + 1); -=20 - if (first) - grub_putchar (DISP_UP); -@@ -151,14 +157,14 @@ - menu_entries++; - } -=20 -- gotoxy (77, y + size); -+ gotoxy ((col_end - 3), y + size); -=20 - if (*menu_entries) - grub_putchar (DISP_DOWN); - else - grub_putchar (' '); -=20 -- gotoxy (74, y + entryno + 1); -+ gotoxy ((col_end - 6), y + entryno + 1); - } -=20 - static void -@@ -196,30 +202,30 @@ - if (current_term->setcolorstate) - current_term->setcolorstate (COLOR_STATE_NORMAL); - =20 -- gotoxy (1, y); -+ gotoxy (1 + col_start, y); -=20 - grub_putchar (DISP_UL); -- for (i =3D 0; i < 73; i++) -+ for (i =3D col_start; i < (col_end - 7); i++) - grub_putchar (DISP_HORIZ); - grub_putchar (DISP_UR); -=20 - i =3D 1; - while (1) - { -- gotoxy (1, y + i); -+ gotoxy (1 + col_start, y + i); -=20 - if (i > size) - break; - =20 - grub_putchar (DISP_VERT); -- gotoxy (75, y + i); -+ gotoxy ((col_end - 5), y + i); - grub_putchar (DISP_VERT); -=20 - i++; - } -=20 - grub_putchar (DISP_LL); -- for (i =3D 0; i < 73; i++) -+ for (i =3D col_start; i < (col_end - 7); i++) - grub_putchar (DISP_HORIZ); - grub_putchar (DISP_LR); -=20 -@@ -233,6 +239,7 @@ - { - int c, time1, time2 =3D -1, first_entry =3D 0; - char *cur_entry =3D 0; -+ struct term_entry *prev_term =3D NULL; -=20 - /* - * Main loop for menu UI. -@@ -250,6 +257,22 @@ - } - } -=20 -+ col_start =3D 0; -+ col_end =3D 80; -+ row_start =3D 0; -+ box_size =3D 12; -+ /* if we're using viewport we need to make sure to setup -+ coordinates correctly. */ -+#ifdef SUPPORT_GRAPHICS -+ if (grub_memcmp (current_term->name, "graphics", sizeof ("graphics") - = 1) =3D=3D 0) -+ { -+ col_start =3D view_x0; -+ col_end =3D view_x1; -+ row_start =3D view_y0; -+ box_size =3D (view_y1 - view_y0) - 13; -+ } -+#endif -+ - /* If the timeout was expired or wasn't set, force to show the menu - interface. */ - if (grub_timeout < 0) -@@ -302,36 +325,36 @@ - if (current_term->flags & TERM_DUMB) - print_entries_raw (num_entries, first_entry, menu_entries); - else -- print_border (3, 12); -+ print_border (3 + row_start, box_size); -=20 - grub_printf ("\n\ -- Use the %c and %c keys to select which entry is highlighted.\n", -+ Use the %c and %c keys to select which entry is highlighted.\n", - DISP_UP, DISP_DOWN); - =20 - if (! auth && password) - { - printf ("\ -- Press enter to boot the selected OS or \'p\' to enter a\n\ -- password to unlock the next set of features."); -+ Press enter to boot the selected OS or \'p\' to enter a\n\ -+ password to unlock the next set of features."); - } - else - { - if (config_entries) - printf ("\ -- Press enter to boot the selected OS, \'e\' to edit the\n\ -- commands before booting, or \'c\' for a command-line."); -+ Press enter to boot the selected OS, \'e\' to edit the\n\ -+ commands before booting, or \'c\' for a command-line."); - else - printf ("\ -- Press \'b\' to boot, \'e\' to edit the selected command in the\n\ -- boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\ -- after (\'O\' for before) the selected line, \'d\' to remove the\n\ -- selected line, or escape to go back to the main menu."); -+ Press \'b\' to boot, \'e\' to edit the selected command in the\n\ -+ boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\ -+ after (\'O\' for before) the selected line, \'d\' to remove the\n\ -+ selected line, or escape to go back to the main menu."); - } -=20 - if (current_term->flags & TERM_DUMB) - grub_printf ("\n\nThe selected entry is %d ", entryno); - else -- print_entries (3, 12, first_entry, entryno, menu_entries); -+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_entri= es); - } -=20 - /* XX using RT clock now, need to initialize value */ -@@ -358,10 +381,10 @@ - entryno, grub_timeout); - else - { -- gotoxy (3, 22); -- grub_printf ("The highlighted entry will be booted automatically i= n %d seconds. ", -+ gotoxy (3 + col_start, 10 + box_size + row_start); -+ grub_printf (" The highlighted entry will be booted automatically = in %d seconds. ", - grub_timeout); -- gotoxy (74, 4 + entryno); -+ gotoxy ((col_end - 6), 4 + entryno + row_start); - } - =20 - grub_timeout--; -@@ -387,12 +410,12 @@ - if (current_term->flags & TERM_DUMB) - grub_putchar ('\r'); - else -- gotoxy (3, 22); -+ gotoxy (3 + col_start, 10 + box_size + row_start); - printf (" = "); - grub_timeout =3D -1; - fallback_entryno =3D -1; - if (! (current_term->flags & TERM_DUMB)) -- gotoxy (74, 4 + entryno); -+ gotoxy ((col_end - 6), 4 + entryno + row_start); - } -=20 - /* We told them above (at least in SUPPORT_SERIAL) to use -@@ -408,12 +431,12 @@ - { - if (entryno > 0) - { -- print_entry (4 + entryno, 0, -+ print_entry (4 + entryno + row_start, 0, - get_entry (menu_entries, - first_entry + entryno, - 0)); - entryno--; -- print_entry (4 + entryno, 1, -+ print_entry (4 + entryno + row_start, 1, - get_entry (menu_entries, - first_entry + entryno, - 0)); -@@ -421,7 +444,7 @@ - else if (first_entry > 0) - { - first_entry--; -- print_entries (3, 12, first_entry, entryno, -+ print_entries (3 + row_start, box_size, first_entry, entryno, - menu_entries); - } - } -@@ -433,29 +456,29 @@ - entryno++; - else - { -- if (entryno < 11) -+ if (entryno < (box_size - 1)) - { -- print_entry (4 + entryno, 0, -+ print_entry (4 + entryno + row_start, 0, - get_entry (menu_entries, - first_entry + entryno, - 0)); - entryno++; -- print_entry (4 + entryno, 1, -+ print_entry (4 + entryno + row_start, 1, - get_entry (menu_entries, - first_entry + entryno, - 0)); - } -- else if (num_entries > 12 + first_entry) -+ else if (num_entries > box_size + first_entry) - { - first_entry++; -- print_entries (3, 12, first_entry, entryno, menu_entries); -+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_= entries); - } - } - } - else if (c =3D=3D 7) - { - /* Page Up */ -- first_entry -=3D 12; -+ first_entry -=3D box_size; - if (first_entry < 0) - { - entryno +=3D first_entry; -@@ -463,20 +486,20 @@ - if (entryno < 0) - entryno =3D 0; - } -- print_entries (3, 12, first_entry, entryno, menu_entries); -+ print_entries (3 + row_start, box_size, first_entry, entryno, menu= _entries); - } - else if (c =3D=3D 3) - { - /* Page Down */ -- first_entry +=3D 12; -+ first_entry +=3D box_size; - if (first_entry + entryno + 1 >=3D num_entries) - { -- first_entry =3D num_entries - 12; -+ first_entry =3D num_entries - box_size; - if (first_entry < 0) - first_entry =3D 0; - entryno =3D num_entries - first_entry - 1; - } -- print_entries (3, 12, first_entry, entryno, menu_entries); -+ print_entries (3 + row_start, box_size, first_entry, entryno, menu= _entries); - } -=20 - if (config_entries) -@@ -489,7 +512,7 @@ - if ((c =3D=3D 'd') || (c =3D=3D 'o') || (c =3D=3D 'O')) - { - if (! (current_term->flags & TERM_DUMB)) -- print_entry (4 + entryno, 0, -+ print_entry (4 + entryno + row_start, 0, - get_entry (menu_entries, - first_entry + entryno, - 0)); -@@ -537,7 +560,7 @@ -=20 - if (entryno >=3D num_entries) - entryno--; -- if (first_entry && num_entries < 12 + first_entry) -+ if (first_entry && num_entries < box_size + first_entry) - first_entry--; - } -=20 -@@ -549,7 +572,7 @@ - grub_printf ("\n"); - } - else -- print_entries (3, 12, first_entry, entryno, menu_entries); -+ print_entries (3 + row_start, box_size, first_entry, entryno, menu_= entries); - } -=20 - cur_entry =3D menu_entries; -@@ -570,7 +593,7 @@ - if (current_term->flags & TERM_DUMB) - grub_printf ("\r "); - else -- gotoxy (1, 21); -+ gotoxy (1 + col_start, 9 + box_size + row_start); -=20 - /* Wipe out the previously entered password */ - grub_memset (entered, 0, sizeof (entered)); -@@ -714,6 +737,15 @@ - =20 - cls (); - setcursor (1); -+ /* if our terminal needed initialization, we should shut it down -+ * before booting the kernel, but we want to save what it was so -+ * we can come back if needed */ -+ prev_term =3D current_term; -+ if (current_term->shutdown)=20 -+ { -+ current_term->shutdown(); -+ current_term =3D term_table; /* assumption: console is first */ -+ } - =20 - while (1) - { -@@ -748,6 +780,13 @@ - break; - } -=20 -+ /* if we get back here, we should go back to what our term was before */ -+ current_term =3D prev_term; -+ if (current_term->startup) -+ /* if our terminal fails to initialize, fall back to console since -+ * it should always work */ -+ if (current_term->startup() =3D=3D 0) -+ current_term =3D term_table; /* we know that console is first */ - show_menu =3D 1; - goto restart; - } -@@ -1050,6 +1089,16 @@ - while (is_preset); - } -=20 -+ /* go ahead and make sure the terminal is setup */ -+ if (current_term->startup) -+ { -+ /* If initialization fails, go back to default terminal */ -+ if (current_term->startup() =3D=3D 0) -+ { -+ current_term =3D term_table; -+ } -+ } -+ - if (! num_entries) - { - /* If no acceptable config file, goto command-line, starting -diff -Naur grub-0.97.orig/stage2/term.h grub-0.97/stage2/term.h ---- grub-0.97.orig/stage2/term.h 2003-07-09 08:45:53.000000000 -0300 -+++ grub-0.97/stage2/term.h 2005-06-13 14:07:40.000000000 -0300 -@@ -60,6 +60,8 @@ - const char *name; - /* The feature flags defined above. */ - unsigned long flags; -+ /* Default for maximum number of lines if not specified */ -+ unsigned short max_lines; - /* Put a character. */ - void (*putchar) (int c); - /* Check if any input character is available. */ -@@ -79,6 +81,10 @@ - void (*setcolor) (int normal_color, int highlight_color); - /* Turn on/off the cursor. */ - int (*setcursor) (int on); -+ /* function to start a terminal */ -+ int (*startup) (void); -+ /* function to use to shutdown a terminal */ -+ void (*shutdown) (void); - }; -=20 - /* This lists up available terminals. */ -@@ -124,4 +130,24 @@ - int hercules_setcursor (int on); - #endif -=20 -+#ifdef SUPPORT_GRAPHICS -+extern int foreground, background, window_border, graphics_inited, saved_= videomode; -+ -+void graphics_set_splash(char *splashfile); -+int set_videomode(int mode); -+int get_videomode(void); -+void graphics_putchar (int c); -+int graphics_getxy(void); -+void graphics_gotoxy(int x, int y); -+void graphics_cls(void); -+void graphics_setcolorstate (color_state state); -+void graphics_setcolor (int normal_color, int highlight_color); -+int graphics_setcursor (int on); -+int graphics_init(void); -+void graphics_end(void); -+ -+int hex(int v); -+void graphics_set_palette(int idx, int red, int green, int blue); -+#endif /* SUPPORT_GRAPHICS */ -+ - #endif /* ! GRUB_TERM_HEADER */ diff --git a/stubdom/grub.patches/11graphics-keyboard.diff b/stubdom/grub.p= atches/11graphics-keyboard.diff deleted file mode 100644 index fe17b20a6f..0000000000 --- a/stubdom/grub.patches/11graphics-keyboard.diff +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/stage2/stage2.c b/stage2/stage2.c -index 9d9fcc3..8353a3b 100644 ---- a/stage2/stage2.c -+++ b/stage2/stage2.c -@@ -395,7 +395,7 @@ restart: - pressed. =20 - This avoids polling (relevant in the grub-shell and later on - in grub if interrupt driven I/O is done). */ -- if (checkkey () >=3D 0 || grub_timeout < 0) -+ if (checkkey () > 0 || grub_timeout < 0) - { - /* Key was pressed, show which entry is selected before GETKEY, - since we're comming in here also on GRUB_TIMEOUT =3D=3D -1 and diff --git a/stubdom/grub.patches/20print_func.diff b/stubdom/grub.patches/= 20print_func.diff deleted file mode 100644 index 71ad042ac2..0000000000 --- a/stubdom/grub.patches/20print_func.diff +++ /dev/null @@ -1,52 +0,0 @@ -2006-01-05 Otavio Salvador - - * Rediff. - -2005-16-10 Samuel Thibault - - * docs/grub.texi: Added print command description. - * stage2/builtins.c(print_func): New function. - (builtin_print): New variable. - (builtin_table): Added builtin_print in table. - -Debian Status Following: - Added by: Otavio Salvador - Date: 2006-01-05 - -diff -Nur grub-0.97-bkp/stage2/builtins.c grub-0.97/stage2/builtins.c ---- grub-0.97-bkp/stage2/builtins.c 2006-01-05 10:59:05.550350040 -0200 -+++ grub-0.97/stage2/builtins.c 2006-01-05 11:19:28.422445224 -0200 -@@ -2323,6 +2323,25 @@ - "Probe I/O ports used for the drive DRIVE." - }; -=20 -+/* print */ -+static int -+print_func (char *arg, int flags) -+{ -+ printf("%s\n", arg); -+ -+ return 0; -+} -+ -+static struct builtin builtin_print =3D -+{ -+ "print", -+ print_func, -+ BUILTIN_CMDLINE | BUILTIN_MENU | BUILTIN_NO_ECHO, -+ "print [MESSAGE ...]", -+ "Print MESSAGE." -+}; -+ -+ - =0C - /* kernel */ - static int -@@ -4848,6 +4867,7 @@ - &builtin_parttype, - &builtin_password, - &builtin_pause, -+ &builtin_print, - #ifdef GRUB_UTIL - &builtin_quit, - #endif /* GRUB_UTIL */ diff --git a/stubdom/grub.patches/30savedefault.diff b/stubdom/grub.patches= /30savedefault.diff deleted file mode 100644 index 2902b876ec..0000000000 --- a/stubdom/grub.patches/30savedefault.diff +++ /dev/null @@ -1,186 +0,0 @@ -Index: grub/stage2/builtins.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/builtins.c 2008-06-02 18:06:08.942580000 +0100 -+++ grub/stage2/builtins.c 2008-06-06 18:35:07.548390000 +0100 -@@ -86,6 +86,10 @@ - inside other functions. */ - static int configfile_func (char *arg, int flags); -=20 -+static int savedefault_helper (char *arg, int flags); -+ -+static int savedefault_shell (char *arg, int flags); -+ - /* Initialize the data for builtins. */ - void - init_builtins (void) -@@ -3512,7 +3516,109 @@ - static int - savedefault_func (char *arg, int flags) - { --#if !defined(SUPPORT_DISKLESS) && !defined(GRUB_UTIL) -+#if !defined(SUPPORT_DISKLESS) -+ #if !defined(GRUB_UTIL) -+ return savedefault_helper(arg, flags); -+ #else -+ return savedefault_shell(arg, flags); -+ #endif -+#else /* !SUPPORT_DISKLESS */=20 -+ errnum =3D ERR_UNRECOGNIZED; -+ return 1; -+#endif /* !SUPPORT_DISKLESS */ -+} -+ -+#if !defined(SUPPORT_DISKLESS) && defined(GRUB_UTIL) -+/* savedefault_shell */ -+static int -+savedefault_shell(char *arg, int flags) -+ { -+ int once_only =3D 0; -+ int new_default; -+ int curr_default =3D -1; -+ int curr_prev_default =3D -1; -+ int new_prev_default =3D -1; -+ FILE *fp; -+ size_t bytes =3D 10; -+ char line[bytes]; -+ char *default_file =3D (char *) DEFAULT_FILE_BUF; -+ char buf[bytes]; -+ int i; -+ =20 -+ while (1) -+ { -+ if (grub_memcmp ("--default=3D", arg, sizeof ("--default=3D") - 1) = =3D=3D 0) -+ { -+ char *p =3D arg + sizeof ("--default=3D") - 1; -+ if (! safe_parse_maxint (&p, &new_default)) -+ return 1; -+ arg =3D skip_to (0, arg); -+ } -+ else if (grub_memcmp ("--once", arg, sizeof ("--once") - 1) =3D=3D = 0) -+ { -+ once_only =3D 1; -+ arg =3D skip_to (0, arg); -+ } -+ else -+ break; -+ } -+ -+ *default_file =3D 0; -+ grub_strncat (default_file, config_file, DEFAULT_FILE_BUFLEN); -+ for (i =3D grub_strlen(default_file); i >=3D 0; i--) -+ if (default_file[i] =3D=3D '/') -+ { -+ i++; -+ break; -+ } -+ default_file[i] =3D 0; -+ grub_strncat (default_file + i, "default", DEFAULT_FILE_BUFLEN - i); -+ -+ if(!(fp =3D fopen(default_file,"r"))) -+ { -+ errnum =3D ERR_READ; -+ goto fail; -+ } -+ =20 -+ fgets(line, bytes, fp); -+ fclose(fp); -+=20 -+ sscanf(line, "%d:%d", &curr_prev_default, &curr_default); -+ =20 -+ if(curr_default !=3D -1) -+ new_prev_default =3D curr_default; -+ else -+ { -+ if(curr_prev_default !=3D -1) -+ new_prev_default =3D curr_prev_default; -+ else -+ new_prev_default =3D 0; -+ } -+ =20 -+ if(once_only) -+ sprintf(buf, "%d:%d", new_prev_default, new_default); -+ else -+ sprintf(buf, "%d", new_default); -+ -+ if(!(fp =3D fopen(default_file,"w"))) -+ { -+ errnum =3D ERR_READ; -+ goto fail; -+ } -+ =20 -+ fprintf(fp, buf); =20 -+ =20 -+fail: -+ fclose(fp); -+ return errnum; -+} -+#endif -+ -+/* savedefault_helper */ -+static int -+savedefault_helper (char *arg, int flags) -+{ -+#if !defined(SUPPORT_DISKLESS) - unsigned long tmp_drive =3D saved_drive; - unsigned long tmp_partition =3D saved_partition; - char *default_file =3D (char *) DEFAULT_FILE_BUF; -@@ -3588,22 +3694,26 @@ - =20 - disk_read_hook =3D disk_read_savesect_func; - len =3D grub_read (buf, sizeof (buf)); -+ buf[9]=3D'\0';/* Make sure grub_strstr() below terminates */ - disk_read_hook =3D 0; - grub_close (); - =20 -- if (len !=3D sizeof (buf)) -- { -- /* This is too small. Do not modify the file manually, please! */ -- errnum =3D ERR_READ; -- goto fail; -- } -- - if (sector_count > 2) - { - /* Is this possible?! Too fragmented! */ - errnum =3D ERR_FSYS_CORRUPT; - goto fail; - } -+ -+ char *tmp; -+ if((tmp =3D grub_strstr(buf, ":")) !=3D NULL) -+ { -+ int f_len =3D grub_strlen(buf) - grub_strlen(tmp); -+ char *def; -+ buf[f_len] =3D '\0'; -+ def =3D buf; -+ safe_parse_maxint (&def, &entryno); -+ } - =20 - /* Set up a string to be written. */ - grub_memset (buf, '\n', sizeof (buf)); -Index: grub/stage2/stage2.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/stage2.c 2008-06-02 18:06:08.858579000 +0100 -+++ grub/stage2/stage2.c 2008-06-06 18:04:03.585354000 +0100 -@@ -49,7 +49,8 @@ - return 0; - #endif /* GRUB_UTIL */ - =20 -- preset_menu_offset =3D 0; -+ if (preset_menu_offset) -+ return 0; - return preset_menu !=3D 0; - } -=20 -@@ -934,7 +935,11 @@ - len =3D grub_read (buf, sizeof (buf)); - if (len > 0) - { -+ char *tmp; - buf[sizeof (buf) - 1] =3D 0; -+ if((tmp =3D grub_strstr(p, ":")) !=3D NULL) -+ p =3D tmp + 1; -+ =20 - safe_parse_maxint (&p, &saved_entryno); - } -=20 diff --git a/stubdom/grub.patches/40ext3_256byte_inode.diff b/stubdom/grub.= patches/40ext3_256byte_inode.diff deleted file mode 100644 index 0c40854f94..0000000000 --- a/stubdom/grub.patches/40ext3_256byte_inode.diff +++ /dev/null @@ -1,114 +0,0 @@ - -Patch from Red Hat. See #463236, #463123. - -Index: grub/stage2/fsys_ext2fs.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/fsys_ext2fs.c 2008-05-27 18:47:19.045183000 +0100 -+++ grub/stage2/fsys_ext2fs.c 2008-05-27 19:09:21.293187000 +0100 -@@ -79,7 +79,52 @@ - __u32 s_rev_level; /* Revision level */ - __u16 s_def_resuid; /* Default uid for reserved blocks */ - __u16 s_def_resgid; /* Default gid for reserved blocks */ -- __u32 s_reserved[235]; /* Padding to the end of the block */ -+ /* -+ * These fields are for EXT2_DYNAMIC_REV superblocks only. -+ * -+ * Note: the difference between the compatible feature set and -+ * the incompatible feature set is that if there is a bit set -+ * in the incompatible feature set that the kernel doesn't -+ * know about, it should refuse to mount the filesystem. -+ * -+ * e2fsck's requirements are more strict; if it doesn't know -+ * about a feature in either the compatible or incompatible -+ * feature set, it must abort and not try to meddle with -+ * things it doesn't understand... -+ */ -+ __u32 s_first_ino; /* First non-reserved inode */ -+ __u16 s_inode_size; /* size of inode structure */ -+ __u16 s_block_group_nr; /* block group # of this superblock */ -+ __u32 s_feature_compat; /* compatible feature set */ -+ __u32 s_feature_incompat; /* incompatible feature set */ -+ __u32 s_feature_ro_compat; /* readonly-compatible feature set */ -+ __u8 s_uuid[16]; /* 128-bit uuid for volume */ -+ char s_volume_name[16]; /* volume name */ -+ char s_last_mounted[64]; /* directory where last mounted */ -+ __u32 s_algorithm_usage_bitmap; /* For compression */ -+ /* -+ * Performance hints. Directory preallocation should only -+ * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. -+ */ -+ __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ -+ __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ -+ __u16 s_reserved_gdt_blocks;/* Per group table for online growth */ -+ /* -+ * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set. -+ */ -+ __u8 s_journal_uuid[16]; /* uuid of journal superblock */ -+ __u32 s_journal_inum; /* inode number of journal file */ -+ __u32 s_journal_dev; /* device number of journal file */ -+ __u32 s_last_orphan; /* start of list of inodes to delete */ -+ __u32 s_hash_seed[4]; /* HTREE hash seed */ -+ __u8 s_def_hash_version; /* Default hash version to use */ -+ __u8 s_jnl_backup_type; /* Default type of journal backup */ -+ __u16 s_reserved_word_pad; -+ __u32 s_default_mount_opts; -+ __u32 s_first_meta_bg; /* First metablock group */ -+ __u32 s_mkfs_time; /* When the filesystem was created */ -+ __u32 s_jnl_blocks[17]; /* Backup of the journal inode */ -+ __u32 s_reserved[172]; /* Padding to the end of the block */ - }; -=20 - struct ext2_group_desc -@@ -218,6 +263,9 @@ - #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u= 32)) - #define EXT2_ADDR_PER_BLOCK_BITS(s) (log2(EXT2_ADDR_PER_BLOCK(s))) -=20 -+#define EXT2_INODE_SIZE(s) (SUPERBLOCK->s_inode_size) -+#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s)) -+ - /* linux/ext2_fs.h */ - #define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) - /* kind of from ext2/super.c */ -@@ -242,7 +290,14 @@ - static __inline__ unsigned long - ffz (unsigned long word) - { -- __asm__ ("bsfl %1,%0" -+ __asm__ ("bsf" -+#ifdef __i386__ -+ "l" -+#endif -+#ifdef __x86_64__ -+ "q" -+#endif -+ " %1,%0" - : "=3Dr" (word) - : "r" (~word)); - return word; -@@ -553,7 +608,7 @@ - gdp =3D GROUP_DESC; - ino_blk =3D gdp[desc].bg_inode_table + - (((current_ino - 1) % (SUPERBLOCK->s_inodes_per_group)) -- >> log2 (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode))); -+ >> log2 (EXT2_INODES_PER_BLOCK (SUPERBLOCK))); - #ifdef E2DEBUG - printf ("inode table fsblock=3D%d\n", ino_blk); - #endif /* E2DEBUG */ -@@ -565,13 +620,12 @@ - /* reset indirect blocks! */ - mapblock2 =3D mapblock1 =3D -1; -=20 -- raw_inode =3D INODE + -- ((current_ino - 1) -- & (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode) - 1)); -+ raw_inode =3D (struct ext2_inode *)((char *)INODE + -+ ((current_ino - 1) & (EXT2_INODES_PER_BLOCK (SUPERBLOCK) - 1)) * -+ EXT2_INODE_SIZE (SUPERBLOCK)); - #ifdef E2DEBUG - printf ("ipb=3D%d, sizeof(inode)=3D%d\n", -- (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode)), -- sizeof (struct ext2_inode)); -+ EXT2_INODES_PER_BLOCK (SUPERBLOCK), EXT2_INODE_SIZE (SUPERBLOCK)); - printf ("inode=3D%x, raw_inode=3D%x\n", INODE, raw_inode); - printf ("offset into inode table block=3D%d\n", (int) raw_inode - (= int) INODE); - for (i =3D (unsigned char *) INODE; i <=3D (unsigned char *) raw_in= ode; diff --git a/stubdom/grub.patches/50fs_fulldisk.diff b/stubdom/grub.patches= /50fs_fulldisk.diff deleted file mode 100644 index d0fbb07bc1..0000000000 --- a/stubdom/grub.patches/50fs_fulldisk.diff +++ /dev/null @@ -1,72 +0,0 @@ -diff -urN grub-0.97.orig/stage2/fsys_ext2fs.c grub-0.97/stage2/fsys_ext2fs= .c ---- grub-0.97.orig/stage2/fsys_ext2fs.c 2004-08-08 18:19:18.000000000 +0000 -+++ grub-0.97/stage2/fsys_ext2fs.c 2008-09-16 19:31:15.000000000 +0000 -@@ -254,7 +254,7 @@ - { - int retval =3D 1; -=20 -- if ((((current_drive & 0x80) || (current_slice !=3D 0)) -+ if ((((current_slice !=3D 0)) - && (current_slice !=3D PC_SLICE_TYPE_EXT2FS) - && (current_slice !=3D PC_SLICE_TYPE_LINUX_RAID) - && (! IS_PC_SLICE_TYPE_BSD_WITH_FS (current_slice, FS_EXT2FS)) -diff -urN grub-0.97.orig/stage2/fsys_fat.c grub-0.97/stage2/fsys_fat.c ---- grub-0.97.orig/stage2/fsys_fat.c 2005-03-15 16:52:00.000000000 +0000 -+++ grub-0.97/stage2/fsys_fat.c 2008-09-16 19:31:26.000000000 +0000 -@@ -70,7 +70,7 @@ - __u32 magic, first_fat; - =20 - /* Check partition type for harddisk */ -- if (((current_drive & 0x80) || (current_slice !=3D 0)) -+ if (((current_slice !=3D 0)) - && ! IS_PC_SLICE_TYPE_FAT (current_slice) - && (! IS_PC_SLICE_TYPE_BSD_WITH_FS (current_slice, FS_MSDOS))) - return 0; -diff -urN grub-0.97.orig/stage2/fsys_ffs.c grub-0.97/stage2/fsys_ffs.c ---- grub-0.97.orig/stage2/fsys_ffs.c 2003-07-09 11:45:52.000000000 +0000 -+++ grub-0.97/stage2/fsys_ffs.c 2008-09-16 19:31:32.000000000 +0000 -@@ -82,7 +82,7 @@ - { - int retval =3D 1; -=20 -- if ((((current_drive & 0x80) || (current_slice !=3D 0)) -+ if ((((current_slice !=3D 0)) - && ! IS_PC_SLICE_TYPE_BSD_WITH_FS (current_slice, FS_BSDFFS)) - || part_length < (SBLOCK + (SBSIZE / DEV_BSIZE)) - || !devread (SBLOCK, 0, SBSIZE, (char *) SUPERBLOCK) -diff -urN grub-0.97.orig/stage2/fsys_minix.c grub-0.97/stage2/fsys_minix.c ---- grub-0.97.orig/stage2/fsys_minix.c 2003-07-09 11:45:53.000000000 +0000 -+++ grub-0.97/stage2/fsys_minix.c 2008-09-16 19:32:01.000000000 +0000 -@@ -160,7 +160,7 @@ - int - minix_mount (void) - { -- if (((current_drive & 0x80) || current_slice !=3D 0) -+ if ((current_slice !=3D 0) - && ! IS_PC_SLICE_TYPE_MINIX (current_slice) - && ! IS_PC_SLICE_TYPE_BSD_WITH_FS (current_slice, FS_OTHER)) - return 0; /* The partition is not of MINIX type */ -diff -urN grub-0.97.orig/stage2/fsys_ufs2.c grub-0.97/stage2/fsys_ufs2.c ---- grub-0.97.orig/stage2/fsys_ufs2.c 2004-06-19 12:17:52.000000000 +0000 -+++ grub-0.97/stage2/fsys_ufs2.c 2008-09-16 19:32:32.000000000 +0000 -@@ -87,7 +87,7 @@ - sblockloc =3D -1; - type =3D 0; - =20 -- if (! (((current_drive & 0x80) || (current_slice !=3D 0)) -+ if (! (((current_slice !=3D 0)) - && ! IS_PC_SLICE_TYPE_BSD_WITH_FS (current_slice, FS_BSDFFS))) - { - for (i =3D 0; sblock_try[i] !=3D -1; ++i) -diff -urN grub-0.97.orig/stage2/fsys_vstafs.c grub-0.97/stage2/fsys_vstafs= .c ---- grub-0.97.orig/stage2/fsys_vstafs.c 2003-07-09 11:45:53.000000000 +0000 -+++ grub-0.97/stage2/fsys_vstafs.c 2008-09-16 19:32:39.000000000 +0000 -@@ -47,7 +47,7 @@ - { - int retval =3D 1; - =20 -- if( (((current_drive & 0x80) || (current_slice !=3D 0)) -+ if( (((current_slice !=3D 0)) - && current_slice !=3D PC_SLICE_TYPE_VSTAFS) - || ! devread (0, 0, BLOCK_SIZE, (char *) FSYS_BUF) - || FIRST_SECTOR->fs_magic !=3D 0xDEADFACE) diff --git a/stubdom/grub.patches/60ext4.diff b/stubdom/grub.patches/60ext4= .diff deleted file mode 100644 index c71cfe1c4f..0000000000 --- a/stubdom/grub.patches/60ext4.diff +++ /dev/null @@ -1,474 +0,0 @@ -Index: grub-0.97/stage2/fsys_ext2fs.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub-0.97.orig/stage2/fsys_ext2fs.c -+++ grub-0.97/stage2/fsys_ext2fs.c -@@ -41,6 +41,7 @@ typedef __signed__ short __s16; - typedef unsigned short __u16; - typedef __signed__ int __s32; - typedef unsigned int __u32; -+typedef unsigned long long __u64; -=20 - /* - * Constants relative to the data blocks, from ext2_fs.h -@@ -51,7 +52,7 @@ typedef unsigned int __u32; - #define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1) - #define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1) -=20 --/* include/linux/ext2_fs.h */ -+/* lib/ext2fs/ext2_fs.h from e2fsprogs */ - struct ext2_super_block - { - __u32 s_inodes_count; /* Inodes count */ -@@ -61,9 +62,9 @@ struct ext2_super_block - __u32 s_free_inodes_count; /* Free inodes count */ - __u32 s_first_data_block; /* First Data Block */ - __u32 s_log_block_size; /* Block size */ -- __s32 s_log_frag_size; /* Fragment size */ -+ __s32 s_obso_log_frag_size; /* Obsoleted Fragment size */ - __u32 s_blocks_per_group; /* # Blocks per group */ -- __u32 s_frags_per_group; /* # Fragments per group */ -+ __u32 s_obso_frags_per_group; /* Obsoleted Fragments per group */ - __u32 s_inodes_per_group; /* # Inodes per group */ - __u32 s_mtime; /* Mount time */ - __u32 s_wtime; /* Write time */ -@@ -72,7 +73,7 @@ struct ext2_super_block - __u16 s_magic; /* Magic signature */ - __u16 s_state; /* File system state */ - __u16 s_errors; /* Behaviour when detecting errors */ -- __u16 s_pad; -+ __u16 s_minor_rev_level; /* minor revision level */ - __u32 s_lastcheck; /* time of last check */ - __u32 s_checkinterval; /* max. time between checks */ - __u32 s_creator_os; /* OS */ -@@ -119,15 +120,29 @@ struct ext2_super_block - __u32 s_hash_seed[4]; /* HTREE hash seed */ - __u8 s_def_hash_version; /* Default hash version to use */ - __u8 s_jnl_backup_type; /* Default type of journal backup */ -- __u16 s_reserved_word_pad; -+ __u16 s_desc_size; /* size of group descriptor */ - __u32 s_default_mount_opts; - __u32 s_first_meta_bg; /* First metablock group */ - __u32 s_mkfs_time; /* When the filesystem was created */ - __u32 s_jnl_blocks[17]; /* Backup of the journal inode */ -- __u32 s_reserved[172]; /* Padding to the end of the block */ -- }; -+ /* 64bit desc support valid if EXT4_FEATURE_INCOMPAT_64BIT */ -+ __u32 s_blocks_count_hi; /* Blocks count */ -+ __u32 s_r_blocks_count_hi; /* Reserved blocks count */ -+ __u32 s_free_blocks_count_hi; /* Free blocks count */ -+ __u16 s_min_extra_isize; /* All inodes have at least # bytes */ -+ __u16 s_max_extra_isize; /* New inodes should reverve # bytes */ -+ __u32 s_flags; /* Miscellaneous flags */ -+ __u16 s_raid_stride; /* Raid stride */ -+ __u16 s_mmp_interval; /* # seconds to wait MMP checking */ -+ __u64 s_mmp_block; /* Block for multi-mount protection */ -+ __u32 s_raid_stripe_width; /* Blocks on all data disks (N*stride)*/ -+ __u8 s_log_groups_per_flex;/* FLEX_BG group size*/ -+ __u8 s_reserved_char_pad; -+ __u16 s_reserved_pad; -+ __u32 s_reserved[162]; /* Padding to the end of the block */ -+}; -=20 --struct ext2_group_desc -+struct ext4_group_desc - { - __u32 bg_block_bitmap; /* Blocks bitmap block */ - __u32 bg_inode_bitmap; /* Inodes bitmap block */ -@@ -135,8 +150,18 @@ struct ext2_group_desc - __u16 bg_free_blocks_count; /* Free blocks count */ - __u16 bg_free_inodes_count; /* Free inodes count */ - __u16 bg_used_dirs_count; /* Directories count */ -- __u16 bg_pad; -- __u32 bg_reserved[3]; -+ __u16 bg_flags; /* EXT4_BG_flags (INODE_UNINIT, etc) */ -+ __u32 bg_reserved[2]; /* Likely block/inode bitmap checksum */ -+ __u16 bg_itable_unused; /* Unused inodes count */ -+ __u16 bg_checksum; /* crc16(sb_uuid+group+desc) */ -+ __u32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */ -+ __u32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */ -+ __u32 bg_inode_table_hi; /* Inodes table block MSB */ -+ __u16 bg_free_blocks_count_hi;/* Free blocks count MSB */ -+ __u16 bg_free_inodes_count_hi;/* Free inodes count MSB */ -+ __u16 bg_used_dirs_count_hi; /* Directories count MSB */ -+ __u16 bg_itable_unused_hi; /* Unused inodes count MSB */ -+ __u32 bg_reserved2[3]; - }; -=20 - struct ext2_inode -@@ -174,22 +199,22 @@ struct ext2_inode - __u32 i_block[EXT2_N_BLOCKS]; /* 40: Pointers to blocks */ - __u32 i_version; /* File version (for NFS) */ - __u32 i_file_acl; /* File ACL */ -- __u32 i_dir_acl; /* Directory ACL */ -- __u32 i_faddr; /* Fragment address */ -+ __u32 i_size_high; -+ __u32 i_obso_faddr; /* Obsoleted fragment address */ - union - { - struct - { -- __u8 l_i_frag; /* Fragment number */ -- __u8 l_i_fsize; /* Fragment size */ -- __u16 i_pad1; -- __u32 l_i_reserved2[2]; -+ __u16 l_i_blocks_high; /* were l_i_reserved1 */ -+ __u16 l_i_file_acl_high; -+ __u16 l_i_uid_high; /* these 2 fields */ -+ __u16 l_i_gid_high; /* were reserved2[0] */ -+ __u32 l_i_reserved2; - } - linux2; - struct - { -- __u8 h_i_frag; /* Fragment number */ -- __u8 h_i_fsize; /* Fragment size */ -+ __u16 h_i_reserved1; /* Obsoleted fragment number/size which are remove= d in ext4 */ - __u16 h_i_mode_high; - __u16 h_i_uid_high; - __u16 h_i_gid_high; -@@ -198,16 +223,36 @@ struct ext2_inode - hurd2; - struct - { -- __u8 m_i_frag; /* Fragment number */ -- __u8 m_i_fsize; /* Fragment size */ -- __u16 m_pad1; -+ __u16 h_i_reserved1; /* Obsoleted fragment number/size which are remove= d in ext4 */ -+ __u16 m_i_file_acl_high; - __u32 m_i_reserved2[2]; - } - masix2; - } - osd2; /* OS dependent 2 */ -+ __u16 i_extra_isize; -+ __u16 i_pad1; -+ __u32 i_ctime_extra; /* extra Change time (nsec << 2 | epoch) */ -+ __u32 i_mtime_extra; /* extra Modification time(nsec << 2 | epoch) */ -+ __u32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ -+ __u32 i_crtime; /* File Creation time */ -+ __u32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */ -+ __u32 i_version_hi; /* high 32 bits for 64-bit version */ - }; -=20 -+#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */ -+#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 /* grub not supported*/ -+#define EXT4_FEATURE_INCOMPAT_MMP 0x0100 -+#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 -+ -+#define EXT4_HAS_INCOMPAT_FEATURE(sb,mask) \ -+ ( sb->s_feature_incompat & mask ) -+ -+#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */ -+#define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */ -+ -+#define EXT4_MIN_DESC_SIZE 32 -+ - /* linux/limits.h */ - #define NAME_MAX 255 /* # chars in a file name */ -=20 -@@ -225,6 +270,57 @@ struct ext2_dir_entry - char name[EXT2_NAME_LEN]; /* File name */ - }; -=20 -+/* linux/ext4_fs_extents.h */ -+/* This is the extent on-disk structure. -+ * It's used at the bottom of the tree. -+ */ -+struct ext4_extent -+ { -+ __u32 ee_block; /* first logical block extent covers */ -+ __u16 ee_len; /* number of blocks covered by extent */ -+ __u16 ee_start_hi; /* high 16 bits of physical block */ -+ __u32 ee_start_lo; /* low 32 bits of physical block */ -+ }; -+ -+/* -+ * This is index on-disk structure. -+ * It's used at all the levels except the bottom. -+ */ -+struct ext4_extent_idx -+ { -+ __u32 ei_block; /* index covers logical blocks from 'block' */ -+ __u32 ei_leaf_lo; /* pointer to the physical block of the next * -+ * level. leaf or next index could be there */ -+ __u16 ei_leaf_hi; /* high 16 bits of physical block */ -+ __u16 ei_unused; -+ }; -+ -+/* -+ * Each block (leaves and indexes), even inode-stored has header. -+ */ -+struct ext4_extent_header -+ { -+ __u16 eh_magic; /* probably will support different formats */ -+ __u16 eh_entries; /* number of valid entries */ -+ __u16 eh_max; /* capacity of store in entries */ -+ __u16 eh_depth; /* has tree real underlying blocks? */ -+ __u32 eh_generation; /* generation of the tree */ -+ }; -+ -+#define EXT4_EXT_MAGIC (0xf30a) -+#define EXT_FIRST_EXTENT(__hdr__) \ -+ ((struct ext4_extent *) (((char *) (__hdr__)) + \ -+ sizeof(struct ext4_extent_header))) -+#define EXT_FIRST_INDEX(__hdr__) \ -+ ((struct ext4_extent_idx *) (((char *) (__hdr__)) + \ -+ sizeof(struct ext4_extent_header))) -+#define EXT_LAST_EXTENT(__hdr__) \ -+ (EXT_FIRST_EXTENT((__hdr__)) + (__u16)((__hdr__)->eh_entries) - 1) -+#define EXT_LAST_INDEX(__hdr__) \ -+ (EXT_FIRST_INDEX((__hdr__)) + (__u16)((__hdr__)->eh_entries) - 1) -+ -+ -+ - /* linux/ext2fs.h */ - /* - * EXT2_DIR_PAD defines the directory entries boundaries -@@ -271,8 +367,17 @@ struct ext2_dir_entry - /* kind of from ext2/super.c */ - #define EXT2_BLOCK_SIZE(s) (1 << EXT2_BLOCK_SIZE_BITS(s)) - /* linux/ext2fs.h */ -+/* sizeof(struct ext2_group_desc) is changed in ext4 -+ * in kernel code, ext2/3 uses sizeof(struct ext2_group_desc) to calculate -+ * number of desc per block, while ext4 uses superblock->s_desc_size in s= tead -+ * superblock->s_desc_size is not available in ext2/3 -+ * */ -+#define EXT2_DESC_SIZE(s) \ -+ (EXT4_HAS_INCOMPAT_FEATURE(s,EXT4_FEATURE_INCOMPAT_64BIT)? \ -+ s->s_desc_size : EXT4_MIN_DESC_SIZE) - #define EXT2_DESC_PER_BLOCK(s) \ -- (EXT2_BLOCK_SIZE(s) / sizeof (struct ext2_group_desc)) -+ (EXT2_BLOCK_SIZE(s) / EXT2_DESC_SIZE(s)) -+ - /* linux/stat.h */ - #define S_IFMT 00170000 - #define S_IFLNK 0120000 -@@ -434,6 +539,122 @@ ext2fs_block_map (int logical_block) - [logical_block & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)]; - } -=20 -+/* extent binary search index -+ * find closest index in the current level extent tree -+ * kind of from ext4_ext_binsearch_idx in ext4/extents.c -+ */ -+static struct ext4_extent_idx* -+ext4_ext_binsearch_idx(struct ext4_extent_header* eh, int logical_block) -+{ -+ struct ext4_extent_idx *r, *l, *m; -+ l =3D EXT_FIRST_INDEX(eh) + 1; -+ r =3D EXT_LAST_INDEX(eh); -+ while (l <=3D r) -+ { -+ m =3D l + (r - l) / 2; -+ if (logical_block < m->ei_block) -+ r =3D m - 1; -+ else -+ l =3D m + 1; -+ } -+ return (struct ext4_extent_idx*)(l - 1); -+} -+ -+/* extent binary search -+ * find closest extent in the leaf level -+ * kind of from ext4_ext_binsearch in ext4/extents.c -+ */ -+static struct ext4_extent* -+ext4_ext_binsearch(struct ext4_extent_header* eh, int logical_block) -+{ -+ struct ext4_extent *r, *l, *m; -+ l =3D EXT_FIRST_EXTENT(eh) + 1; -+ r =3D EXT_LAST_EXTENT(eh); -+ while (l <=3D r) -+ { -+ m =3D l + (r - l) / 2; -+ if (logical_block < m->ee_block) -+ r =3D m - 1; -+ else -+ l =3D m + 1; -+ } -+ return (struct ext4_extent*)(l - 1); -+} -+ -+/* Maps extents enabled logical block into physical block via an inode. -+ * EXT4_HUGE_FILE_FL should be checked before calling this. -+ */ -+static int -+ext4fs_block_map (int logical_block) -+{ -+ struct ext4_extent_header *eh; -+ struct ext4_extent *ex, *extent; -+ struct ext4_extent_idx *ei, *index; -+ int depth; -+ int i; -+ -+#ifdef E2DEBUG -+ unsigned char *i; -+ for (i =3D (unsigned char *) INODE; -+ i < ((unsigned char *) INODE + sizeof (struct ext2_inode)); -+ i++) -+ { -+ printf ("%c", "0123456789abcdef"[*i >> 4]); -+ printf ("%c", "0123456789abcdef"[*i % 16]); -+ if (!((i + 1 - (unsigned char *) INODE) % 16)) -+ { -+ printf ("\n"); -+ } -+ else -+ { -+ printf (" "); -+ } -+ } -+ printf ("logical block %d\n", logical_block); -+#endif /* E2DEBUG */ -+ eh =3D (struct ext4_extent_header*)INODE->i_block; -+ if (eh->eh_magic !=3D EXT4_EXT_MAGIC) -+ { -+ errnum =3D ERR_FSYS_CORRUPT; -+ return -1; -+ } -+ while((depth =3D eh->eh_depth) !=3D 0) -+ { /* extent index */ -+ if (eh->eh_magic !=3D EXT4_EXT_MAGIC) -+ { -+ errnum =3D ERR_FSYS_CORRUPT; -+ return -1; -+ } -+ ei =3D ext4_ext_binsearch_idx(eh, logical_block); -+ if (ei->ei_leaf_hi) -+ {/* 64bit physical block number not supported */ -+ errnum =3D ERR_FILELENGTH; -+ return -1; -+ } -+ if (!ext2_rdfsb(ei->ei_leaf_lo, DATABLOCK1)) -+ { -+ errnum =3D ERR_FSYS_CORRUPT; -+ return -1; -+ } -+ eh =3D (struct ext4_extent_header*)DATABLOCK1; -+ } -+ -+ /* depth=3D=3D0, we come to the leaf */ -+ ex =3D ext4_ext_binsearch(eh, logical_block); -+ if (ex->ee_start_hi) -+ {/* 64bit physical block number not supported */ -+ errnum =3D ERR_FILELENGTH; -+ return -1; -+ } -+ if ((ex->ee_block + ex->ee_len) < logical_block) -+ { -+ errnum =3D ERR_FSYS_CORRUPT; -+ return -1; -+ } -+ return ex->ee_start_lo + logical_block - ex->ee_block; -+ -+} -+ - /* preconditions: all preconds of ext2fs_block_map */ - int - ext2fs_read (char *buf, int len) -@@ -468,6 +689,11 @@ ext2fs_read (char *buf, int len) - /* find the (logical) block component of our location */ - logical_block =3D filepos >> EXT2_BLOCK_SIZE_BITS (SUPERBLOCK); - offset =3D filepos & (EXT2_BLOCK_SIZE (SUPERBLOCK) - 1); -+ /* map extents enabled logical block number to physical fs on-disk = block number */ -+ if (EXT4_HAS_INCOMPAT_FEATURE(SUPERBLOCK,EXT4_FEATURE_INCOMPAT_EXTE= NTS) -+ && INODE->i_flags & EXT4_EXTENTS_FL) -+ map =3D ext4fs_block_map (logical_block); -+ else - map =3D ext2fs_block_map (logical_block); - #ifdef E2DEBUG - printf ("map=3D%d\n", map); -@@ -552,7 +778,7 @@ ext2fs_dir (char *dirname) - int desc; /* index within that group */ - int ino_blk; /* fs pointer of the inode's information */ - int str_chk =3D 0; /* used to hold the results of a string compare */ -- struct ext2_group_desc *gdp; -+ struct ext4_group_desc *ext4_gdp; - struct ext2_inode *raw_inode; /* inode info corresponding to current_in= o */ -=20 - char linkbuf[PATH_MAX]; /* buffer for following symbolic links */ -@@ -598,8 +824,15 @@ ext2fs_dir (char *dirname) - { - return 0; - } -- gdp =3D GROUP_DESC; -- ino_blk =3D gdp[desc].bg_inode_table + -+ ext4_gdp =3D (struct ext4_group_desc *)( (__u8*)GROUP_DESC + -+ desc * EXT2_DESC_SIZE(SUPERBLOCK)); -+ if (EXT4_HAS_INCOMPAT_FEATURE(SUPERBLOCK, EXT4_FEATURE_INCOMPAT_64BIT) -+ && (! ext4_gdp->bg_inode_table_hi)) -+ {/* 64bit itable not supported */ -+ errnum =3D ERR_FILELENGTH; -+ return -1; -+ } -+ ino_blk =3D ext4_gdp->bg_inode_table + - (((current_ino - 1) % (SUPERBLOCK->s_inodes_per_group)) - >> log2 (EXT2_INODES_PER_BLOCK (SUPERBLOCK))); - #ifdef E2DEBUG -@@ -676,7 +909,10 @@ ext2fs_dir (char *dirname) - } - linkbuf[filemax + len] =3D '\0'; -=20 -- /* Read the symlink data. */ -+ /* Read the symlink data. -+ * Slow symlink is extents enabled -+ * But since grub_read invokes ext2fs_read, nothing to change here -+ */ - if (! ext2_is_fast_symlink ()) - { - /* Read the necessary blocks, and reset the file pointer. */ -@@ -687,7 +923,9 @@ ext2fs_dir (char *dirname) - } - else - { -- /* Copy the data directly from the inode. */ -+ /* Copy the data directly from the inode. -+ * Fast symlink is not extents enabled -+ */ - len =3D filemax; - memmove (linkbuf, (char *) INODE->i_block, len); - } -@@ -721,6 +959,13 @@ ext2fs_dir (char *dirname) - errnum =3D ERR_BAD_FILETYPE; - return 0; - } -+ /* if file is too large, just stop and report an error*/ -+ if ( (INODE->i_flags & EXT4_HUGE_FILE_FL) && !(INODE->i_size_high)) -+ { -+ /* file too large, stop reading */ -+ errnum =3D ERR_FILELENGTH; -+ return 0; -+ } -=20 - filemax =3D (INODE->i_size); - return 1; -@@ -775,17 +1020,28 @@ ext2fs_dir (char *dirname) - } -=20 - /* else, find the (logical) block component of our location */ -+ /* ext4 logical block number the same as ext2/3 */ - blk =3D loc >> EXT2_BLOCK_SIZE_BITS (SUPERBLOCK); -=20 - /* we know which logical block of the directory entry we are looking - for, now we have to translate that to the physical (fs) block on - the disk */ -+ /* map extents enabled logical block number to physical fs on-disk blo= ck number */ -+ if (EXT4_HAS_INCOMPAT_FEATURE(SUPERBLOCK,EXT4_FEATURE_INCOMPAT_EXTENTS) -+ && INODE->i_flags & EXT4_EXTENTS_FL) -+ map =3D ext4fs_block_map (blk); -+ else - map =3D ext2fs_block_map (blk); - #ifdef E2DEBUG - printf ("fs block=3D%d\n", map); - #endif /* E2DEBUG */ - mapblock2 =3D -1; -- if ((map < 0) || !ext2_rdfsb (map, DATABLOCK2)) -+ if (map < 0) -+ { -+ *rest =3D ch; -+ return 0; -+ } -+ if (!ext2_rdfsb (map, DATABLOCK2)) - { - errnum =3D ERR_FSYS_CORRUPT; - *rest =3D ch; diff --git a/stubdom/grub.patches/61btrfs.diff b/stubdom/grub.patches/61btr= fs.diff deleted file mode 100644 index ae8f866e50..0000000000 --- a/stubdom/grub.patches/61btrfs.diff +++ /dev/null @@ -1,3499 +0,0 @@ -diff -up grub-upstream.wip/AUTHORS.btrfs grub-upstream.wip/AUTHORS ---- grub-upstream.wip/AUTHORS.btrfs 2004-03-27 16:25:17.000000000 +0000 -+++ grub-upstream.wip/AUTHORS 2012-03-20 05:07:09.000000000 +0000 -@@ -41,6 +41,8 @@ Kristoffer Branemyr added VSTa filesyste -=20 - Serguei Tzukanov added JFS and XFS support. -=20 -+Edward Shishkin added Btrfs support. -+ - Jason Thomas added Linux DAC960 support and support for hiding/unhiding - logical partitions, and did a significant bugfix for the terminal stuff. -=20 -diff -up grub-upstream.wip/configure.ac.btrfs grub-upstream.wip/configure.= ac ---- grub-upstream.wip/configure.ac.btrfs 2012-03-20 05:06:49.000000000 +00= 00 -+++ grub-upstream.wip/configure.ac 2012-03-20 05:07:09.000000000 +0000 -@@ -274,6 +274,13 @@ if test x"$enable_reiserfs" !=3D xno; then - FSYS_CFLAGS=3D"$FSYS_CFLAGS -DFSYS_REISERFS=3D1" - fi -=20 -+AC_ARG_ENABLE(btrfs, -+ [ --disable-btrfs disable BtrFS support in Stage 2]) -+ -+if test x"$enable_btrfs" !=3D xno; then -+ FSYS_CFLAGS=3D"$FSYS_CFLAGS -DFSYS_BTRFS=3D1" -+fi -+ - AC_ARG_ENABLE(vstafs, - [ --disable-vstafs disable VSTa FS support in Stage 2]) -=20 -diff -up grub-upstream.wip/grub/Makefile.am.btrfs grub-upstream.wip/grub/M= akefile.am ---- grub-upstream.wip/grub/Makefile.am.btrfs 2005-02-02 20:38:19.000000000= +0000 -+++ grub-upstream.wip/grub/Makefile.am 2012-03-20 05:07:09.000000000 +0000 -@@ -8,7 +8,7 @@ endif -=20 - AM_CPPFLAGS =3D -DGRUB_UTIL=3D1 -DFSYS_EXT2FS=3D1 -DFSYS_FAT=3D1 -DFSYS_F= FS=3D1 \ - -DFSYS_ISO9660=3D1 -DFSYS_JFS=3D1 -DFSYS_MINIX=3D1 -DFSYS_REISERFS=3D1 \ -- -DFSYS_UFS2=3D1 -DFSYS_VSTAFS=3D1 -DFSYS_XFS=3D1 \ -+ -DFSYS_BTRFS=3D1 -DFSYS_UFS2=3D1 -DFSYS_VSTAFS=3D1 -DFSYS_XFS=3D1 \ - -DUSE_MD5_PASSWORDS=3D1 -DSUPPORT_HERCULES=3D1 \ - $(SERIAL_FLAGS) -I$(top_srcdir)/stage2 \ - -I$(top_srcdir)/stage1 -I$(top_srcdir)/lib -diff -up grub-upstream.wip/INSTALL.btrfs grub-upstream.wip/INSTALL ---- grub-upstream.wip/INSTALL.btrfs 2005-05-08 02:43:15.000000000 +0000 -+++ grub-upstream.wip/INSTALL 2012-03-20 05:07:09.000000000 +0000 -@@ -207,6 +207,9 @@ operates. - `--disable-reiserfs' - Omit the ReiserFS support in Stage 2. -=20 -+`--disable-btrfs' -+ Omit the BtrFS support in Stage 2. -+ - `--disable-vstafs' - Omit the VSTa filesystem support in Stage 2. -=20 -diff -up /dev/null grub-upstream.wip/stage2/btrfs.h ---- /dev/null 2009-06-03 06:46:26.160951000 +0000 -+++ grub-upstream.wip/stage2/btrfs.h 2012-03-20 05:07:09.000000000 +0000 -@@ -0,0 +1,1413 @@ -+/* btrfs.h - an extraction from btrfs-progs-0.18/ctree.h into one file -+ * -+ * Copyright (C) 2007 Oracle. All rights reserved. -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public -+ * License v2 as published by the Free Software Foundation. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ * General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public -+ * License along with this program; If not, see -+ */ -+ -+/* include/asm-i386/types.h */ -+ -+typedef __signed__ char __s8; -+typedef unsigned char __u8; -+typedef __signed__ short __s16; -+typedef unsigned short __u16; -+typedef __signed__ int __s32; -+typedef unsigned int __u32; -+typedef unsigned long long __u64; -+typedef __signed__ long long __s64; -+ -+typedef __s8 s8; -+typedef __u8 u8; -+typedef __u16 u16; -+typedef __u32 u32; -+typedef __u64 u64; -+typedef __s64 s64; -+ -+#define __bitwise -+ -+typedef u16 __bitwise __le16; -+typedef u32 __bitwise __le32; -+typedef u64 __bitwise __le64; -+ -+/* linux/posix_type.h */ -+typedef long linux_off_t; -+ -+/* linux/little_endian.h */ -+#define cpu_to_le64(x) ((__u64) (x)) -+#define le64_to_cpu(x) ((__u64) (x)) -+#define cpu_to_le32(x) ((__u32) (x)) -+#define le32_to_cpu(x) ((__u32) (x)) -+#define cpu_to_le16(x) ((__u16) (x)) -+#define le16_to_cpu(x) ((__u16) (x)) -+#define le8_to_cpu(x) ((__u8) (x)) -+#define cpu_to_le8(x) ((__u8) (x)) -+ -+/* linux/stat.h */ -+#define S_IFMT 00170000 -+#define S_IFLNK 0120000 -+#define S_IFREG 0100000 -+#define S_IFDIR 0040000 -+#define S_ISLNK(m) (((m) & S_IFMT) =3D=3D S_IFLNK) -+#define S_ISREG(m) (((m) & S_IFMT) =3D=3D S_IFREG) -+#define S_ISDIR(m) (((m) & S_IFMT) =3D=3D S_IFDIR) -+ -+struct btrfs_root; -+#define BTRFS_MAGIC "_BHRfS_M" -+ -+#define BTRFS_SUPER_INFO_OFFSET (64 * 1024) -+#define BTRFS_SUPER_INFO_SIZE 4096 -+ -+#define BTRFS_SUPER_MIRROR_MAX 3 -+#define BTRFS_SUPER_MIRROR_SHIFT 12 -+ -+#define PATH_MAX 1024 /* include/linux/limits.h */ -+#define MAX_LINK_COUNT 5 /* number of symbolic links -+ to follow */ -+#define BTRFS_MAX_LEVEL 8 -+#define BTRFS_ROOT_TREE_OBJECTID 1ULL -+#define BTRFS_EXTENT_TREE_OBJECTID 2ULL -+#define BTRFS_CHUNK_TREE_OBJECTID 3ULL -+#define BTRFS_DEV_TREE_OBJECTID 4ULL -+#define BTRFS_FS_TREE_OBJECTID 5ULL -+#define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL -+#define BTRFS_CSUM_TREE_OBJECTID 7ULL -+ -+#define BTRFS_ORPHAN_OBJECTID -5ULL -+#define BTRFS_TREE_LOG_OBJECTID -6ULL -+#define BTRFS_TREE_LOG_FIXUP_OBJECTID -7ULL -+#define BTRFS_TREE_RELOC_OBJECTID -8ULL -+#define BTRFS_DATA_RELOC_TREE_OBJECTID -9ULL -+#define BTRFS_EXTENT_CSUM_OBJECTID -10ULL -+ -+#define BTRFS_MULTIPLE_OBJECTIDS -255ULL -+#define BTRFS_FIRST_FREE_OBJECTID 256ULL -+#define BTRFS_LAST_FREE_OBJECTID -256ULL -+#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL -+#define BTRFS_DEV_ITEMS_OBJECTID 1ULL -+ -+ -+#define BTRFS_NAME_LEN 255 -+#define BTRFS_CSUM_SIZE 32 -+#define BTRFS_CSUM_TYPE_CRC32 0 -+ -+static int btrfs_csum_sizes[] =3D { 4, 0 }; -+ -+/* four bytes for CRC32 */ -+#define BTRFS_CRC32_SIZE 4 -+#define BTRFS_EMPTY_DIR_SIZE 0 -+ -+#define BTRFS_FT_UNKNOWN 0 -+#define BTRFS_FT_REG_FILE 1 -+#define BTRFS_FT_DIR 2 -+#define BTRFS_FT_CHRDEV 3 -+#define BTRFS_FT_BLKDEV 4 -+#define BTRFS_FT_FIFO 5 -+#define BTRFS_FT_SOCK 6 -+#define BTRFS_FT_SYMLINK 7 -+#define BTRFS_FT_XATTR 8 -+#define BTRFS_FT_MAX 9 -+ -+#define BTRFS_UUID_SIZE 16 -+ -+#define BTRFS_DEFAULT_NUM_DEVICES 1 -+#define BTRFS_DEFAULT_NODE_SIZE 4096 -+#define BTRFS_DEFAULT_LEAF_SIZE 4096 -+#define BTRFS_NUM_CACHED_DEVICES 128 -+ -+#define WARN_ON(c) -+#define cassert(cond) ({ switch (-1) { case (cond): case 0: break; } }) -+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -+ -+#define offsetof(type, memb) \ -+ ((unsigned long)(&((type *)0)->memb)) -+ -+struct btrfs_disk_key { -+ __le64 objectid; -+ u8 type; -+ __le64 offset; -+} __attribute__ ((__packed__)); -+ -+/* cpu key */ -+struct btrfs_key { -+ u64 objectid; -+ u8 type; -+ u64 offset; -+} __attribute__ ((__packed__)); -+ -+/* this represents a divice in a chunk tree */ -+struct btrfs_dev_item { -+ __le64 devid; /* internal device id */ -+ __le64 total_bytes; /* size of the device */ -+ __le64 bytes_used; -+ __le32 io_align; /* optimal io alignment */ -+ __le32 io_width; /* optimal io width */ -+ __le32 sector_size; /* minimal io size */ -+ __le64 type; /* type and info about this device */ -+ __le64 generation; /* expected generation */ -+ __le64 start_offset; /* of the partition on a device */ -+ -+ /* info for allocation decisions */ -+ __le32 dev_group; -+ -+ u8 seek_speed; /* 0-100 (100 is fastest) */ -+ u8 bandwidth; /* 0-100 (100 is fastest) */ -+ -+ u8 uuid[BTRFS_UUID_SIZE]; /* dev uuid generated by btrfs */ -+ u8 fsid[BTRFS_UUID_SIZE]; /* uuid of the host FS */ -+} __attribute__ ((__packed__)); -+ -+struct btrfs_stripe { -+ __le64 devid; -+ __le64 offset; -+ u8 dev_uuid[BTRFS_UUID_SIZE]; -+} __attribute__ ((__packed__)); -+ -+struct btrfs_chunk { -+ /* size of this chunk in bytes */ -+ __le64 length; -+ __le64 owner; /* objectid of the root referincing this chunk */ -+ __le64 stripe_len; -+ __le64 type; -+ __le32 io_align; /* optimal io alignment for this chunk */ -+ __le32 io_width; /* optimal io width for this chunk */ -+ __le32 sector_size; /* minimal io size for this chunk */ -+ __le16 num_stripes; -+ __le16 sub_stripes; /* sub stripes (for raid10) */ -+ struct btrfs_stripe stripe; -+} __attribute__ ((__packed__)); -+ -+static inline unsigned long btrfs_chunk_item_size(int num_stripes) -+{ -+ return sizeof(struct btrfs_chunk) + -+ sizeof(struct btrfs_stripe) * (num_stripes - 1); -+} -+ -+#define BTRFS_FSID_SIZE 16 -+#define BTRFS_HEADER_FLAG_WRITTEN (1 << 0) -+ -+struct btrfs_header { -+ /* these first four must match the super block */ -+ u8 csum[BTRFS_CSUM_SIZE]; -+ u8 fsid[BTRFS_FSID_SIZE]; /* uuid of the host fs */ -+ __le64 bytenr; /* which block this node is supposed to live in */ -+ __le64 flags; -+ -+ /* allowed to be different from the super from here on down */ -+ u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; -+ __le64 generation; -+ __le64 owner; -+ __le32 nritems; -+ u8 level; -+} __attribute__ ((__packed__)); -+ -+#define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \ -+ sizeof(struct btrfs_header)) / \ -+ sizeof(struct btrfs_key_ptr)) -+#define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header)) -+#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize)) -+#define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ -+ sizeof(struct btrfs_item) - \ -+ sizeof(struct btrfs_file_extent_it= em)) -+ -+#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32) -+#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) -+ -+/* -+ * a portion of superblock which is used -+ * for chunk translation (up to 14 chunks -+ * with 3 stripes each. -+ */ -+#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048 -+#define BTRFS_LABEL_SIZE 256 -+ -+/* -+ * the super block basically lists the main trees of the FS -+ * it currently lacks any block count etc etc -+ */ -+ -+struct btrfs_super_block { -+ u8 csum[BTRFS_CSUM_SIZE]; -+ /* the first 3 fields must match struct btrfs_header */ -+ u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */ -+ __le64 bytenr; /* this block number */ -+ __le64 flags; -+ -+ /* allowed to be different from the btrfs_header from here own dow= n */ -+ __le64 magic; -+ __le64 generation; -+ __le64 root; /* tree root */ -+ __le64 chunk_root; -+ __le64 log_root; -+ -+ /* this will help find the new super based on the log root */ -+ __le64 log_root_transid; -+ __le64 total_bytes; -+ __le64 bytes_used; -+ __le64 root_dir_objectid; -+ __le64 num_devices; -+ __le32 sectorsize; -+ __le32 nodesize; -+ __le32 leafsize; -+ __le32 stripesize; -+ __le32 sys_chunk_array_size; -+ __le64 chunk_root_generation; -+ __le64 compat_flags; -+ __le64 compat_ro_flags; -+ __le64 incompat_flags; -+ __le16 csum_type; -+ u8 root_level; -+ u8 chunk_root_level; -+ u8 log_root_level; -+ struct btrfs_dev_item dev_item; -+ -+ char label[BTRFS_LABEL_SIZE]; -+ -+ /* future expansion */ -+ __le64 reserved[32]; -+ u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE]; -+} __attribute__ ((__packed__)); -+ -+/* -+ * Compat flags that we support. If any incompat flags are set other tha= n the -+ * ones specified below then we will fail to mount -+ */ -+#define BTRFS_FEATURE_COMPAT_SUPP 0x0 -+#define BTRFS_FEATURE_COMPAT_RO_SUPP 0x0 -+#define BTRFS_FEATURE_INCOMPAT_SUPP 0x0 -+ -+/* Item header for per-leaf lookup */ -+struct btrfs_item { -+ struct btrfs_disk_key key; -+ __le32 offset; -+ __le32 size; -+} __attribute__ ((__packed__)); -+ -+/* -+ * Format of the leaves: -+ * [item0, item1....itemN] [free space] [dataN...data1, data0] -+ */ -+struct btrfs_leaf { -+ struct btrfs_header header; -+ struct btrfs_item items[]; -+} __attribute__ ((__packed__)); -+ -+/* -+ * keys-pointers pairs for per-node (non-leaf) lookup -+ */ -+struct btrfs_key_ptr { -+ struct btrfs_disk_key key; -+ __le64 blockptr; -+ __le64 generation; -+} __attribute__ ((__packed__)); -+ -+struct btrfs_node { -+ struct btrfs_header header; -+ struct btrfs_key_ptr ptrs[]; -+} __attribute__ ((__packed__)); -+ -+struct btrfs_device { -+ /* the internal btrfs device id */ -+ u64 devid; -+ /* the internal grub device representation */ -+ unsigned long drive; -+ unsigned long part; -+ unsigned long length; -+}; -+ -+struct extent_buffer { -+ /* metadata */ -+ struct btrfs_device dev; -+ u64 start; -+ u64 dev_bytenr; -+ u32 len; -+ /* data */ -+ char *data; -+}; -+ -+static inline void read_extent_buffer(struct extent_buffer *eb, -+ void *dst, unsigned long start, -+ unsigned long len) -+{ -+ memcpy(dst, eb->data + start, len); -+} -+ -+static inline void write_extent_buffer(struct extent_buffer *eb, -+ const void *src, unsigned long star= t, -+ unsigned long len) -+{ -+ memcpy(eb->data + start, src, len); -+} -+ -+/* -+ * NOTE: -+ * don't increase a number of levels for grub-0.97! -+ */ -+typedef enum { -+ FIRST_EXTERNAL_LOOKUP_POOL, -+ SECOND_EXTERNAL_LOOKUP_POOL, -+ INTERNAL_LOOKUP_POOL, -+ LAST_LOOKUP_POOL -+} lookup_pool_id; -+ -+/* Relationship between lookup pools: -+ * depth -+ * -+ * ^ +----> INTERNAL <----+ -+ * | | | -+ * | | | -+ * - FIRST_EXTERNAL SECOND_EXTERNAL -+ */ -+ -+struct btrfs_path { -+ lookup_pool_id lpid; -+ struct extent_buffer nodes[BTRFS_MAX_LEVEL]; -+ int slots[BTRFS_MAX_LEVEL]; -+}; -+ -+/* -+ * items in the extent btree are used to record the objectid of the -+ * owner of the block and the number of references -+ */ -+struct btrfs_extent_item { -+ __le32 refs; -+} __attribute__ ((__packed__)); -+ -+struct btrfs_extent_ref { -+ __le64 root; -+ __le64 generation; -+ __le64 objectid; -+ __le32 num_refs; -+} __attribute__ ((__packed__)); -+ -+/* dev extents record free space on individual devices. The owner -+ * field points back to the chunk allocation mapping tree that allocated -+ * the extent. The chunk tree uuid field is a way to double check the ow= ner -+ */ -+struct btrfs_dev_extent { -+ __le64 chunk_tree; -+ __le64 chunk_objectid; -+ __le64 chunk_offset; -+ __le64 length; -+ u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; -+} __attribute__ ((__packed__)); -+ -+struct btrfs_inode_ref { -+ __le64 index; -+ __le16 name_len; -+ /* name goes here */ -+} __attribute__ ((__packed__)); -+ -+struct btrfs_timespec { -+ __le64 sec; -+ __le32 nsec; -+} __attribute__ ((__packed__)); -+ -+typedef enum { -+ BTRFS_COMPRESS_NONE =3D 0, -+ BTRFS_COMPRESS_ZLIB =3D 1, -+ BTRFS_COMPRESS_LAST =3D 2, -+} btrfs_compression_type; -+ -+/* we don't understand any encryption methods right now */ -+typedef enum { -+ BTRFS_ENCRYPTION_NONE =3D 0, -+ BTRFS_ENCRYPTION_LAST =3D 1, -+} btrfs_encryption_type; -+ -+struct btrfs_inode_item { -+ /* nfs style generation number */ -+ __le64 generation; -+ /* transid that last touched this inode */ -+ __le64 transid; -+ __le64 size; -+ __le64 nbytes; -+ __le64 block_group; -+ __le32 nlink; -+ __le32 uid; -+ __le32 gid; -+ __le32 mode; -+ __le64 rdev; -+ __le64 flags; -+ -+ /* modification sequence number for NFS */ -+ __le64 sequence; -+ -+ /* -+ * a little future expansion, for more than this we can -+ * just grow the inode item and version it -+ */ -+ __le64 reserved[4]; -+ struct btrfs_timespec atime; -+ struct btrfs_timespec ctime; -+ struct btrfs_timespec mtime; -+ struct btrfs_timespec otime; -+} __attribute__ ((__packed__)); -+ -+struct btrfs_dir_item { -+ struct btrfs_disk_key location; -+ __le64 transid; -+ __le16 data_len; -+ __le16 name_len; -+ u8 type; -+} __attribute__ ((__packed__)); -+ -+struct btrfs_root_item { -+ struct btrfs_inode_item inode; -+ __le64 generation; -+ __le64 root_dirid; -+ __le64 bytenr; -+ __le64 byte_limit; -+ __le64 bytes_used; -+ __le64 last_snapshot; -+ __le64 flags; -+ __le32 refs; -+ struct btrfs_disk_key drop_progress; -+ u8 drop_level; -+ u8 level; -+} __attribute__ ((__packed__)); -+ -+/* -+ * this is used for both forward and backward root refs -+ */ -+struct btrfs_root_ref { -+ __le64 dirid; -+ __le64 sequence; -+ __le16 name_len; -+} __attribute__ ((__packed__)); -+ -+#define BTRFS_FILE_EXTENT_INLINE 0 -+#define BTRFS_FILE_EXTENT_REG 1 -+#define BTRFS_FILE_EXTENT_PREALLOC 2 -+ -+struct btrfs_file_extent_item { -+ /* -+ * transaction id that created this extent -+ */ -+ __le64 generation; -+ /* -+ * max number of bytes to hold this extent in ram -+ * when we split a compressed extent we can't know how big -+ * each of the resulting pieces will be. So, this is -+ * an upper limit on the size of the extent in ram instead of -+ * an exact limit. -+ */ -+ __le64 ram_bytes; -+ -+ /* -+ * 32 bits for the various ways we might encode the data, -+ * including compression and encryption. If any of these -+ * are set to something a given disk format doesn't understand -+ * it is treated like an incompat flag for reading and writing, -+ * but not for stat. -+ */ -+ u8 compression; -+ u8 encryption; -+ __le16 other_encoding; /* spare for later use */ -+ -+ /* are we inline data or a real extent? */ -+ u8 type; -+ -+ /* -+ * disk space consumed by the extent, checksum blocks are included -+ * in these numbers -+ */ -+ __le64 disk_bytenr; -+ __le64 disk_num_bytes; -+ /* -+ * the logical offset in file blocks (no csums) -+ * this extent record is for. This allows a file extent to point -+ * into the middle of an existing extent on disk, sharing it -+ * between two snapshots (useful if some bytes in the middle of the -+ * extent have changed -+ */ -+ __le64 offset; -+ /* -+ * the logical number of file blocks (no csums included) -+ */ -+ __le64 num_bytes; -+ -+} __attribute__ ((__packed__)); -+ -+struct btrfs_csum_item { -+ u8 csum; -+} __attribute__ ((__packed__)); -+ -+/* tag for the radix tree of block groups in ram */ -+#define BTRFS_BLOCK_GROUP_DATA (1 << 0) -+#define BTRFS_BLOCK_GROUP_SYSTEM (1 << 1) -+#define BTRFS_BLOCK_GROUP_METADATA (1 << 2) -+#define BTRFS_BLOCK_GROUP_RAID0 (1 << 3) -+#define BTRFS_BLOCK_GROUP_RAID1 (1 << 4) -+#define BTRFS_BLOCK_GROUP_DUP (1 << 5) -+#define BTRFS_BLOCK_GROUP_RAID10 (1 << 6) -+ -+struct btrfs_block_group_item { -+ __le64 used; -+ __le64 chunk_objectid; -+ __le64 flags; -+} __attribute__ ((__packed__)); -+ -+/* -+ * in ram representation of the tree. extent_root is used for all alloca= tions -+ * and for the extent tree extent_root root. -+ */ -+struct btrfs_root { -+ struct extent_buffer node; -+ char data[4096]; -+ struct btrfs_root_item root_item; -+ u64 objectid; -+ =20 -+ /* data allocations are done in sectorsize units */ -+ u32 sectorsize; -+ -+ /* node allocations are done in nodesize units */ -+ u32 nodesize; -+ -+ /* leaf allocations are done in leafsize units */ -+ u32 leafsize; -+ -+ /* leaf allocations are done in leafsize units */ -+ u32 stripesize; -+}; -+ -+struct btrfs_file_info { -+ struct btrfs_key key; -+}; -+ -+struct btrfs_root; -+struct btrfs_fs_devices; -+struct btrfs_fs_info { -+ u8 fsid[BTRFS_FSID_SIZE]; -+ struct btrfs_root fs_root; -+ struct btrfs_root tree_root; -+ struct btrfs_root chunk_root; -+ -+ struct btrfs_file_info file_info; /* currently opened file */ -+ struct btrfs_path paths [LAST_LOOKUP_POOL]; -+ -+ char mbr[SECTOR_SIZE]; -+ -+ int sb_mirror; -+ u64 sb_transid; -+ struct btrfs_device sb_dev; -+ struct btrfs_super_block sb_copy; -+ -+ struct btrfs_device devices[BTRFS_NUM_CACHED_DEVICES + 1]; -+}; -+ -+/* -+ * inode items have the data typically returned from stat and store other -+ * info about object characteristics. There is one for every file and di= r in -+ * the FS -+ */ -+#define BTRFS_INODE_ITEM_KEY 1 -+#define BTRFS_INODE_REF_KEY 12 -+#define BTRFS_XATTR_ITEM_KEY 24 -+#define BTRFS_ORPHAN_ITEM_KEY 48 -+ -+#define BTRFS_DIR_LOG_ITEM_KEY 60 -+#define BTRFS_DIR_LOG_INDEX_KEY 72 -+/* -+ * dir items are the name -> inode pointers in a directory. There is one -+ * for every name in a directory. -+ */ -+#define BTRFS_DIR_ITEM_KEY 84 -+#define BTRFS_DIR_INDEX_KEY 96 -+ -+/* -+ * extent data is for file data -+ */ -+#define BTRFS_EXTENT_DATA_KEY 108 -+ -+/* -+ * csum items have the checksums for data in the extents -+ */ -+#define BTRFS_CSUM_ITEM_KEY 120 -+/* -+ * extent csums are stored in a separate tree and hold csums for -+ * an entire extent on disk. -+ */ -+#define BTRFS_EXTENT_CSUM_KEY 128 -+ -+/* -+ * root items point to tree roots. There are typically in the root -+ * tree used by the super block to find all the other trees -+ */ -+#define BTRFS_ROOT_ITEM_KEY 132 -+ -+/* -+ * root backrefs tie subvols and snapshots to the directory entries that -+ * reference them -+ */ -+#define BTRFS_ROOT_BACKREF_KEY 144 -+ -+/* -+ * root refs make a fast index for listing all of the snapshots and -+ * subvolumes referenced by a given root. They point directly to the -+ * directory item in the root that references the subvol -+ */ -+#define BTRFS_ROOT_REF_KEY 156 -+ -+/* -++ * extent items are in the extent map tree. These record which blocks -++ * are used, and how many references there are to each block -++ */ -+#define BTRFS_EXTENT_ITEM_KEY 168 -+#define BTRFS_EXTENT_REF_KEY 180 -+ -+/* -+ * block groups give us hints into the extent allocation trees. Which -+ * blocks are free etc etc -+ */ -+#define BTRFS_BLOCK_GROUP_ITEM_KEY 192 -+ -+#define BTRFS_DEV_EXTENT_KEY 204 -+#define BTRFS_DEV_ITEM_KEY 216 -+#define BTRFS_CHUNK_ITEM_KEY 228 -+ -+/* -+ * string items are for debugging. They just store a short string of -+ * data in the FS -+ */ -+#define BTRFS_STRING_ITEM_KEY 253 -+/* -+ * Inode flags -+ */ -+#define BTRFS_INODE_NODATASUM (1 << 0) -+#define BTRFS_INODE_NODATACOW (1 << 1) -+#define BTRFS_INODE_READONLY (1 << 2) -+ -+#define read_eb_member(eb, ptr, type, member, result) ( = \ -+ read_extent_buffer(eb, (char *)(result), \ -+ ((unsigned long)(ptr)) + \ -+ offsetof(type, member), \ -+ sizeof(((type *)0)->member))) -+ -+#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ -+static inline u##bits btrfs_##name(struct extent_buffer *eb) \ -+{ \ -+ struct btrfs_header *h =3D (struct btrfs_header *)eb->data; \ -+ return le##bits##_to_cpu(h->member); \ -+} \ -+static inline void btrfs_set_##name(struct extent_buffer *eb, \ -+ u##bits val) \ -+{ \ -+ struct btrfs_header *h =3D (struct btrfs_header *)eb->data; \ -+ h->member =3D cpu_to_le##bits(val); \ -+} -+ -+#define BTRFS_SETGET_FUNCS(name, type, member, bits) \ -+static inline u##bits btrfs_##name(struct extent_buffer *eb, \ -+ type *s) \ -+{ \ -+ unsigned long offset =3D (unsigned long)s; \ -+ type *p =3D (type *) (eb->data + offset); \ -+ return le##bits##_to_cpu(p->member); \ -+} \ -+static inline void btrfs_set_##name(struct extent_buffer *eb, \ -+ type *s, u##bits val) \ -+{ \ -+ unsigned long offset =3D (unsigned long)s; \ -+ type *p =3D (type *) (eb->data + offset); \ -+ p->member =3D cpu_to_le##bits(val); \ -+} -+ -+#define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \ -+static inline u##bits btrfs_##name(type *s) \ -+{ \ -+ return le##bits##_to_cpu(s->member); \ -+} \ -+static inline void btrfs_set_##name(type *s, u##bits val) \ -+{ \ -+ s->member =3D cpu_to_le##bits(val); \ -+} -+ -+BTRFS_SETGET_FUNCS(device_type, struct btrfs_dev_item, type, 64); -+BTRFS_SETGET_FUNCS(device_total_bytes, struct btrfs_dev_item, total_bytes= , 64); -+BTRFS_SETGET_FUNCS(device_bytes_used, struct btrfs_dev_item, bytes_used, = 64); -+BTRFS_SETGET_FUNCS(device_io_align, struct btrfs_dev_item, io_align, 32); -+BTRFS_SETGET_FUNCS(device_io_width, struct btrfs_dev_item, io_width, 32); -+BTRFS_SETGET_FUNCS(device_start_offset, struct btrfs_dev_item, -+ start_offset, 64); -+BTRFS_SETGET_FUNCS(device_sector_size, struct btrfs_dev_item, sector_size= , 32); -+BTRFS_SETGET_FUNCS(device_id, struct btrfs_dev_item, devid, 64); -+BTRFS_SETGET_FUNCS(device_group, struct btrfs_dev_item, dev_group, 32); -+BTRFS_SETGET_FUNCS(device_seek_speed, struct btrfs_dev_item, seek_speed, = 8); -+BTRFS_SETGET_FUNCS(device_bandwidth, struct btrfs_dev_item, bandwidth, 8); -+BTRFS_SETGET_FUNCS(device_generation, struct btrfs_dev_item, generation, = 64); -+ -+BTRFS_SETGET_STACK_FUNCS(stack_device_type, struct btrfs_dev_item, type, = 64); -+BTRFS_SETGET_STACK_FUNCS(stack_device_total_bytes, struct btrfs_dev_item, -+ total_bytes, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_device_bytes_used, struct btrfs_dev_item, -+ bytes_used, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_device_io_align, struct btrfs_dev_item, -+ io_align, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_device_io_width, struct btrfs_dev_item, -+ io_width, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_device_sector_size, struct btrfs_dev_item, -+ sector_size, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_device_id, struct btrfs_dev_item, devid, 6= 4); -+BTRFS_SETGET_STACK_FUNCS(stack_device_group, struct btrfs_dev_item, -+ dev_group, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_device_seek_speed, struct btrfs_dev_item, -+ seek_speed, 8); -+BTRFS_SETGET_STACK_FUNCS(stack_device_bandwidth, struct btrfs_dev_item, -+ bandwidth, 8); -+BTRFS_SETGET_STACK_FUNCS(stack_device_generation, struct btrfs_dev_item, -+ generation, 64); -+ -+static inline char *btrfs_device_uuid(struct btrfs_dev_item *d) -+{ -+ return (char *)d + offsetof(struct btrfs_dev_item, uuid); -+} -+ -+static inline char *btrfs_device_fsid(struct btrfs_dev_item *d) -+{ -+ return (char *)d + offsetof(struct btrfs_dev_item, fsid); -+} -+ -+BTRFS_SETGET_FUNCS(chunk_length, struct btrfs_chunk, length, 64); -+BTRFS_SETGET_FUNCS(chunk_owner, struct btrfs_chunk, owner, 64); -+BTRFS_SETGET_FUNCS(chunk_stripe_len, struct btrfs_chunk, stripe_len, 64); -+BTRFS_SETGET_FUNCS(chunk_io_align, struct btrfs_chunk, io_align, 32); -+BTRFS_SETGET_FUNCS(chunk_io_width, struct btrfs_chunk, io_width, 32); -+BTRFS_SETGET_FUNCS(chunk_sector_size, struct btrfs_chunk, sector_size, 32= ); -+BTRFS_SETGET_FUNCS(chunk_type, struct btrfs_chunk, type, 64); -+BTRFS_SETGET_FUNCS(chunk_num_stripes, struct btrfs_chunk, num_stripes, 16= ); -+BTRFS_SETGET_FUNCS(chunk_sub_stripes, struct btrfs_chunk, sub_stripes, 16= ); -+BTRFS_SETGET_FUNCS(stripe_devid, struct btrfs_stripe, devid, 64); -+BTRFS_SETGET_FUNCS(stripe_offset, struct btrfs_stripe, offset, 64); -+ -+static inline char *btrfs_stripe_dev_uuid(struct btrfs_stripe *s) -+{ -+ return (char *)s + offsetof(struct btrfs_stripe, dev_uuid); -+} -+ -+BTRFS_SETGET_STACK_FUNCS(stack_chunk_length, struct btrfs_chunk, length, = 64); -+BTRFS_SETGET_STACK_FUNCS(stack_chunk_owner, struct btrfs_chunk, owner, 64= ); -+BTRFS_SETGET_STACK_FUNCS(stack_chunk_stripe_len, struct btrfs_chunk, -+ stripe_len, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_chunk_io_align, struct btrfs_chunk, -+ io_align, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_chunk_io_width, struct btrfs_chunk, -+ io_width, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_chunk_sector_size, struct btrfs_chunk, -+ sector_size, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_chunk_type, struct btrfs_chunk, type, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_chunk_num_stripes, struct btrfs_chunk, -+ num_stripes, 16); -+BTRFS_SETGET_STACK_FUNCS(stack_chunk_sub_stripes, struct btrfs_chunk, -+ sub_stripes, 16); -+BTRFS_SETGET_STACK_FUNCS(stack_stripe_devid, struct btrfs_stripe, devid, = 64); -+BTRFS_SETGET_STACK_FUNCS(stack_stripe_offset, struct btrfs_stripe, offset= , 64); -+ -+static inline struct btrfs_stripe *btrfs_stripe_nr(struct btrfs_chunk *c, -+ int nr) -+{ -+ unsigned long offset =3D (unsigned long)c; -+ offset +=3D offsetof(struct btrfs_chunk, stripe); -+ offset +=3D nr * sizeof(struct btrfs_stripe); -+ return (struct btrfs_stripe *)offset; -+} -+ -+static inline char *btrfs_stripe_dev_uuid_nr(struct btrfs_chunk *c, int n= r) -+{ -+ return btrfs_stripe_dev_uuid(btrfs_stripe_nr(c, nr)); -+} -+ -+static inline u64 btrfs_stripe_offset_nr(struct extent_buffer *eb, -+ struct btrfs_chunk *c, int nr) -+{ -+ return btrfs_stripe_offset(eb, btrfs_stripe_nr(c, nr)); -+} -+ -+static inline void btrfs_set_stripe_offset_nr(struct extent_buffer *eb, -+ struct btrfs_chunk *c, int nr, -+ u64 val) -+{ -+ btrfs_set_stripe_offset(eb, btrfs_stripe_nr(c, nr), val); -+} -+ -+static inline u64 btrfs_stripe_devid_nr(struct extent_buffer *eb, -+ struct btrfs_chunk *c, int nr) -+{ -+ return btrfs_stripe_devid(eb, btrfs_stripe_nr(c, nr)); -+} -+ -+static inline void btrfs_set_stripe_devid_nr(struct extent_buffer *eb, -+ struct btrfs_chunk *c, int nr, -+ u64 val) -+{ -+ btrfs_set_stripe_devid(eb, btrfs_stripe_nr(c, nr), val); -+} -+ -+/* struct btrfs_block_group_item */ -+BTRFS_SETGET_STACK_FUNCS(block_group_used, struct btrfs_block_group_item, -+ used, 64); -+BTRFS_SETGET_FUNCS(disk_block_group_used, struct btrfs_block_group_item, -+ used, 64); -+BTRFS_SETGET_STACK_FUNCS(block_group_chunk_objectid, -+ struct btrfs_block_group_item, chunk_objectid, 64); -+ -+BTRFS_SETGET_FUNCS(disk_block_group_chunk_objectid, -+ struct btrfs_block_group_item, chunk_objectid, 64); -+BTRFS_SETGET_FUNCS(disk_block_group_flags, -+ struct btrfs_block_group_item, flags, 64); -+BTRFS_SETGET_STACK_FUNCS(block_group_flags, -+ struct btrfs_block_group_item, flags, 64); -+ -+/* struct btrfs_inode_ref */ -+BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, = 16); -+BTRFS_SETGET_FUNCS(inode_ref_index, struct btrfs_inode_ref, index, 64); -+ -+/* struct btrfs_inode_item */ -+BTRFS_SETGET_FUNCS(inode_generation, struct btrfs_inode_item, generation,= 64); -+BTRFS_SETGET_FUNCS(inode_sequence, struct btrfs_inode_item, sequence, 64); -+BTRFS_SETGET_FUNCS(inode_transid, struct btrfs_inode_item, transid, 64); -+BTRFS_SETGET_FUNCS(inode_size, struct btrfs_inode_item, size, 64); -+BTRFS_SETGET_FUNCS(inode_nbytes, struct btrfs_inode_item, nbytes, 64); -+BTRFS_SETGET_FUNCS(inode_block_group, struct btrfs_inode_item, block_grou= p, 64); -+BTRFS_SETGET_FUNCS(inode_nlink, struct btrfs_inode_item, nlink, 32); -+BTRFS_SETGET_FUNCS(inode_uid, struct btrfs_inode_item, uid, 32); -+BTRFS_SETGET_FUNCS(inode_gid, struct btrfs_inode_item, gid, 32); -+BTRFS_SETGET_FUNCS(inode_mode, struct btrfs_inode_item, mode, 32); -+BTRFS_SETGET_FUNCS(inode_rdev, struct btrfs_inode_item, rdev, 64); -+BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64); -+ -+BTRFS_SETGET_STACK_FUNCS(stack_inode_generation, -+ struct btrfs_inode_item, generation, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_inode_sequence, -+ struct btrfs_inode_item, generation, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_inode_size, -+ struct btrfs_inode_item, size, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_inode_nbytes, -+ struct btrfs_inode_item, nbytes, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_inode_block_group, -+ struct btrfs_inode_item, block_group, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_inode_nlink, -+ struct btrfs_inode_item, nlink, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_inode_uid, -+ struct btrfs_inode_item, uid, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_inode_gid, -+ struct btrfs_inode_item, gid, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_inode_mode, -+ struct btrfs_inode_item, mode, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_inode_rdev, -+ struct btrfs_inode_item, rdev, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_inode_flags, -+ struct btrfs_inode_item, flags, 64); -+ -+BTRFS_SETGET_FUNCS(timespec_sec, struct btrfs_timespec, sec, 64); -+BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_timespec, nsec, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_timespec_sec, struct btrfs_timespec, -+ sec, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_timespec_nsec, struct btrfs_timespec, -+ nsec, 32); -+ -+/* struct btrfs_dev_extent */ -+BTRFS_SETGET_FUNCS(dev_extent_chunk_tree, struct btrfs_dev_extent, -+ chunk_tree, 64); -+BTRFS_SETGET_FUNCS(dev_extent_chunk_objectid, struct btrfs_dev_extent, -+ chunk_objectid, 64); -+BTRFS_SETGET_FUNCS(dev_extent_chunk_offset, struct btrfs_dev_extent, -+ chunk_offset, 64); -+BTRFS_SETGET_FUNCS(dev_extent_length, struct btrfs_dev_extent, length, 64= ); -+ -+static inline u8 *btrfs_dev_extent_chunk_tree_uuid(struct btrfs_dev_exten= t *dev) -+{ -+ unsigned long ptr =3D offsetof(struct btrfs_dev_extent, chunk_tree= _uuid); -+ return (u8 *)((unsigned long)dev + ptr); -+} -+ -+/* struct btrfs_extent_ref */ -+BTRFS_SETGET_FUNCS(ref_root, struct btrfs_extent_ref, root, 64); -+BTRFS_SETGET_FUNCS(ref_generation, struct btrfs_extent_ref, generation, 6= 4); -+BTRFS_SETGET_FUNCS(ref_objectid, struct btrfs_extent_ref, objectid, 64); -+BTRFS_SETGET_FUNCS(ref_num_refs, struct btrfs_extent_ref, num_refs, 32); -+ -+BTRFS_SETGET_STACK_FUNCS(stack_ref_root, struct btrfs_extent_ref, root, 6= 4); -+BTRFS_SETGET_STACK_FUNCS(stack_ref_generation, struct btrfs_extent_ref, -+ generation, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_ref_objectid, struct btrfs_extent_ref, -+ objectid, 64); -+BTRFS_SETGET_STACK_FUNCS(stack_ref_num_refs, struct btrfs_extent_ref, -+ num_refs, 32); -+ -+/* struct btrfs_extent_item */ -+BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32); -+BTRFS_SETGET_STACK_FUNCS(stack_extent_refs, struct btrfs_extent_item, -+ refs, 32); -+ -+/* struct btrfs_node */ -+BTRFS_SETGET_FUNCS(key_blockptr, struct btrfs_key_ptr, blockptr, 64); -+BTRFS_SETGET_FUNCS(key_generation, struct btrfs_key_ptr, generation, 64); -+ -+static inline u64 btrfs_node_blockptr(struct extent_buffer *eb, int nr) -+{ -+ unsigned long ptr; -+ ptr =3D offsetof(struct btrfs_node, ptrs) + -+ sizeof(struct btrfs_key_ptr) * nr; -+ return btrfs_key_blockptr(eb, (struct btrfs_key_ptr *)ptr); -+} -+ -+static inline void btrfs_set_node_blockptr(struct extent_buffer *eb, -+ int nr, u64 val) -+{ -+ unsigned long ptr; -+ ptr =3D offsetof(struct btrfs_node, ptrs) + -+ sizeof(struct btrfs_key_ptr) * nr; -+ btrfs_set_key_blockptr(eb, (struct btrfs_key_ptr *)ptr, val); -+} -+ -+static inline u64 btrfs_node_ptr_generation(struct extent_buffer *eb, int= nr) -+{ -+ unsigned long ptr; -+ ptr =3D offsetof(struct btrfs_node, ptrs) + -+ sizeof(struct btrfs_key_ptr) * nr; -+ return btrfs_key_generation(eb, (struct btrfs_key_ptr *)ptr); -+} -+ -+static inline void btrfs_set_node_ptr_generation(struct extent_buffer *eb, -+ int nr, u64 val) -+{ -+ unsigned long ptr; -+ ptr =3D offsetof(struct btrfs_node, ptrs) + -+ sizeof(struct btrfs_key_ptr) * nr; -+ btrfs_set_key_generation(eb, (struct btrfs_key_ptr *)ptr, val); -+} -+ -+static inline unsigned long btrfs_node_key_ptr_offset(int nr) -+{ -+ return offsetof(struct btrfs_node, ptrs) + -+ sizeof(struct btrfs_key_ptr) * nr; -+} -+ -+static inline void btrfs_node_key(struct extent_buffer *eb, -+ struct btrfs_disk_key *disk_key, int nr) -+{ -+ unsigned long ptr; -+ ptr =3D btrfs_node_key_ptr_offset(nr); -+ read_eb_member(eb, (struct btrfs_key_ptr *)ptr, -+ struct btrfs_key_ptr, key, disk_key); -+} -+ -+/* struct btrfs_item */ -+BTRFS_SETGET_FUNCS(item_offset, struct btrfs_item, offset, 32); -+BTRFS_SETGET_FUNCS(item_size, struct btrfs_item, size, 32); -+ -+static inline unsigned long btrfs_item_nr_offset(int nr) -+{ -+ return offsetof(struct btrfs_leaf, items) + -+ sizeof(struct btrfs_item) * nr; -+} -+ -+static inline struct btrfs_item *btrfs_item_nr(struct extent_buffer *eb, -+ int nr) -+{ -+ return (struct btrfs_item *)btrfs_item_nr_offset(nr); -+} -+ -+static inline u32 btrfs_item_end(struct extent_buffer *eb, -+ struct btrfs_item *item) -+{ -+ return btrfs_item_offset(eb, item) + btrfs_item_size(eb, item); -+} -+ -+static inline u32 btrfs_item_end_nr(struct extent_buffer *eb, int nr) -+{ -+ return btrfs_item_end(eb, btrfs_item_nr(eb, nr)); -+} -+ -+static inline u32 btrfs_item_offset_nr(struct extent_buffer *eb, int nr) -+{ -+ return btrfs_item_offset(eb, btrfs_item_nr(eb, nr)); -+} -+ -+static inline u32 btrfs_item_size_nr(struct extent_buffer *eb, int nr) -+{ -+ return btrfs_item_size(eb, btrfs_item_nr(eb, nr)); -+} -+ -+static inline void btrfs_item_key(struct extent_buffer *eb, -+ struct btrfs_disk_key *disk_key, int nr) -+{ -+ struct btrfs_item *item =3D btrfs_item_nr(eb, nr); -+ read_eb_member(eb, item, struct btrfs_item, key, disk_key); -+} -+ -+/* -+ * struct btrfs_root_ref -+ */ -+BTRFS_SETGET_FUNCS(root_ref_dirid, struct btrfs_root_ref, dirid, 64); -+BTRFS_SETGET_FUNCS(root_ref_sequence, struct btrfs_root_ref, sequence, 64= ); -+BTRFS_SETGET_FUNCS(root_ref_name_len, struct btrfs_root_ref, name_len, 16= ); -+ -+/* struct btrfs_dir_item */ -+BTRFS_SETGET_FUNCS(dir_data_len, struct btrfs_dir_item, data_len, 16); -+BTRFS_SETGET_FUNCS(dir_type, struct btrfs_dir_item, type, 8); -+BTRFS_SETGET_FUNCS(dir_name_len, struct btrfs_dir_item, name_len, 16); -+BTRFS_SETGET_FUNCS(dir_transid, struct btrfs_dir_item, transid, 64); -+ -+static inline void btrfs_dir_item_key(struct extent_buffer *eb, -+ struct btrfs_dir_item *item, -+ struct btrfs_disk_key *key) -+{ -+ read_eb_member(eb, item, struct btrfs_dir_item, location, key); -+} -+ -+/* struct btrfs_disk_key */ -+BTRFS_SETGET_STACK_FUNCS(disk_key_objectid, struct btrfs_disk_key, -+ objectid, 64); -+BTRFS_SETGET_STACK_FUNCS(disk_key_offset, struct btrfs_disk_key, offset, = 64); -+BTRFS_SETGET_STACK_FUNCS(disk_key_type, struct btrfs_disk_key, type, 8); -+ -+static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu, -+ struct btrfs_disk_key *disk) -+{ -+ cpu->offset =3D le64_to_cpu(disk->offset); -+ cpu->type =3D disk->type; -+ cpu->objectid =3D le64_to_cpu(disk->objectid); -+} -+ -+static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk, -+ struct btrfs_key *cpu) -+{ -+ disk->offset =3D cpu_to_le64(cpu->offset); -+ disk->type =3D cpu->type; -+ disk->objectid =3D cpu_to_le64(cpu->objectid); -+} -+ -+static inline void btrfs_node_key_to_cpu(struct extent_buffer *eb, -+ struct btrfs_key *key, int nr) -+{ -+ struct btrfs_disk_key disk_key; -+ btrfs_node_key(eb, &disk_key, nr); -+ btrfs_disk_key_to_cpu(key, &disk_key); -+} -+ -+static inline void btrfs_item_key_to_cpu(struct extent_buffer *eb, -+ struct btrfs_key *key, int nr) -+{ -+ struct btrfs_disk_key disk_key; -+ btrfs_item_key(eb, &disk_key, nr); -+ btrfs_disk_key_to_cpu(key, &disk_key); -+} -+ -+static inline void btrfs_dir_item_key_to_cpu(struct extent_buffer *eb, -+ struct btrfs_dir_item *item, -+ struct btrfs_key *key) -+{ -+ struct btrfs_disk_key disk_key; -+ btrfs_dir_item_key(eb, item, &disk_key); -+ btrfs_disk_key_to_cpu(key, &disk_key); -+} -+ -+static inline u8 btrfs_key_type(struct btrfs_key *key) -+{ -+ return key->type; -+} -+ -+static inline void btrfs_set_key_type(struct btrfs_key *key, u8 val) -+{ -+ key->type =3D val; -+} -+ -+static inline u64 btrfs_super_devid(struct btrfs_super_block *disk_super) -+{ -+ return le64_to_cpu(disk_super->dev_item.devid); -+} -+ -+/* struct btrfs_header */ -+BTRFS_SETGET_HEADER_FUNCS(header_bytenr, struct btrfs_header, bytenr, 64); -+BTRFS_SETGET_HEADER_FUNCS(header_generation, struct btrfs_header, -+ generation, 64); -+BTRFS_SETGET_HEADER_FUNCS(header_owner, struct btrfs_header, owner, 64); -+BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 3= 2); -+BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64); -+BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8); -+ -+/* struct btrfs_root_item */ -+BTRFS_SETGET_FUNCS(disk_root_generation, struct btrfs_root_item, -+ generation, 64); -+BTRFS_SETGET_FUNCS(disk_root_refs, struct btrfs_root_item, refs, 32); -+BTRFS_SETGET_FUNCS(disk_root_bytenr, struct btrfs_root_item, bytenr, 64); -+BTRFS_SETGET_FUNCS(disk_root_level, struct btrfs_root_item, level, 8); -+ -+BTRFS_SETGET_STACK_FUNCS(root_generation, struct btrfs_root_item, -+ generation, 64); -+BTRFS_SETGET_STACK_FUNCS(root_bytenr, struct btrfs_root_item, bytenr, 64); -+BTRFS_SETGET_STACK_FUNCS(root_level, struct btrfs_root_item, level, 8); -+BTRFS_SETGET_STACK_FUNCS(root_dirid, struct btrfs_root_item, root_dirid, = 64); -+BTRFS_SETGET_STACK_FUNCS(root_refs, struct btrfs_root_item, refs, 32); -+BTRFS_SETGET_STACK_FUNCS(root_flags, struct btrfs_root_item, flags, 64); -+BTRFS_SETGET_STACK_FUNCS(root_used, struct btrfs_root_item, bytes_used, 6= 4); -+BTRFS_SETGET_STACK_FUNCS(root_limit, struct btrfs_root_item, byte_limit, = 64); -+BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item, -+ last_snapshot, 64); -+ -+/* struct btrfs_super_block */ -+ -+BTRFS_SETGET_STACK_FUNCS(super_bytenr, struct btrfs_super_block, bytenr, = 64); -+BTRFS_SETGET_STACK_FUNCS(super_flags, struct btrfs_super_block, flags, 64= ); -+BTRFS_SETGET_STACK_FUNCS(super_generation, struct btrfs_super_block, -+ generation, 64); -+BTRFS_SETGET_STACK_FUNCS(super_root, struct btrfs_super_block, root, 64); -+BTRFS_SETGET_STACK_FUNCS(super_sys_array_size, -+ struct btrfs_super_block, sys_chunk_array_size, 3= 2); -+BTRFS_SETGET_STACK_FUNCS(super_chunk_root_generation, -+ struct btrfs_super_block, chunk_root_generation, = 64); -+BTRFS_SETGET_STACK_FUNCS(super_root_level, struct btrfs_super_block, -+ root_level, 8); -+BTRFS_SETGET_STACK_FUNCS(super_chunk_root, struct btrfs_super_block, -+ chunk_root, 64); -+BTRFS_SETGET_STACK_FUNCS(super_chunk_root_level, struct btrfs_super_block, -+ chunk_root_level, 8); -+BTRFS_SETGET_STACK_FUNCS(super_log_root, struct btrfs_super_block, -+ log_root, 64); -+BTRFS_SETGET_STACK_FUNCS(super_log_root_transid, struct btrfs_super_block, -+ log_root_transid, 64); -+BTRFS_SETGET_STACK_FUNCS(super_log_root_level, struct btrfs_super_block, -+ log_root_level, 8); -+BTRFS_SETGET_STACK_FUNCS(super_total_bytes, struct btrfs_super_block, -+ total_bytes, 64); -+BTRFS_SETGET_STACK_FUNCS(super_bytes_used, struct btrfs_super_block, -+ bytes_used, 64); -+BTRFS_SETGET_STACK_FUNCS(super_sectorsize, struct btrfs_super_block, -+ sectorsize, 32); -+BTRFS_SETGET_STACK_FUNCS(super_nodesize, struct btrfs_super_block, -+ nodesize, 32); -+BTRFS_SETGET_STACK_FUNCS(super_leafsize, struct btrfs_super_block, -+ leafsize, 32); -+BTRFS_SETGET_STACK_FUNCS(super_stripesize, struct btrfs_super_block, -+ stripesize, 32); -+BTRFS_SETGET_STACK_FUNCS(super_root_dir, struct btrfs_super_block, -+ root_dir_objectid, 64); -+BTRFS_SETGET_STACK_FUNCS(super_num_devices, struct btrfs_super_block, -+ num_devices, 64); -+BTRFS_SETGET_STACK_FUNCS(super_compat_flags, struct btrfs_super_block, -+ compat_flags, 64); -+BTRFS_SETGET_STACK_FUNCS(super_compat_ro_flags, struct btrfs_super_block, -+ compat_flags, 64); -+BTRFS_SETGET_STACK_FUNCS(super_incompat_flags, struct btrfs_super_block, -+ incompat_flags, 64); -+BTRFS_SETGET_STACK_FUNCS(super_csum_type, struct btrfs_super_block, -+ csum_type, 16); -+ -+static inline int btrfs_super_csum_size(struct btrfs_super_block *s) -+{ -+ int t =3D btrfs_super_csum_type(s); -+ //BUG_ON(t >=3D ARRAY_SIZE(btrfs_csum_sizes)); -+ return btrfs_csum_sizes[t]; -+} -+ -+static inline unsigned long btrfs_leaf_data(struct extent_buffer *l) -+{ -+ return offsetof(struct btrfs_leaf, items); -+} -+ -+/* struct btrfs_file_extent_item */ -+BTRFS_SETGET_FUNCS(file_extent_type, struct btrfs_file_extent_item, type,= 8); -+ -+static inline unsigned long btrfs_file_extent_inline_start(struct -+ btrfs_file_extent_item = *e) -+{ -+ unsigned long offset =3D (unsigned long)e; -+ offset +=3D offsetof(struct btrfs_file_extent_item, disk_bytenr); -+ return offset; -+} -+ -+static inline u32 btrfs_file_extent_calc_inline_size(u32 datasize) -+{ -+ return offsetof(struct btrfs_file_extent_item, disk_bytenr) + data= size; -+} -+ -+BTRFS_SETGET_FUNCS(file_extent_disk_bytenr, struct btrfs_file_extent_item, -+ disk_bytenr, 64); -+BTRFS_SETGET_FUNCS(file_extent_generation, struct btrfs_file_extent_item, -+ generation, 64); -+BTRFS_SETGET_FUNCS(file_extent_disk_num_bytes, struct btrfs_file_extent_i= tem, -+ disk_num_bytes, 64); -+BTRFS_SETGET_FUNCS(file_extent_offset, struct btrfs_file_extent_item, -+ offset, 64); -+BTRFS_SETGET_FUNCS(file_extent_num_bytes, struct btrfs_file_extent_item, -+ num_bytes, 64); -+BTRFS_SETGET_FUNCS(file_extent_ram_bytes, struct btrfs_file_extent_item, -+ ram_bytes, 64); -+BTRFS_SETGET_FUNCS(file_extent_compression, struct btrfs_file_extent_item, -+ compression, 8); -+BTRFS_SETGET_FUNCS(file_extent_encryption, struct btrfs_file_extent_item, -+ encryption, 8); -+BTRFS_SETGET_FUNCS(file_extent_other_encoding, struct btrfs_file_extent_i= tem, -+ other_encoding, 16); -+ -+/* this returns the number of file bytes represented by the inline item. -+ * If an item is compressed, this is the uncompressed size -+ */ -+static inline u32 btrfs_file_extent_inline_len(struct extent_buffer *eb, -+ struct btrfs_file_extent_item *e) -+{ -+ return btrfs_file_extent_ram_bytes(eb, e); -+} -+ -+/* -+ * this returns the number of bytes used by the item on disk, minus the -+ * size of any extent headers. If a file is compressed on disk, this is -+ * the compressed size -+ */ -+static inline u32 btrfs_file_extent_inline_item_len(struct extent_buffer = *eb, -+ struct btrfs_item *e) -+{ -+ unsigned long offset; -+ offset =3D offsetof(struct btrfs_file_extent_item, disk_bytenr); -+ return btrfs_item_size(eb, e) - offset; -+} -+ -+static inline u32 btrfs_level_size(struct btrfs_root *root, int level) { -+ if (level =3D=3D 0) -+ return root->leafsize; -+ return root->nodesize; -+} -+ -+static inline u32 btrfs_root_level_size(struct btrfs_super_block *sb) { -+ return btrfs_super_root_level(sb) =3D=3D 0 ? -+ btrfs_super_leafsize(sb) : -+ btrfs_super_nodesize(sb); -+} -+ -+static inline u32 btrfs_chunk_root_level_size(struct btrfs_super_block *s= b) { -+ return btrfs_super_chunk_root_level(sb) =3D=3D 0 ? -+ btrfs_super_leafsize(sb) : -+ btrfs_super_nodesize(sb); -+} -+ -+/* helper function to cast into the data area of the leaf. */ -+#define btrfs_item_ptr(leaf, slot, type) \ -+ ((type *)(btrfs_leaf_data(leaf) + \ -+ btrfs_item_offset_nr(leaf, slot))) -+ -+#define btrfs_item_ptr_offset(leaf, slot) \ -+ ((unsigned long)(btrfs_leaf_data(leaf) + \ -+ btrfs_item_offset_nr(leaf, slot))) -+ -+/*volumes.h */ -+ -+struct btrfs_fs_devices { -+ u8 fsid[BTRFS_FSID_SIZE]; /* FS specific uuid */ -+ -+ /* the device with this id has the most recent coyp of the super */ -+ u64 latest_devid; -+ u64 latest_trans; -+ u64 lowest_devid; -+ int latest_bdev; -+ int lowest_bdev; -+ int seeding; -+ struct btrfs_fs_devices *seed; -+}; -+ -+struct btrfs_bio_stripe { -+ struct btrfs_device dev; -+ u64 physical; -+}; -+ -+#define MAX_NRSTRIPES 8 -+struct btrfs_multi_bio { -+ int error; -+ int num_stripes; -+ struct btrfs_bio_stripe stripes[MAX_NRSTRIPES]; -+}; -+ -+#define btrfs_multi_bio_size(n) (sizeof(struct btrfs_multi_bio) + \ -+ (sizeof(struct btrfs_bio_stripe) * (n))) -+ -+static int aux_tree_lookup(struct btrfs_root *root, -+ struct btrfs_key *key, -+ struct btrfs_path *path); -+ -+struct cache_extent { -+ u64 start; -+ u64 size; -+}; -+ -+struct map_lookup { -+ struct cache_extent ce; -+ u64 type; -+ int io_align; -+ int io_width; -+ int stripe_len; -+ int sector_size; -+ int num_stripes; -+ int sub_stripes; -+ struct btrfs_bio_stripe stripes[MAX_NRSTRIPES]; -+}; -+ -+/* "VFS" things */ -+ -+/* file types recognized by grub */ -+typedef enum { -+ BTRFS_REGULAR_FILE, -+ BTRFS_DIRECTORY_FILE, -+ BTRFS_SYMLINK_FILE, -+ BTRFS_UNKNOWN_FILE -+} btrfs_file_type; -+ -+static inline int coord_is_root(struct btrfs_root *root, -+ struct btrfs_path *path) -+{ -+ return btrfs_header_bytenr(&path->nodes[0]) =3D=3D -+ btrfs_header_bytenr(&root->node); -+} -+ -+static inline btrfs_file_type btrfs_get_file_type (int mode) -+{ -+ if (S_ISLNK(mode)) -+ return BTRFS_SYMLINK_FILE; -+ if (S_ISREG(mode)) -+ return BTRFS_REGULAR_FILE; -+ if (S_ISDIR(mode)) -+ return BTRFS_DIRECTORY_FILE; -+ return BTRFS_UNKNOWN_FILE; -+} -+ -+#define min_t(type,x,y) = \ -+ ({ type __x =3D (x); type __y =3D (y); __x < __y ? __x: __y; }) -+#define max_t(type,x,y) = \ -+ ({ type __x =3D (x); type __y =3D (y); __x > __y ? __x: __y; }) -+ -+ -+int sys_array_lookup(struct map_lookup *map, u64 logical); -+int tree_chunk_lookup(struct map_lookup *map, -+ u64 logical); -+int __btrfs_map_block(u64 logical, u64 *length, -+ struct btrfs_multi_bio *multi_ret, int mirror_num); -+int read_tree_block(struct btrfs_root *root, -+ struct extent_buffer *eb, -+ u64 bytenr, /* logical */ -+ u32 blocksize, -+ u64 parent_transid, -+ lookup_pool_id lpid); -+int check_read_chunk(struct btrfs_key *key, -+ struct extent_buffer *leaf, -+ struct btrfs_chunk *chunk, -+ struct map_lookup *map, -+ u64 logical); -+/* -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 80 -+ scroll-step: 1 -+ End: -+*/ -\ No newline at end of file -diff -up grub-upstream.wip/stage2/builtins.c.btrfs grub-upstream.wip/stage= 2/builtins.c ---- grub-upstream.wip/stage2/builtins.c.btrfs 2012-03-20 05:06:49.00000000= 0 +0000 -+++ grub-upstream.wip/stage2/builtins.c 2012-03-20 05:11:13.000000000 +0000 -@@ -2456,6 +2456,16 @@ install_func (char *arg, int flags) - else - #endif /* GRUB_UTIL */ - { -+ /* -+ * FIXME: Ugly hack. -+ * Do not write to btrfs partition -+ * without a help of the file system! -+ */ -+ if (!strcmp(fsys_table[fsys_type].name, "btrfs")) -+ { -+ errnum =3D ERR_BAD_ARGUMENT; -+ goto fail; -+ } - if (! devwrite (saved_sector - part_start, 1, stage2_buffer)) - goto fail; - } -@@ -4281,6 +4291,7 @@ setup_func (char *arg, int flags) - {"jfs", "/jfs_stage1_5"}, - {"minix", "/minix_stage1_5"}, - {"reiserfs", "/reiserfs_stage1_5"}, -+ {"btrfs", "/btrfs_stage1_5"}, - {"vstafs", "/vstafs_stage1_5"}, - {"xfs", "/xfs_stage1_5"} - }; -diff -up grub-upstream.wip/stage2/disk_io.c.btrfs grub-upstream.wip/stage2= /disk_io.c ---- grub-upstream.wip/stage2/disk_io.c.btrfs 2012-03-20 05:06:49.000000000= +0000 -+++ grub-upstream.wip/stage2/disk_io.c 2012-03-20 05:07:09.000000000 +0000 -@@ -78,6 +78,9 @@ struct fsys_entry fsys_table[NUM_FSYS +=20 - # ifdef FSYS_ISO9660 - {"iso9660", iso9660_mount, iso9660_read, iso9660_dir, 0, 0}, - # endif -+# ifdef FSYS_BTRFS -+ {"btrfs", btrfs_mount, btrfs_read, btrfs_dir, 0, btrfs_embed}, -+# endif - /* XX FFS should come last as it's superblock is commonly crossing trac= ks - on floppies from track 1 to 2, while others only use 1. */ - # ifdef FSYS_FFS -diff -up grub-upstream.wip/stage2/filesys.h.btrfs grub-upstream.wip/stage2= /filesys.h ---- grub-upstream.wip/stage2/filesys.h.btrfs 2004-05-14 19:36:43.000000000= +0000 -+++ grub-upstream.wip/stage2/filesys.h 2012-03-20 05:07:09.000000000 +0000 -@@ -77,6 +77,16 @@ int reiserfs_embed (int *start_sector, i - #define FSYS_REISERFS_NUM 0 - #endif -=20 -+#ifdef FSYS_BTRFS -+#define FSYS_BTRFS_NUM 1 -+int btrfs_mount (void); -+int btrfs_read (char *buf, int len); -+int btrfs_dir (char *dirname); -+int btrfs_embed (int *start_sector, int needed_sectors); -+#else -+#define FSYS_BTRFS_NUM 0 -+#endif -+ - #ifdef FSYS_VSTAFS - #define FSYS_VSTAFS_NUM 1 - int vstafs_mount (void); -@@ -127,8 +137,8 @@ int iso9660_dir (char *dirname); - #ifndef NUM_FSYS - #define NUM_FSYS \ - (FSYS_FFS_NUM + FSYS_FAT_NUM + FSYS_EXT2FS_NUM + FSYS_MINIX_NUM \ -- + FSYS_REISERFS_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM + FSYS_XFS_NUM \ -- + FSYS_TFTP_NUM + FSYS_ISO9660_NUM + FSYS_UFS2_NUM) -+ + FSYS_REISERFS_NUM + FSYS_BTRFS_NUM + FSYS_VSTAFS_NUM + FSYS_JFS_NUM \ -+ + FSYS_XFS_NUM + FSYS_TFTP_NUM + FSYS_ISO9660_NUM + FSYS_UFS2_NUM) - #endif -=20 - /* defines for the block filesystem info area */ -diff -up /dev/null grub-upstream.wip/stage2/fsys_btrfs.c ---- /dev/null 2009-06-03 06:46:26.160951000 +0000 -+++ grub-upstream.wip/stage2/fsys_btrfs.c 2012-03-20 05:07:09.000000000 +0= 000 -@@ -0,0 +1,1820 @@ -+/* fsys_btrfs.c - an implementation for the Btrfs filesystem -+ * -+ * Copyright 2009 Red Hat, Inc. All rights reserved. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * This program is distributed in the hope that it will be useful, -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ * GNU General Public License for more details. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program. If not, see . -+ */ -+ -+#ifdef FSYS_BTRFS -+ -+#include "shared.h" -+#include "filesys.h" -+#include "btrfs.h" -+ -+#define BTRFS_VERBOSE 0 -+ -+/* Cache layouts */ -+ -+#define LOOKUP_CACHE_BUF_SIZE (4096) -+#define LOOKUP_CACHE_SIZE (LOOKUP_CACHE_BUF_SIZE * LAST_LOOKUP_POOL) -+#define BTRFS_FS_INFO \ -+ ((struct btrfs_fs_info *)((unsigned long)FSYS_BUF + \ -+ LOOKUP_CACHE_SIZE)) -+#define BTRFS_CACHE_SIZE (sizeof(struct btrfs_fs_info) + \ -+ LOOKUP_CACHE_SIZE) -+#define BTRFS_TREE_ROOT (&BTRFS_FS_INFO->tree_root) -+#define BTRFS_CHUNK_ROOT (&BTRFS_FS_INFO->chunk_root) -+#define BTRFS_FS_ROOT (&BTRFS_FS_INFO->fs_root) -+#define BTRFS_SUPER (&BTRFS_FS_INFO->sb_copy) -+#define BTRFS_DEVICES (&BTRFS_FS_INFO->devices[0]) -+#define BTRFS_FILE_INFO (&BTRFS_FS_INFO->file_info) -+#define BTRFS_FILE_INFO_KEY (&BTRFS_FILE_INFO->key) -+ -+#define BTRFS_VOLATILE_DEV_CACHE \ -+ (&BTRFS_FS_INFO->devices[BTRFS_NUM_CACHED_DEVICES]) -+ -+#define LOOKUP_CACHE_BUF(id) ((char *)((unsigned long)FSYS_BUF + \ -+ id * LOOKUP_CACHE_BUF_SIZE)) -+ -+#define noop do {; } while (0) -+ -+#if BTRFS_VERBOSE -+#define btrfs_msg(format, ...) printf(format , ## __VA_ARGS__) -+#else -+#define btrfs_msg(format, args...) noop -+#endif -+ -+/* compile-time check to make sure we don't overlap -+ filesystem buffer */ -+static inline void check_btrfs_cache_size(void) -+{ -+ cassert(BTRFS_CACHE_SIZE <=3D FSYS_BUFLEN); -+} -+ -+static inline u64 btrfs_sb_offset(int mirror) -+{ -+ u64 start =3D 16 * 1024; -+ if (mirror) -+ return start << (BTRFS_SUPER_MIRROR_SHIFT * mirror); -+ return BTRFS_SUPER_INFO_OFFSET; -+} -+ -+static inline char *grab_lookup_cache(lookup_pool_id lpid) -+{ -+ char *buf =3D LOOKUP_CACHE_BUF(lpid); -+ memset(buf, 0, LOOKUP_CACHE_BUF_SIZE); -+ return buf; -+} -+ -+static inline struct btrfs_path *btrfs_grab_path(lookup_pool_id lpid) -+{ -+ return &BTRFS_FS_INFO->paths[lpid]; -+} -+ -+static inline void btrfs_set_path_key(struct btrfs_path *path, -+ struct btrfs_key *key) -+{ -+ btrfs_item_key_to_cpu(&path->nodes[0], -+ key, -+ path->slots[0]); -+} -+ -+static inline void btrfs_update_file_info(struct btrfs_path *path) -+{ -+ btrfs_set_path_key(path, BTRFS_FILE_INFO_KEY); -+} -+ -+static inline void btrfs_set_root_dir_key(struct btrfs_key *key) -+{ -+ key->objectid =3D BTRFS_FIRST_FREE_OBJECTID; -+ btrfs_set_key_type(key, BTRFS_INODE_ITEM_KEY); -+ key->offset =3D 0; -+} -+ -+static inline void copy_extent_buffer(struct extent_buffer *dst, -+ struct extent_buffer *src) -+{ -+ char *data =3D dst->data; -+ memcpy(dst, src, sizeof(*dst)); -+ memcpy(data, src->data, 4096); -+ dst->data =3D data; -+} -+ -+static inline void move_extent_buffer(struct extent_buffer *dst, -+ struct extent_buffer *src) -+{ -+ memcpy(dst, src, sizeof(*dst)); -+} -+ -+static inline void init_btrfs_root (struct btrfs_root *root) -+{ -+ root->node.data =3D root->data; -+} -+ -+static inline void init_btrfs_path(lookup_pool_id lpid) -+{ -+ struct btrfs_path *path; -+ path =3D btrfs_grab_path(lpid); -+ path->lpid =3D lpid; -+} -+ -+static inline void init_btrfs_info(void) -+{ -+ int i; -+=09 -+ memset(BTRFS_FS_INFO, 0, sizeof(struct btrfs_fs_info)); -+ for(i =3D 0; i < LAST_LOOKUP_POOL; i++) -+ init_btrfs_path(i); -+ init_btrfs_root(BTRFS_TREE_ROOT); -+ init_btrfs_root(BTRFS_CHUNK_ROOT); -+ init_btrfs_root(BTRFS_FS_ROOT); -+} -+ -+static void setup_root(struct btrfs_root *root, -+ u32 nodesize, -+ u32 leafsize, -+ u32 sectorsize, -+ u32 stripesize, -+ u64 objectid) -+{ -+ root->nodesize =3D nodesize; -+ root->leafsize =3D leafsize; -+ root->sectorsize =3D sectorsize; -+ root->stripesize =3D stripesize; -+ root->objectid =3D objectid; -+} -+ -+/* -+ * Pick up the latest root of a -+ * tree with specified @objectid -+ */ -+static int btrfs_find_last_root(struct btrfs_root *tree_root, -+ u64 objectid, -+ struct btrfs_root_item *item, -+ lookup_pool_id lpid) -+{ -+ int ret; -+ int slot; -+ struct btrfs_key search_key; -+ struct btrfs_key found_key; -+ struct btrfs_path *path; -+ -+ search_key.objectid =3D objectid; -+ search_key.type =3D BTRFS_ROOT_ITEM_KEY; -+ search_key.offset =3D (u64)-1; -+ path =3D btrfs_grab_path(lpid); -+ -+ ret =3D aux_tree_lookup(tree_root, &search_key, path); -+ if (ret < 0) -+ return 1; -+ slot =3D path->slots[0]; -+ WARN_ON(slot =3D=3D 0); -+ slot -=3D 1; -+ btrfs_item_key_to_cpu(&path->nodes[0], &found_key, slot); -+ if (found_key.objectid !=3D objectid) -+ return 1; -+=09 -+ read_extent_buffer(&path->nodes[0], item, -+ btrfs_item_ptr_offset(&path->nodes[0], slot), -+ sizeof(*item)); -+ return 0; -+} -+ -+static int find_setup_root(struct btrfs_root *tree_root, -+ u32 nodesize, -+ u32 leafsize, -+ u32 sectorsize, -+ u32 stripesize, -+ u64 objectid, -+ struct btrfs_root *dest_root, -+ u64 bytenr, -+ u32 blocksize, -+ u64 generation, -+ lookup_pool_id lpid) -+{ -+ int ret; -+ struct extent_buffer eb; -+ -+ setup_root(dest_root, -+ nodesize, -+ leafsize, -+ sectorsize, -+ stripesize, -+ objectid); -+ if (tree_root) { -+ /* -+ * pick up the latest version -+ * of the root we want to set up -+ */ -+ ret =3D btrfs_find_last_root(tree_root, objectid, -+ &dest_root->root_item, -+ lpid); -+ if (ret) -+ return ret; -+ bytenr =3D btrfs_root_bytenr(&dest_root->root_item); -+ blocksize =3D btrfs_level_size(dest_root, -+ btrfs_root_level(&dest_root->root_item)); -+ generation =3D btrfs_root_generation(&dest_root->root_item); -+ } -+ ret =3D read_tree_block(dest_root, -+ &eb, -+ bytenr, -+ blocksize, -+ generation, -+ lpid); -+ if (!ret) -+ return 1; -+ copy_extent_buffer(&dest_root->node, &eb); -+ return 0; -+} -+ -+static inline int btrfs_strncmp(const char *cs, const char *ct, int count) -+{ -+ signed char __res =3D 0; -+ -+ while (count) { -+ if ((__res =3D *cs - *ct++) !=3D 0 || !*cs++) -+ break; -+ count--; -+ } -+ return __res; -+} -+ -+/* -+ * the same as devread, but accepts -+ * device number, start and length. -+ */ -+static int btrfs_devread(unsigned long drive, unsigned long part, -+ unsigned long dev_len, int sector, -+ int byte_offset, int byte_len, char *buf) -+{ -+ if (sector < 0 -+ || ((sector + ((byte_offset + byte_len - 1) >> SECTOR_BITS)) -+ >=3D dev_len)) { -+ errnum =3D ERR_OUTSIDE_PART; -+ return 0; -+ } -+ sector +=3D byte_offset >> SECTOR_BITS; -+ byte_offset &=3D SECTOR_SIZE - 1; -+#if !defined(STAGE1_5) -+ if (disk_read_hook && debug) -+ printf ("<%d, %d, %d>", sector, byte_offset, byte_len); -+#endif /* !STAGE1_5 */ -+ return rawread(drive, part + sector, byte_offset, -+ byte_len, buf); -+} -+ -+static int btrfs_check_super(void) -+{ -+ struct btrfs_super_block *sb =3D BTRFS_SUPER; -+ -+ if (sb->nodesize !=3D BTRFS_DEFAULT_NODE_SIZE) { -+ btrfs_msg("Btrfs node size (%d) !=3D %d unsupported\n", -+ sb->nodesize, BTRFS_DEFAULT_NODE_SIZE); -+ goto error; -+ } -+ if (sb->leafsize !=3D BTRFS_DEFAULT_LEAF_SIZE) { -+ btrfs_msg("Btrfs leaf size (%d) !=3D %d unsupported\n", -+ sb->leafsize, BTRFS_DEFAULT_LEAF_SIZE); -+ goto error; -+ } -+=09 -+ return 0; -+error: -+ return 1; -+} -+ -+/* lift the super block */ -+static int btrfs_uptodate_super_copy(struct btrfs_fs_info *fs) -+{ -+ errnum =3D ERR_NONE; -+ btrfs_devread(BTRFS_FS_INFO->sb_dev.drive, -+ BTRFS_FS_INFO->sb_dev.part, -+ BTRFS_FS_INFO->sb_dev.length, -+ btrfs_sb_offset(BTRFS_FS_INFO->sb_mirror) >> SECTOR_BITS, -+ 0, -+ sizeof(struct btrfs_super_block), -+ (char *)BTRFS_SUPER); -+ return btrfs_check_super(); -+} -+ =20 -+/* -+ * Looking for a btrfs super block by magic, @fsid and @devid -+ * (the last two ones are optional). Update latest transid (if -+ * any). Return 0, if such super block was found. Otherwise, -+ * return 1. -+ * -+ * NOTE: -+ * After calling this function the sb_copy of global btrfs_fs_info -+ * can contain garbage, so the caller is responsible for this to be -+ * uptodate (see the function btrfs_uptodate_super_copy()). -+ */ -+static int btrfs_find_super(struct btrfs_device *dev, char *fsid, u64 *de= vid) -+{ -+ int i, ret; -+ int found =3D 0; -+ -+ for (i =3D 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { -+ ret =3D btrfs_devread(dev->drive, -+ dev->part, -+ dev->length, -+ btrfs_sb_offset(i) >> SECTOR_BITS, -+ 0, -+ sizeof(struct btrfs_super_block), -+ (char *)BTRFS_SUPER); -+ if (!ret) { -+ if (errnum =3D=3D ERR_OUTSIDE_PART) { -+ errnum =3D ERR_NONE; -+ break; -+ } else { -+ errnum =3D ERR_NONE; -+ continue; -+ } -+ } -+ if (btrfs_super_bytenr(BTRFS_SUPER) !=3D btrfs_sb_offset(i) || -+ btrfs_strncmp((char *)(&BTRFS_SUPER->magic), -+ BTRFS_MAGIC, -+ sizeof(BTRFS_SUPER->magic))) -+ continue; -+ if (fsid && -+ btrfs_strncmp(fsid, -+ (char *)BTRFS_SUPER->fsid, -+ BTRFS_FSID_SIZE)) -+ return 1; -+ if (devid && -+ *devid !=3D btrfs_super_devid(BTRFS_SUPER)) -+ return 1; -+ found =3D 1; -+ dev->devid =3D btrfs_super_devid(BTRFS_SUPER); -+ -+ if (btrfs_super_generation(BTRFS_SUPER) > -+ BTRFS_FS_INFO->sb_transid) { -+ BTRFS_FS_INFO->sb_transid =3D -+ btrfs_super_generation(BTRFS_SUPER); -+ BTRFS_FS_INFO->sb_mirror =3D i; -+ BTRFS_FS_INFO->sb_dev.devid =3D -+ btrfs_super_devid(BTRFS_SUPER); -+ BTRFS_FS_INFO->sb_dev.drive =3D dev->drive; -+ BTRFS_FS_INFO->sb_dev.part =3D dev->part; -+ BTRFS_FS_INFO->sb_dev.length =3D dev->length; -+ } -+ } -+ return !found; -+} -+ -+/* -+ * "Discern" a btrfs device by fsid and -+ * optionaly by devid (if lookup is set). -+ * Populate persistent device cache (if -+ * there are free slots). -+ */ -+static int btrfs_discerner(struct btrfs_device **dev, int lookup) -+{ -+ if (btrfs_find_super(*dev, -+ (char *)BTRFS_FS_INFO->fsid, -+ (lookup ? &(*dev)->devid : 0))) -+ /* not found */ -+ return 0; -+ if (*dev < BTRFS_VOLATILE_DEV_CACHE) { -+ /* populate persistent device cache */ -+ memcpy(*dev + 1, *dev, sizeof(struct btrfs_device)); -+ (*dev)++; -+ } -+ return 1; -+} -+ -+/* -+ * Scan available grub devices and call discerner -+ * for them. Return a number of discerned devices -+ * The scanner was stolen from print_completions(). -+ * -+ * Preconditions: -+ * The global structure btrfs_fs_info contains -+ * the latest valid version of btrfs superblock -+ * (the field @sb_copy) -+ */ -+static u64 scan_grub_devices(struct btrfs_device *dev, -+ int (*discerner)(struct btrfs_device **, int), -+ int lookup) -+{ -+ int i, j; -+ u64 count =3D 0; -+ struct geometry geom; -+ -+ for (i =3D 0; i < 2; i++) -+ for (j =3D 0; j < 8; j++) { -+ unsigned long part =3D 0xFFFFFF; -+ int type, entry, gpt_count, gpt_size; -+ unsigned long offset, ext_offset, gpt_offset; -+ -+ dev->drive =3D (i * 0x80) + j; -+ if (get_diskinfo(dev->drive, &geom)) -+ continue; -+ while (1) { -+ int ret; -+ buf_drive =3D -1; -+ errnum =3D ERR_NONE; -+ ret =3D next_partition(dev->drive, 0xFFFFFF, -+ &part, &type, &dev->part, -+ &dev->length, &offset, -+ &entry, &ext_offset, -+ &gpt_offset, &gpt_count, -+ &gpt_size, -+ BTRFS_FS_INFO->mbr); -+ if (!ret) -+ break; -+ if (discerner(&dev, lookup)) { -+ count++; -+ if (lookup) -+ goto exit; -+ } -+ } -+ } -+#if 0 -+ errnum =3D ERR_NONE; -+ if (cdrom_drive !=3D GRUB_INVALID_DRIVE && -+ !get_diskinfo(cdrom_drive, &geom)) { -+ dev->drive =3D cdrom_drive; -+ dev->part =3D 0; -+ dev->length =3D geom.total_sectors; -+ if (discerner(&dev, lookup)) { -+ count++; -+ if (lookup) -+ goto exit; -+ } -+ } -+#ifdef SUPPORT_NETBOOT -+ errnum =3D ERR_NONE; -+ if (network_ready && -+ !get_diskinfo(NETWORK_DRIVE, &geom)) { -+ dev->drive =3D NETWORK_DRIVE; -+ dev->part =3D 0; -+ dev->length =3D geom.total_sectors; -+ if (discerner(&dev, lookup)) { -+ count++; -+ if (lookup) -+ goto exit; -+ } -+ } -+#endif /* SUPPORT_NETBOOT */ -+#endif /* 0 */ -+ exit: -+ return count; -+} -+ -+#if 0 -+static int btrfs_next_item(struct btrfs_root *root, -+ struct btrfs_path *path); -+ -+/* -+ * Scan the chunk tree for dev items -+ * and call a seeker for all of them. -+ * Preconditions: chunk root is installed -+ * to the global btrfs_fs_info. -+ */ -+static int scan_dev_tree(struct btrfs_device* (*seeker)(u64)) -+{ -+ int ret; -+ u64 num_devices =3D 0; -+ struct btrfs_key key; -+ struct btrfs_key found_key; -+ struct btrfs_path *path; -+ struct btrfs_root *root; -+ -+ root =3D BTRFS_CHUNK_ROOT; -+ path =3D btrfs_grab_path(FIRST_EXTERNAL_LOOKUP_POOL); -+ key.objectid =3D BTRFS_DEV_ITEMS_OBJECTID; -+ key.type =3D 0; -+ key.offset =3D 0; -+ -+ ret =3D aux_tree_lookup(root, &key, path); -+ if (ret =3D=3D -1) -+ goto corrupted; -+ while (1) { -+ struct btrfs_device *result; -+ struct btrfs_dev_item *dev_item; -+ -+ btrfs_item_key_to_cpu(&path->nodes[0], -+ &found_key, -+ path->slots[0]); -+ if (found_key.objectid !=3D BTRFS_DEV_ITEMS_OBJECTID) -+ break; -+ dev_item =3D btrfs_item_ptr(&path->nodes[0], -+ path->slots[0], -+ struct btrfs_dev_item); -+ result =3D seeker(btrfs_device_id(&path->nodes[0], dev_item)); -+ if (result =3D=3D NULL) { -+ btrfs_msg("Btrfs device %llu is not available\n", -+ btrfs_device_id(&path->nodes[0], dev_item)); -+ goto missed_dev; -+ } -+ num_devices++; -+ ret =3D btrfs_next_item(root, path); -+ if (ret) -+ break; -+ } -+ if (num_devices =3D=3D btrfs_super_num_devices(BTRFS_SUPER)) -+ return 0; -+ corrupted: -+ errnum =3D ERR_FSYS_CORRUPT; -+ return 1; -+ missed_dev: -+ errnum =3D ERR_FSYS_MOUNT; -+ return 1; -+} -+#endif /* 0 */ -+ -+/* -+ * Find a grub btrfs device by devid. -+ * Preconditions: global btrfs_fs_info -+ * contains a copy of btrfs super block. -+ * -+ * Return pointer to the cached device on success. -+ * Otherwise return NULL. -+ */ -+static struct btrfs_device *btrfs_lookup_device(u64 devid) -+{ -+ int i, result; -+ struct btrfs_device *cdev; -+ -+ for (i =3D 0; i < BTRFS_NUM_CACHED_DEVICES; i++) { -+ cdev =3D &BTRFS_DEVICES[i]; -+ if (cdev->devid =3D=3D devid) -+ goto found_in_cache; -+ if (cdev->devid =3D=3D 0) -+ goto not_found_in_cache; -+ } -+not_found_in_cache: -+ cdev =3D BTRFS_VOLATILE_DEV_CACHE; -+ cdev->devid =3D devid; -+ result =3D scan_grub_devices(cdev, -+ btrfs_discerner, -+ 1); -+ if (result =3D=3D 0) -+ /* -+ * At mount time we have figured out that -+ * number of available devices is not less -+ * then number of devices recorded in the -+ * super block. Hence we treat this case as -+ * file system corruption. -+ */ -+ goto corrupt; -+ result =3D btrfs_uptodate_super_copy(BTRFS_FS_INFO); -+ if (result) -+ goto corrupt; -+found_in_cache: -+ return cdev; -+corrupt: -+ errnum =3D ERR_FSYS_CORRUPT; -+ return NULL; -+} -+ -+static int btrfs_find_device(struct btrfs_device *dev) -+{ -+ struct btrfs_device *cdev; -+ -+ if (btrfs_super_num_devices(BTRFS_SUPER) =3D=3D 1) { -+ dev->drive =3D current_drive; -+ dev->part =3D part_start; -+ dev->length =3D part_length; -+ return 0; -+ } -+ cdev =3D btrfs_lookup_device(dev->devid); -+ if (cdev =3D=3D NULL) -+ return 1; -+ dev->drive =3D cdev->drive; -+ dev->part =3D cdev->part; -+ dev->length =3D cdev->length; -+ return 0; -+} -+ -+static inline void init_btrfs_volatile_dev_cache(void) -+{ -+ BTRFS_VOLATILE_DEV_CACHE->devid =3D 0; -+ BTRFS_VOLATILE_DEV_CACHE->drive =3D current_drive; -+ BTRFS_VOLATILE_DEV_CACHE->part =3D part_start; -+ BTRFS_VOLATILE_DEV_CACHE->length =3D part_length; -+} -+ -+/* -+ * check availability of btrfs devices -+ * and populate the persistent device cache -+ */ -+static int btrfs_check_devices(void) -+{ -+ u64 num_dev; -+ -+ if (btrfs_super_num_devices(BTRFS_SUPER) =3D=3D 1) -+ return 0; -+ num_dev =3D scan_grub_devices(BTRFS_DEVICES, -+ btrfs_discerner, 0); -+ if (btrfs_uptodate_super_copy(BTRFS_FS_INFO)) -+ return 1; -+ if (num_dev < btrfs_super_num_devices(BTRFS_SUPER)) { -+ btrfs_msg("Some (%llu) Btrfs devices is not available\n", -+ btrfs_super_num_devices(BTRFS_SUPER) - num_dev); -+ return 1; -+ } -+ return 0; -+} -+ -+int btrfs_mount(void) -+{ -+ int ret; -+ -+ check_btrfs_cache_size(); -+ init_btrfs_info(); -+ init_btrfs_volatile_dev_cache(); -+ -+ ret =3D btrfs_find_super(BTRFS_VOLATILE_DEV_CACHE, NULL, NULL); -+ if (ret) { -+ btrfs_msg("Drive %lu, partition %lu: no Btrfs metadata\n", -+ current_drive, part_start); -+ goto error; -+ } -+ ret =3D btrfs_uptodate_super_copy(BTRFS_FS_INFO); -+ if (ret) -+ goto error; -+ BTRFS_FS_INFO->sb_transid =3D -+ btrfs_super_generation(BTRFS_SUPER); -+ memcpy(BTRFS_FS_INFO->fsid, -+ BTRFS_SUPER->fsid, -+ BTRFS_FSID_SIZE); -+ ret =3D btrfs_check_devices(); -+ if (ret) -+ goto error; -+ /* setup chunk root */ -+ ret =3D find_setup_root(NULL, -+ btrfs_super_nodesize(BTRFS_SUPER), -+ btrfs_super_leafsize(BTRFS_SUPER), -+ btrfs_super_sectorsize(BTRFS_SUPER), -+ btrfs_super_stripesize(BTRFS_SUPER), -+ BTRFS_CHUNK_TREE_OBJECTID, -+ BTRFS_CHUNK_ROOT, -+ btrfs_super_chunk_root(BTRFS_SUPER), -+ btrfs_chunk_root_level_size(BTRFS_SUPER), -+ btrfs_super_chunk_root_generation(BTRFS_SUPER), -+ FIRST_EXTERNAL_LOOKUP_POOL); -+ if (ret) -+ return 0; -+ /* setup tree root */ -+ ret =3D find_setup_root(NULL, -+ btrfs_super_nodesize(BTRFS_SUPER), -+ btrfs_super_leafsize(BTRFS_SUPER), -+ btrfs_super_sectorsize(BTRFS_SUPER), -+ btrfs_super_stripesize(BTRFS_SUPER), -+ BTRFS_ROOT_TREE_OBJECTID, -+ BTRFS_TREE_ROOT, -+ btrfs_super_root(BTRFS_SUPER), -+ btrfs_root_level_size(BTRFS_SUPER), -+ btrfs_super_generation(BTRFS_SUPER), -+ FIRST_EXTERNAL_LOOKUP_POOL); -+ if (ret) -+ return 0; -+ /* setup fs_root */ -+ ret =3D find_setup_root(BTRFS_TREE_ROOT, -+ btrfs_super_nodesize(BTRFS_SUPER), -+ btrfs_super_leafsize(BTRFS_SUPER), -+ btrfs_super_sectorsize(BTRFS_SUPER), -+ btrfs_super_stripesize(BTRFS_SUPER), -+ BTRFS_FS_TREE_OBJECTID, -+ BTRFS_FS_ROOT, -+ 0, -+ 0, -+ 0, -+ FIRST_EXTERNAL_LOOKUP_POOL); -+ return !ret; -+ -+error: -+ errnum =3D ERR_FSYS_MOUNT; -+ return 0; -+} -+ -+/* -+ * Check, whether @chunk is the map for a -+ * block with @logical block number. -+ * If yes, then fill the @map. -+ * Return 1 on affirmative result, -+ * otherwise return 0. -+ */ -+int check_read_chunk(struct btrfs_key *key, -+ struct extent_buffer *leaf, -+ struct btrfs_chunk *chunk, -+ struct map_lookup *map, -+ u64 logical) -+{ -+ int i, ret; -+ u64 chunk_start; -+ u64 chunk_size; -+ int num_stripes; -+ -+ chunk_start =3D key->offset; -+ chunk_size =3D btrfs_chunk_length(leaf, chunk); -+ -+ if (logical + 1 > chunk_start + chunk_size || -+ logical < chunk_start) -+ /* not a fit */ -+ return 0; -+ num_stripes =3D btrfs_chunk_num_stripes(leaf, chunk); -+ map->ce.start =3D chunk_start; -+ map->ce.size =3D chunk_size; -+ map->num_stripes =3D num_stripes; -+ map->io_width =3D btrfs_chunk_io_width(leaf, chunk); -+ map->io_align =3D btrfs_chunk_io_align(leaf, chunk); -+ map->sector_size =3D btrfs_chunk_sector_size(leaf, chunk); -+ map->stripe_len =3D btrfs_chunk_stripe_len(leaf, chunk); -+ map->type =3D btrfs_chunk_type(leaf, chunk); -+ map->sub_stripes =3D btrfs_chunk_sub_stripes(leaf, chunk); -+ -+ for (i =3D 0; i < num_stripes; i++) { -+ map->stripes[i].physical =3D -+ btrfs_stripe_offset_nr(leaf, chunk, i); -+ map->stripes[i].dev.devid =3D -+ btrfs_stripe_devid_nr(leaf, chunk, i); -+ ret =3D btrfs_find_device(&map->stripes[i].dev); -+ if (ret) -+ return 0; -+ } -+ return 1; -+} -+ -+static void init_extent_buffer(struct extent_buffer *eb, -+ struct btrfs_device *dev, -+ u64 logical, -+ u32 blocksize, -+ u64 physical, -+ lookup_pool_id lpid) -+{ -+ if (dev) -+ memcpy(&eb->dev, dev, sizeof(*dev)); -+ eb->start =3D logical; -+ eb->len =3D blocksize; -+ eb->dev_bytenr =3D physical; -+ eb->data =3D grab_lookup_cache(lpid); -+} -+ -+/* -+ * Search for a map by logical offset in sys array. -+ * Return -1 on errors; -+ * Return 1 if the map is found, -+ * Return 0 if the map is not found. -+ */ -+int sys_array_lookup(struct map_lookup *map, u64 logical) -+{ -+ struct extent_buffer sb; -+ struct btrfs_disk_key *disk_key; -+ struct btrfs_chunk *chunk; -+ struct btrfs_key key; -+ u32 num_stripes; -+ u32 array_size; -+ u32 len =3D 0; -+ u8 *ptr; -+ unsigned long sb_ptr; -+ u32 cur; -+ int ret; -+ int i =3D 0; -+ -+ sb.data =3D (char *)BTRFS_SUPER; -+ array_size =3D btrfs_super_sys_array_size(BTRFS_SUPER); -+ -+ ptr =3D BTRFS_SUPER->sys_chunk_array; -+ sb_ptr =3D offsetof(struct btrfs_super_block, sys_chunk_array); -+ cur =3D 0; -+ -+ while (cur < array_size) { -+ disk_key =3D (struct btrfs_disk_key *)ptr; -+ btrfs_disk_key_to_cpu(&key, disk_key); -+ -+ len =3D sizeof(*disk_key); -+ ptr +=3D len; -+ sb_ptr +=3D len; -+ cur +=3D len; -+ -+ if (key.type =3D=3D BTRFS_CHUNK_ITEM_KEY) { -+ chunk =3D (struct btrfs_chunk *)sb_ptr; -+ ret =3D check_read_chunk(&key, &sb, -+ chunk, map, logical); -+ if (ret) -+ /* map is found */ -+ return ret; -+ num_stripes =3D btrfs_chunk_num_stripes(&sb, chunk); -+ len =3D btrfs_chunk_item_size(num_stripes); -+ } else { -+ errnum =3D ERR_FSYS_CORRUPT; -+ return -1; -+ } -+ ptr +=3D len; -+ sb_ptr +=3D len; -+ cur +=3D len; -+ i++; -+ } -+ return 0; -+} -+ -+/* -+ * Search for a map by logical offset in the chunk tree. -+ * Return 1 if map is found, otherwise return 0. -+ */ -+static int chunk_tree_lookup(struct map_lookup *map, -+ u64 logical) -+{ -+ int ret; -+ int slot; -+ struct extent_buffer *leaf; -+ struct btrfs_key key; -+ struct btrfs_key found_key; -+ struct btrfs_chunk *chunk; -+ struct btrfs_path *path; -+ -+ path =3D btrfs_grab_path(INTERNAL_LOOKUP_POOL); -+ -+ key.objectid =3D BTRFS_FIRST_CHUNK_TREE_OBJECTID; -+ key.offset =3D logical; -+ key.type =3D BTRFS_CHUNK_ITEM_KEY; -+ -+ ret =3D aux_tree_lookup(BTRFS_CHUNK_ROOT, &key, path); -+ if (ret < 0) -+ return 0; -+ leaf =3D &path->nodes[0]; -+ slot =3D path->slots[0]; -+ if (ret =3D=3D 1) { -+ WARN_ON(slot =3D=3D 0); -+ slot -=3D 1; -+ } -+ btrfs_item_key_to_cpu(leaf, &found_key, slot); -+ if (found_key.type !=3D BTRFS_CHUNK_ITEM_KEY) -+ return 0; -+ chunk =3D btrfs_item_ptr(leaf, slot, struct btrfs_chunk); -+ return check_read_chunk(&found_key, leaf, -+ chunk, map, logical); -+} -+ -+/* -+ * Btrfs logical/physical block mapper. -+ * Look for an appropriate map-extent and -+ * perform a translation. Return 1 on errors. -+ */ -+static int btrfs_map_block(u64 logical, u64 *length, -+ struct btrfs_multi_bio *multi, -+ int mirror_num) -+{ -+ struct map_lookup map; -+ u64 offset; -+ u64 stripe_offset; -+ u64 stripe_nr; -+ struct cache_extent *ce; -+ int stripe_index; -+ int i; -+ int ret; -+ -+ memset(&map, 0, sizeof(map)); -+ ret =3D sys_array_lookup(&map, logical); -+ if (ret =3D=3D -1) { -+ errnum =3D ERR_FSYS_CORRUPT; -+ return 1; -+ } -+ if (ret =3D=3D 0) { -+ ret =3D chunk_tree_lookup(&map, logical); -+ if (!ret) { -+ /* something should be found! */ -+ errnum =3D ERR_FSYS_CORRUPT; -+ return 1; -+ } -+ } -+ /* do translation */ -+ ce =3D &map.ce; -+ -+ offset =3D logical - ce->start; -+ stripe_nr =3D offset / map.stripe_len; -+ stripe_offset =3D stripe_nr * map.stripe_len; -+ WARN_ON(offset < stripe_offset); -+ -+ stripe_offset =3D offset - stripe_offset; -+ -+ if (map.type & (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | -+ BTRFS_BLOCK_GROUP_RAID10 | -+ BTRFS_BLOCK_GROUP_DUP)) { -+ *length =3D min_t(u64, ce->size - offset, -+ map.stripe_len - stripe_offset); -+ } else { -+ *length =3D ce->size - offset; -+ } -+ multi->num_stripes =3D 1; -+ stripe_index =3D 0; -+ if (map.type & BTRFS_BLOCK_GROUP_RAID1) { -+ if (mirror_num) -+ stripe_index =3D mirror_num - 1; -+ else -+ stripe_index =3D stripe_nr % map.num_stripes; -+ } else if (map.type & BTRFS_BLOCK_GROUP_RAID10) { -+ int factor =3D map.num_stripes / map.sub_stripes; -+ -+ stripe_index =3D stripe_nr % factor; -+ stripe_index *=3D map.sub_stripes; -+ -+ if (mirror_num) -+ stripe_index +=3D mirror_num - 1; -+ else -+ stripe_index =3D stripe_nr % map.sub_stripes; -+ -+ stripe_nr =3D stripe_nr / factor; -+ } else if (map.type & BTRFS_BLOCK_GROUP_DUP) { -+ if (mirror_num) -+ stripe_index =3D mirror_num - 1; -+ } else { -+ stripe_index =3D stripe_nr % map.num_stripes; -+ stripe_nr =3D stripe_nr / map.num_stripes; -+ } -+ WARN_ON(stripe_index >=3D map.num_stripes); -+ -+ for (i =3D 0; i < multi->num_stripes; i++) { -+ asm("" : "+r"(multi)); -+ multi->stripes[i].physical =3D -+ map.stripes[stripe_index].physical + stripe_offset + -+ stripe_nr * map.stripe_len; -+ memcpy(&multi->stripes[i].dev, -+ &map.stripes[stripe_index].dev, -+ sizeof(struct btrfs_device)); -+ stripe_index++; -+ } -+ return 0; -+} -+ -+static u64 read_data_extent(u64 logical_start, u64 to_read, char *pos) -+{ -+ int ret; -+ u64 length; -+ struct btrfs_multi_bio multi; -+ -+ while (to_read) { -+ ret =3D btrfs_map_block(logical_start, &length, &multi, 0); -+ if (ret) { -+ errnum =3D ERR_FSYS_CORRUPT; -+ return ret; -+ } -+ if (length > to_read) -+ length =3D to_read; -+ disk_read_func =3D disk_read_hook; -+ ret =3D btrfs_devread(multi.stripes[0].dev.drive, -+ multi.stripes[0].dev.part, -+ multi.stripes[0].dev.length, -+ multi.stripes[0].physical >> SECTOR_BITS, -+ logical_start & ((u64)SECTOR_SIZE - 1), -+ length, -+ pos); -+ disk_read_func =3D NULL; -+ if (!ret) -+ return 1; -+ btrfs_msg("BTRFS data extent: read %llu bytes\n", length); -+ to_read -=3D length; -+ pos +=3D length; -+ logical_start +=3D length; -+ } -+ return 0; -+} -+ -+static int read_extent_from_disk(struct extent_buffer *eb) -+{ -+ WARN_ON(eb->dev_bytenr % SECTOR_BITS); -+ return btrfs_devread(eb->dev.drive, -+ eb->dev.part, -+ eb->dev.length, -+ eb->dev_bytenr >> SECTOR_BITS, -+ 0, -+ eb->len, -+ eb->data); -+} -+ -+static int verify_parent_transid(struct extent_buffer *eb, u64 parent_tra= nsid) -+{ -+ return parent_transid && (btrfs_header_generation(eb) !=3D parent_transi= d); -+} -+ -+static int btrfs_num_copies(u64 logical, u64 len) -+{ -+ return 1; -+} -+ -+static int check_tree_block(struct btrfs_root *root, struct extent_buffer= *buf) -+{ -+ return 0; -+} -+ -+static int csum_tree_block(struct btrfs_root *root, struct extent_buffer = *buf, -+ int verify) -+{ -+ return 0; -+} -+ -+/* -+ * Read a block of logical number @bytenr -+ * from disk to buffer @eb. -+ * Return 1 on success. -+ */ -+int read_tree_block(struct btrfs_root *root, -+ struct extent_buffer *eb, -+ u64 bytenr, /* logical */ -+ u32 blocksize, -+ u64 parent_transid, -+ lookup_pool_id lpid) -+{ -+ int ret; -+ int dev_nr; -+ u64 length; -+ struct btrfs_multi_bio multi; -+ int mirror_num =3D 0; -+ int num_copies; -+ -+ dev_nr =3D 0; -+ length =3D blocksize; -+ while (1) { -+ ret =3D btrfs_map_block(bytenr, -+ &length, &multi, mirror_num); -+ if (ret) { -+ errnum =3D ERR_FSYS_CORRUPT; -+ return 0; -+ } -+ init_extent_buffer(eb, -+ &multi.stripes[0].dev, -+ bytenr, -+ blocksize, -+ multi.stripes[0].physical, -+ lpid); -+ -+ ret =3D read_extent_from_disk(eb); -+ if (ret && -+ check_tree_block(root, eb) =3D=3D 0 && -+ csum_tree_block(root, eb, 1) =3D=3D 0 && -+ verify_parent_transid(eb, parent_transid) =3D=3D 0) -+ return 1; -+ -+ num_copies =3D btrfs_num_copies(eb->start, eb->len); -+ if (num_copies =3D=3D 1) -+ break; -+ mirror_num++; -+ if (mirror_num > num_copies) -+ break; -+ } -+ return 0; -+} -+ -+/* -+ * Read a child pointed by @slot node pointer -+ * of @parent. Put the result to @parent. -+ * Return 1 on success. -+ */ -+static int parent2child(struct btrfs_root *root, -+ struct extent_buffer *parent, -+ int slot, -+ lookup_pool_id lpid) -+{ -+ int level; -+ -+ WARN_ON(slot < 0); -+ WARN_ON(slot >=3D btrfs_header_nritems(parent)); -+ -+ level =3D btrfs_header_level(parent); -+ WARN_ON(level <=3D 0); -+ -+ return read_tree_block(root, -+ parent, -+ btrfs_node_blockptr(parent, slot), -+ btrfs_level_size(root, level - 1), -+ btrfs_node_ptr_generation(parent, slot), -+ lpid); -+} -+ -+static int btrfs_comp_keys(struct btrfs_disk_key *disk, struct btrfs_key = *k2) -+{ -+ struct btrfs_key k1; -+ -+ btrfs_disk_key_to_cpu(&k1, disk); -+ -+ if (k1.objectid > k2->objectid) -+ return 1; -+ if (k1.objectid < k2->objectid) -+ return -1; -+ if (k1.type > k2->type) -+ return 1; -+ if (k1.type < k2->type) -+ return -1; -+ if (k1.offset > k2->offset) -+ return 1; -+ if (k1.offset < k2->offset) -+ return -1; -+ return 0; -+} -+ -+static int bin_search(struct extent_buffer *eb, unsigned long p, -+ int item_size, struct btrfs_key *key, -+ int max, int *slot) -+{ -+ int low =3D 0; -+ int high =3D max; -+ int mid; -+ int ret; -+ unsigned long offset; -+ struct btrfs_disk_key *tmp; -+ -+ while(low < high) { -+ mid =3D (low + high) / 2; -+ offset =3D p + mid * item_size; -+ -+ tmp =3D (struct btrfs_disk_key *)(eb->data + offset); -+ ret =3D btrfs_comp_keys(tmp, key); -+ -+ if (ret < 0) -+ low =3D mid + 1; -+ else if (ret > 0) -+ high =3D mid; -+ else { -+ *slot =3D mid; -+ return 0; -+ } -+ } -+ *slot =3D low; -+ return 1; -+} -+ -+/* look for a key in a node */ -+static int node_lookup(struct extent_buffer *eb, -+ struct btrfs_key *key, -+ int *slot) -+{ -+ if (btrfs_header_level(eb) =3D=3D 0) { -+ return bin_search(eb, -+ offsetof(struct btrfs_leaf, items), -+ sizeof(struct btrfs_item), -+ key, btrfs_header_nritems(eb), -+ slot); -+ } else { -+ return bin_search(eb, -+ offsetof(struct btrfs_node, ptrs), -+ sizeof(struct btrfs_key_ptr), -+ key, btrfs_header_nritems(eb), -+ slot); -+ } -+ return -1; -+} -+ -+static inline int check_node(struct extent_buffer *buf, int slot) -+{ -+ return 0; -+} -+ -+/* -+ * Look for an item by key in read-only tree. -+ * Return 0, if key was found. Return -1 on io errors. -+ * -+ * Preconditions: btrfs_mount already executed. -+ * Postconditions: if returned value is non-negative, -+ * then path[0] represents the found position in the -+ * tree. All components of the @path from leaf to root -+ * are valid except their data buffers (only path[0] -+ * has valid attached data buffer). -+ */ -+ -+int aux_tree_lookup(struct btrfs_root *root, -+ struct btrfs_key *key, -+ struct btrfs_path *path) -+{ -+ int ret; -+ int slot =3D 0; -+ int level; -+ struct extent_buffer node; -+ init_extent_buffer(&node, -+ NULL, -+ 0, -+ 0, -+ 0, -+ path->lpid); -+ copy_extent_buffer(&node, &root->node); -+ do { -+ level =3D btrfs_header_level(&node); -+ ret =3D check_node(&node, slot); -+ if (ret) -+ return -1; -+ move_extent_buffer(&path->nodes[level], -+ &node); -+ ret =3D node_lookup(&node, key, &slot); -+ if (ret < 0) -+ return ret; -+ if (level) { -+ /* -+ * non-leaf, -+ * jump to the next level -+ */ -+ if (ret && slot > 0) -+ slot -=3D 1; -+ ret =3D parent2child(root, &node, slot, path->lpid); -+ if (ret =3D=3D 0) -+ return -1; -+ } -+ path->slots[level] =3D slot; -+ } while (level); -+ return ret; -+} -+ -+static int readup_buffer(struct extent_buffer *buf, lookup_pool_id lpid) -+{ -+ buf->data =3D grab_lookup_cache(lpid); -+ return read_extent_from_disk(buf); -+} -+ -+/* -+ * Find the next leaf in accordance with tree order; -+ * walk up the tree as far as required to find it. -+ * Returns 0 if something was found, or 1 if there -+ * are no greater leaves. Returns < 0 on io errors. -+ * -+ * Preconditions: all @path components from leaf to -+ * root have valid meta-data fields. path[0] has a -+ * valid attached data buffer with initial leaf. -+ * Postcondition: the same as above, but path[0] has -+ * an attached data buffer with the next leaf. -+ */ -+static int btrfs_next_leaf(struct btrfs_root *root, -+ struct btrfs_path *path) -+{ -+ int res; -+ int slot; -+ int level =3D 1; -+ struct extent_buffer *buf; -+ -+ while(level < BTRFS_MAX_LEVEL) { -+ buf =3D &path->nodes[level]; -+ slot =3D path->slots[level] + 1; -+ /* -+ * lift data on this level -+ */ -+ res =3D readup_buffer(buf, path->lpid); -+ if (!res) -+ break; -+ if (slot >=3D btrfs_header_nritems(buf)) { -+ /* alas, go to parent (if any) */ -+ level++; -+ res =3D 1; -+ continue; -+ } -+ break; -+ } -+ if (!res) -+ return 1; -+ /* -+ * At this level slot points to -+ * the subtree we are interested in. -+ */ -+ path->slots[level] =3D slot; -+ while(level) { -+ struct extent_buffer tmp; -+ move_extent_buffer(&tmp, &path->nodes[level]); -+ res =3D parent2child(root, &tmp, slot, path->lpid); -+ if (res =3D=3D 0) -+ return -1; -+ level --; -+ slot =3D 0; -+ move_extent_buffer(&path->nodes[level], &tmp); -+ path->slots[level] =3D slot; -+ } -+ return 0; -+} -+ -+/* Preconditions: path is valid, data buffer -+ * is attached to leaf node. -+ * Postcondition: path is updated to point to -+ * the next position with respect to the tree -+ * order. -+ * -+ * Return -1 on io errors. -+ * Return 0, if next item was found. -+ * Return 1, if next item wasn't found (no more items). -+ */ -+static int btrfs_next_item(struct btrfs_root *root, -+ struct btrfs_path *path) -+{ -+ WARN_ON(path->slots[0] >=3D btrfs_header_nritems(&path->nodes[0])); -+ -+ path->slots[0] +=3D 1; -+ -+ if (path->slots[0] < btrfs_header_nritems(&path->nodes[0])) -+ return 0; -+ if (coord_is_root(root, path)) -+ /* no more items */ -+ return 1; -+ return btrfs_next_leaf(root, path); -+} -+ -+/* -+ * check if we can reuse results of previous -+ * search for read operation -+ */ -+static int path_is_valid(struct btrfs_path *path, -+ struct btrfs_key *key, u64 offset) -+{ -+ btrfs_item_key_to_cpu(&path->nodes[0], -+ key, -+ path->slots[0]); -+ if (BTRFS_FILE_INFO_KEY->objectid !=3D key->objectid) -+ return 0; -+ if (btrfs_key_type(key) =3D=3D BTRFS_INODE_ITEM_KEY) -+ return 1; -+ if (btrfs_key_type(key) !=3D BTRFS_EXTENT_DATA_KEY) -+ return 0; -+ return BTRFS_FILE_INFO_KEY->offset <=3D offset; -+} -+ -+/* ->read_func() */ -+int btrfs_read(char *buf, int len) -+{ -+ int ret; -+ struct btrfs_root *fs_root; -+ struct btrfs_path *path; -+ struct btrfs_key path_key; -+ u64 ioff; -+ u64 bytes; -+ int to_read; -+ char *pos =3D buf; -+ -+ fs_root =3D BTRFS_FS_ROOT; -+ path =3D btrfs_grab_path(FIRST_EXTERNAL_LOOKUP_POOL); -+ -+ if (!path_is_valid(path, &path_key, filepos)) { -+ ret =3D aux_tree_lookup(fs_root, BTRFS_FILE_INFO_KEY, path); -+ if (ret < 0) -+ errnum =3D ERR_FSYS_CORRUPT; -+ } -+ while (!errnum) { -+ struct btrfs_item *item; -+ struct btrfs_file_extent_item *fi; -+ u64 from; -+ -+ btrfs_item_key_to_cpu(&path->nodes[0], -+ &path_key, -+ path->slots[0]); -+ if (BTRFS_FILE_INFO_KEY->objectid !=3D path_key.objectid) -+ break; -+ if (btrfs_key_type(&path_key) !=3D BTRFS_EXTENT_DATA_KEY) -+ goto next; -+ /* -+ * current position is extent item -+ */ -+ item =3D btrfs_item_nr(&path->nodes[0], path->slots[0]); -+ fi =3D btrfs_item_ptr(&path->nodes[0], -+ path->slots[0], -+ struct btrfs_file_extent_item); -+ if (btrfs_file_extent_compression(&path->nodes[0], fi)) { -+ btrfs_msg("Btrfs transparent compression unsupported\n"); -+ errnum =3D ERR_BAD_FILETYPE; -+ goto exit; -+ } -+ ioff =3D filepos - path_key.offset; -+ -+ switch (btrfs_file_extent_type(&path->nodes[0], fi)) { -+ case BTRFS_FILE_EXTENT_INLINE: -+ bytes =3D btrfs_file_extent_inline_item_len(&path-> -+ nodes[0], -+ item); -+ if (path_key.offset + bytes < filepos) -+ goto next; -+ to_read =3D bytes - ioff; -+ if (to_read > len) -+ to_read =3D len; -+ from =3D ioff + btrfs_file_extent_inline_start(fi); -+ if (disk_read_hook !=3D NULL) { -+ disk_read_func =3D disk_read_hook; -+ ret =3D btrfs_devread(path->nodes[0].dev.drive, -+ path->nodes[0].dev.part, -+ path->nodes[0].dev.length, -+ path->nodes[0].dev_bytenr >> -+ SECTOR_BITS, -+ from, -+ to_read, -+ pos); -+ disk_read_func =3D NULL; -+ if (ret) -+ goto exit; -+ } else -+ memcpy(pos, -+ path->nodes[0].data + from, -+ to_read); -+ btrfs_msg("BTRFS inline extent: read %d bytes pos %d\n", -+ to_read, filepos); -+ break; -+ case BTRFS_FILE_EXTENT_REG: -+ bytes =3D btrfs_file_extent_num_bytes(&path->nodes[0], -+ fi); -+ if (path_key.offset + bytes < filepos) -+ goto next; -+ to_read =3D bytes - ioff; -+ if (to_read > len) -+ to_read =3D len; -+ from =3D ioff + -+ btrfs_file_extent_disk_bytenr(&path->nodes[0], -+ fi) + -+ btrfs_file_extent_offset(&path->nodes[0], -+ fi); -+ ret =3D read_data_extent(from, to_read, pos); -+ if (ret) -+ goto exit; -+ break; -+ case BTRFS_FILE_EXTENT_PREALLOC: -+ btrfs_msg("Btrfs preallocated extents unsupported\n"); -+ errnum =3D ERR_BAD_FILETYPE; -+ goto exit; -+ default: -+ errnum =3D ERR_FSYS_CORRUPT; -+ goto exit; -+ } -+ len -=3D to_read; -+ pos +=3D to_read; -+ filepos +=3D to_read; -+ if (len =3D=3D 0) -+ break; -+ /* not everything was read */ -+ next: -+ ret =3D btrfs_next_item(fs_root, path); -+ if (ret < 0) { -+ errnum =3D ERR_FSYS_CORRUPT; -+ break; -+ } -+ btrfs_update_file_info(path); -+ continue; -+ } -+exit: -+ return errnum ? 0 : pos - buf; -+} -+ -+static int btrfs_follow_link(struct btrfs_root *root, -+ struct btrfs_path *path, -+ char **dirname, char *linkbuf, -+ int *link_count, -+ struct btrfs_inode_item *sd) -+{ -+ int ret; -+ int len; -+ char *name =3D *dirname; -+ -+ if (++(*link_count) > MAX_LINK_COUNT) { -+ errnum =3D ERR_SYMLINK_LOOP; -+ return 0; -+ } -+ /* calculate remaining name size */ -+ filemax =3D btrfs_inode_size(&path->nodes[0], sd); -+ for (len =3D 0; -+ name[len] && isspace(name[len]); -+ len ++); -+ -+ if (filemax + len > PATH_MAX - 1) { -+ errnum =3D ERR_FILELENGTH; -+ return 0; -+ } -+ grub_memmove(linkbuf + filemax, name, len + 1); -+ btrfs_update_file_info(path); -+ filepos =3D 0; -+ /* extract symlink content */ -+ while (1) { -+ u64 oid =3D BTRFS_FILE_INFO_KEY->objectid; -+ ret =3D btrfs_next_item(root, path); -+ if (ret) -+ break; -+ btrfs_update_file_info(path); -+ if (oid !=3D BTRFS_FILE_INFO_KEY->objectid) -+ break; -+ if (btrfs_key_type(BTRFS_FILE_INFO_KEY) =3D=3D -+ BTRFS_EXTENT_DATA_KEY) -+ goto found; -+ } -+ /* no target was found */ -+ errnum =3D ERR_FSYS_CORRUPT; -+ return 0; -+found: -+ /* fill the rest of linkbuf with the content */ -+ ret =3D btrfs_read(linkbuf, filemax); -+ if (ret !=3D filemax) { -+ errnum =3D ERR_FSYS_CORRUPT; -+ return 0; -+ } -+ return 1; -+} -+ -+static int update_fs_root(struct btrfs_root *fs_root, -+ struct btrfs_key *location) -+{ -+ int ret; -+ struct btrfs_root *tree_root; -+ -+ if (location->offset !=3D (u64)-1) -+ return 0; -+ tree_root =3D &BTRFS_FS_INFO->tree_root; -+ ret =3D find_setup_root(tree_root, -+ tree_root->nodesize, -+ tree_root->leafsize, -+ tree_root->sectorsize, -+ tree_root->stripesize, -+ location->objectid, -+ fs_root, -+ 0, -+ 0, -+ 0, -+ SECOND_EXTERNAL_LOOKUP_POOL); -+ if (ret) -+ return ret; -+ location->objectid =3D btrfs_root_dirid(&fs_root->root_item); -+ btrfs_set_key_type(location, BTRFS_INODE_ITEM_KEY); -+ location->offset =3D 0; -+ return 0; -+} -+ -+#ifndef STAGE1_5 -+static inline void update_possibilities(void) -+{ -+ if (print_possibilities > 0) -+ print_possibilities =3D -+ -print_possibilities; -+} -+#endif -+ -+/* -+ * Look for a directory item by name. -+ * Print possibilities, if needed. -+ * Postconditions: on success @sd_key points -+ * to the key contained in the directory entry. -+ */ -+static int btrfs_de_index_by_name(struct btrfs_root *root, -+ struct btrfs_path *path, -+ char **dirname, -+ struct btrfs_key *sd_key) -+{ -+ char ch; -+ int ret; -+ char *rest; -+ struct btrfs_dir_item *di; -+#ifndef STAGE1_5 -+ int do_possibilities =3D 0; -+#endif -+ for (; **dirname =3D=3D '/'; (*dirname)++); -+ for (rest =3D *dirname; -+ (ch =3D *rest) && !isspace(ch) && ch !=3D '/'; -+ rest++); -+ *rest =3D 0; /* for substrung() */ -+#ifndef STAGE1_5 -+ if (print_possibilities && ch !=3D '/') -+ do_possibilities =3D 1; -+#endif -+ /* scan a directory */ -+ while (1) { -+ u32 total; -+ u32 cur =3D 0; -+ u32 len; -+ struct btrfs_key di_key; -+ struct btrfs_disk_key location; -+ struct btrfs_item *item; -+ -+ /* extract next dir entry */ -+ ret =3D btrfs_next_item(root, path); -+ if (ret) -+ break; -+ item =3D btrfs_item_nr(&path->nodes[0], -+ path->slots[0]); -+ btrfs_item_key_to_cpu(&path->nodes[0], -+ &di_key, -+ path->slots[0]); -+ if (di_key.objectid !=3D sd_key->objectid) -+ /* no more entries */ -+ break; -+ di =3D btrfs_item_ptr(&path->nodes[0], -+ path->slots[0], -+ struct btrfs_dir_item); -+ /* -+ * working around special cases: -+ * btrfs doesn't maintain directory entries -+ * which contain names "." and ".." -+ */ -+ if (!substring(".", *dirname)) { -+#ifndef STAGE1_5 -+ if (do_possibilities) { -+ update_possibilities(); -+ return 1; -+ } -+#endif -+ goto found; -+ } -+ if (!substring("..", *dirname)) { -+ if (di_key.type !=3D BTRFS_INODE_REF_KEY) -+ continue; -+ sd_key->objectid =3D di_key.offset; -+ btrfs_set_key_type(sd_key, BTRFS_INODE_ITEM_KEY); -+ sd_key->offset =3D 0; -+#ifndef STAGE1_5 -+ if (do_possibilities) { -+ update_possibilities(); -+ return 1; -+ } -+#endif -+ goto found; -+ } -+ if (di_key.type !=3D BTRFS_DIR_ITEM_KEY) -+ continue; -+ total =3D btrfs_item_size(&path->nodes[0], item); -+ /* scan a directory item */ -+ while (cur < total) { -+ char tmp; -+ int result; -+ char *filename; -+ char *end_of_name; -+ int name_len; -+ int data_len; -+ -+ btrfs_dir_item_key(&path->nodes[0], di, &location); -+ -+ name_len =3D btrfs_dir_name_len(&path->nodes[0], di); -+ data_len =3D btrfs_dir_data_len(&path->nodes[0], di); -+ -+ WARN_ON(name_len > BTRFS_NAME_LEN); -+ -+ filename =3D (char *)(path->nodes[0].data + -+ (unsigned long)(di + 1)); -+ end_of_name =3D filename + name_len; -+ /* -+ * working around not null-terminated -+ * directory names in btrfs: just -+ * a short-term overwrite of the -+ * cache with the following rollback -+ * of the change. -+ */ -+ tmp =3D *end_of_name; -+ *end_of_name =3D 0; -+ result =3D substring(*dirname, filename); -+ *end_of_name =3D tmp; -+#ifndef STAGE1_5 -+ if (do_possibilities) { -+ if (result <=3D 0) { -+ update_possibilities(); -+ *end_of_name =3D 0; -+ print_a_completion(filename); -+ *end_of_name =3D tmp; -+ } -+ } -+ else -+#endif -+ if (result =3D=3D 0) { -+ btrfs_dir_item_key_to_cpu(&path->nodes[0], -+ di, sd_key); -+ goto found; -+ } -+ len =3D sizeof(*di) + name_len + data_len; -+ di =3D (struct btrfs_dir_item *)((char *)di + len); -+ cur +=3D len; -+ } -+ } -+#ifndef STAGE1_5 -+ if (print_possibilities < 0) -+ return 1; -+#endif -+ errnum =3D ERR_FILE_NOT_FOUND; -+ *rest =3D ch; -+ return 0; -+ found: -+ *rest =3D ch; -+ *dirname =3D rest; -+ return 1; -+} -+ -+/* -+ * ->dir_func(). -+ * Postcondition: on a non-zero return BTRFS_FS_INFO -+ * contains the latest fs_root of file's subvolume. -+ * BTRFS_FS_INFO points to a subvolume of a file we -+ * were trying to look up. -+ * BTRFS_FILE_INFO contains info of the file we were -+ * trying to look up. -+ */ -+ -+int btrfs_dir(char *dirname) -+{ -+ int ret; -+ int mode; -+ u64 size; -+ int linkcount =3D 0; -+ char linkbuf[PATH_MAX]; -+ -+ struct btrfs_path *path; -+ struct btrfs_root *root; -+ -+ struct btrfs_key sd_key; -+ struct btrfs_inode_item *sd; -+ struct btrfs_key parent_sd_key; -+ -+ root =3D BTRFS_FS_ROOT; -+ path =3D btrfs_grab_path(FIRST_EXTERNAL_LOOKUP_POOL); -+ -+ btrfs_set_root_dir_key(&sd_key); -+ while (1) { -+ struct extent_buffer *leaf; -+ ret =3D aux_tree_lookup(root, &sd_key, path); -+ if (ret) -+ return 0; -+ leaf =3D &path->nodes[0]; -+ sd =3D btrfs_item_ptr(leaf, -+ path->slots[0], -+ struct btrfs_inode_item); -+ mode =3D btrfs_inode_mode(leaf, sd); -+ size =3D btrfs_inode_size(leaf, sd); -+ switch (btrfs_get_file_type(mode)) { -+ case BTRFS_SYMLINK_FILE: -+ ret =3D btrfs_follow_link(root, -+ path, -+ &dirname, -+ linkbuf, -+ &linkcount, -+ sd); -+ if (!ret) -+ return 0; -+ dirname =3D linkbuf; -+ if (*dirname =3D=3D '/') -+ /* absolute name */ -+ btrfs_set_root_dir_key(&sd_key); -+ else -+ memcpy(&sd_key, &parent_sd_key, -+ sizeof(sd_key)); -+ continue; -+ case BTRFS_REGULAR_FILE: -+ /* -+ * normally we want to exit here -+ */ -+ if (*dirname && !isspace (*dirname)) { -+ errnum =3D ERR_BAD_FILETYPE; -+ return 0; -+ } -+ filepos =3D 0; -+ filemax =3D btrfs_inode_size(leaf, sd); -+ btrfs_update_file_info(path); -+ return 1; -+ case BTRFS_DIRECTORY_FILE: -+ memcpy(&parent_sd_key, &sd_key, sizeof(sd_key)); -+ ret =3D btrfs_de_index_by_name(root, -+ path, -+ &dirname, -+ &sd_key); -+ if (!ret) -+ return 0; -+#ifndef STAGE1_5 -+ if (print_possibilities < 0) -+ return 1; -+#endif -+ /* -+ * update fs_tree: -+ * subvolume stuff goes here -+ */ -+ ret =3D update_fs_root(root, &sd_key); -+ if (ret) -+ return 0; -+ continue; -+ case BTRFS_UNKNOWN_FILE: -+ default: -+ btrfs_msg("Btrfs: bad file type\n"); -+ errnum =3D ERR_BAD_FILETYPE; -+ return 0; -+ } -+ } -+} -+ -+int btrfs_embed(int *start_sector, int needed_sectors) -+{ -+ int ret; -+ init_btrfs_info(); -+ init_btrfs_volatile_dev_cache(); -+ -+ ret =3D btrfs_find_super(BTRFS_VOLATILE_DEV_CACHE, NULL, NULL); -+ if (ret) -+ return 0; -+ ret =3D btrfs_uptodate_super_copy(BTRFS_FS_INFO); -+ if (ret) -+ return 0; -+ *start_sector =3D 1; /* reserve first sector for stage1 */ -+ return needed_sectors <=3D -+ ((BTRFS_SUPER_INFO_OFFSET >> SECTOR_BITS) - 1); -+} -+#endif /* FSYS_BTRFS */ -+ -+/* -+ Local variables: -+ c-indentation-style: "K&R" -+ mode-name: "LC" -+ c-basic-offset: 8 -+ tab-width: 8 -+ fill-column: 80 -+ scroll-step: 1 -+ End: -+*/ -diff -up grub-upstream.wip/stage2/Makefile.am.btrfs grub-upstream.wip/stag= e2/Makefile.am ---- grub-upstream.wip/stage2/Makefile.am.btrfs 2012-03-20 05:06:49.0000000= 00 +0000 -+++ grub-upstream.wip/stage2/Makefile.am 2012-03-20 05:07:09.000000000 +00= 00 -@@ -17,13 +17,13 @@ INCLUDES =3D -I$(top_srcdir)/stage1 - noinst_LIBRARIES =3D libgrub.a - libgrub_a_SOURCES =3D boot.c builtins.c char_io.c cmdline.c common.c \ - disk_io.c fsys_ext2fs.c fsys_fat.c fsys_ffs.c fsys_iso9660.c \ -- fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_ufs2.c \ -+ fsys_jfs.c fsys_minix.c fsys_reiserfs.c fsys_btrfs.c fsys_ufs2.c \ - fsys_vstafs.c fsys_xfs.c gunzip.c md5.c serial.c stage2.c \ - terminfo.c tparm.c graphics.c - libgrub_a_CFLAGS =3D $(GRUB_CFLAGS) -I$(top_srcdir)/lib \ - -DGRUB_UTIL=3D1 -DFSYS_EXT2FS=3D1 -DFSYS_FAT=3D1 -DFSYS_FFS=3D1 \ - -DFSYS_ISO9660=3D1 -DFSYS_JFS=3D1 -DFSYS_MINIX=3D1 -DFSYS_REISERFS=3D1 \ -- -DFSYS_UFS2=3D1 -DFSYS_VSTAFS=3D1 -DFSYS_XFS=3D1 \ -+ -DFSYS_BTRFS=3D1 -DFSYS_UFS2=3D1 -DFSYS_VSTAFS=3D1 -DFSYS_XFS=3D1 \ - -DUSE_MD5_PASSWORDS=3D1 -DSUPPORT_SERIAL=3D1 -DSUPPORT_HERCULES=3D1 -=20 - # Stage 2 and Stage 1.5's. -@@ -34,24 +34,26 @@ EXTRA_PROGRAMS =3D nbloader.exec pxeloader - if DISKLESS_SUPPORT - pkglib_DATA =3D stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \ - ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \ -- reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 \ -- nbgrub pxegrub -+ reiserfs_stage1_5 btrfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 \ -+ xfs_stage1_5 nbgrub pxegrub - noinst_DATA =3D pre_stage2 start start_eltorito nbloader pxeloader diskle= ss - noinst_PROGRAMS =3D pre_stage2.exec start.exec start_eltorito.exec \ - e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \ - iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \ -- reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \ -- xfs_stage1_5.exec nbloader.exec pxeloader.exec diskless.exec -+ reiserfs_stage1_5.exec btrfs_stage1_5.exec ufs2_stage1_5.exec \ -+ vstafs_stage1_5.exec xfs_stage1_5.exec nbloader.exec \ -+ pxeloader.exec diskless.exec - else - pkglib_DATA =3D stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \ - ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \ -- reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 -+ reiserfs_stage1_5 btrfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 \ -+ xfs_stage1_5 - noinst_DATA =3D pre_stage2 start start_eltorito - noinst_PROGRAMS =3D pre_stage2.exec start.exec start_eltorito.exec \ - e2fs_stage1_5.exec fat_stage1_5.exec ffs_stage1_5.exec \ - iso9660_stage1_5.exec jfs_stage1_5.exec minix_stage1_5.exec \ -- reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \ -- xfs_stage1_5.exec -+ reiserfs_stage1_5.exec btrfs_stage1_5.exec ufs2_stage1_5.exec \ -+ vstafs_stage1_5.exec xfs_stage1_5.exec - endif - MOSTLYCLEANFILES =3D $(noinst_PROGRAMS) -=20 -@@ -95,15 +97,17 @@ STAGE1_5_COMPILE =3D $(STAGE2_COMPILE) -DN - pre_stage2_exec_SOURCES =3D asm.S bios.c boot.c builtins.c char_io.c \ - cmdline.c common.c console.c disk_io.c fsys_ext2fs.c \ - fsys_fat.c fsys_ffs.c fsys_iso9660.c fsys_jfs.c fsys_minix.c \ -- fsys_reiserfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c gunzip.c \ -- hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c tparm.c \ -- graphics.c -+ fsys_reiserfs.c fsys_btrfs.c fsys_ufs2.c fsys_vstafs.c fsys_xfs.c \ -+ gunzip.c hercules.c md5.c serial.c smp-imps.c stage2.c terminfo.c \ -+ tparm.c graphics.c - pre_stage2_exec_CFLAGS =3D $(STAGE2_COMPILE) $(FSYS_CFLAGS) - pre_stage2_exec_CCASFLAGS =3D $(STAGE2_COMPILE) $(FSYS_CFLAGS) - pre_stage2_exec_LDFLAGS =3D $(PRE_STAGE2_LINK) -=20 - if NETBOOT_SUPPORT --pre_stage2_exec_LDADD =3D ../netboot/libdrivers.a -+pre_stage2_exec_LDADD =3D ../netboot/libdrivers.a -lgcc -+else -+pre_stage2_exec_LDADD =3D -lgcc - endif -=20 - if DISKLESS_SUPPORT -@@ -197,6 +201,16 @@ reiserfs_stage1_5_exec_CCASFLAGS =3D $(STA - -DNO_BLOCK_FILES=3D1 - reiserfs_stage1_5_exec_LDFLAGS =3D $(STAGE1_5_LINK) -=20 -+# For btrfs_stage1_5 target. -+btrfs_stage1_5_exec_SOURCES =3D start.S asm.S common.c char_io.c \ -+ disk_io.c stage1_5.c fsys_btrfs.c bios.c -+btrfs_stage1_5_exec_CFLAGS =3D $(STAGE1_5_COMPILE) -DFSYS_BTRFS=3D1 \ -+ -DNO_BLOCK_FILES=3D1 -+btrfs_stage1_5_exec_CCASFLAGS =3D $(STAGE1_5_COMPILE) -DFSYS_BTRFS=3D1 \ -+ -DNO_BLOCK_FILES=3D1 -+btrfs_stage1_5_exec_LDFLAGS =3D $(STAGE1_5_LINK) -+btrfs_stage1_5_exec_LDADD =3D -lgcc -+ - # For vstafs_stage1_5 target. - vstafs_stage1_5_exec_SOURCES =3D start.S asm.S common.c char_io.c \ - disk_io.c stage1_5.c fsys_vstafs.c bios.c -@@ -240,7 +254,7 @@ diskless_exec_CFLAGS =3D $(STAGE2_COMPILE) - diskless_exec_CCASFLAGS =3D $(STAGE2_COMPILE) $(FSYS_CFLAGS) \ - -DSUPPORT_DISKLESS=3D1 - diskless_exec_LDFLAGS =3D $(PRE_STAGE2_LINK) --diskless_exec_LDADD =3D ../netboot/libdrivers.a -+diskless_exec_LDADD =3D ../netboot/libdrivers.a -lgcc -=20 - diskless_size.h: diskless - -rm -f $@ -diff -up grub-upstream.wip/stage2/shared.h.btrfs grub-upstream.wip/stage2/= shared.h ---- grub-upstream.wip/stage2/shared.h.btrfs 2012-03-20 05:06:49.000000000 = +0000 -+++ grub-upstream.wip/stage2/shared.h 2012-03-20 05:07:09.000000000 +0000 -@@ -207,11 +207,12 @@ extern char *grub_scratch_mem; - #define STAGE2_ID_FAT_STAGE1_5 3 - #define STAGE2_ID_MINIX_STAGE1_5 4 - #define STAGE2_ID_REISERFS_STAGE1_5 5 --#define STAGE2_ID_VSTAFS_STAGE1_5 6 --#define STAGE2_ID_JFS_STAGE1_5 7 --#define STAGE2_ID_XFS_STAGE1_5 8 --#define STAGE2_ID_ISO9660_STAGE1_5 9 --#define STAGE2_ID_UFS2_STAGE1_5 10 -+#define STAGE2_ID_BTRFS_STAGE1_5 6 -+#define STAGE2_ID_VSTAFS_STAGE1_5 7 -+#define STAGE2_ID_JFS_STAGE1_5 8 -+#define STAGE2_ID_XFS_STAGE1_5 9 -+#define STAGE2_ID_ISO9660_STAGE1_5 10 -+#define STAGE2_ID_UFS2_STAGE1_5 11 -=20 - #ifndef STAGE1_5 - # define STAGE2_ID STAGE2_ID_STAGE2 -@@ -226,6 +227,8 @@ extern char *grub_scratch_mem; - # define STAGE2_ID STAGE2_ID_MINIX_STAGE1_5 - # elif defined(FSYS_REISERFS) - # define STAGE2_ID STAGE2_ID_REISERFS_STAGE1_5 -+# elif defined(FSYS_BTRFS) -+# define STAGE2_ID STAGE2_ID_BTRFS_STAGE1_5 - # elif defined(FSYS_VSTAFS) - # define STAGE2_ID STAGE2_ID_VSTAFS_STAGE1_5 - # elif defined(FSYS_JFS) diff --git a/stubdom/grub.patches/70compiler_warnings.diff b/stubdom/grub.p= atches/70compiler_warnings.diff deleted file mode 100644 index 15181fcfaa..0000000000 --- a/stubdom/grub.patches/70compiler_warnings.diff +++ /dev/null @@ -1,45 +0,0 @@ -[ 1436s] ../grub-upstream/netboot/fsys_tftp.c:213: warning: operation on '= block' may be undefined -[ 1437s] ../grub-upstream/netboot/main.c:444: warning: operation on 'block= ' may be undefined - -[ 1234s] E: xen sequence-point ../grub-upstream/netboot/fsys_tftp.c:213 -[ 1234s] E: xen sequence-point ../grub-upstream/netboot/main.c:444 - ---- - netboot/fsys_tftp.c | 5 ++++- - netboot/main.c | 5 ++++- - 2 files changed, 8 insertions(+), 2 deletions(-) - -Index: grub-0.97/netboot/fsys_tftp.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub-0.97.orig/netboot/fsys_tftp.c -+++ grub-0.97/netboot/fsys_tftp.c -@@ -209,8 +209,11 @@ buf_fill (int abort) - break; -=20 - if ((block || bcounter) && (block !=3D prevblock + (unsigned short)= 1)) -+ { -+ block =3D prevblock; - /* Block order should be continuous */ -- tp.u.ack.block =3D htons (block =3D prevblock); -+ tp.u.ack.block =3D htons (block); -+ } - =20 - /* Should be continuous. */ - tp.opcode =3D abort ? htons (TFTP_ERROR) : htons (TFTP_ACK); -Index: grub-0.97/netboot/main.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub-0.97.orig/netboot/main.c -+++ grub-0.97/netboot/main.c -@@ -440,8 +440,11 @@ tftp (const char *name, int (*fnc) (unsi - break; - =20 - if ((block || bcounter) && (block !=3D prevblock + 1)) -+ { -+ block =3D prevblock; - /* Block order should be continuous */ -- tp.u.ack.block =3D htons (block =3D prevblock); -+ tp.u.ack.block =3D htons (block); -+ } - =20 - /* Should be continuous. */ - tp.opcode =3D htons (TFTP_ACK); diff --git a/stubdom/grub.patches/99minios b/stubdom/grub.patches/99minios deleted file mode 100644 index d9b19138fd..0000000000 --- a/stubdom/grub.patches/99minios +++ /dev/null @@ -1,1570 +0,0 @@ -Index: grub/stage2/builtins.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/builtins.c 2008-06-16 15:18:14.649009000 +0100 -+++ grub/stage2/builtins.c 2008-06-16 15:18:14.719009000 +0100 -@@ -45,8 +45,10 @@ - #ifdef GRUB_UTIL - # include - #else /* ! GRUB_UTIL */ -+#ifndef __MINIOS - # include - # include -+#endif - #endif /* ! GRUB_UTIL */ -=20 - #ifdef USE_MD5_PASSWORDS -@@ -246,11 +248,13 @@ - boot_func (char *arg, int flags) - { - struct term_entry *prev_term =3D current_term; -+#ifndef __MINIOS__ - /* Clear the int15 handler if we can boot the kernel successfully. - This assumes that the boot code never fails only if KERNEL_TYPE is - not KERNEL_TYPE_NONE. Is this assumption is bad? */ - if (kernel_type !=3D KERNEL_TYPE_NONE) - unset_int15_handler (); -+#endif -=20 - /* if our terminal needed initialization, we should shut it down - * before booting the kernel, but we want to save what it was so -@@ -261,13 +265,21 @@ - current_term =3D term_table; /* assumption: console is first */ - } -=20 -+#ifndef __MINIOS__ - #ifdef SUPPORT_NETBOOT - /* Shut down the networking. */ - cleanup_net (); - #endif -+#endif - =20 - switch (kernel_type) - { -+#ifdef __MINIOS__ -+ case KERNEL_TYPE_PV: -+ /* Paravirtualized */ -+ pv_boot(); -+ break; -+#else - case KERNEL_TYPE_FREEBSD: - case KERNEL_TYPE_NETBSD: - /* *BSD */ -@@ -319,6 +331,7 @@ - multi_boot ((int) entry_addr, (int) &mbi); - break; -=20 -+#endif - default: - errnum =3D ERR_BOOT_COMMAND; - return 1; -@@ -1123,6 +1136,7 @@ - }; -=20 - =0C -+#ifndef __MINIOS__ - /* displayapm */ - static int - displayapm_func (char *arg, int flags) -@@ -1163,8 +1177,10 @@ - "displayapm", - "Display APM BIOS information." - }; -+#endif -=20 - =0C -+#ifndef __MINIOS__ - /* displaymem */ - static int - displaymem_func (char *arg, int flags) -@@ -1218,6 +1234,7 @@ - "Display what GRUB thinks the system address space map of the" - " machine is, including all regions of physical RAM installed." - }; -+#endif -=20 - =0C - /* dump FROM TO */ -@@ -1280,6 +1297,7 @@ - #endif /* GRUB_UTIL */ -=20 - =0C -+#ifndef __MINIOS__ - static char embed_info[32]; - /* embed */ - /* Embed a Stage 1.5 in the first cylinder after MBR or in the -@@ -1413,6 +1431,7 @@ - " is a drive, or in the \"bootloader\" area if DEVICE is a FFS partitio= n." - " Print the number of sectors which STAGE1_5 occupies if successful." - }; -+#endif -=20 - =0C - /* fallback */ -@@ -1956,6 +1975,7 @@ - #endif /* SUPPORT_NETBOOT */ -=20 - =0C -+#ifndef __MINIOS__ - /* impsprobe */ - static int - impsprobe_func (char *arg, int flags) -@@ -1982,6 +2002,7 @@ - " configuration table and boot the various CPUs which are found into" - " a tight loop." - }; -+#endif -=20 - =0C - /* initrd */ -@@ -1992,6 +2013,7 @@ - { - case KERNEL_TYPE_LINUX: - case KERNEL_TYPE_BIG_LINUX: -+ case KERNEL_TYPE_PV: - if (! load_initrd (arg)) - return 1; - break; -@@ -2015,6 +2037,7 @@ - }; -=20 - =0C -+#ifndef __MINIOS__ - /* install */ - static int - install_func (char *arg, int flags) -@@ -2555,8 +2578,10 @@ - " for LBA mode. If the option `--stage2' is specified, rewrite the Stag= e" - " 2 via your OS's filesystem instead of the raw device." - }; -+#endif -=20 - =0C -+#ifndef __MINIOS__ - /* ioprobe */ - static int - ioprobe_func (char *arg, int flags) -@@ -2598,6 +2623,7 @@ - "ioprobe DRIVE", - "Probe I/O ports used for the drive DRIVE." - }; -+#endif -=20 - /* print */ - static int -@@ -2910,6 +2910,7 @@ - switch (kernel_type) - { - case KERNEL_TYPE_MULTIBOOT: -+ case KERNEL_TYPE_PV: - if (mb_cmdline + len + 1 > (char *) MB_CMDLINE_BUF + MB_CMDLINE_BUF= LEN) - { - errnum =3D ERR_WONT_FIT; -@@ -3776,6 +3802,7 @@ - }; -=20 - =0C -+#ifndef __MINIOS__ - #ifdef SUPPORT_SERIAL - /* serial */ - static int -@@ -3927,8 +3954,10 @@ - " default values are COM1, 9600, 8N1." - }; - #endif /* SUPPORT_SERIAL */ -+#endif -=20 - =0C -+#ifndef __MINIOS__ - /* setkey */ - struct keysym - { -@@ -4174,8 +4203,10 @@ - " is a digit), and delete. If no argument is specified, reset key" - " mappings." - }; -+#endif -=20 - =0C -+#ifndef __MINIOS__ - /* setup */ - static int - setup_func (char *arg, int flags) -@@ -4484,6 +4515,7 @@ - " partition where GRUB images reside, specify the option `--stage2'" - " to tell GRUB the file name under your OS." - }; -+#endif -=20 - =0C - #if defined(SUPPORT_SERIAL) || defined(SUPPORT_HERCULES) || defined(SUPPO= RT_GRAPHICS) -@@ -4788,6 +4820,7 @@ - #endif /* SUPPORT_SERIAL */ - =20 - =0C -+#ifndef __MINIOS__ - /* testload */ - static int - testload_func (char *arg, int flags) -@@ -4874,8 +4907,10 @@ - " consistent offset error. If this test succeeds, then a good next" - " step is to try loading a kernel." - }; -+#endif -=20 - =0C -+#ifndef __MINIOS__ - /* testvbe MODE */ - static int - testvbe_func (char *arg, int flags) -@@ -4979,6 +5014,7 @@ - "testvbe MODE", - "Test the VBE mode MODE. Hit any key to return." - }; -+#endif -=20 - =0C - #ifdef SUPPORT_NETBOOT -@@ -5075,6 +5111,7 @@ - }; -=20 - =0C -+#ifndef __MINIOS__ - /* uppermem */ - static int - uppermem_func (char *arg, int flags) -@@ -5095,8 +5132,10 @@ - "Force GRUB to assume that only KBYTES kilobytes of upper memory are" - " installed. Any system address range maps are discarded." - }; -+#endif -=20 - =0C -+#ifndef __MINIOS__ - /* vbeprobe */ - static int - vbeprobe_func (char *arg, int flags) -@@ -5203,6 +5242,7 @@ - "Probe VBE information. If the mode number MODE is specified, show only" - " the information about only the mode." - }; -+#endif - =20 - =0C - /* The table of builtin commands. Sorted in dictionary order. */ -@@ -5233,12 +5273,16 @@ - #ifdef SUPPORT_NETBOOT - &builtin_dhcp, - #endif /* SUPPORT_NETBOOT */ -+#ifndef __MINIOS__ - &builtin_displayapm, - &builtin_displaymem, -+#endif - #ifdef GRUB_UTIL - &builtin_dump, - #endif /* GRUB_UTIL */ -+#ifndef __MINIOS__ - &builtin_embed, -+#endif - &builtin_fallback, - &builtin_find, - #ifdef SUPPORT_GRAPHICS -@@ -5253,10 +5297,14 @@ - #ifdef SUPPORT_NETBOOT - &builtin_ifconfig, - #endif /* SUPPORT_NETBOOT */ -+#ifndef __MINIOS__ - &builtin_impsprobe, -+#endif - &builtin_initrd, -+#ifndef __MINIOS__ - &builtin_install, - &builtin_ioprobe, -+#endif - &builtin_kernel, - &builtin_lock, - &builtin_makeactive, -@@ -5283,11 +5331,13 @@ - &builtin_root, - &builtin_rootnoverify, - &builtin_savedefault, -+#ifndef __MINIOS__ - #ifdef SUPPORT_SERIAL - &builtin_serial, - #endif /* SUPPORT_SERIAL */ - &builtin_setkey, - &builtin_setup, -+#endif - #ifdef SUPPORT_GRAPHICS - &builtin_shade, - &builtin_splashimage, -@@ -5298,16 +5348,20 @@ - #ifdef SUPPORT_SERIAL - &builtin_terminfo, - #endif /* SUPPORT_SERIAL */ -+#ifndef __MINIOS__ - &builtin_testload, - &builtin_testvbe, -+#endif - #ifdef SUPPORT_NETBOOT - &builtin_tftpserver, - #endif /* SUPPORT_NETBOOT */ - &builtin_timeout, - &builtin_title, - &builtin_unhide, -+#ifndef __MINIOS__ - &builtin_uppermem, - &builtin_vbeprobe, -+#endif - #ifdef SUPPORT_GRAPHICS - &builtin_viewport, - #endif -Index: grub/stage2/char_io.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/char_io.c 2008-06-16 15:18:14.516009000 +0100 -+++ grub/stage2/char_io.c 2008-06-16 15:18:14.726009000 +0100 -@@ -20,6 +20,7 @@ -=20 - #include - #include -+#include -=20 - #ifdef SUPPORT_HERCULES - # include -@@ -36,6 +37,7 @@ - #ifndef STAGE1_5 - struct term_entry term_table[] =3D - { -+#ifdef SUPPORT_CONSOLE - { - "console", - 0, -@@ -52,6 +54,7 @@ - 0,=20 - 0 - }, -+#endif - #ifdef SUPPORT_SERIAL - { - "serial", -@@ -131,9 +134,9 @@ - } -=20 - char * --convert_to_ascii (char *buf, int c,...) -+convert_to_ascii (char *buf, int c, int _num) - { -- unsigned long num =3D *((&c) + 1), mult =3D 10; -+ unsigned long num =3D _num, mult =3D 10; - char *ptr =3D buf; -=20 - #ifndef STAGE1_5 -@@ -182,11 +185,11 @@ - void - grub_printf (const char *format,...) - { -- int *dataptr =3D (int *) &format; -+ va_list ap; - char c, str[16]; -- =20 -- dataptr++; -=20 -+ va_start(ap, format); -+ =20 - while ((c =3D *(format++)) !=3D 0) - { - if (c !=3D '%') -@@ -200,21 +203,32 @@ - case 'X': - #endif - case 'u': -- *convert_to_ascii (str, c, *((unsigned long *) dataptr++)) =3D 0; -+ { -+ unsigned i =3D va_arg(ap, unsigned); -+ *convert_to_ascii (str, c, i) =3D 0; - grub_putstr (str); - break; -+ } -=20 - #ifndef STAGE1_5 - case 'c': -- grub_putchar ((*(dataptr++)) & 0xff); -+ { -+ int c =3D va_arg(ap, int); -+ grub_putchar (c & 0xff); - break; -+ } -=20 - case 's': -- grub_putstr ((char *) *(dataptr++)); -+ { -+ char *s =3D va_arg(ap, char*); -+ grub_putstr (s); - break; -+ } - #endif - } - } -+ -+ va_end(ap); - } -=20 - #ifndef STAGE1_5 -@@ -223,11 +237,11 @@ - { - /* XXX hohmuth - ugly hack -- should unify with printf() */ -- int *dataptr =3D (int *) &format; -+ va_list ap; - char c, *ptr, str[16]; - char *bp =3D buffer; -=20 -- dataptr++; -+ va_start(ap, format); -=20 - while ((c =3D *format++) !=3D 0) - { -@@ -237,20 +251,27 @@ - switch (c =3D *(format++)) - { - case 'd': case 'u': case 'x': -- *convert_to_ascii (str, c, *((unsigned long *) dataptr++)) =3D 0; -+ { -+ unsigned i =3D va_arg(ap, unsigned); -+ *convert_to_ascii (str, c, i) =3D 0; -=20 - ptr =3D str; -=20 - while (*ptr) - *bp++ =3D *(ptr++); /* putchar(*(ptr++)); */ - break; -+ } -=20 -- case 'c': *bp++ =3D (*(dataptr++))&0xff; -+ case 'c': -+ { -+ int c =3D va_arg(ap, int); -+ *bp++ =3D c&0xff; - /* putchar((*(dataptr++))&0xff); */ - break; -+ } -=20 - case 's': -- ptr =3D (char *) (*(dataptr++)); -+ ptr =3D va_arg(ap, char *); -=20 - while ((c =3D *ptr++) !=3D 0) - *bp++ =3D c; /* putchar(c); */ -@@ -258,6 +279,8 @@ - } - } -=20 -+ va_end(ap); -+ - *bp =3D 0; - return bp - buffer; - } -@@ -1263,12 +1286,14 @@ - return ! errnum; - #endif /* GRUB_UTIL */ -=20 -+#ifndef __MINIOS__ - if ((addr < RAW_ADDR (0x1000)) - || (addr < RAW_ADDR (0x100000) - && RAW_ADDR (mbi.mem_lower * 1024) < (addr + len)) - || (addr >=3D RAW_ADDR (0x100000) - && RAW_ADDR (mbi.mem_upper * 1024) < ((addr - 0x100000) + len))) - errnum =3D ERR_WONT_FIT; -+#endif -=20 - return ! errnum; - } -@@ -1342,7 +1367,7 @@ - } - #endif /* ! STAGE1_5 */ -=20 --#ifndef GRUB_UTIL -+#if !defined(GRUB_UTIL) && !defined(__MINIOS__) - # undef memcpy - /* GCC emits references to memcpy() for struct copies etc. */ - void *memcpy (void *dest, const void *src, int n) __attribute__ ((alias = ("grub_memmove"))); -Index: grub/stage2/disk_io.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/disk_io.c 2008-06-16 15:18:03.327932000 +0100 -+++ grub/stage2/disk_io.c 2008-06-16 15:18:14.733009000 +0100 -@@ -130,7 +130,14 @@ - static inline unsigned long - log2 (unsigned long word) - { -- asm volatile ("bsfl %1,%0" -+ asm volatile ("bsf" -+#ifdef __i386__ -+ "l" -+#endif -+#ifdef __x86_64__ -+ "q" -+#endif =20 -+ " %1,%0" - : "=3Dr" (word) - : "r" (word)); - return word; -Index: grub/stage2/fsys_fat.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/fsys_fat.c 2008-06-16 15:18:03.337934000 +0100 -+++ grub/stage2/fsys_fat.c 2008-06-16 15:18:14.737009000 +0100 -@@ -57,7 +57,14 @@ - static __inline__ unsigned long - log2 (unsigned long word) - { -- __asm__ ("bsfl %1,%0" -+ __asm__ ("bsf" -+#ifdef __i386__ -+ "l" -+#endif -+#ifdef __x86_64__ -+ "q" -+#endif -+ " %1,%0" - : "=3Dr" (word) - : "r" (word)); - return word; -Index: grub/stage2/pc_slice.h -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/pc_slice.h 2008-06-16 15:18:03.347932000 +0100 -+++ grub/stage2/pc_slice.h 2008-06-16 15:18:14.746009000 +0100 -@@ -38,50 +38,50 @@ - */ -=20 - #define PC_MBR_CHECK_SIG(mbr_ptr) \ -- ( *( (unsigned short *) (((int) mbr_ptr) + PC_MBR_SIG_OFFSET) ) \ -+ ( *( (unsigned short *) (((long) mbr_ptr) + PC_MBR_SIG_OFFSET) ) \ - =3D=3D PC_MBR_SIGNATURE ) -=20 - #define PC_MBR_SIG(mbr_ptr) \ -- ( *( (unsigned short *) (((int) mbr_ptr) + PC_MBR_SIG_OFFSET) ) ) -+ ( *( (unsigned short *) (((long) mbr_ptr) + PC_MBR_SIG_OFFSET) ) ) -=20 - #define PC_SLICE_FLAG(mbr_ptr, part) \ -- ( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET \ -+ ( *( (unsigned char *) (((long) mbr_ptr) + PC_SLICE_OFFSET \ - + (part << 4)) ) ) -=20 - #define PC_SLICE_HEAD(mbr_ptr, part) \ -- ( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 1 \ -+ ( *( (unsigned char *) (((long) mbr_ptr) + PC_SLICE_OFFSET + 1 \ - + (part << 4)) ) ) -=20 - #define PC_SLICE_SEC(mbr_ptr, part) \ -- ( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 2 \ -+ ( *( (unsigned char *) (((long) mbr_ptr) + PC_SLICE_OFFSET + 2 \ - + (part << 4)) ) ) -=20 - #define PC_SLICE_CYL(mbr_ptr, part) \ -- ( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 3 \ -+ ( *( (unsigned char *) (((long) mbr_ptr) + PC_SLICE_OFFSET + 3 \ - + (part << 4)) ) ) -=20 - #define PC_SLICE_TYPE(mbr_ptr, part) \ -- ( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 4 \ -+ ( *( (unsigned char *) (((long) mbr_ptr) + PC_SLICE_OFFSET + 4 \ - + (part << 4)) ) ) -=20 - #define PC_SLICE_EHEAD(mbr_ptr, part) \ -- ( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 5 \ -+ ( *( (unsigned char *) (((long) mbr_ptr) + PC_SLICE_OFFSET + 5 \ - + (part << 4)) ) ) -=20 - #define PC_SLICE_ESEC(mbr_ptr, part) \ -- ( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 6 \ -+ ( *( (unsigned char *) (((long) mbr_ptr) + PC_SLICE_OFFSET + 6 \ - + (part << 4)) ) ) -=20 - #define PC_SLICE_ECYL(mbr_ptr, part) \ -- ( *( (unsigned char *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 7 \ -+ ( *( (unsigned char *) (((long) mbr_ptr) + PC_SLICE_OFFSET + 7 \ - + (part << 4)) ) ) -=20 - #define PC_SLICE_START(mbr_ptr, part) \ -- ( *( (unsigned long *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 8 \ -+ ( *( (unsigned long *) (((long) mbr_ptr) + PC_SLICE_OFFSET + 8 \ - + (part << 4)) ) ) -=20 - #define PC_SLICE_LENGTH(mbr_ptr, part) \ -- ( *( (unsigned long *) (((int) mbr_ptr) + PC_SLICE_OFFSET + 12 \ -+ ( *( (unsigned long *) (((long) mbr_ptr) + PC_SLICE_OFFSET + 12 \ - + (part << 4)) ) ) -=20 -=20 -Index: grub/stage2/shared.h -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/shared.h 2008-06-16 15:18:14.537009000 +0100 -+++ grub/stage2/shared.h 2008-06-17 14:25:08.443906000 +0100 -@@ -39,6 +39,10 @@ - extern char *grub_scratch_mem; - # define RAW_ADDR(x) ((x) + (int) grub_scratch_mem) - # define RAW_SEG(x) (RAW_ADDR ((x) << 4) >> 4) -+#elif defined(__MINIOS__) -+extern char grub_scratch_mem[]; -+# define RAW_ADDR(x) ((x) + (int) grub_scratch_mem) -+# define RAW_SEG(x) (RAW_ADDR ((x) << 4) >> 4) - #else - # define RAW_ADDR(x) (x) - # define RAW_SEG(x) (x) -@@ -707,7 +711,9 @@ -=20 - /* Halt the system, using APM if possible. If NO_APM is true, don't use - APM even if it is available. */ -+#ifndef __MINIOS__ - void grub_halt (int no_apm) __attribute__ ((noreturn)); -+#endif -=20 - /* Copy MAP to the drive map and set up int13_handler. */ - void set_int13_handler (unsigned short *map); -@@ -857,7 +863,8 @@ - KERNEL_TYPE_BIG_LINUX, /* Big Linux. */ - KERNEL_TYPE_FREEBSD, /* FreeBSD. */ - KERNEL_TYPE_NETBSD, /* NetBSD. */ -- KERNEL_TYPE_CHAINLOADER /* Chainloader. */ -+ KERNEL_TYPE_CHAINLOADER, /* Chainloader. */ -+ KERNEL_TYPE_PV /* Paravirtualized. */ - } - kernel_t; -=20 -@@ -890,7 +897,7 @@ - int grub_strlen (const char *str); - char *grub_strcpy (char *dest, const char *src); -=20 --#ifndef GRUB_UTIL -+#if !defined(GRUB_UTIL) && !defined(__MINIOS__) - typedef unsigned long grub_jmp_buf[6]; - #else - /* In the grub shell, use the libc jmp_buf instead. */ -@@ -898,7 +905,7 @@ - # define grub_jmp_buf jmp_buf - #endif -=20 --#ifdef GRUB_UTIL -+#if defined(GRUB_UTIL) || defined(__MINIOS__) - # define grub_setjmp setjmp - # define grub_longjmp longjmp - #else /* ! GRUB_UTIL */ -@@ -914,7 +921,7 @@ - /* misc */ - void init_page (void); - void print_error (void); --char *convert_to_ascii (char *buf, int c, ...); -+char *convert_to_ascii (char *buf, int c, int num); - int get_cmdline (char *prompt, char *cmdline, int maxlen, - int echo_char, int history); - int substring (const char *s1, const char *s2); -Index: grub/netboot/etherboot.h -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/netboot/etherboot.h 2008-06-16 15:18:03.446934000 +0100 -+++ grub/netboot/etherboot.h 2008-06-16 15:18:14.760009000 +0100 -@@ -246,7 +246,7 @@ -=20 - typedef struct - { -- unsigned long s_addr; -+ unsigned int s_addr; - } - in_addr; -=20 -@@ -302,7 +302,7 @@ - char bp_htype; - char bp_hlen; - char bp_hops; -- unsigned long bp_xid; -+ unsigned int bp_xid; - unsigned short bp_secs; - unsigned short unused; - in_addr bp_ciaddr; -@@ -411,25 +411,25 @@ - =20 - struct - { -- long id; -- long type; -- long rpcvers; -- long prog; -- long vers; -- long proc; -- long data[1]; -+ int id; -+ int type; -+ int rpcvers; -+ int prog; -+ int vers; -+ int proc; -+ int data[1]; - } - call; - =20 - struct - { -- long id; -- long type; -- long rstatus; -- long verifier; -- long v2; -- long astatus; -- long data[1]; -+ int id; -+ int type; -+ int rstatus; -+ int verifier; -+ int v2; -+ int astatus; -+ int data[1]; - } - reply; - } -@@ -517,7 +517,9 @@ -=20 - /* misc.c */ - extern void twiddle (void); -+#ifndef __MINIOS__ - extern void sleep (int secs); -+#endif - extern int getdec (char **s); - extern void etherboot_printf (const char *, ...); - extern int etherboot_sprintf (char *, const char *, ...); -Index: grub/stage2/common.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/common.c 2008-06-16 15:18:03.366934000 +0100 -+++ grub/stage2/common.c 2008-06-16 15:18:14.764009000 +0100 -@@ -137,6 +137,7 @@ - } - #endif /* ! STAGE1_5 */ -=20 -+#ifndef __MINIOS__ - /* This queries for BIOS information. */ - void - init_bios_info (void) -@@ -335,3 +336,4 @@ - /* Start main routine here. */ - cmain (); - } -+#endif -Index: grub/stage2/serial.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/serial.c 2008-06-16 15:18:03.376934000 +0100 -+++ grub/stage2/serial.c 2008-06-16 15:18:14.769009000 +0100 -@@ -37,7 +37,7 @@ - =0C - /* Hardware-dependent definitions. */ -=20 --#ifndef GRUB_UTIL -+#if !defined(GRUB_UTIL) && !defined(__MINIOS__) - /* The structure for speed vs. divisor. */ - struct divisor - { -@@ -222,6 +222,8 @@ - {('3' | ('~' << 8)), 4}, - {('5' | ('~' << 8)), 7}, - {('6' | ('~' << 8)), 3}, -+ {('7' | ('~' << 8)), 1}, -+ {('8' | ('~' << 8)), 5}, - }; - =20 - /* The buffer must start with ``ESC [''. */ -Index: grub/stage2/tparm.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/tparm.c 2008-06-16 15:18:03.390933000 +0100 -+++ grub/stage2/tparm.c 2008-06-16 15:18:14.774010000 +0100 -@@ -48,6 +48,7 @@ - #include "shared.h" -=20 - #include "tparm.h" -+#include -=20 - /* - * Common/troublesome character definitions -@@ -320,7 +321,7 @@ - #define isLOWER(c) ((c) >=3D 'a' && (c) <=3D 'z') -=20 - static inline char * --tparam_internal(const char *string, int *dataptr) -+tparam_internal(const char *string, va_list ap) - { - #define NUM_VARS 26 - char *p_is_s[9]; -@@ -461,9 +462,9 @@ - * a char* and an int may not be the same size on the stack. - */ - if (p_is_s[i] !=3D 0) { -- p_is_s[i] =3D (char *)(*(dataptr++)); -+ p_is_s[i] =3D va_arg(ap, char *); - } else { -- param[i] =3D (int)(*(dataptr++)); -+ param[i] =3D va_arg(ap, int); - } - } -=20 -@@ -716,11 +717,13 @@ - grub_tparm(const char *string,...) - { - char *result; -- int *dataptr =3D (int *) &string; -+ va_list ap; -=20 -- dataptr++; -+ va_start(ap, string); -=20 -- result =3D tparam_internal(string, dataptr); -+ result =3D tparam_internal(string, ap); -+ -+ va_end(ap); -=20 - return result; - } -Index: grub/stage2/fsys_iso9660.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/fsys_iso9660.c 2008-06-16 15:18:03.400933000 +0100 -+++ grub/stage2/fsys_iso9660.c 2008-06-16 15:18:14.779009000 +0100 -@@ -59,7 +59,14 @@ - static inline unsigned long - log2 (unsigned long word) - { -- asm volatile ("bsfl %1,%0" -+ asm volatile ("bsf" -+#ifdef __i386__ -+ "l" -+#endif -+#ifdef __x86_64__ -+ "q" -+#endif -+ " %1,%0" - : "=3Dr" (word) - : "r" (word)); - return word; -Index: grub/stage2/fsys_reiserfs.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/fsys_reiserfs.c 2008-06-16 15:18:03.410933000 +0100 -+++ grub/stage2/fsys_reiserfs.c 2008-06-20 18:33:52.002100000 +0100 -@@ -224,8 +224,8 @@ -=20 - struct disk_child - { -- unsigned long dc_block_number; /* Disk child's block= number. */ -- unsigned short dc_size; /* Disk child's used space. = */ -+ __u32 dc_block_number; /* Disk child's block number.= */ -+ __u16 dc_size; /* Disk child's used space. */ - }; -=20 - #define DC_SIZE (sizeof (struct disk_child)) -@@ -369,7 +369,14 @@ - static __inline__ unsigned long - log2 (unsigned long word) - { -- __asm__ ("bsfl %1,%0" -+ __asm__ ("bsf" -+#ifdef __i386__ -+ "l" -+#endif -+#ifdef __x86_64__ -+ "q" -+#endif -+ " %1,%0" - : "=3Dr" (word) - : "r" (word)); - return word; -Index: grub/netboot/misc.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/netboot/misc.c 2008-06-16 15:18:03.456934000 +0100 -+++ grub/netboot/misc.c 2008-06-16 15:18:14.790009000 +0100 -@@ -21,7 +21,9 @@ -=20 - #define GRUB 1 - #include -+#include -=20 -+#ifndef __MINIOS__ - void - sleep (int secs) - { -@@ -30,6 +32,7 @@ - while (currticks () < tmo) - ; - } -+#endif -=20 - void - twiddle (void) -@@ -71,7 +74,7 @@ - Note: width specification not supported - *************************************************************************= */ - static int --etherboot_vsprintf (char *buf, const char *fmt, const int *dp) -+etherboot_vsprintf (char *buf, const char *fmt, va_list ap) - { - char *p, *s; - =20 -@@ -86,7 +89,7 @@ - =20 - if (*++fmt =3D=3D 's') - { -- for (p =3D (char *) *dp++; *p !=3D '\0'; p++) -+ for (p =3D va_arg(ap, char *); *p !=3D '\0'; p++) - buf ? *s++ =3D *p : grub_putchar (*p); - } - else -@@ -121,11 +124,9 @@ - if ((*fmt | 0x20) =3D=3D 'x') - { - /* With x86 gcc, sizeof(long) =3D=3D sizeof(int) */ -- const long *lp =3D (const long *) dp; -- long h =3D *lp++; -+ long h =3D va_arg(ap, int); - int ncase =3D (*fmt & 0x20); - =20 -- dp =3D (const int *) lp; - if (alt) - { - *q++ =3D '0'; -@@ -136,7 +137,7 @@ - } - else if (*fmt =3D=3D 'd') - { -- int i =3D *dp++; -+ int i =3D va_arg(ap, int); - char *r; - =20 - if (i < 0) -@@ -171,10 +172,8 @@ - unsigned char c[4]; - } - u; -- const long *lp =3D (const long *) dp; - =20 -- u.l =3D *lp++; -- dp =3D (const int *) lp; -+ u.l =3D va_arg(ap, int); - =20 - for (r =3D &u.c[0]; r < &u.c[4]; ++r) - q +=3D etherboot_sprintf (q, "%d.", *r); -@@ -184,7 +183,7 @@ - else if (*fmt =3D=3D '!') - { - char *r; -- p =3D (char *) *dp++; -+ p =3D va_arg(ap, char *); - =20 - for (r =3D p + ETH_ALEN; p < r; ++p) - q +=3D etherboot_sprintf (q, "%hhX:", *p); -@@ -192,7 +191,7 @@ - --q; - } - else if (*fmt =3D=3D 'c') -- *q++ =3D *dp++; -+ *q++ =3D va_arg(ap, int); - else - *q++ =3D *fmt; - =20 -@@ -211,13 +210,21 @@ - int - etherboot_sprintf (char *buf, const char *fmt, ...) - { -- return etherboot_vsprintf (buf, fmt, ((const int *) &fmt) + 1); -+ va_list ap; -+ int ret; -+ va_start(ap, fmt); -+ ret =3D etherboot_vsprintf (buf, fmt, ap); -+ va_end(ap); -+ return ret; - } -=20 - void - etherboot_printf (const char *fmt, ...) - { -- (void) etherboot_vsprintf (0, fmt, ((const int *) &fmt) + 1); -+ va_list ap; -+ va_start(ap, fmt); -+ etherboot_vsprintf (0, fmt, ap); -+ va_end(ap); - } -=20 - int -Index: grub/netboot/main.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/netboot/main.c 2008-06-16 15:18:03.470932000 +0100 -+++ grub/netboot/main.c 2008-06-16 15:18:14.797009000 +0100 -@@ -55,7 +55,7 @@ - static int vendorext_isvalid; - static unsigned long netmask; - static struct bootpd_t bootp_data; --static unsigned long xid; -+static unsigned int xid; -=20 - #define BOOTP_DATA_ADDR (&bootp_data) -=20 -@@ -778,7 +778,7 @@ -=20 - arpreply =3D (struct arprequest *) &nic.packet[ETH_HLEN]; - =20 -- if (arpreply->opcode =3D=3D htons (ARP_REPLY) -+ if (arpreply->opcode =3D=3D htons (ARP_REPLY) && ptr - && ! grub_memcmp (arpreply->sipaddr, ptr, sizeof (in_addr)) - && type =3D=3D AWAIT_ARP) - { -@@ -827,7 +827,7 @@ - { - arpreply =3D (struct arprequest *) &nic.packet[ETH_HLEN]; - =20 -- if (arpreply->opcode =3D=3D htons (RARP_REPLY) -+ if (arpreply->opcode =3D=3D htons (RARP_REPLY) && ptr - && ! grub_memcmp (arpreply->thwaddr, ptr, ETH_ALEN)) - { - grub_memmove ((char *) arptable[ARP_SERVER].node, -@@ -1135,7 +1135,7 @@ - long - rfc2131_sleep_interval (int base, int exp) - { -- static long seed =3D 0; -+ static unsigned seed =3D 0; - long q; - unsigned long tmo; - =20 -Index: grub/stage2/graphics.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/graphics.c 2008-06-16 15:18:14.524009000 +0100 -+++ grub/stage2/graphics.c 2008-06-17 14:29:05.204328000 +0100 -@@ -30,7 +30,29 @@ - #include - #include -=20 -+#ifdef __MINIOS__ -+#include -+typedef uint8_t Bit8u; -+#include -+#include -+#include -+#define set_int1c_handler() (void)0 -+#define unset_int1c_handler() (void)0 -+static uint32_t *VIDEOMEM; -+static struct fbfront_dev *fb_dev; -+static uint32_t palette[17]; -+short cursorX, cursorY; -+/* TODO: blink */ -+uint32_t cursorBuf32[16*8]; -+#define WIDTH 640 -+#define HEIGHT 480 -+#define DEPTH 32 -+#define RAMSIZE (WIDTH * HEIGHT * (DEPTH / 8)) -+#else -+#define fbfront_update(dev, x, y, w, h) (void)0 - int saved_videomode; -+#endif -+ - unsigned char *font8x16; -=20 - int graphics_inited =3D 0; -@@ -38,11 +60,15 @@ -=20 - int shade =3D 1, no_cursor =3D 0; -=20 -+#ifdef __MINIOS__ -+uint32_t VSHADOW[RAMSIZE]; -+#else - #define VSHADOW VSHADOW1 - unsigned char VSHADOW1[38400]; - unsigned char VSHADOW2[38400]; - unsigned char VSHADOW4[38400]; - unsigned char VSHADOW8[38400]; -+#endif -=20 - /* define the default viewable area */ - int view_x0 =3D 0; -@@ -129,6 +155,8 @@ - count_lines =3D k; -=20 - no_scroll =3D 0; -+ -+ fbfront_update(fb_dev, view_x0 * 8, view_y0 * 16, (view_x1 - view_x0)= * 8, (view_y1 - view_y0) * 16); - } -=20 - /* Set the splash image */ -@@ -154,17 +182,29 @@ - int graphics_init() - { - if (!graphics_inited) { -+#ifdef __MINIOS__ -+ VIDEOMEM =3D memalign(PAGE_SIZE, RAMSIZE); -+ if (!(fb_dev =3D fb_open(VIDEOMEM, WIDTH, HEIGHT, DEPTH))) { -+ free(VIDEOMEM); -+ return 0; -+ } -+#else - saved_videomode =3D set_videomode(0x12); - if (get_videomode() !=3D 0x12) { - set_videomode(saved_videomode); - return 0; - } -+#endif - graphics_inited =3D 1; - } - else - return 1; -=20 -+#ifdef __MINIOS__ -+ font8x16 =3D vgafont16; -+#else - font8x16 =3D (unsigned char*)graphics_get_font(); -+#endif -=20 - /* make sure that the highlight color is set correctly */ - graphics_highlight_color =3D ((graphics_normal_color >> 4) |=20 -@@ -176,7 +216,11 @@ - grub_printf("Failed to read splash image (%s)\n", splashimage); - grub_printf("Press any key to continue..."); - getkey(); -+#ifdef __MINIOS__ -+ fb_close(); -+#else - set_videomode(saved_videomode); -+#endif - graphics_inited =3D 0; - return 0; - } -@@ -190,8 +234,13 @@ - void graphics_end(void) - { - if (graphics_inited) { -+#ifdef __MINIOS__ -+ fb_close(); -+ free(VIDEOMEM); -+#else - unset_int1c_handler(); - set_videomode(saved_videomode); -+#endif - graphics_inited =3D 0; - no_cursor =3D 0; - } -@@ -204,15 +253,19 @@ - graphics_cursor(0); -=20 - if (ch =3D=3D '\n') { -+ fbfront_update(fb_dev, cursorX, cursorY, 8, 16); - if (fonty + 1 < view_y1) - graphics_setxy(fontx, fonty + 1); - else - graphics_scroll(); - graphics_cursor(1); -+ fbfront_update(fb_dev, cursorX, cursorY, 8, 16); - return; - } else if (ch =3D=3D '\r') { -+ fbfront_update(fb_dev, cursorX, cursorY, 8, 16); - graphics_setxy(view_x0, fonty); - graphics_cursor(1); -+ fbfront_update(fb_dev, cursorX, cursorY, 8, 16); - return; - } -=20 -@@ -224,6 +277,7 @@ - text[fonty * 80 + fontx] |=3D 0x100; -=20 - graphics_cursor(0); -+ fbfront_update(fb_dev, cursorX, cursorY, 8, 16); -=20 - if ((fontx + 1) >=3D view_x1) { - graphics_setxy(view_x0, fonty); -@@ -232,13 +286,16 @@ - else - graphics_scroll(); - graphics_cursor(1); -+ fbfront_update(fb_dev, cursorX, cursorY, 8, 16); - do_more (); - graphics_cursor(0); -+ fbfront_update(fb_dev, cursorX, cursorY, 8, 16); - } else { - graphics_setxy(fontx + 1, fonty); - } -=20 - graphics_cursor(1); -+ fbfront_update(fb_dev, cursorX, cursorY, 8, 16); - } -=20 - /* get the current location of the cursor */ -@@ -248,10 +305,12 @@ -=20 - void graphics_gotoxy(int x, int y) { - graphics_cursor(0); -+ fbfront_update(fb_dev, cursorX, cursorY, 8, 16); -=20 - graphics_setxy(x, y); -=20 - graphics_cursor(1); -+ fbfront_update(fb_dev, cursorX, cursorY, 8, 16); - } -=20 - void graphics_cls(void) { -@@ -262,15 +321,21 @@ - graphics_gotoxy(view_x0, view_y0); -=20 - mem =3D (unsigned char*)VIDEOMEM; -+#ifndef __MINIOS__ - s1 =3D (unsigned char*)VSHADOW1; - s2 =3D (unsigned char*)VSHADOW2; - s4 =3D (unsigned char*)VSHADOW4; - s8 =3D (unsigned char*)VSHADOW8; -+#endif -=20 - for (i =3D 0; i < 80 * 30; i++) - text[i] =3D ' '; - graphics_cursor(1); -=20 -+#ifdef __MINIOS__ -+ memcpy(mem, VSHADOW, RAMSIZE); -+ fbfront_update(fb_dev, 0, 0, 640, 480); -+#else - BitMask(0xff); -=20 - /* plane 1 */ -@@ -290,6 +355,7 @@ - grub_memcpy(mem, s8, 38400); -=20 - MapMask(15); -+#endif -=20 - if (no_cursor) { - no_cursor =3D 0; -@@ -337,6 +403,11 @@ - return 0; - } -=20 -+void graphics_set_palette(int idx, int red, int green, int blue) -+{ -+ palette[idx] =3D (red << (16 + 2)) | (green << (8 + 2)) | (blue << 2); -+} -+ - /* Read in the splashscreen image and set the palette up appropriately. - * Format of splashscreen is an xpm (can be gzipped) with 16 colors and - * 640x480. */ -@@ -413,18 +484,19 @@ - } -=20 - if (len =3D=3D 6 && idx < 15) { -- int r =3D ((hex(buf[0]) << 4) | hex(buf[1])) >> 2; -- int g =3D ((hex(buf[2]) << 4) | hex(buf[3])) >> 2; -- int b =3D ((hex(buf[4]) << 4) | hex(buf[5])) >> 2; -+ int r =3D ((hex(buf[0]) << 4) | hex(buf[1])); -+ int g =3D ((hex(buf[2]) << 4) | hex(buf[3])); -+ int b =3D ((hex(buf[4]) << 4) | hex(buf[5])); -=20 - pal[idx] =3D base; -- graphics_set_palette(idx, r, g, b); -+ graphics_set_palette(idx, r / 4, g / 4, b / 4); - ++idx; - } - } -=20 - x =3D y =3D len =3D 0; -=20 -+#ifndef __MINIOS__ - s1 =3D (unsigned char*)VSHADOW1; - s2 =3D (unsigned char*)VSHADOW2; - s4 =3D (unsigned char*)VSHADOW4; -@@ -432,6 +504,7 @@ -=20 - for (i =3D 0; i < 38400; i++) - s1[i] =3D s2[i] =3D s4[i] =3D s8[i] =3D 0; -+#endif -=20 - /* parse xpm data */ - while (y < height) { -@@ -451,6 +524,9 @@ - break; - } -=20 -+#ifdef __MINIOS__ -+ VSHADOW[x + y * 640] =3D palette[i]; -+#else - mask =3D 0x80 >> (x & 7); - if (c & 1) - s1[len + (x >> 3)] |=3D mask; -@@ -460,6 +536,7 @@ - s4[len + (x >> 3)] |=3D mask; - if (c & 8) - s8[len + (x >> 3)] |=3D mask; -+#endif -=20 - if (++x >=3D 640) { - x =3D 0; -@@ -494,7 +571,13 @@ - } -=20 - void graphics_cursor(int set) { -- unsigned char *pat, *mem, *ptr, chr[16 << 2]; -+ unsigned char *pat; -+#ifdef __MINIOS__ -+ uint32_t *mem, *ptr, chr[16 * 8]; -+ int j; -+#else -+ unsigned char *mem, *ptr, chr[16 << 2]; -+#endif - int i, ch, invert, offset; -=20 - if (set && (no_cursor || no_scroll)) -@@ -505,71 +588,127 @@ - invert =3D (text[fonty * 80 + fontx] & 0xff00) !=3D 0; - pat =3D font8x16 + (ch << 4); -=20 -- mem =3D (unsigned char*)VIDEOMEM + offset; -+ mem =3D (unsigned char*)VIDEOMEM + offset -+#ifdef __MINIOS__ -+ * 8 * 4 -+#endif -+ ; -=20 - if (!set) { - for (i =3D 0; i < 16; i++) { - unsigned char mask =3D pat[i]; -=20 - if (!invert) { -+#ifdef __MINIOS__ -+ memcpy(chr + i * 8, VSHADOW + offset * 8, 8 * 4); -+#else - chr[i ] =3D ((unsigned char*)VSHADOW1)[offset]; - chr[16 + i] =3D ((unsigned char*)VSHADOW2)[offset]; - chr[32 + i] =3D ((unsigned char*)VSHADOW4)[offset]; - chr[48 + i] =3D ((unsigned char*)VSHADOW8)[offset]; -+#endif -=20 - if (shade) { - if (ch =3D=3D DISP_VERT || ch =3D=3D DISP_LL || - ch =3D=3D DISP_UR || ch =3D=3D DISP_LR) { - unsigned char pmask =3D ~(pat[i] >> 1); -=20 -+#ifdef __MINIOS__ -+ for (j =3D 0; j < 8; j++) -+ if (!(pmask & (1U << j))) -+ chr[i * 8 + (7 - j)] =3D palette[0]; -+#else - chr[i ] &=3D pmask; - chr[16 + i] &=3D pmask; - chr[32 + i] &=3D pmask; - chr[48 + i] &=3D pmask; -+#endif - } - if (i > 0 && ch !=3D DISP_VERT) { - unsigned char pmask =3D ~(pat[i - 1] >> 1); -=20 -+#ifdef __MINIOS__ -+ for (j =3D 0; j < 8; j++) -+ if (!(pmask & (1U << j))) -+ chr[i * 8 + (7 - j)] =3D palette[0]; -+#else - chr[i ] &=3D pmask; - chr[16 + i] &=3D pmask; - chr[32 + i] &=3D pmask; - chr[48 + i] &=3D pmask; -+#endif - if (ch =3D=3D DISP_HORIZ || ch =3D=3D DISP_UR || = ch =3D=3D DISP_LR) { - pmask =3D ~pat[i - 1]; -=20 -+#ifdef __MINIOS__ -+ for (j =3D 0; j < 8; j++) -+ if (!(pmask & (1U << j))) -+ chr[i * 8 + (7 - j)] =3D palette[0]; -+#else - chr[i ] &=3D pmask; - chr[16 + i] &=3D pmask; - chr[32 + i] &=3D pmask; - chr[48 + i] &=3D pmask; -+#endif - } - } - } -+#ifdef __MINIOS__ -+ for (j =3D 0; j < 8; j++) -+ if (mask & (1U << j)) -+ chr[i * 8 + (7 - j)] =3D palette[15]; -+#else - chr[i ] |=3D mask; - chr[16 + i] |=3D mask; - chr[32 + i] |=3D mask; - chr[48 + i] |=3D mask; -+#endif -=20 - offset +=3D 80; - } - else { -+#ifdef __MINIOS__ -+ for (j =3D 0; j < 8; j++) -+ if (mask & (1U << j)) -+ chr[i * 8 + (7 - j)] =3D palette[15]; -+ else -+ chr[i * 8 + (7 - j)] =3D palette[0]; -+#else - chr[i ] =3D mask; - chr[16 + i] =3D mask; - chr[32 + i] =3D mask; - chr[48 + i] =3D mask; -+#endif - } - } - } - else { -+#ifdef __MINIOS__ -+ ptr =3D mem; -+ for (i =3D 0; i < 16; i++, ptr +=3D 80 * 8) -+ for (j =3D 0; j < 8; j++) { -+ if (pat[i] & (1U << (7 - j))) -+ cursorBuf32[i * 8 + j] =3D ptr[j] =3D palette[0]; -+ else -+ cursorBuf32[i * 8 + j] =3D ptr[j] =3D palette[15]; -+ } -+#else - MapMask(15); - ptr =3D mem; - for (i =3D 0; i < 16; i++, ptr +=3D 80) { - cursorBuf[i] =3D pat[i]; - *ptr =3D ~pat[i]; - } -+#endif - return; - } -=20 - offset =3D 0; -+#ifdef __MINIOS__ -+ ptr =3D mem; -+ for (j =3D 0; j < 16; j++, ptr +=3D 80 * 8) -+ memcpy(ptr, chr + j * 8 + offset * 8, 8 * 4); -+#else - for (i =3D 1; i < 16; i <<=3D 1, offset +=3D 16) { - int j; -=20 -@@ -580,6 +719,7 @@ - } -=20 - MapMask(15); -+#endif - } -=20 - #endif /* SUPPORT_GRAPHICS */ -Index: grub/stage2/graphics.h -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/graphics.h 2008-06-16 15:18:14.527010000 +0100 -+++ grub/stage2/graphics.h 2008-06-16 15:18:14.805010000 +0100 -@@ -21,8 +21,10 @@ - #ifndef GRAPHICS_H - #define GRAPHICS_H -=20 -+#ifndef __MINIOS__ - /* magic constant */ - #define VIDEOMEM 0xA0000 -+#endif -=20 - /* function prototypes */ - char *graphics_get_splash(void); -Index: grub/stage2/stage2.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D ---- grub.orig/stage2/stage2.c 2008-06-17 11:06:47.873523000 +0100 -+++ grub/stage2/stage2.c 2008-06-17 11:07:05.225628000 +0100 -@@ -31,10 +31,10 @@ - #if defined(PRESET_MENU_STRING) || defined(SUPPORT_DISKLESS) -=20 - # if defined(PRESET_MENU_STRING) --static const char *preset_menu =3D PRESET_MENU_STRING; -+const char *preset_menu =3D PRESET_MENU_STRING; - # elif defined(SUPPORT_DISKLESS) - /* Execute the command "bootp" automatically. */ --static const char *preset_menu =3D "bootp\n"; -+const char *preset_menu =3D "bootp\n"; - # endif /* SUPPORT_DISKLESS */ -=20 - static int preset_menu_offset; -Index: grub/stage2/fsys_xfs.c -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -RCS file: /sources/grub/grub/stage2/fsys_xfs.c,v -retrieving revision 1.5 -diff -u -p -r1.5 fsys_xfs.c ---- grub/stage2/fsys_xfs.c 8 May 2005 02:18:14 -0000 1.5 -+++ grub/stage2/fsys_xfs.c 10 Jul 2008 13:09:50 -0000 -@@ -101,7 +101,7 @@ static inline __const__ xfs_uint16_t - le16 (xfs_uint16_t x) - { - __asm__("xchgb %b0,%h0" \ -- : "=3Dq" (x) \ -+ : "=3DQ" (x) \ - : "0" (x)); \ - return x; - } -@@ -109,9 +109,9 @@ le16 (xfs_uint16_t x) - static inline __const__ xfs_uint32_t - le32 (xfs_uint32_t x) - { --#if 0 -+#if 1 - /* 386 doesn't have bswap. */ -- __asm__("bswap %0" : "=3Dr" (x) : "0" (x)); -+ __asm__("bswapl %k0" : "=3Dr" (x) : "0" (x)); - #else - /* This is slower but this works on all x86 architectures. */ - __asm__("xchgb %b0, %h0" \ ---- grub.orig/stage2/gunzip.c 2010-03-07 23:03:34.000000000 +0100 -+++ grub/stage2/gunzip.c 2010-03-07 23:05:36.000000000 +0100 -@@ -141,7 +141,7 @@ - static int gzip_filemax; - static int gzip_fsmax; - static int saved_filepos; --static unsigned long gzip_crc; -+static unsigned int gzip_crc; -=20 - /* internal extra variables for use of inflate code */ - static int block_type; -@@ -157,7 +157,7 @@ - * Linear allocator. - */ -=20 --static unsigned long linalloc_topaddr; -+static unsigned int linalloc_topaddr; -=20 - static void * - linalloc (int size) -@@ -253,7 +253,7 @@ -=20 - typedef unsigned char uch; - typedef unsigned short ush; --typedef unsigned long ulg; -+typedef unsigned int ulg; -=20 - /* - * Window Size -@@ -316,8 +316,8 @@ - return 0; - } -=20 -- gzip_crc =3D *((unsigned long *) buf); -- gzip_fsmax =3D gzip_filemax =3D *((unsigned long *) (buf + 4)); -+ gzip_crc =3D *((unsigned int *) buf); -+ gzip_fsmax =3D gzip_filemax =3D *((unsigned int *) (buf + 4)); -=20 - initialize_tables (); -=20 -diff -ur grub.orig/stage2/fsys_iso9660.c grub-upstream/stage2/fsys_iso9660= .c ---- grub.orig/stage2/fsys_iso9660.c 2010-03-07 23:39:00.000000000 +0100 -+++ grub/stage2/fsys_iso9660.c 2010-03-07 23:39:56.000000000 +0100 -@@ -43,7 +43,7 @@ -=20 - /* iso fs inode data in memory */ - struct iso_inode_info { -- unsigned long file_start; -+ unsigned int file_start; - }; -=20 - #define ISO_SUPER \ -@@ -88,12 +88,12 @@ - if (byte_len <=3D 0) - return 1; -=20 -- sector +=3D (byte_offset >> sector_size_lg2); -- byte_offset &=3D (buf_geom.sector_size - 1); - asm volatile ("shl%L0 %1,%0" - : "=3Dr"(sector) - : "Ic"((int8_t)(ISO_SECTOR_BITS - sector_size_lg2)), - "0"(sector)); -+ sector +=3D (byte_offset >> sector_size_lg2); -+ byte_offset &=3D (buf_geom.sector_size - 1); -=20 - #if !defined(STAGE1_5) - if (disk_read_hook && debug) diff --git a/stubdom/grub/Makefile b/stubdom/grub/Makefile deleted file mode 100644 index 7397661c9b..0000000000 --- a/stubdom/grub/Makefile +++ /dev/null @@ -1,88 +0,0 @@ -XEN_ROOT =3D $(CURDIR)/../.. - -include $(XEN_ROOT)/Config.mk -vpath %.c ../grub-upstream - -BOOT=3D$(OBJ_DIR)/boot-$(XEN_TARGET_ARCH).o - -DEF_CPPFLAGS +=3D -I$(XEN_ROOT)/tools/libs/toollog/include -DEF_CPPFLAGS +=3D -I$(XEN_ROOT)/tools/libs/ctrl/include -DEF_CPPFLAGS +=3D -I$(XEN_ROOT)/tools/libs/guest/include -DEF_CPPFLAGS +=3D -I$(XEN_ROOT)/tools/include -I. -DEF_CPPFLAGS +=3D -I../grub-upstream/stage1 -DEF_CPPFLAGS +=3D -I../grub-upstream/stage2 -DEF_CPPFLAGS +=3D -I../grub-upstream/netboot -DEF_CPPFLAGS +=3D -I$(XEN_ROOT)/tools/firmware/vgabios -DEF_CPPFLAGS +=3D -DWITHOUT_LIBC_STUBS -DEF_CPPFLAGS +=3D -DSUPPORT_NETBOOT -DEF_CPPFLAGS +=3D -DSUPPORT_GRAPHICS -DEF_CPPFLAGS +=3D -DSUPPORT_SERIAL -DEF_CPPFLAGS +=3D -DPRESET_MENU_STRING=3D'""' -DEF_CPPFLAGS +=3D -DPACKAGE=3D'"grubdom"' -DVERSION=3D'"0.97"' - -all: $(OBJ_DIR)/main.a - -STAGE2_SOURCES=3Dbuiltins.c char_io.c cmdline.c common.c console.c disk_io= .c graphics.c gunzip.c md5.c serial.c stage2.c terminfo.c tparm.c - -NETBOOT_SOURCES=3Dfsys_tftp.c main.c misc.c -CPPFLAGS +=3D -DFSYS_TFTP=3D1 - -STAGE2_SOURCES+=3Dfsys_ext2fs.c -CPPFLAGS +=3D -DFSYS_EXT2FS=3D1 - -STAGE2_SOURCES+=3Dfsys_fat.c -CPPFLAGS +=3D -DFSYS_FAT=3D1 - -STAGE2_SOURCES+=3Dfsys_ffs.c -CPPFLAGS +=3D -DFSYS_FFS=3D1 - -STAGE2_SOURCES+=3Dfsys_iso9660.c -CPPFLAGS +=3D -DFSYS_ISO9660=3D1 - -STAGE2_SOURCES+=3Dfsys_jfs.c -CPPFLAGS +=3D -DFSYS_JFS=3D1 - -STAGE2_SOURCES+=3Dfsys_minix.c -CPPFLAGS +=3D -DFSYS_MINIX=3D1 - -STAGE2_SOURCES+=3Dfsys_reiserfs.c -CPPFLAGS +=3D -DFSYS_REISERFS=3D1 - -STAGE2_SOURCES+=3Dfsys_ufs2.c -CPPFLAGS +=3D -DFSYS_UFS2=3D1 - -STAGE2_SOURCES+=3Dfsys_vstafs.c -CPPFLAGS +=3D -DFSYS_VSTAFS=3D1 - -STAGE2_SOURCES+=3Dfsys_xfs.c -CPPFLAGS +=3D -DFSYS_XFS=3D1 - -STAGE2_SOURCES:=3D$(addprefix stage2/,$(STAGE2_SOURCES)) -NETBOOT_SOURCES:=3D$(addprefix netboot/,$(NETBOOT_SOURCES)) - -$(BOOT): DEF_CPPFLAGS+=3D-D__ASSEMBLY__ - -PV_GRUB_SOURCES =3D kexec.c mini-os.c -PV_GRUB_SOURCES +=3D ../polarssl-$(XEN_TARGET_ARCH)/library/sha1.o - -SOURCES =3D $(NETBOOT_SOURCES) $(STAGE2_SOURCES) $(PV_GRUB_SOURCES) - -OBJS =3D $(addprefix $(OBJ_DIR)/,$(SOURCES:.c=3D.o)) - -$(OBJ_DIR)/dirs: - mkdir -p $(OBJ_DIR)/netboot $(OBJ_DIR)/stage2 - touch $@ - -$(OBJS): $(OBJ_DIR)/dirs - -$(OBJ_DIR)/main.a: $(BOOT) $(OBJS) - $(AR) cr $@ $^ - -$(OBJ_DIR)/%.o: %.c - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ - -$(OBJ_DIR)/%.o: %.S - $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ - -clean: - rm -fr dirs *.a *.o stage2 netboot diff --git a/stubdom/grub/boot-x86_32.S b/stubdom/grub/boot-x86_32.S deleted file mode 100644 index c95fd30dd3..0000000000 --- a/stubdom/grub/boot-x86_32.S +++ /dev/null @@ -1,112 +0,0 @@ -#include -#include -#include - -/* For simplicity, we keep all of this into just one data page */ -.data -.globl _boot_page -_boot_page: - .align __PAGE_SIZE - -/* - * The following data is initialized from C code - */ - -/* Pte of this page */ -.globl _boot_page_entry -_boot_page_entry: -_boot_page_entry_lo: - .long 0 -_boot_page_entry_hi: - .long 0 - -/* mmuext_op structure */ -/* Set new page directory */ -_boot_mmuext: - /* Op # */ - .long MMUEXT_NEW_BASEPTR - - /* MFN of target page table directory */ -.globl _boot_pdmfn -_boot_pdmfn: - .long 0 - - /* Unused */ - .long 0 - -/* Unpin old page directory */ - /* Op # */ - .long MMUEXT_UNPIN_TABLE - - /* MFN of old page table directory */ -.globl _boot_oldpdmfn -_boot_oldpdmfn: - .long 0 - - /* Unused */ - .long 0 - -/* Target stack address, also target virtual address of this page */ -.globl _boot_stack -_boot_stack: - .long 0 - .long __KERNEL_SS -.globl _boot_target -_boot_target: - .long 0 - -/* Target start info */ -.globl _boot_start_info -_boot_start_info: - .long 0 - -/* Target start address */ -.globl _boot_start -_boot_start: - .long 0 - -/* - * Boot target OS, does not return - */ -.globl _boot -_boot: - /* Project ourselves at the target place. */ - movl _boot_target, %ebx - movl %ebx, %ebp /* also keep it in ebp for relative address= ing */ - movl _boot_page_entry_lo, %ecx - movl _boot_page_entry_hi, %edx - movl $2, %esi /* UVMF_INVLPG */ - movl $__HYPERVISOR_update_va_mapping, %eax - int $0x82 - testl %eax, %eax - jz 0f - ud2 - -0: - /* Go there. */ - movl $(0f - _boot_page), %eax - movl _boot_target, %ebx - addl %ebx, %eax - jmpl *%eax -0: - =20 - /* Load target page table and unpin old page table. */ - /* We shouldn't have any problem since in the new page table our p= age is - mapped at the same place. */ - leal (_boot_mmuext-_boot_page)(%ebp), %ebx - movl $2, %ecx - xorl %edx, %edx - movl $0x7FF0, %esi /* DOMID_SELF */ - movl $__HYPERVISOR_mmuext_op, %eax - int $0x82 - testl %eax, %eax - jns 0f - ud2 - -0: - /* Initialize registers. */ - lss (_boot_stack-_boot_page)(%ebp), %esp - movl (_boot_start_info-_boot_page)(%ebp), %esi - - /* Jump! */ - jmpl *(_boot_start-_boot_page)(%ebp) diff --git a/stubdom/grub/boot-x86_64.S b/stubdom/grub/boot-x86_64.S deleted file mode 100644 index 2eae6c3437..0000000000 --- a/stubdom/grub/boot-x86_64.S +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include -#include - -/* For simplicity, we keep all of this into just one data page */ -.data -.globl _boot_page -_boot_page: - .align __PAGE_SIZE - -/* - * The following data is initialized from C code - */ - -/* Pte of this page */ -.globl _boot_page_entry -_boot_page_entry: - .quad 0 - -/* mmuext_op structure */ -/* Set new page directory */ -_boot_mmuext: - /* Op # */ - .long MMUEXT_NEW_BASEPTR - .long 0 /* pad */ - - /* MFN of target page table directory */ -.globl _boot_pdmfn -_boot_pdmfn: - .quad 0 - - /* Unused */ - .quad 0 - -/* Unpin old page directory */ - /* Op # */ - .long MMUEXT_UNPIN_TABLE - .long 0 /* pad */ - - /* MFN of old page table directory */ -.globl _boot_oldpdmfn -_boot_oldpdmfn: - .quad 0 - - /* Unused */ - .quad 0 - -/* Target stack address, also target virtual address of this page */ -.globl _boot_stack -_boot_stack: - .quad 0 -.globl _boot_target -_boot_target: - .quad 0 - -/* Target start info */ -.globl _boot_start_info -_boot_start_info: - .quad 0 - -/* Target start address */ -.globl _boot_start -_boot_start: - .quad 0 - -/* - * Boot target OS, does not return - */ -.globl _boot -_boot: - /* Project ourselves at the target place. */ - movq _boot_target, %rdi - movq _boot_page_entry, %rsi - movq $2, %rdx /* UVMF_INVLPG */ - movq $__HYPERVISOR_update_va_mapping, %rax - syscall - testq %rax, %rax - jz 0f - ud2 - -0: - /* Go there. */ - movq $(0f - _boot_page), %rax - movq _boot_target, %rbx - addq %rbx, %rax - jmpq *%rax -0: - =20 - /* Load target page table and unpin old page table. */ - /* We shouldn't have any problem since in the new page table our p= age is - mapped at the same place. */ - leaq _boot_mmuext(%rip), %rdi - movq $2, %rsi - xorq %rdx, %rdx - movq $0x7FF0, %r10 /* DOMID_SELF */ - movq $__HYPERVISOR_mmuext_op, %rax - syscall - testq %rax, %rax - jns 0f - ud2 - -0: - /* Initialize registers. */ - movq _boot_stack(%rip), %rsp - movq _boot_start_info(%rip), %rsi - - /* Jump! */ - jmpq *_boot_start(%rip) diff --git a/stubdom/grub/config.h b/stubdom/grub/config.h deleted file mode 100644 index 15a6583999..0000000000 --- a/stubdom/grub/config.h +++ /dev/null @@ -1,12 +0,0 @@ -#include -#undef putchar -#include -#include -#include -#define debug _debug -#define grub_halt(a) do_exit() -#define printf grub_printf -void kexec(void *kernel, long kernel_size, void *module, long module_size,= char *cmdline, unsigned long flags); -struct fbfront_dev *fb_open(void *fb, int width, int height, int depth); -void fb_close(void); -void pv_boot (void); diff --git a/stubdom/grub/kexec.c b/stubdom/grub/kexec.c deleted file mode 100644 index 92646ad8cd..0000000000 --- a/stubdom/grub/kexec.c +++ /dev/null @@ -1,434 +0,0 @@ -/* - * This supports booting another PV kernel from Mini-OS - * - * The idea is to setup it using libxc, answer to day0 memory allocation - * requests, and using a trampoline boot page to switch to the new page ta= ble. - * - * The procedure of the boot page is: - * - map itself at the target position (that may overwrite some C stuff, b= ut we - * do not care any more) - * - jump there - * - switch to the target page table - * - unpin the old page table - * - jump to the new kernel - * - * Samuel Thibault , May 2008 - */ -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mini-os.h" - -#undef start_info - -#if 0 -#define DEBUG(fmt, ...) printk(fmt, ## __VA_ARGS__) -#else -#define DEBUG(fmt, ...) (void)0 -#endif - -/* Assembly boot page from boot.S */ -extern void _boot_page; -extern pgentry_t _boot_page_entry; -extern unsigned long _boot_pdmfn; -extern unsigned long _boot_stack, _boot_target, _boot_start_info, _boot_st= art; -extern xen_pfn_t _boot_oldpdmfn; -extern void _boot(void); - -static unsigned long *pages; -static unsigned long *pages_mfns; -static xen_pfn_t *pages_moved2pfns; -static unsigned long allocated; - -int pin_table(xc_interface *xc_handle, unsigned int type, unsigned long mf= n, - domid_t dom); - -#define TPM_TAG_RQU_COMMAND 0xC1 -#define TPM_ORD_Extend 20 - -struct pcr_extend_cmd { - uint16_t tag; - uint32_t size; - uint32_t ord; - - uint32_t pcr; - unsigned char hash[20]; -} __attribute__((packed)); - -struct pcr_extend_rsp { - uint16_t tag; - uint32_t size; - uint32_t status; - - unsigned char hash[20]; -} __attribute__((packed)); - -/* Not imported from polarssl's header since the prototype unhelpfully def= ines - * the input as unsigned char, which causes pointer type mismatches */ -void sha1(const void *input, size_t ilen, unsigned char output[20]); - -/* We need mfn to appear as target_pfn, so exchange with the MFN there */ -static void do_exchange(struct xc_dom_image *dom, xen_pfn_t target_pfn, xe= n_pfn_t source_mfn) -{ - xen_pfn_t source_pfn; - xen_pfn_t target_mfn; - - for (source_pfn =3D 0; source_pfn < start_info_ptr->nr_pages; source_p= fn++) - if (dom->pv_p2m[source_pfn] =3D=3D source_mfn) - break; - ASSERT(source_pfn < start_info_ptr->nr_pages); - - target_mfn =3D dom->pv_p2m[target_pfn]; - - /* Put target MFN at source PFN */ - dom->pv_p2m[source_pfn] =3D target_mfn; - - /* Put source MFN at target PFN */ - dom->pv_p2m[target_pfn] =3D source_mfn; -} - -int kexec_allocate(struct xc_dom_image *dom) -{ - unsigned long new_allocated =3D dom->pfn_alloc_end - dom->rambase_pfn; - unsigned long i; - - pages =3D realloc(pages, new_allocated * sizeof(*pages)); - pages_mfns =3D realloc(pages_mfns, new_allocated * sizeof(*pages_mfns)= ); - pages_moved2pfns =3D realloc(pages_moved2pfns, new_allocated * sizeof(= *pages_moved2pfns)); - for (i =3D allocated; i < new_allocated; i++) { - /* Exchange old page of PFN i with a newly allocated page. */ - xen_pfn_t old_mfn =3D dom->pv_p2m[i]; - xen_pfn_t new_pfn; - xen_pfn_t new_mfn; - - pages[i] =3D alloc_page(); - memset((void*) pages[i], 0, PAGE_SIZE); - new_pfn =3D PHYS_PFN(to_phys(pages[i])); - pages_mfns[i] =3D new_mfn =3D pfn_to_mfn(new_pfn); - - /* - * If PFN of newly allocated page (new_pfn) is less then currently - * requested PFN (i) then look for relevant PFN/MFN pair. In this - * situation dom->pv_p2m[new_pfn] no longer contains proper MFN - * because original page with new_pfn was moved earlier - * to different location. - */ - for (; new_pfn < i; new_pfn =3D pages_moved2pfns[new_pfn]); - - /* Store destination PFN of currently requested page. */ - pages_moved2pfns[i] =3D new_pfn; - - /* Put old page at new PFN */ - dom->pv_p2m[new_pfn] =3D old_mfn; - - /* Put new page at PFN i */ - dom->pv_p2m[i] =3D new_mfn; - } - - allocated =3D new_allocated; - - return 0; -} - -/* Filled from mini-os command line or left as NULL */ -char *vtpm_label; - -static void tpm_hash2pcr(struct xc_dom_image *dom, char *cmdline) -{ - struct tpmfront_dev* tpm =3D init_tpmfront(NULL); - struct pcr_extend_rsp *resp; - size_t resplen =3D 0; - struct pcr_extend_cmd cmd; - int rv; - - /* - * If vtpm_label was specified on the command line, require a vTPM to be - * attached and for the domain providing the vTPM to have the given - * label. - */ - if (vtpm_label) { - char ctx[128]; - if (!tpm) { - printf("No TPM found and vtpm_label specified, aborting!\n"); - do_exit(); - } - rv =3D evtchn_get_peercontext(tpm->evtchn, ctx, sizeof(ctx) - 1); - if (rv < 0) { - printf("Could not verify vtpm_label: %d\n", rv); - do_exit(); - } - ctx[127] =3D 0; - rv =3D strcmp(ctx, vtpm_label); - if (rv && vtpm_label[0] =3D=3D '*') { - int match_len =3D strlen(vtpm_label) - 1; - int offset =3D strlen(ctx) - match_len; - if (offset > 0) - rv =3D strcmp(ctx + offset, vtpm_label + 1); - } - - if (rv) { - printf("Mismatched vtpm_label: '%s' !=3D '%s'\n", ctx, vtpm_label); - do_exit(); - } - } else if (!tpm) { - return; - } - - cmd.tag =3D bswap_16(TPM_TAG_RQU_COMMAND); - cmd.size =3D bswap_32(sizeof(cmd)); - cmd.ord =3D bswap_32(TPM_ORD_Extend); - cmd.pcr =3D bswap_32(4); // PCR #4 for kernel - sha1(dom->kernel_blob, dom->kernel_size, cmd.hash); - - rv =3D tpmfront_cmd(tpm, (void*)&cmd, sizeof(cmd), (void*)&resp, &resplen= ); - ASSERT(rv =3D=3D 0 && resp->status =3D=3D 0); - - cmd.pcr =3D bswap_32(5); // PCR #5 for cmdline - sha1(cmdline, strlen(cmdline), cmd.hash); - rv =3D tpmfront_cmd(tpm, (void*)&cmd, sizeof(cmd), (void*)&resp, &resplen= ); - ASSERT(rv =3D=3D 0 && resp->status =3D=3D 0); - - cmd.pcr =3D bswap_32(5); // PCR #5 for initrd - sha1(dom->modules[0].blob, dom->modules[0].size, cmd.hash); - rv =3D tpmfront_cmd(tpm, (void*)&cmd, sizeof(cmd), (void*)&resp, &resplen= ); - ASSERT(rv =3D=3D 0 && resp->status =3D=3D 0); - - shutdown_tpmfront(tpm); -} - -void kexec(void *kernel, long kernel_size, void *module, long module_size,= char *cmdline, unsigned long flags) -{ - struct xc_dom_image *dom; - int rc; - domid_t domid =3D DOMID_SELF; - xen_pfn_t pfn; - xc_interface *xc_handle; - unsigned long i; - void *seg; - xen_pfn_t boot_page_mfn =3D virt_to_mfn(&_boot_page); - char features[] =3D ""; - struct mmu_update *m2p_updates; - unsigned long nr_m2p_updates; - uint64_t virt_base; - - DEBUG("booting with cmdline %s\n", cmdline); - xc_handle =3D xc_interface_open(0,0,0); - - dom =3D xc_dom_allocate(xc_handle, cmdline, features); - dom->allocate =3D kexec_allocate; - - /* We are using guest owned memory, therefore no limits. */ - xc_dom_kernel_max_size(dom, 0); - xc_dom_module_max_size(dom, 0); - - dom->kernel_blob =3D kernel; - dom->kernel_size =3D kernel_size; - - xc_dom_module_mem(dom, module, module_size, NULL); - - dom->flags =3D flags; - dom->console_evtchn =3D start_info_ptr->console.domU.evtchn; - dom->xenstore_evtchn =3D start_info_ptr->store_evtchn; - - tpm_hash2pcr(dom, cmdline); - - if ( (rc =3D xc_dom_boot_xen_init(dom, xc_handle, domid)) !=3D 0 ) { - printk("xc_dom_boot_xen_init returned %d\n", rc); - errnum =3D ERR_BOOT_FAILURE; - goto out; - } - if ( (rc =3D xc_dom_parse_image(dom)) !=3D 0 ) { - printk("xc_dom_parse_image returned %d\n", rc); - errnum =3D ERR_BOOT_FAILURE; - goto out; - } - -#ifdef __i386__ - if (strcmp(dom->guest_type, "xen-3.0-x86_32p")) { - printk("can only boot x86 32 PAE kernels, not %s\n", dom->guest_ty= pe); - errnum =3D ERR_EXEC_FORMAT; - goto out; - } -#endif -#ifdef __x86_64__ - if (strcmp(dom->guest_type, "xen-3.0-x86_64")) { - printk("can only boot x86 64 kernels, not %s\n", dom->guest_type); - errnum =3D ERR_EXEC_FORMAT; - goto out; - } -#endif - - /* equivalent of xc_dom_mem_init */ - if (xc_dom_set_arch_hooks(dom)) { - printk("xc_dom_set_arch_hooks failed\n"); - errnum =3D ERR_EXEC_FORMAT; - goto out; - } - dom->total_pages =3D start_info_ptr->nr_pages; - - /* equivalent of arch_setup_meminit */ - dom->p2m_size =3D dom->total_pages; - - /* setup initial p2m */ - dom->pv_p2m =3D malloc(sizeof(*dom->pv_p2m) * dom->p2m_size); - - /* Start with our current P2M */ - for (i =3D 0; i < dom->p2m_size; i++) - dom->pv_p2m[i] =3D pfn_to_mfn(i); - - if ( (rc =3D xc_dom_build_image(dom)) !=3D 0 ) { - printk("xc_dom_build_image returned %d\n", rc); - errnum =3D ERR_BOOT_FAILURE; - goto out; - } - - virt_base =3D xc_dom_virt_base(dom); - /* copy hypercall page */ - /* TODO: domctl instead, but requires privileges */ - if (xc_dom_virt_hypercall(dom) !=3D -1) { - pfn =3D PHYS_PFN(xc_dom_virt_hypercall(dom) - virt_base); - memcpy((void *) pages[pfn], hypercall_page, PAGE_SIZE); - } - - /* Equivalent of xc_dom_boot_image */ - dom->shared_info_mfn =3D PHYS_PFN(start_info_ptr->shared_info); - - if (!xc_dom_compat_check(dom)) { - printk("xc_dom_compat_check failed\n"); - errnum =3D ERR_EXEC_FORMAT; - goto out; - } - - /* Move current console, xenstore and boot MFNs to the allocated place= */ - do_exchange(dom, dom->console_pfn, start_info_ptr->console.domU.mfn); - do_exchange(dom, dom->xenstore_pfn, start_info_ptr->store_mfn); - DEBUG("virt base at %llx\n", virt_base); - DEBUG("bootstack_pfn %lx\n", dom->bootstack_pfn); - _boot_target =3D virt_base + PFN_PHYS(dom->bootstack_pfn); - DEBUG("_boot_target %lx\n", _boot_target); - do_exchange(dom, PHYS_PFN(_boot_target - virt_base), - virt_to_mfn(&_boot_page)); - - if ( dom->arch_hooks->setup_pgtables ) - if ( (rc =3D dom->arch_hooks->setup_pgtables(dom))) { - printk("setup_pgtables returned %d\n", rc); - errnum =3D ERR_BOOT_FAILURE; - goto out; - } - - /* start info page */ - if ( dom->arch_hooks->start_info ) - dom->arch_hooks->start_info(dom); - - xc_dom_log_memory_footprint(dom); - - /* Unmap libxc's projection of the boot page table */ - seg =3D xc_dom_seg_to_ptr(dom, &dom->pgtables_seg); - munmap(seg, dom->pgtables_seg.vend - dom->pgtables_seg.vstart); - seg =3D xc_dom_seg_to_ptr(dom, &dom->p2m_seg); - munmap(seg, dom->p2m_seg.vend - dom->p2m_seg.vstart); - - /* Unmap day0 pages to avoid having a r/w mapping of the future page t= able */ - for (pfn =3D 0; pfn < allocated; pfn++) - munmap((void*) pages[pfn], PAGE_SIZE); - - /* Pin the boot page table base */ - if ( (rc =3D pin_table(dom->xch, -#ifdef __i386__ - MMUEXT_PIN_L3_TABLE, -#endif -#ifdef __x86_64__ - MMUEXT_PIN_L4_TABLE, -#endif - xc_dom_p2m(dom, dom->pgtables_seg.pfn), - dom->guest_domid)) !=3D 0 ) { - printk("pin_table(%lx) returned %d\n", xc_dom_p2m(dom, - dom->pgtables_seg.pfn), rc); - errnum =3D ERR_BOOT_FAILURE; - goto out_remap; - } - - /* We populate the Mini-OS page table here so that boot.S can just call - * update_va_mapping to project itself there. */ - need_pgt(_boot_target); - DEBUG("day0 pages %lx\n", allocated); - DEBUG("boot target page %lx\n", _boot_target); - DEBUG("boot page %p\n", &_boot_page); - DEBUG("boot page mfn %lx\n", boot_page_mfn); - _boot_page_entry =3D PFN_PHYS(boot_page_mfn) | L1_PROT; - DEBUG("boot page entry %llx\n", _boot_page_entry); - _boot_oldpdmfn =3D virt_to_mfn(start_info_ptr->pt_base); - DEBUG("boot old pd mfn %lx\n", _boot_oldpdmfn); - DEBUG("boot pd virt %lx\n", dom->pgtables_seg.vstart); - _boot_pdmfn =3D dom->pv_p2m[PHYS_PFN(dom->pgtables_seg.vstart - virt_b= ase)]; - DEBUG("boot pd mfn %lx\n", _boot_pdmfn); - _boot_stack =3D _boot_target + PAGE_SIZE; - DEBUG("boot stack %lx\n", _boot_stack); - _boot_start_info =3D virt_base + PFN_PHYS(dom->start_info_pfn); - DEBUG("boot start info %lx\n", _boot_start_info); - _boot_start =3D xc_dom_virt_entry(dom); - DEBUG("boot start %lx\n", _boot_start); - - /* Keep only useful entries */ - for (nr_m2p_updates =3D pfn =3D 0; pfn < start_info_ptr->nr_pages; pfn= ++) - if (dom->pv_p2m[pfn] !=3D pfn_to_mfn(pfn)) - nr_m2p_updates++; - - m2p_updates =3D malloc(sizeof(*m2p_updates) * nr_m2p_updates); - for (i =3D pfn =3D 0; pfn < start_info_ptr->nr_pages; pfn++) - if (dom->pv_p2m[pfn] !=3D pfn_to_mfn(pfn)) { - m2p_updates[i].ptr =3D PFN_PHYS(dom->pv_p2m[pfn]) | MMU_MACHPH= YS_UPDATE; - m2p_updates[i].val =3D pfn; - i++; - } - - for (i =3D 0; i < blk_nb; i++) - shutdown_blkfront(blk_dev[i]); - if (net_dev) - shutdown_netfront(net_dev); - if (kbd_dev) - shutdown_kbdfront(kbd_dev); - stop_kernel(); - - /* Update M2P */ - if ((rc =3D HYPERVISOR_mmu_update(m2p_updates, nr_m2p_updates, NULL, D= OMID_SELF)) < 0) { - xprintk("Could not update M2P\n"); - ASSERT(0); - } - - xprintk("go!\n"); - - /* Jump to trampoline boot page */ - _boot(); - - ASSERT(0); - -out_remap: - for (pfn =3D 0; pfn < allocated; pfn++) - do_map_frames(pages[pfn], &pages_mfns[pfn], 1, 0, 0, DOMID_SELF, 0= , L1_PROT); -out: - xc_dom_release(dom); - for (pfn =3D 0; pfn < allocated; pfn++) - free_page((void*)pages[pfn]); - free(pages); - free(pages_mfns); - pages =3D NULL; - pages_mfns =3D NULL; - allocated =3D 0; - xc_interface_close(xc_handle ); -} diff --git a/stubdom/grub/mini-os.c b/stubdom/grub/mini-os.c deleted file mode 100644 index 4fc052a255..0000000000 --- a/stubdom/grub/mini-os.c +++ /dev/null @@ -1,771 +0,0 @@ -/* - * Mini-OS support for GRUB. - * - * Samuel Thibault , May 2008 - */ -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "mini-os.h" - -extern const char *preset_menu; -char config_file[DEFAULT_FILE_BUFLEN] =3D "(hd0,0)/boot/grub/menu.lst"; -unsigned long boot_drive =3D NETWORK_DRIVE; -unsigned long install_partition =3D 0xFFFFFF; - -char version_string[] =3D VERSION; - -/* Variables from asm.S */ -int saved_entryno; - -/* - * Disk - */ - -struct blkfront_dev **blk_dev; -int blk_nb; -static struct blkfront_info *blk_info; - -static int vbdcmp(const void *_vbd1, const void *_vbd2) { - char *vbd1 =3D *(char **)_vbd1; - char *vbd2 =3D *(char **)_vbd2; - int vbdn1 =3D atoi(vbd1); - int vbdn2 =3D atoi(vbd2); - return vbdn1 - vbdn2; -} - -void init_disk (void) -{ - char **list; - char *msg; - int i; - char *path; - - msg =3D xenbus_ls(XBT_NIL, "device/vbd", &list); - if (msg) { - printk("Error %s while reading list of disks\n", msg); - free(msg); - return; - } - blk_nb =3D 0; - while (list[blk_nb]) - blk_nb++; - blk_dev =3D malloc(blk_nb * sizeof(*blk_dev)); - blk_info =3D malloc(blk_nb * sizeof(*blk_info)); - - qsort(list, blk_nb, sizeof(*list), vbdcmp); - - for (i =3D 0; i < blk_nb; i++) { - printk("vbd %s is hd%d\n", list[i], i); - asprintf(&path, "device/vbd/%s", list[i]); - blk_dev[i] =3D init_blkfront(path, &blk_info[i]); - free(path); - free(list[i]); - } -} - -/* Return the geometry of DRIVE in GEOMETRY. If an error occurs, return - non-zero, otherwise zero. */ -int get_diskinfo (int drive, struct geometry *geometry) -{ - int i; - if (!(drive & 0x80)) - return -1; - - i =3D drive - 0x80; - if (i >=3D blk_nb) - return -1; - - /* Bogus geometry */ - geometry->cylinders =3D 65535; - geometry->heads =3D 255; - geometry->sectors =3D 63; - - geometry->total_sectors =3D blk_info[i].sectors; - geometry->sector_size =3D blk_info[i].sector_size; - geometry->flags =3D BIOSDISK_FLAG_LBA_EXTENSION; - if (blk_info[i].info & VDISK_CDROM) - geometry->flags |=3D BIOSDISK_FLAG_CDROM; - return 0; -} - -/* Read/write NSEC sectors starting from SECTOR in DRIVE disk with GEOMETRY - from/into SEGMENT segment. If READ is BIOSDISK_READ, then read it, - else if READ is BIOSDISK_WRITE, then write it. If an geometry error - occurs, return BIOSDISK_ERROR_GEOMETRY, and if other error occurs, then - return the error number. Otherwise, return 0. */ -int -biosdisk (int read, int drive, struct geometry *geometry, - unsigned int sector, int nsec, int segment) -{ - void *addr =3D (void *) ((unsigned long)segment << 4); - struct blkfront_aiocb aiocb; - int i; - - if (!(drive & 0x80)) - return -1; - - i =3D drive - 0x80; - if (i >=3D blk_nb) - return -1; - - if (sector + nsec > geometry->total_sectors) - return -1; - - aiocb.aio_dev =3D blk_dev[i]; - aiocb.aio_buf =3D addr; - aiocb.aio_nbytes =3D (size_t)nsec * blk_info[i].sector_size; - aiocb.aio_offset =3D (off_t)sector * blk_info[i].sector_size; - aiocb.aio_cb =3D NULL; - - blkfront_io(&aiocb, read =3D=3D BIOSDISK_WRITE); - - return 0; -} - -static int -load_file(char *name, void **ptr, long *size) -{ - char *buf =3D NULL; - int allocated =3D 1 * 1024 * 1024; - int len, filled =3D 0; - - if (!grub_open (name)) - return -1; - - buf =3D malloc(allocated); - - errnum =3D 0; - while (1) { - len =3D grub_read (buf + filled, allocated - filled); - if (! len) { - if (!errnum) - break; - grub_close (); - return -1; - } - filled +=3D len; - if (filled < allocated) - break; - allocated *=3D 2; - buf =3D realloc(buf, allocated); - } - grub_close (); - *ptr =3D buf; - *size =3D filled; - return 0; -} - -void *kernel_image, *module_image; -long kernel_size, module_size; -char *kernel_arg, *module_arg; -void *multiboot_next_module; -struct xen_multiboot_mod_list *multiboot_next_module_header; - -kernel_t -load_image (char *kernel, char *arg, kernel_t suggested_type, - unsigned long load_flags) -{ - arg =3D skip_to(0, arg); - if (kernel_image) - free(kernel_image); - kernel_image =3D NULL; - if (load_file (kernel, &kernel_image, &kernel_size)) - return KERNEL_TYPE_NONE; - if (kernel_arg) - free(kernel_arg); - kernel_arg =3D strdup(arg); - return KERNEL_TYPE_PV; -} - -int -load_initrd (char *initrd) -{ - if (module_image) - free(module_image); - module_image =3D NULL; - multiboot_next_module =3D NULL; - multiboot_next_module_header =3D NULL; - load_file (initrd, &module_image, &module_size); - return ! errnum; -} - -int -load_module (char *module, char *arg) -{ - void *new_module, *new_module_image; - long new_module_size, rounded_new_module_size; - - if (load_file (module, &new_module, &new_module_size)) - return 0; - if (strlen(arg) >=3D PAGE_SIZE) { - /* Too big module command line */ - errnum =3D ERR_WONT_FIT; - return 0; - } - rounded_new_module_size =3D (new_module_size + PAGE_SIZE - 1) & PAGE_M= ASK; - - if (module_image && !multiboot_next_module_header) { - /* Initrd already loaded, drop it */ - free(module_image); - if (module_arg) - free(module_arg); - module_image =3D NULL; - } - if (!module_image) - /* Reserve one page for the header */ - multiboot_next_module =3D (void*) PAGE_SIZE; - - /* Allocate more room for the new module plus its arg */ - new_module_image =3D realloc(module_image, - (multiboot_next_module - module_image) + rounded_new_module_si= ze + PAGE_SIZE); - - /* Update pointers */ - multiboot_next_module +=3D new_module_image - module_image; - multiboot_next_module_header =3D (void*) multiboot_next_module_header = + (new_module_image - module_image); - module_image =3D new_module_image; - - if ((void*) (multiboot_next_module_header+1) - module_image > PAGE_SIZ= E) { - /* Too many modules */ - errnum =3D ERR_WONT_FIT; - return 0; - } - - /* Copy module */ - memcpy(multiboot_next_module, new_module, new_module_size); - multiboot_next_module_header->mod_start =3D multiboot_next_module - mo= dule_image; - multiboot_next_module_header->mod_end =3D multiboot_next_module_header= ->mod_start + new_module_size - 1; - multiboot_next_module +=3D rounded_new_module_size; - - /* Copy cmdline */ - strcpy(multiboot_next_module, arg); - multiboot_next_module_header->cmdline =3D multiboot_next_module - modu= le_image; - multiboot_next_module +=3D PAGE_SIZE; - - /* Pad */ - multiboot_next_module_header->pad =3D 0; - - multiboot_next_module_header++; - - return 1; -} - -void -pv_boot (void) -{ - unsigned long flags =3D 0; - if (multiboot_next_module_header) { - /* Termination entry */ - multiboot_next_module_header->mod_start =3D 0; - /* Total size */ - module_size =3D multiboot_next_module - module_image; - /* It's a multiboot module */ - flags |=3D SIF_MULTIBOOT_MOD; - } - kexec(kernel_image, kernel_size, module_image, module_size, kernel_arg= , flags); -} - -/* - * Network - */ - -struct netfront_dev *net_dev; - -int -minios_probe (struct nic *nic) -{ - char *ip; - - if (net_dev) - return 1; - - /* Clear the ARP table. */ - grub_memset ((char *) arptable, 0, - MAX_ARP * sizeof (struct arptable_t)); - - net_dev =3D init_netfront(NULL, (void*) -1, nic->node_addr, &ip); - if (!net_dev) - return 0; - - return 1; -} - -/* reset adapter */ -static void minios_reset(struct nic *nic) -{ - /* TODO? */ -} - -static void minios_disable(struct nic *nic) -{ -} - -/* Wait for a frame */ -static int minios_poll(struct nic *nic) -{ - return !! (nic->packetlen =3D netfront_receive(net_dev, (void*) nic->p= acket, ETH_FRAME_LEN)); -} - -/* Transmit a frame */ -struct frame { - uint8_t dest[ETH_ALEN]; - uint8_t src[ETH_ALEN]; - uint16_t type; - unsigned char data[]; -}; -static void minios_transmit (struct nic *nic, const char *d, unsigned int = t, - unsigned int s, const char *p) -{ - struct frame *frame =3D alloca(sizeof(*frame) + s); - - memcpy(frame->dest, d, ETH_ALEN); - memcpy(frame->src, nic->node_addr, ETH_ALEN); - frame->type =3D htons(t); - memcpy(frame->data, p, s); - - netfront_xmit(net_dev, (void*) frame, sizeof(*frame) + s); -} - -static char packet[ETH_FRAME_LEN]; - -struct nic nic =3D { - .reset =3D minios_reset, - .poll =3D minios_poll, - .transmit =3D minios_transmit, - .disable =3D minios_disable, - .flags =3D 0, - .rom_info =3D NULL, - .node_addr =3D arptable[ARP_CLIENT].node, - .packet =3D packet, - .packetlen =3D 0, - .priv_data =3D NULL, -}; - -int -eth_probe (void) -{ - return minios_probe(&nic); -} - -int -eth_poll (void) -{ - return minios_poll (&nic); -} - -void -eth_disable (void) -{ - minios_disable (&nic); -} - -void -eth_transmit (const char *d, unsigned int t, - unsigned int s, const void *p) -{ - minios_transmit (&nic, d, t, s, p); - if (t =3D=3D IP) - twiddle(); -} - -/* - * Console - */ -void -serial_hw_put (int _c) -{ - char c =3D _c; - console_print(NULL, &c, 1); -} - -int -serial_hw_fetch (void) -{ - char key; - - if (!xencons_ring_avail(NULL)) - return -1; - - read(STDIN_FILENO, &key, 1); - switch (key) { - case 0x7f: key =3D '\b'; break; - } - return key; -} - -/* - * PVFB - */ -struct kbdfront_dev *kbd_dev; -struct fbfront_dev *fb_dev; -static union xenkbd_in_event ev; -static int has_ev; -int console_checkkey (void) -{ - if (has_ev) - return 1; - has_ev =3D kbdfront_receive(kbd_dev, &ev, 1); - return has_ev; -} - -/* static QWERTY layout, that's what most PC BIOSes do anyway */ -static char linux2ascii[] =3D { - [ 1 ] =3D 27, - [ 2 ] =3D '1', - [ 3 ] =3D '2', - [ 4 ] =3D '3', - [ 5 ] =3D '4', - [ 6 ] =3D '5', - [ 7 ] =3D '6', - [ 8 ] =3D '7', - [ 9 ] =3D '8', - [ 10 ] =3D '9', - [ 11 ] =3D '0', - [ 12 ] =3D '-', - [ 13 ] =3D '=3D', - [ 14 ] =3D '\b', - [ 15 ] =3D '\t', - [ 16 ] =3D 'q', - [ 17 ] =3D 'w', - [ 18 ] =3D 'e', - [ 19 ] =3D 'r', - [ 20 ] =3D 't', - [ 21 ] =3D 'y', - [ 22 ] =3D 'u', - [ 23 ] =3D 'i', - [ 24 ] =3D 'o', - [ 25 ] =3D 'p', - [ 26 ] =3D '[', - [ 27 ] =3D ']', - [ 28 ] =3D '\n', - - [ 30 ] =3D 'a', - [ 31 ] =3D 's', - [ 32 ] =3D 'd', - [ 33 ] =3D 'f', - [ 34 ] =3D 'g', - [ 35 ] =3D 'h', - [ 36 ] =3D 'j', - [ 37 ] =3D 'k', - [ 38 ] =3D 'l', - [ 39 ] =3D ';', - [ 40 ] =3D '\'', - [ 41 ] =3D '`', - - [ 43 ] =3D '\\', - [ 44 ] =3D 'z', - [ 45 ] =3D 'x', - [ 46 ] =3D 'c', - [ 47 ] =3D 'v', - [ 48 ] =3D 'b', - [ 49 ] =3D 'n', - [ 50 ] =3D 'm', - [ 51 ] =3D ',', - [ 52 ] =3D '.', - [ 53 ] =3D '/', - - [ 55 ] =3D '*', - [ 57 ] =3D ' ', - - [ 71 ] =3D '7', - [ 72 ] =3D '8', - [ 73 ] =3D '9', - [ 74 ] =3D '-', - [ 75 ] =3D '4', - [ 76 ] =3D '5', - [ 77 ] =3D '6', - [ 78 ] =3D '+', - [ 79 ] =3D '1', - [ 80 ] =3D '2', - [ 81 ] =3D '3', - [ 82 ] =3D '0', - [ 83 ] =3D '.', - - [ 86 ] =3D '<', - - [ 96 ] =3D '\n', - - [ 98 ] =3D '/', - - [ 102 ] =3D 1, /* home */ - [ 103 ] =3D 16, /* up */ - [ 104 ] =3D 7, /* page up */ - [ 105 ] =3D 2, /* left */ - [ 106 ] =3D 6, /* right */ - [ 107 ] =3D 5, /* end */ - [ 108 ] =3D 14, /* down */ - [ 109 ] =3D 3, /* page down */ - - [ 111 ] =3D 4, /* delete */ -}; - -static char linux2ascii_shifted[] =3D { - [ 1 ] =3D 27, - [ 2 ] =3D '!', - [ 3 ] =3D '@', - [ 4 ] =3D '#', - [ 5 ] =3D '$', - [ 6 ] =3D '%', - [ 7 ] =3D '^', - [ 8 ] =3D '&', - [ 9 ] =3D '*', - [ 10 ] =3D '(', - [ 11 ] =3D ')', - [ 12 ] =3D '_', - [ 13 ] =3D '+', - [ 14 ] =3D '\b', - [ 15 ] =3D '\t', - [ 16 ] =3D 'Q', - [ 17 ] =3D 'W', - [ 18 ] =3D 'E', - [ 19 ] =3D 'R', - [ 20 ] =3D 'T', - [ 21 ] =3D 'Y', - [ 22 ] =3D 'U', - [ 23 ] =3D 'I', - [ 24 ] =3D 'O', - [ 25 ] =3D 'P', - [ 26 ] =3D '{', - [ 27 ] =3D '}', - [ 28 ] =3D '\n', - - [ 30 ] =3D 'A', - [ 31 ] =3D 'S', - [ 32 ] =3D 'D', - [ 33 ] =3D 'F', - [ 34 ] =3D 'G', - [ 35 ] =3D 'H', - [ 36 ] =3D 'J', - [ 37 ] =3D 'K', - [ 38 ] =3D 'L', - [ 39 ] =3D ':', - [ 40 ] =3D '"', - [ 41 ] =3D '~', - - [ 43 ] =3D '|', - [ 44 ] =3D 'Z', - [ 45 ] =3D 'X', - [ 46 ] =3D 'C', - [ 47 ] =3D 'V', - [ 48 ] =3D 'B', - [ 49 ] =3D 'N', - [ 50 ] =3D 'M', - [ 51 ] =3D '<', - [ 52 ] =3D '>', - [ 53 ] =3D '?', - - [ 55 ] =3D '*', - [ 57 ] =3D ' ', - - [ 71 ] =3D '7', - [ 72 ] =3D '8', - [ 73 ] =3D '9', - [ 74 ] =3D '-', - [ 75 ] =3D '4', - [ 76 ] =3D '5', - [ 77 ] =3D '6', - [ 78 ] =3D '+', - [ 79 ] =3D '1', - [ 80 ] =3D '2', - [ 81 ] =3D '3', - [ 82 ] =3D '0', - [ 83 ] =3D '.', - - [ 86 ] =3D '>', - - [ 96 ] =3D '\n', - - [ 98 ] =3D '/', - - [ 102 ] =3D 1, /* home */ - [ 103 ] =3D 16, /* up */ - [ 104 ] =3D 7, /* page up */ - [ 105 ] =3D 2, /* left */ - [ 106 ] =3D 6, /* right */ - [ 107 ] =3D 5, /* end */ - [ 108 ] =3D 14, /* down */ - [ 109 ] =3D 3, /* page down */ - - [ 111 ] =3D 4, /* delete */ -}; - -int console_getkey (void) -{ - static int shift, control, alt, caps_lock; - - if (!has_ev) - has_ev =3D kbdfront_receive(kbd_dev, &ev, 1); - if (!has_ev) - return 0; - - has_ev =3D 0; - if (ev.type !=3D XENKBD_TYPE_KEY) - return 0; - - if (ev.key.keycode =3D=3D 42 || ev.key.keycode =3D=3D 54) { - caps_lock =3D 0; - shift =3D ev.key.pressed; - return 0; - } - if (ev.key.keycode =3D=3D 58) { - caps_lock ^=3D 1; - return 0; - } - if (ev.key.keycode =3D=3D 29 || ev.key.keycode =3D=3D 97) { - control =3D ev.key.pressed; - return 0; - } - if (ev.key.keycode =3D=3D 56) { - alt =3D ev.key.pressed; - return 0; - } - - if (!ev.key.pressed) - return 0; - - if (ev.key.keycode < sizeof(linux2ascii) / sizeof(*linux2ascii)) { - char val; - if (shift || caps_lock) - val =3D linux2ascii_shifted[ev.key.keycode]; - else - val =3D linux2ascii[ev.key.keycode]; - if (control) - val &=3D ~0x60; - return val; - } - - return 0; -} - -static DECLARE_MUTEX_LOCKED(kbd_sem); -static void kbd_thread(void *p) -{ - kbd_dev =3D init_kbdfront(NULL, 1); - up(&kbd_sem); -} - -struct fbfront_dev *fb_open(void *fb, int width, int height, int depth) -{ - unsigned long *mfns; - int linesize =3D width * (depth / 8); - int memsize =3D linesize * height; - int numpages =3D (memsize + PAGE_SIZE - 1) / PAGE_SIZE; - int i; - - create_thread("kbdfront", kbd_thread, &kbd_sem); - - mfns =3D malloc(numpages * sizeof(*mfns)); - for (i =3D 0; i < numpages; i++) { - memset(fb + i * PAGE_SIZE, 0, PAGE_SIZE); - mfns[i] =3D virtual_to_mfn(fb + i * PAGE_SIZE); - } - fb_dev =3D init_fbfront(NULL, mfns, width, height, depth, linesize, nu= mpages); - free(mfns); - - if (!fb_dev) - return NULL; - - down(&kbd_sem); - if (!kbd_dev) - return NULL; - - return fb_dev; -} - -void kbd_close(void *foo) -{ - shutdown_kbdfront(kbd_dev); - kbd_dev =3D NULL; -} - -void fb_close(void) -{ - create_thread("kbdfront close", kbd_close, NULL); - shutdown_fbfront(fb_dev); - fb_dev =3D NULL; -} - -/* - * Misc - */ - -int getrtsecs (void) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - return tv.tv_sec % 10 + ((tv.tv_sec / 10) % 6) * 0x10; -} - -int currticks (void) -{ - struct timeval tv; - gettimeofday(&tv, NULL); - return ((tv.tv_sec * 1000000ULL + tv.tv_usec) * TICKS_PER_SEC) / 10000= 00; -} - -void __attribute__ ((noreturn)) grub_reboot (void) -{ - for ( ;; ) - { - struct sched_shutdown sched_shutdown =3D { .reason =3D SHUTDOWN_re= boot }; - HYPERVISOR_sched_op(SCHEDOP_shutdown, &sched_shutdown); - } -} - -#define SCRATCH_MEMSIZE (4 * 1024 * 1024) - -/* Note: not allocating it dynamically permits to make sure it lays below = 4G - * for grub's 32bit pointers to work */ -char grub_scratch_mem[SCRATCH_MEMSIZE] __attribute__((aligned(PAGE_SIZE))); - -int main(int argc, char **argv) -{ - if (argc > 1 && memcmp(argv[1], "--vtpm-label=3D", 13) =3D=3D 0) { - vtpm_label =3D argv[1] + 13; - argc--; - argv++; - } - - if (argc > 1) { - strncpy(config_file, argv[1], sizeof(config_file) - 1); - config_file[sizeof(config_file) - 1] =3D 0; - if (!strncmp(config_file, "(nd)", 4)) - preset_menu =3D "dhcp"; - } else if (start_info.mod_len) - preset_menu =3D (void*) start_info.mod_start; - else - preset_menu =3D "dhcp --with-configfile"; - - mbi.drives_addr =3D BOOTSEC_LOCATION + (60 * 1024); - mbi.drives_length =3D 0; - - mbi.boot_loader_name =3D (unsigned long) "GNU GRUB " VERSION; - mbi.mem_lower =3D (start_info.nr_pages * PAGE_SIZE) / 1024; - mbi.mem_upper =3D 0; - saved_drive =3D boot_drive; - saved_partition =3D install_partition; - - init_disk(); - - /* Try to make sure the client part got launched */ - sleep(1); - cmain(); - printk("cmain returned!\n"); -} diff --git a/stubdom/grub/mini-os.h b/stubdom/grub/mini-os.h deleted file mode 100644 index 9ec2bda014..0000000000 --- a/stubdom/grub/mini-os.h +++ /dev/null @@ -1,7 +0,0 @@ -extern int blk_nb; -extern struct blkfront_dev **blk_dev; -extern struct netfront_dev *net_dev; -extern struct kbdfront_dev *kbd_dev; -extern struct fbfront_dev *fb_dev; - -extern char* vtpm_label; diff --git a/stubdom/grub/minios.cfg b/stubdom/grub/minios.cfg deleted file mode 100644 index 5145b357e0..0000000000 --- a/stubdom/grub/minios.cfg +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG_LIBC=3Dy -CONFIG_LWIP=3Dn -CONFIG_SPARSE_BSS=3Dn -CONFIG_TPMFRONT=3Dy diff --git a/stubdom/grub/osdep.h b/stubdom/grub/osdep.h deleted file mode 100644 index 1d3e50adbf..0000000000 --- a/stubdom/grub/osdep.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef __OSDEP_H__ -#define __OSDEP_H__ - -#include -#define swap32(x) bswap_32(x) -#define swap16(x) bswap_16(x) - -#include -#if BYTE_ORDER =3D=3D BIG_ENDIAN -#define htons(x) (x) -#define ntohs(x) (x) -#define htonl(x) (x) -#define ntohl(x) (x) -#else -#define htons(x) swap16(x) -#define ntohs(x) swap16(x) -#define htonl(x) swap32(x) -#define ntohl(x) swap32(x) -#endif - -typedef unsigned long Address; - -/* ANSI prototyping macro */ -#ifdef __STDC__ -#define P(x) x -#else -#define P(x) () -#endif - -#endif --=20 2.54.0 From nobody Thu Jul 23 21:11:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1784535555; cv=none; d=zohomail.com; s=zohoarc; b=OG49jd/6ov+YXfEHpRYWYmkf8e83FXCncW2BCEV3aQ4BeXfH2q/OpeJ+1eLEhEuZxGlqlCfadpx5Mcm7VwuYllyxHmTY3lmKsQnLWV2kDYAiLczkg1Ct2PCDz8SJw3iwnBide2PUs2SgZWeUWlkLy4dhhQB1gRuguDLt9Vq9wcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784535555; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Z6EAc2AbX/aQuKD/P9abpYa37fs6FYgsEE4fa9CoGsA=; b=VPx3h9rYJAeYIpxwOUx8QEUfhrQWpOdB3Dpa8ecGmBmbGPt5NYekip8fp9QiMf4FYTcq3p+oMTUt/U2cAi2AYyzZjq9Iik5Oo0vwFsItJ8C4SuMQ7Ri1B5kHlrziZJPIsl8RTUBB1spWgG9OREV8bmzZU6LKIzv7UtqWSr2Ez50= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784535555551112.12656994703434; Mon, 20 Jul 2026 01:19:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366243.1616139 (Exim 4.92) (envelope-from ) id 1wljD7-0005ti-Gh; Mon, 20 Jul 2026 08:18:49 +0000 Received: by outflank-mailman (output) from mailman id 1366243.1616139; Mon, 20 Jul 2026 08:18:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wljD7-0005tV-Dp; Mon, 20 Jul 2026 08:18:49 +0000 Received: by outflank-mailman (input) for mailman id 1366243; Mon, 20 Jul 2026 08:18:48 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wljD6-0005si-8L for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 08:18:48 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wljD5-008gXE-LC for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 10:18:47 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5dd9e5-e002-0a2a0a5209dd-0a2a45039940-18 for ; Mon, 20 Jul 2026 10:18:47 +0200 Received: from [195.135.223.130] (helo=smtp-out1.suse.de) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5dd9e7-fae8-0a2a45030019-c387df82bd3c-3 for ; Mon, 20 Jul 2026 10:18:47 +0200 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 42BC379E46; Mon, 20 Jul 2026 08:18:47 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 1E01B779AA; Mon, 20 Jul 2026 08:18:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id gY8KBufZXWrGXgAAD6G6ig (envelope-from ); Mon, 20 Jul 2026 08:18:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784535527; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z6EAc2AbX/aQuKD/P9abpYa37fs6FYgsEE4fa9CoGsA=; b=BSVnLg8oYtfHgJlFSRoU8KoDH7hEe74V41rkCOQ86k+f1GeGwBySCD5UHiAwj35RzVoUST +tN6OvPoYeA7Hy5NGeyDoPUCQNsq0aXxg2ZewTQdFILIu1YzNOWSd2a9KkShAMWAP1iwvO QLG2UUzeYOCC7fNyFyw9FNG3zwketyg= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=BSVnLg8o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784535527; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z6EAc2AbX/aQuKD/P9abpYa37fs6FYgsEE4fa9CoGsA=; b=BSVnLg8oYtfHgJlFSRoU8KoDH7hEe74V41rkCOQ86k+f1GeGwBySCD5UHiAwj35RzVoUST +tN6OvPoYeA7Hy5NGeyDoPUCQNsq0aXxg2ZewTQdFILIu1YzNOWSd2a9KkShAMWAP1iwvO QLG2UUzeYOCC7fNyFyw9FNG3zwketyg= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Anthony PERARD , Samuel Thibault Subject: [PATCH v2 2/5] stubdom: remove support for building in 32-bit mode Date: Mon, 20 Jul 2026 10:18:29 +0200 Message-ID: <20260720081833.4122182-3-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260720081833.4122182-1-jgross@suse.com> References: <20260720081833.4122182-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Action: no action X-Rspamd-Queue-Id: 42BC379E46 X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.com:dkim,suse.com:email,suse.com:mid]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.com:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-purgate-ID: tlsNG-33051d/1784535527-6D4D74E9-FE930673/0/0 X-purgate-type: clean X-purgate-size: 1110 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1784535557577158500 Content-Type: text/plain; charset="utf-8" With the removal of grub-pv there is no 32-bit stubdom left. Remove 32-bit support from the stubdom build system. Signed-off-by: Juergen Gross --- stubdom/Makefile | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/stubdom/Makefile b/stubdom/Makefile index 850e8544ca..2698bddc9d 100644 --- a/stubdom/Makefile +++ b/stubdom/Makefile @@ -31,15 +31,7 @@ endef $(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_deps,$(lib)))) =20 GNU_TARGET_ARCH:=3D$(XEN_TARGET_ARCH) -ifeq ($(XEN_TARGET_ARCH),x86_32) -GNU_TARGET_ARCH:=3Di686 -endif =20 -ifeq ($(GNU_TARGET_ARCH), i686) -TARGET_CFLAGS=3D -NEWLIB_CFLAGS+=3D-D_I386MACH_ALLOW_HW_INTERRUPTS -STUBDOM_SUPPORTED=3D1 -endif ifeq ($(GNU_TARGET_ARCH), x86_64) TARGET_CFLAGS=3D-mno-red-zone NEWLIB_CFLAGS+=3D-D_I386MACH_ALLOW_HW_INTERRUPTS @@ -179,9 +171,6 @@ gmp-$(GMP_VERSION).tar.bz2: $(FETCHER) $@ $(GMP_URL)/$@ =20 .PHONY: cross-gmp -ifeq ($(XEN_TARGET_ARCH), x86_32) - GMPEXT=3DABI=3D32 -endif gmp-$(XEN_TARGET_ARCH): gmp-$(GMP_VERSION).tar.bz2 $(NEWLIB_STAMPFILE) tar xjf $< rm $@ -rf || : --=20 2.54.0 From nobody Thu Jul 23 21:11:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1784535565; cv=none; d=zohomail.com; s=zohoarc; b=dLFCjLEaMlbXrVzLl2NCF3U2AaILKmV3ahfgt6aHwHEK5SzpPJS+zuO7/2LFR17qOmag9MWOo5IZvEuyrINc00RQSlJ6RVzy+DQlLMo7HzZLLDBGTIAr8G7eM/CJr3MCmBl3LokoU2n1IxR3hD4dRBUWtSwuBBRM3Ig84PUNnks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784535565; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+rR6a7u62PrIE8LmzzOCco11yRON8r8BBfjyeOxn53M=; b=dbw9594rNrsO2VNunAVGCXikMLGDIQd5LSI4eNYDYO8Tz/k26MVWapDjt6WB624FIQYZ5yxv0b2RVa8DMY0aOxP33wbyjr6Q8qnlOh3tbj9/iXSsC3bi7DCCbj5fgsgnGtFel7EYWlg5toMWEGWQfdPmJUoAMYIiYL6hQbj5PH8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784535565231121.99393092702644; Mon, 20 Jul 2026 01:19:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366244.1616149 (Exim 4.92) (envelope-from ) id 1wljDD-0006Dk-Ol; Mon, 20 Jul 2026 08:18:55 +0000 Received: by outflank-mailman (output) from mailman id 1366244.1616149; Mon, 20 Jul 2026 08:18:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wljDD-0006Dd-L9; Mon, 20 Jul 2026 08:18:55 +0000 Received: by outflank-mailman (input) for mailman id 1366244; Mon, 20 Jul 2026 08:18:53 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wljDB-0006BU-QP for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 08:18:53 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wljDB-000Q8b-7D for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 10:18:53 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5dd9e5-2eae-0a2a0a5409dd-0a2a4506b5d4-32 for ; Mon, 20 Jul 2026 10:18:53 +0200 Received: from [195.135.223.130] (helo=smtp-out1.suse.de) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5dd9ed-195a-0a2a45060019-c387df828f60-3 for ; Mon, 20 Jul 2026 10:18:53 +0200 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BAF3379E46; Mon, 20 Jul 2026 08:18:52 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 95AB1779AA; Mon, 20 Jul 2026 08:18:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ABMqI+zZXWrLXgAAD6G6ig (envelope-from ); Mon, 20 Jul 2026 08:18:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784535532; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+rR6a7u62PrIE8LmzzOCco11yRON8r8BBfjyeOxn53M=; b=Twg0vhucaNAvaoxVABi3APoMRF/QHfavTSV6x2mEHmnlb+3B2ClmXyFhuPK1bTY/HzXDG9 9FypavQX2z88Yytf6SG0mRaFCE2ng8KXZJHFbuT/fjMNsY718Z7J0CwKJbY8O8tjnSsci+ jaQSq5Z7ucQo7R0qnNBS3NfFbUoY60U= Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.com header.s=susede1 header.b=Twg0vhuc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784535532; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+rR6a7u62PrIE8LmzzOCco11yRON8r8BBfjyeOxn53M=; b=Twg0vhucaNAvaoxVABi3APoMRF/QHfavTSV6x2mEHmnlb+3B2ClmXyFhuPK1bTY/HzXDG9 9FypavQX2z88Yytf6SG0mRaFCE2ng8KXZJHFbuT/fjMNsY718Z7J0CwKJbY8O8tjnSsci+ jaQSq5Z7ucQo7R0qnNBS3NfFbUoY60U= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Anthony PERARD , Samuel Thibault Subject: [PATCH v2 3/5] stubdom: remove building of libxenguest and libxenctrl Date: Mon, 20 Jul 2026 10:18:30 +0200 Message-ID: <20260720081833.4122182-4-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260720081833.4122182-1-jgross@suse.com> References: <20260720081833.4122182-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Rspamd-Action: no action X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.com:s=susede1]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.com:email,suse.com:dkim,suse.com:mid]; FUZZY_RATELIMITED(0.00)[rspamd.com]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[suse.com:+] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: BAF3379E46 X-Spam-Score: -3.01 X-purgate-ID: tlsNG-16d1c6/1784535533-F480577B-4A5DA928/0/0 X-purgate-type: clean X-purgate-size: 784 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1784535567316158500 Content-Type: text/plain; charset="utf-8" grub-pv was the last user of the stubdom variants of libxenguest and libxenctrl. Remove both libraries from the stubdom build system. Signed-off-by: Juergen Gross --- stubdom/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/stubdom/Makefile b/stubdom/Makefile index 2698bddc9d..40b6ececf1 100644 --- a/stubdom/Makefile +++ b/stubdom/Makefile @@ -256,9 +256,7 @@ $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci # libraries under tools/libs ####### =20 -STUB_LIBS :=3D toolcore toollog evtchn gnttab call foreignmemory devicemod= el ctrl guest manage - -LIBDEP_guest :=3D cross-zlib +STUB_LIBS :=3D toolcore toollog evtchn gnttab call foreignmemory devicemod= el manage =20 ####### # common handling --=20 2.54.0 From nobody Thu Jul 23 21:11:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1784535564; cv=none; d=zohomail.com; s=zohoarc; b=YdS+/hlcbSOKKR+8D3vOg2hIkSxuElscohsmv4QyRDTLsw6R8YM+lF7Qlhqs6A6wp1WfvVKELvgjLbCJN0z6RO3uiM9gMtLzh5Syxoej2QBZjOU7jdOKXGHtMsLU3wmBr+lYFXYnCwxzQjIV/J9or00QPefxwP8fuqjbXoieGkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784535564; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=i7QVV4zU+HBTHHGxFIUYe6BxCNLKsfYFRbHiHIdGaFw=; b=Rzzqm1HvTM9JHp083O7caENm3HCzU6sKjh8RGWaLwCIU3NqWyycf+XagAGJ6bCJlPa1Fjm6P91X5VjAZt9blidJ7Q2ATsrysDVwpGFuOIkW2vnswG6kaBz5l4vrSkYYYAB0AOtX7UkbxugKyyNTbKL0FhjcwO5IWCSbpgGf+MTQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784535564903532.8237721822577; Mon, 20 Jul 2026 01:19:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366246.1616158 (Exim 4.92) (envelope-from ) id 1wljDI-0006ZE-W3; Mon, 20 Jul 2026 08:19:00 +0000 Received: by outflank-mailman (output) from mailman id 1366246.1616158; Mon, 20 Jul 2026 08:19:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wljDI-0006Z7-SS; Mon, 20 Jul 2026 08:19:00 +0000 Received: by outflank-mailman (input) for mailman id 1366246; Mon, 20 Jul 2026 08:19:00 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wljDI-0006YL-Fj for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 08:19:00 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wljDH-00G43B-Se for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 10:18:59 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5dd9f2-bab6-0a2a0a5309dd-0a2a45099b72-6 for ; Mon, 20 Jul 2026 10:18:59 +0200 Received: from [195.135.223.131] (helo=smtp-out2.suse.de) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5dd9f3-be1a-0a2a45090019-c387df83e1da-3 for ; Mon, 20 Jul 2026 10:18:59 +0200 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 576153E09; Mon, 20 Jul 2026 08:18:58 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 16137779AA; Mon, 20 Jul 2026 08:18:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id uuYdBPLZXWrOXgAAD6G6ig (envelope-from ); Mon, 20 Jul 2026 08:18:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784535539; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i7QVV4zU+HBTHHGxFIUYe6BxCNLKsfYFRbHiHIdGaFw=; b=e5QBiW4DM081VgGinkM1H6FkX2WP9eGvAl0tjrmsZcV9fdXHlArc5YoQ/oxAvcTopgZUPz uyCXkcOzJnuP20sAuFcOlx1lctZsrgoKcisIUP8lo2na8NSMcR3NQP4KuxVhFZUKyzeWZI LAwbTmTyFVcBq88SJBiyi9oBKNKua80= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784535538; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i7QVV4zU+HBTHHGxFIUYe6BxCNLKsfYFRbHiHIdGaFw=; b=AMtzWKtOeP9VfrP6vXd6FqT+F1BOfBc/xggTJGFNwcvNiBcF9S71Cx7/i6ruqhu+j2Oz8d NpvGnlmz5BvxI/enKVitmipLooFK0nawAqMZHy9vAynK0j+xakCdqicsR+z7uLFQfmxsus gM3iMszzHQxvSpGOTJydFNjyHxuWasE= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v2 4/5] docs: remove stale stubdom entries from stubdom.txt Date: Mon, 20 Jul 2026 10:18:31 +0200 Message-ID: <20260720081833.4122182-5-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260720081833.4122182-1-jgross@suse.com> References: <20260720081833.4122182-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.997]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_SEVEN(0.00)[9]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; TO_DN_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: X-purgate-ID: tlsNG-bad1c0/1784535539-3BAD0034-3C750BC9/0/0 X-purgate-type: clean X-purgate-size: 2552 X-ZohoMail-DKIM: pass (identity @suse.com) (identity @suse.com) X-ZM-MESSAGEID: 1784535567353158500 Content-Type: text/plain; charset="utf-8" There are several stubdoms mentioned in docs/misc/stubdom.txt which no longer exist. Remove them. Signed-off-by: Juergen Gross --- docs/misc/stubdom.txt | 69 ------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/docs/misc/stubdom.txt b/docs/misc/stubdom.txt index cfcba4ba96..3ee96d5063 100644 --- a/docs/misc/stubdom.txt +++ b/docs/misc/stubdom.txt @@ -85,72 +85,3 @@ To change the CD-ROM medium, libxl will: =20 The stubdom must internally add /dev/xvdc to an fdset in QEMU with opaque = set to "stub-devid:$devid". libxl will lookup the fdset with that string. - - PV-GRUB - =3D=3D=3D=3D=3D=3D=3D - - This replaces pygrub to boot domU images safely: it runs the regular grub -inside the created domain itself and uses regular domU facilities to read = the -disk / fetch files from network etc. ; it eventually loads the PV kernel a= nd -chain-boots it. - =20 -Configuration -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -In your PV config, - -- use pv-grub.gz as kernel: - -kernel =3D "pv-grub.gz" - -- set the path to menu.lst, as seen from the domU, in extra: - -extra =3D "(hd0,0)/boot/grub/menu.lst" - -or you can provide the content of a menu.lst stored in dom0 by passing it = as a -ramdisk: - -ramdisk =3D "/boot/domU-1-menu.lst" - -or you can also use a tftp path (dhcp will be automatically performed): - -extra =3D "(nd)/somepath/menu.lst" - -or you can set it in option 150 of your dhcp server and leave extra and ra= mdisk -empty (dhcp will be automatically performed) - -Limitations -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -- You can not boot a 64bit kernel with a 32bit-compiled PV-GRUB and vice-v= ersa. -To cross-compile a 32bit PV-GRUB, - -export XEN_TARGET_ARCH=3Dx86_32 - -- bootsplash is supported, but the ioemu backend does not yet support rest= art -for use by the booted kernel. - -- PV-GRUB doesn't support virtualized partitions. For instance: - -disk =3D [ 'phy:hda7,hda7,w' ] - -will be seen by PV-GRUB as (hd0), not (hd0,6), since GRUB will not see any -partition table. - - - Your own stubdom - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D - - By running - -cd stubdom/ -make c-stubdom - - or - -cd stubdom/ -make caml-stubdom - - you can compile examples of C or caml stub domain kernels. You can use = these -and the relevant Makefile rules as basis to build your own stub domain ker= nel. -Available libraries are libc, libxc, libxs, zlib and libpci. --=20 2.54.0 From nobody Thu Jul 23 21:11:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1784535570; cv=none; d=zohomail.com; s=zohoarc; b=UKlwFQdjyG+GW8OjUAIg/xSYFxu9carC+JIsAVsyRjAIaujr3S3MecCp9Mgexbjq4VIhJW8c7qOKs53DY3D2aMweGbvFhJg/DlK/47mkgIlsXcL35c5JrVcxFbcTPB8YXB0rg8VSkWBHgXg5cXuNx9LpYbuiHc9f6RrKqwutM+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784535570; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dKp2RqqaXDo0PHr9j/gRjRh2meprNkvF0eE5dIq0h18=; b=FTMn5HbHMfDWL//tsECGn2NRR/t1LWDE4uYs1avq60bpS7l3GeCQ54cd/2LvLyLJCe1vHqacylmxoQ/NnWmbawYBiq+p7B7FITK2RWgHhQPL5rKJzE0dyJNpByhFYGo/TJlveX69LRS/md59pTepBvroh/pGm9zM9XZLywNC1OU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1784535570235796.8906256580113; Mon, 20 Jul 2026 01:19:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1366254.1616166 (Exim 4.92) (envelope-from ) id 1wljDO-00078h-7G; Mon, 20 Jul 2026 08:19:06 +0000 Received: by outflank-mailman (output) from mailman id 1366254.1616166; Mon, 20 Jul 2026 08:19:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wljDO-00078Z-4M; Mon, 20 Jul 2026 08:19:06 +0000 Received: by outflank-mailman (input) for mailman id 1366254; Mon, 20 Jul 2026 08:19:04 +0000 Received: from mx.expurgate.net ([194.145.224.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wljDM-0006zX-Og for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 08:19:04 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wljDM-000QCH-5L for xen-devel@lists.xenproject.org; Mon, 20 Jul 2026 10:19:04 +0200 Received: from [10.42.69.6] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a5dd9f2-2eae-0a2a0a5409dd-0a2a4506c774-24 for ; Mon, 20 Jul 2026 10:19:04 +0200 Received: from [195.135.223.131] (helo=smtp-out2.suse.de) by tlsNG-16d1c6.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a5dd9f7-195a-0a2a45060019-c387df8397dc-3 for ; Mon, 20 Jul 2026 10:19:04 +0200 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CB2A23E18; Mon, 20 Jul 2026 08:19:03 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A8BD1779AA; Mon, 20 Jul 2026 08:19:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ERvhJ/fZXWrXXgAAD6G6ig (envelope-from ); Mon, 20 Jul 2026 08:19:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References"; dkim=pass header.s=susede1 header.d=suse.com header.i="@suse.com" header.h="From:Date:Message-ID:To:Cc:MIME-Version:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784535543; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dKp2RqqaXDo0PHr9j/gRjRh2meprNkvF0eE5dIq0h18=; b=eOMVapg44BA3yltb4cx7k1w3X3FMwoRaDy8wdaojBbgwY2PqHQkQVEaHJ2UMzlov5nflAp F4cwEzEtXiuDKaacbObIFi/hcH5Sshf/ceVNypcJt1xaMHxmvyaMqsUM8m7tDVaOFZMB9e ZUpwwJxq45/pPf4/+Cbk1zqIsF6XD1w= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1784535543; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dKp2RqqaXDo0PHr9j/gRjRh2meprNkvF0eE5dIq0h18=; b=eOMVapg44BA3yltb4cx7k1w3X3FMwoRaDy8wdaojBbgwY2PqHQkQVEaHJ2UMzlov5nflAp F4cwEzEtXiuDKaacbObIFi/hcH5Sshf/ceVNypcJt1xaMHxmvyaMqsUM8m7tDVaOFZMB9e ZUpwwJxq45/pPf4/+Cbk1zqIsF6XD1w= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Anthony PERARD Subject: [PATCH v2 5/5] tools/libxenguest: remove Mini-OS specific parts Date: Mon, 20 Jul 2026 10:18:32 +0200 Message-ID: <20260720081833.4122182-6-jgross@suse.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260720081833.4122182-1-jgross@suse.com> References: <20260720081833.4122182-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Flag: NO X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.997]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:email,suse.com:mid] X-Spam-Level: X-Spam-Score: -2.80 X-purgate-ID: tlsNG-16d1c6/1784535544-F540B77B-A338931E/0/0 X-purgate-type: clean X-purgate-size: 11480 X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1784535571351158500 Content-Type: text/plain; charset="utf-8" The last Mini-OS use case of libxenguest is gone, so remove the Mini-OS specific parts of libxenguest. Signed-off-by: Juergen Gross --- tools/libs/guest/Makefile.common | 15 ------ tools/libs/guest/xg_dom_decompress_unsafe.c | 48 ------------------- tools/libs/guest/xg_dom_decompress_unsafe.h | 28 ----------- .../guest/xg_dom_decompress_unsafe_bzip2.c | 14 ------ .../libs/guest/xg_dom_decompress_unsafe_lz4.c | 39 --------------- .../guest/xg_dom_decompress_unsafe_lzma.c | 14 ------ .../guest/xg_dom_decompress_unsafe_lzo1x.c | 44 ----------------- .../libs/guest/xg_dom_decompress_unsafe_xz.c | 46 ------------------ .../guest/xg_dom_decompress_unsafe_zstd.c | 44 ----------------- 9 files changed, 292 deletions(-) delete mode 100644 tools/libs/guest/xg_dom_decompress_unsafe.c delete mode 100644 tools/libs/guest/xg_dom_decompress_unsafe.h delete mode 100644 tools/libs/guest/xg_dom_decompress_unsafe_bzip2.c delete mode 100644 tools/libs/guest/xg_dom_decompress_unsafe_lz4.c delete mode 100644 tools/libs/guest/xg_dom_decompress_unsafe_lzma.c delete mode 100644 tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c delete mode 100644 tools/libs/guest/xg_dom_decompress_unsafe_xz.c delete mode 100644 tools/libs/guest/xg_dom_decompress_unsafe_zstd.c diff --git a/tools/libs/guest/Makefile.common b/tools/libs/guest/Makefile.c= ommon index 86b1f160e5..47b3a52360 100644 --- a/tools/libs/guest/Makefile.common +++ b/tools/libs/guest/Makefile.common @@ -1,8 +1,3 @@ -ifeq ($(CONFIG_LIBXC_MINIOS),y) -# Save/restore of a domain is currently incompatible with a stubdom enviro= nment -override CONFIG_MIGRATE :=3D n -endif - OBJS-y +=3D xg_private.o OBJS-y +=3D xg_domain.o OBJS-y +=3D xg_suspend.o @@ -55,16 +50,6 @@ OBJS-$(CONFIG_X86) +=3D xg_dom_x86.o OBJS-$(CONFIG_X86) +=3D xg_cpuid_x86.o OBJS-$(CONFIG_ARM) +=3D xg_dom_arm.o =20 -ifeq ($(CONFIG_LIBXC_MINIOS),y) -OBJS-y +=3D xg_dom_decompress_unsafe.o -OBJS-y +=3D xg_dom_decompress_unsafe_bzip2.o -OBJS-y +=3D xg_dom_decompress_unsafe_lz4.o -OBJS-y +=3D xg_dom_decompress_unsafe_lzma.o -OBJS-y +=3D xg_dom_decompress_unsafe_lzo1x.o -OBJS-y +=3D xg_dom_decompress_unsafe_xz.o -OBJS-y +=3D xg_dom_decompress_unsafe_zstd.o -endif - CFLAGS +=3D -D__XEN_TOOLS__ CFLAGS +=3D -include $(XEN_ROOT)/tools/config.h CFLAGS +=3D -iquote ../../../xen/common/libelf diff --git a/tools/libs/guest/xg_dom_decompress_unsafe.c b/tools/libs/guest= /xg_dom_decompress_unsafe.c deleted file mode 100644 index 21d964787d..0000000000 --- a/tools/libs/guest/xg_dom_decompress_unsafe.c +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include - -#include "xg_private.h" -#include "xg_dom_decompress_unsafe.h" - -static struct xc_dom_image *unsafe_dom; -static unsigned char *output_blob; -static unsigned int output_size; - -static void unsafe_error(const char *msg) -{ - xc_dom_panic(unsafe_dom->xch, XC_INVALID_KERNEL, "%s", msg); -} - -static int unsafe_flush(void *src, unsigned int size) -{ - void *n =3D realloc(output_blob, output_size + size); - if (!n) - return -1; - output_blob =3D n; - - memcpy(&output_blob[output_size], src, size); - output_size +=3D size; - return size; -} - -int xc_dom_decompress_unsafe( - decompress_fn fn, struct xc_dom_image *dom, void **blob, size_t *size) -{ - int ret; - - unsafe_dom =3D dom; - output_blob =3D NULL; - output_size =3D 0; - - ret =3D fn(dom->kernel_blob, dom->kernel_size, NULL, unsafe_flush, NUL= L, NULL, unsafe_error); - - if (ret) - free(output_blob); - else { - *blob =3D output_blob; - *size =3D output_size; - } - - return ret; -} diff --git a/tools/libs/guest/xg_dom_decompress_unsafe.h b/tools/libs/guest= /xg_dom_decompress_unsafe.h deleted file mode 100644 index 5bc2222076..0000000000 --- a/tools/libs/guest/xg_dom_decompress_unsafe.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifdef __MINIOS__ -# include "../../xen/include/xen/decompress.h" -#else -typedef int decompress_fn(unsigned char *inbuf, unsigned int len, - int (*fill)(void*, unsigned int), - int (*flush)(void*, unsigned int), - unsigned char *outbuf, unsigned int *posp, - void (*error)(const char *x)); -#endif - -#define cf_check /* No Control Flow Integriy checking */ - -int xc_dom_decompress_unsafe( - decompress_fn fn, struct xc_dom_image *dom, void **blob, size_t *size) - __attribute__((visibility("internal"))); - -int xc_try_bzip2_decode(struct xc_dom_image *dom, void **blob, size_t *siz= e) - __attribute__((visibility("internal"))); -int xc_try_lz4_decode(struct xc_dom_image *dom, void **blob, size_t *size) - __attribute__((visibility("internal"))); -int xc_try_lzma_decode(struct xc_dom_image *dom, void **blob, size_t *size) - __attribute__((visibility("internal"))); -int xc_try_lzo1x_decode(struct xc_dom_image *dom, void **blob, size_t *siz= e) - __attribute__((visibility("internal"))); -int xc_try_xz_decode(struct xc_dom_image *dom, void **blob, size_t *size) - __attribute__((visibility("internal"))); -int xc_try_zstd_decode(struct xc_dom_image *dom, void **blob, size_t *size) - __attribute__((visibility("internal"))); diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_bzip2.c b/tools/libs= /guest/xg_dom_decompress_unsafe_bzip2.c deleted file mode 100644 index 9d3709e6cc..0000000000 --- a/tools/libs/guest/xg_dom_decompress_unsafe_bzip2.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include - -#include "xg_private.h" -#include "xg_dom_decompress_unsafe.h" - -#include "../../xen/common/bunzip2.c" - -int xc_try_bzip2_decode( - struct xc_dom_image *dom, void **blob, size_t *size) -{ - return xc_dom_decompress_unsafe(bunzip2, dom, blob, size); -} diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_lz4.c b/tools/libs/g= uest/xg_dom_decompress_unsafe_lz4.c deleted file mode 100644 index 405143aa61..0000000000 --- a/tools/libs/guest/xg_dom_decompress_unsafe_lz4.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include - -#include INCLUDE_ENDIAN_H - -#define XG_NEED_UNALIGNED -#include "xg_private.h" -#include "xg_dom_decompress.h" - -#define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; - -#define likely(a) a -#define unlikely(a) a - -static inline uint16_t le16_to_cpu(uint16_t v) -{ -#if BYTE_ORDER =3D=3D BIG_ENDIAN - return __builtin_bswap16(v); -#else - return v; -#endif -} - -#include "../../xen/include/xen/lz4.h" -#include "../../xen/common/decompress.h" -#include "../../xen/common/unlz4.c" - -int xc_try_lz4_decode( - struct xc_dom_image *dom, void **blob, size_t *size) -{ - return xc_dom_decompress_unsafe(unlz4, dom, blob, size); -} diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_lzma.c b/tools/libs/= guest/xg_dom_decompress_unsafe_lzma.c deleted file mode 100644 index 5d178f0c43..0000000000 --- a/tools/libs/guest/xg_dom_decompress_unsafe_lzma.c +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include - -#include "xg_private.h" -#include "xg_dom_decompress_unsafe.h" - -#include "../../xen/common/unlzma.c" - -int xc_try_lzma_decode( - struct xc_dom_image *dom, void **blob, size_t *size) -{ - return xc_dom_decompress_unsafe(unlzma, dom, blob, size); -} diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c b/tools/libs= /guest/xg_dom_decompress_unsafe_lzo1x.c deleted file mode 100644 index 356f228718..0000000000 --- a/tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include -#include INCLUDE_ENDIAN_H -#include - -#include "xg_private.h" -#include "xg_dom_decompress_unsafe.h" - -typedef uint8_t u8; -typedef uint32_t u32; -typedef uint16_t u16; -typedef uint64_t u64; - -#define likely(a) a -#define noinline -#define unlikely(a) a - -static inline uint16_t be16_to_cpu(const uint16_t v) -{ -#if BYTE_ORDER =3D=3D LITTLE_ENDIAN - return __builtin_bswap16(v); -#else - return v; -#endif -} - -static inline uint32_t be32_to_cpu(const uint32_t v) -{ -#if BYTE_ORDER =3D=3D LITTLE_ENDIAN - return __builtin_bswap32(v); -#else - return v; -#endif -} - -#include "../../xen/common/lzo.c" -#include "../../xen/common/unlzo.c" - -int xc_try_lzo1x_decode( - struct xc_dom_image *dom, void **blob, size_t *size) -{ - return xc_dom_decompress_unsafe(unlzo, dom, blob, size); -} diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_xz.c b/tools/libs/gu= est/xg_dom_decompress_unsafe_xz.c deleted file mode 100644 index 0501f7f693..0000000000 --- a/tools/libs/guest/xg_dom_decompress_unsafe_xz.c +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include INCLUDE_ENDIAN_H -#include -#include -#include -#include - -#include "xg_private.h" -#include "xg_dom_decompress_unsafe.h" - -// TODO -#define XZ_DEC_X86 - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint32_t __le32; - -static inline uint32_t cpu_to_le32(const uint32_t v) -{ -#if BYTE_ORDER =3D=3D BIG_ENDIAN - return __builtin_bswap32(v); -#else - return v; -#endif -} - -static inline uint32_t le32_to_cpu(const uint32_t v) -{ -#if BYTE_ORDER =3D=3D BIG_ENDIAN - return __builtin_bswap32(v); -#else - return v; -#endif -} - -#define __force -#define always_inline - -#include "../../xen/common/unxz.c" - -int xc_try_xz_decode( - struct xc_dom_image *dom, void **blob, size_t *size) -{ - return xc_dom_decompress_unsafe(unxz, dom, blob, size); -} diff --git a/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c b/tools/libs/= guest/xg_dom_decompress_unsafe_zstd.c deleted file mode 100644 index 319816a390..0000000000 --- a/tools/libs/guest/xg_dom_decompress_unsafe_zstd.c +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include INCLUDE_ENDIAN_H -#include -#include -#include -#include - -#include "xg_private.h" -#include "xg_dom_decompress_unsafe.h" - -typedef uint8_t u8; - -typedef uint16_t __u16; -typedef uint32_t __u32; -typedef uint64_t __u64; - -typedef uint16_t __le16; -typedef uint32_t __le32; -typedef uint64_t __le64; - -typedef uint16_t __be16; -typedef uint32_t __be32; -typedef uint64_t __be64; - -#define attr_const -#define __force -#define always_inline -#define noinline -#define __packed __attribute__((__packed__)) - -#undef ERROR - -#define __TYPES_H__ /* xen/types.h guard */ -#include "../../xen/include/xen/byteorder.h" -#include "../../xen/include/xen/unaligned.h" -#include "../../xen/include/xen/xxhash.h" -#include "../../xen/lib/xxhash64.c" -#include "../../xen/common/unzstd.c" - -int xc_try_zstd_decode( - struct xc_dom_image *dom, void **blob, size_t *size) -{ - return xc_dom_decompress_unsafe(unzstd, dom, blob, size); -} --=20 2.54.0