direct-io.hg

changeset 13464:58633caeece9

merge with xen-unstable.hg
author awilliam@xenbuild2.aw
date Wed Jan 10 08:40:47 2007 -0700 (2007-01-10)
parents 42babffffba5 0b679a6d8ad0
children bca11a0161e3
files tools/ioemu/vl.c tools/python/xen/xend/image.py xen/arch/ia64/xen/domain.c
line diff
     1.1 --- a/.hgignore	Wed Jan 10 08:00:50 2007 -0700
     1.2 +++ b/.hgignore	Wed Jan 10 08:40:47 2007 -0700
     1.3 @@ -20,6 +20,7 @@
     1.4  ^\.config$
     1.5  ^TAGS$
     1.6  ^tags$
     1.7 +^build.*$
     1.8  ^dist/.*$
     1.9  ^docs/.*\.aux$
    1.10  ^docs/.*\.dvi$
    1.11 @@ -205,6 +206,7 @@
    1.12  ^xen/ddb/.*$
    1.13  ^xen/include/asm$
    1.14  ^xen/include/asm-.*/asm-offsets\.h$
    1.15 +^xen/include/compat/.*$
    1.16  ^xen/include/hypervisor-ifs/arch$
    1.17  ^xen/include/public/public$
    1.18  ^xen/include/xen/.*\.new$
     2.1 --- a/.hgtags	Wed Jan 10 08:00:50 2007 -0700
     2.2 +++ b/.hgtags	Wed Jan 10 08:40:47 2007 -0700
     2.3 @@ -16,3 +16,4 @@ c8fdb0caa77b429cf47f9707926e83947778cb48
     2.4  af0573e9e5258db0a9d28aa954dd302ddd2c2d23 3.0.2-rc
     2.5  d0d3fef37685be264a7f52201f8ef44c030daad3 3.0.2-branched
     2.6  6ed4368b4a9e1924c983774c4b1a2b6baf8e98a6 3.0.3-branched
     2.7 +057f7c4dbed1c75a3fbe446d346cee04cff31497 3.0.4-branched
     3.1 --- a/Config.mk	Wed Jan 10 08:00:50 2007 -0700
     3.2 +++ b/Config.mk	Wed Jan 10 08:40:47 2007 -0700
     3.3 @@ -11,6 +11,8 @@ XEN_OS              ?= $(shell uname -s)
     3.4  
     3.5  CONFIG_$(XEN_OS) := y
     3.6  
     3.7 +SHELL     ?= /bin/sh
     3.8 +
     3.9  # Tools to run on system hosting the build
    3.10  HOSTCC     = gcc
    3.11  HOSTCFLAGS = -Wall -Werror -Wstrict-prototypes -O2 -fomit-frame-pointer
     4.1 --- a/buildconfigs/mk.linux-2.6-xen	Wed Jan 10 08:00:50 2007 -0700
     4.2 +++ b/buildconfigs/mk.linux-2.6-xen	Wed Jan 10 08:40:47 2007 -0700
     4.3 @@ -3,7 +3,8 @@ LINUX_VER    = 2.6.16.33
     4.4  
     4.5  EXTRAVERSION ?= xen
     4.6  
     4.7 -LINUX_DIR    = linux-$(LINUX_VER)-$(EXTRAVERSION)
     4.8 +LINUX_SRCDIR = linux-$(LINUX_VER)-xen
     4.9 +LINUX_DIR    = build-linux-$(LINUX_VER)-$(EXTRAVERSION)_$(XEN_TARGET_ARCH)
    4.10  
    4.11  IMAGE_TARGET ?= vmlinuz
    4.12  INSTALL_BOOT_PATH ?= $(DESTDIR)
    4.13 @@ -23,24 +24,31 @@ build: $(LINUX_DIR)/include/linux/autoco
    4.14  	mkdir -p $(INSTALL_BOOT_PATH)
    4.15  	$(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_PATH=$(INSTALL_BOOT_PATH) install
    4.16  
    4.17 -$(LINUX_DIR)/include/linux/autoconf.h: ref-linux-$(LINUX_VER)/.valid-ref
    4.18 -	rm -rf $(LINUX_DIR)
    4.19 -	cp -al $(<D) $(LINUX_DIR)
    4.20 +$(LINUX_SRCDIR)/.valid-src: ref-linux-$(LINUX_VER)/.valid-ref
    4.21 +	rm -rf $(LINUX_SRCDIR)
    4.22 +	cp -al $(<D) $(LINUX_SRCDIR)
    4.23  	# Apply arch-xen patches
    4.24  	( cd linux-$(LINUX_SERIES)-xen-sparse && \
    4.25 -          LINUX_ARCH=$(LINUX_ARCH) bash ./mkbuildtree ../$(LINUX_DIR) )
    4.26 +          LINUX_ARCH=$(LINUX_ARCH) bash ./mkbuildtree ../$(LINUX_SRCDIR) )
    4.27 +	# Patch kernel Makefile to set EXTRAVERSION
    4.28 +	( cd $(LINUX_SRCDIR) ; \
    4.29 +	  sed -e 's,^EXTRAVERSION.*,&$$(XENGUEST),' \
    4.30 +	      -e 's,^KERNELRELEASE,XENGUEST := $$(shell [ -r $$(objtree)/.xenguest ] \&\& cat $$(objtree)/.xenguest)\n&,' Makefile >Mk.tmp ; \
    4.31 +	  rm -f Makefile ; mv Mk.tmp Makefile )
    4.32 +	touch $@
    4.33 +
    4.34 +$(LINUX_DIR)/include/linux/autoconf.h: $(LINUX_SRCDIR)/.valid-src
    4.35 +	rm -rf $(LINUX_DIR)
    4.36 +	mkdir -p $(LINUX_DIR)
    4.37  	# Re-use config from install dir if one exits else use default config
    4.38 -	CONFIG_VERSION=$$(sed -ne 's/^EXTRAVERSION = //p' $(LINUX_DIR)/Makefile); \
    4.39 +	CONFIG_VERSION=$$(sed -ne 's/$$(XENGUEST)//; s/^EXTRAVERSION = //p' $(LINUX_SRCDIR)/Makefile); \
    4.40  	[ -r $(DESTDIR)/boot/config-$(LINUX_VER3)$$CONFIG_VERSION-$(EXTRAVERSION) ] && \
    4.41  	  cp $(DESTDIR)/boot/config-$(LINUX_VER3)$$CONFIG_VERSION-$(EXTRAVERSION) $(LINUX_DIR)/.config \
    4.42  	  || sh buildconfigs/create_config.sh $(LINUX_DIR)/.config $(EXTRAVERSION) $(XEN_TARGET_ARCH) $(XEN_SYSTYPE)
    4.43  	# See if we need to munge config to enable PAE
    4.44  	$(MAKE) CONFIG_FILE=$(LINUX_DIR)/.config -f buildconfigs/Rules.mk config-update-pae
    4.45 -	# Patch kernel Makefile to set EXTRAVERSION
    4.46 -	( cd $(LINUX_DIR) ; \
    4.47 -	  sed -e 's/^EXTRAVERSION.*/&$$(XENGUEST)\nXENGUEST = -$(EXTRAVERSION)/' Makefile >Mk.tmp ; \
    4.48 -	  rm -f Makefile ; mv Mk.tmp Makefile )
    4.49 -	$(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_ARCH) oldconfig
    4.50 +	echo "-$(EXTRAVERSION)" >$(LINUX_DIR)/.xenguest
    4.51 +	$(MAKE) -C $(LINUX_SRCDIR) ARCH=$(LINUX_ARCH) oldconfig O=$$(/bin/pwd)/$(LINUX_DIR)
    4.52  
    4.53  .PHONY: prep
    4.54  prep: $(LINUX_DIR)/include/linux/autoconf.h
    4.55 @@ -62,4 +70,5 @@ delete:
    4.56  
    4.57  .PHONY: mrpropper
    4.58  mrpropper:
    4.59 +	rm -rf $(LINUX_SRCDIR)
    4.60  	rm -f linux-$(LINUX_VER).tar.bz2
     5.1 --- a/config/StdGNU.mk	Wed Jan 10 08:00:50 2007 -0700
     5.2 +++ b/config/StdGNU.mk	Wed Jan 10 08:40:47 2007 -0700
     5.3 @@ -9,6 +9,8 @@ STRIP      = $(CROSS_COMPILE)strip
     5.4  OBJCOPY    = $(CROSS_COMPILE)objcopy
     5.5  OBJDUMP    = $(CROSS_COMPILE)objdump
     5.6  
     5.7 +MSGFMT     = msgfmt
     5.8 +
     5.9  INSTALL      = install
    5.10  INSTALL_DIR  = $(INSTALL) -d -m0755
    5.11  INSTALL_DATA = $(INSTALL) -m0644
     6.1 --- a/config/SunOS.mk	Wed Jan 10 08:00:50 2007 -0700
     6.2 +++ b/config/SunOS.mk	Wed Jan 10 08:40:47 2007 -0700
     6.3 @@ -9,6 +9,8 @@ STRIP      = $(CROSS_COMPILE)gstrip
     6.4  OBJCOPY    = $(CROSS_COMPILE)gobjcopy
     6.5  OBJDUMP    = $(CROSS_COMPILE)gobjdump
     6.6  
     6.7 +MSGFMT     = gmsgfmt
     6.8 +
     6.9  SHELL      = bash
    6.10  
    6.11  INSTALL      = ginstall
     7.1 --- a/config/x86_64.mk	Wed Jan 10 08:00:50 2007 -0700
     7.2 +++ b/config/x86_64.mk	Wed Jan 10 08:40:47 2007 -0700
     7.3 @@ -2,6 +2,7 @@ CONFIG_X86 := y
     7.4  CONFIG_X86_64 := y
     7.5  CONFIG_X86_$(XEN_OS) := y
     7.6  
     7.7 +CONFIG_COMPAT := y
     7.8  CONFIG_HVM := y
     7.9  CONFIG_MIGRATE := y
    7.10  CONFIG_XCUTILS := y
     8.1 --- a/docs/xen-api/wire-protocol.tex	Wed Jan 10 08:00:50 2007 -0700
     8.2 +++ b/docs/xen-api/wire-protocol.tex	Wed Jan 10 08:40:47 2007 -0700
     8.3 @@ -105,11 +105,13 @@ In the case where {\tt Status} is set to
     8.4  the struct contains a second element named {\tt ErrorDescription}:
     8.5  \begin{itemize}
     8.6  \item The element of the struct named {\tt ErrorDescription} contains
     8.7 -an array of string values. The first element of the array is an XML-RPC 32-bit {\tt i4} and represents an error code;
     8.8 -the remainder of the array are strings representing error parameters relating to that code.
     8.9 +an array of string values. The first element of the array is an error code;
    8.10 +the remainder of the array are strings representing error parameters relating
    8.11 +to that code.
    8.12  \end{itemize}
    8.13  
    8.14 -For example, an XML-RPC return value from the {\tt Host.ListAllVMs} function above
    8.15 +For example, an XML-RPC return value from the {\tt host.get\_resident\_VMs}
    8.16 +function above
    8.17  may look like this:
    8.18  \begin{verbatim}
    8.19      <struct>
    8.20 @@ -122,9 +124,9 @@ may look like this:
    8.21            <value>
    8.22              <array>
    8.23                 <data>
    8.24 -                 <value>vm-id-1</value>
    8.25 -                 <value>vm-id-2</value>
    8.26 -                 <value>vm-id-3</value>
    8.27 +                 <value>81547a35-205c-a551-c577-00b982c5fe00</value>
    8.28 +                 <value>61c85a22-05da-b8a2-2e55-06b0847da503</value>
    8.29 +                 <value>1d401ec4-3c17-35a6-fc79-cee6bd9811fe</value>
    8.30                 </data>
    8.31              </array>
    8.32           </value>
    8.33 @@ -147,16 +149,16 @@ We ought to support at least
    8.34  The XML-RPC interface is session-based; before you can make arbitrary RPC calls
    8.35  you must login and initiate a session. For example:
    8.36  \begin{verbatim}
    8.37 -   session_id    Session.login_with_password(string uname, string pwd)
    8.38 +   session_id    session.login_with_password(string uname, string pwd)
    8.39  \end{verbatim}
    8.40  Where {\tt uname} and {\tt password} refer to your username and password
    8.41  respectively, as defined by the Xen administrator.
    8.42 -The {\tt session\_id} returned by {\tt Session.Login} is passed to subequent
    8.43 -RPC calls as an authentication token.
    8.44 +The {\tt session\_id} returned by {\tt session.login_with_password} is passed
    8.45 +to subequent RPC calls as an authentication token.
    8.46  
    8.47 -A session can be terminated with the {\tt Session.Logout} function:
    8.48 +A session can be terminated with the {\tt session.logout} function:
    8.49  \begin{verbatim}
    8.50 -   void          Session.Logout(session_id session)
    8.51 +   void          session.logout(session_id session)
    8.52  \end{verbatim}
    8.53  
    8.54  \subsection{Synchronous and Asynchronous invocation}
    8.55 @@ -214,10 +216,12 @@ Create a python object referencing the r
    8.56  >>> xen = xmlrpclib.Server("http://test:4464")
    8.57  \end{verbatim}
    8.58  
    8.59 -Acquire a session token by logging in with a username and password (error-handling ommitted for brevity; the session token is pointed to by the key {\tt 'Value'} in the returned dictionary)
    8.60 +Acquire a session token by logging in with a username and password
    8.61 +(error-handling ommitted for brevity; the session token is pointed to by the
    8.62 +key {\tt 'Value'} in the returned dictionary)
    8.63  
    8.64  \begin{verbatim}
    8.65 ->>> session = xen.Session.do_login_with_password("user", "passwd")['Value']
    8.66 +>>> session = session.login_with_password("user", "passwd")['Value']
    8.67  \end{verbatim}
    8.68  
    8.69  When serialised, this call looks like the following:
    8.70 @@ -225,7 +229,7 @@ When serialised, this call looks like th
    8.71  \begin{verbatim}
    8.72  <?xml version='1.0'?>
    8.73  <methodCall>
    8.74 -  <methodName>Session.do_login_with_password</methodName>
    8.75 +  <methodName>session.login_with_password</methodName>
    8.76    <params>
    8.77      <param>
    8.78        <value><string>user</string></value>
    8.79 @@ -237,27 +241,34 @@ When serialised, this call looks like th
    8.80  </methodCall>
    8.81  \end{verbatim}
    8.82  
    8.83 -Next, the user may acquire a list of all the VMs known to the host: (Note the call takes the session token as the only parameter)
    8.84 +Next, the user may acquire a list of all the VMs known to the host: (Note the
    8.85 +call takes the session token as the only parameter)
    8.86  
    8.87  \begin{verbatim}
    8.88 ->>> all_vms = xen.VM.do_list(session)['Value']
    8.89 +>>> all_vms = host.get_resident_VMs(session)['Value']
    8.90  >>> all_vms
    8.91  ['b7b92d9e-d442-4710-92a5-ab039fd7d89b', '23e1e837-abbf-4675-b077-d4007989b0cc',
    8.92    '2045dbc0-0734-4eea-9cb2-b8218c6b5bf2', '3202ae18-a046-4c32-9fda-e32e9631866e']
    8.93  \end{verbatim}
    8.94  
    8.95 -Note the VM references are internally UUIDs. Once a reference to a VM has been acquired a lifecycle operation may be invoked:
    8.96 +The VM references here are UUIDs, though they may not be that simple in the
    8.97 +future, and you should treat them as opaque strings.  Once a reference to a VM
    8.98 +has been acquired a lifecycle operation may be invoked:
    8.99  
   8.100  \begin{verbatim}
   8.101 ->>> xen.VM.do_start(session, all_vms[3], False)
   8.102 -{'Status': 'Failure', 'ErrorDescription': 'Operation not implemented'}
   8.103 +>>> xen.VM.start(session, all_vms[3], False)
   8.104 +{'Status': 'Failure', 'ErrorDescription': ['VM_BAD_POWER_STATE', 'Halted', 'Running']}
   8.105  \end{verbatim}
   8.106  
   8.107 -In this case the {\tt start} message has not been implemented and an error response has been returned. Currently these high-level errors are returned as structured data (rather than as XMLRPC faults), allowing for internationalised errors in future. Finally, here are some examples of using accessors for object fields:
   8.108 +In this case the {\tt start} message has been rejected, because the VM is
   8.109 +already running, and so an error response has been returned.  These high-level
   8.110 +errors are returned as structured data (rather than as XML-RPC faults),
   8.111 +allowing them to be internationalised.  Finally, here are some examples of
   8.112 +using accessors for object fields:
   8.113  
   8.114  \begin{verbatim}
   8.115 ->>> xen.VM.getname_label(session, all_vms[3])['Value']
   8.116 +>>> xen.VM.get_name_label(session, all_vms[3])['Value']
   8.117  'SMP'
   8.118 ->>> xen.VM.getname_description(session, all_vms[3])['Value']
   8.119 +>>> xen.VM.get_name_description(session, all_vms[3])['Value']
   8.120  'Debian for Xen'
   8.121  \end{verbatim}
     9.1 --- a/docs/xen-api/xenapi-datamodel.tex	Wed Jan 10 08:00:50 2007 -0700
     9.2 +++ b/docs/xen-api/xenapi-datamodel.tex	Wed Jan 10 08:40:47 2007 -0700
     9.3 @@ -184,8 +184,8 @@ The following enumeration types are used
     9.4  \hspace{0.5cm}{\tt NX} &  Execute Disable  \\
     9.5  \hspace{0.5cm}{\tt MMXEXT} &  AMD MMX extensions  \\
     9.6  \hspace{0.5cm}{\tt LM} &  Long Mode (x86-64)  \\
     9.7 -\hspace{0.5cm}{\tt 3DNOWEXT} &  AMD 3DNow! extensions  \\
     9.8 -\hspace{0.5cm}{\tt 3DNOW} &  3DNow!  \\
     9.9 +\hspace{0.5cm}{\tt THREEDNOWEXT} &  AMD 3DNow! extensions  \\
    9.10 +\hspace{0.5cm}{\tt THREEDNOW} &  3DNow!  \\
    9.11  \hspace{0.5cm}{\tt RECOVERY} &  CPU in recovery mode  \\
    9.12  \hspace{0.5cm}{\tt LONGRUN} &  Longrun power control  \\
    9.13  \hspace{0.5cm}{\tt LRTI} &  LongRun table interface  \\
    9.14 @@ -244,18 +244,6 @@ The following enumeration types are used
    9.15  \vspace{1cm}
    9.16  \begin{longtable}{|ll|}
    9.17  \hline
    9.18 -{\tt enum boot\_type} & \\
    9.19 -\hline
    9.20 -\hspace{0.5cm}{\tt bios} & boot an HVM guest using an emulated BIOS \\
    9.21 -\hspace{0.5cm}{\tt grub} & boot from inside the machine using grub \\
    9.22 -\hspace{0.5cm}{\tt kernel\_external} & boot from an external kernel \\
    9.23 -\hspace{0.5cm}{\tt kernel\_internal} & boot from a kernel inside the guest filesystem \\
    9.24 -\hline
    9.25 -\end{longtable}
    9.26 -
    9.27 -\vspace{1cm}
    9.28 -\begin{longtable}{|ll|}
    9.29 -\hline
    9.30  {\tt enum vbd\_mode} & \\
    9.31  \hline
    9.32  \hspace{0.5cm}{\tt RO} & disk is mounted read-only \\
    9.33 @@ -298,6 +286,7 @@ Quals & Field & Type & Description \\
    9.34  $\mathit{RO}_\mathit{run}$ &  {\tt uuid} & string & unique identifier/object reference \\
    9.35  $\mathit{RO}_\mathit{ins}$ &  {\tt this\_host} & host ref & Currently connected host \\
    9.36  $\mathit{RO}_\mathit{ins}$ &  {\tt this\_user} & user ref & Currently connected user \\
    9.37 +$\mathit{RO}_\mathit{run}$ &  {\tt last\_active} & int & Timestamp for last time session was active \\
    9.38  \hline
    9.39  \end{longtable}
    9.40  \subsection{Additional RPCs associated with class: session}
    9.41 @@ -452,45 +441,13 @@ value of the field
    9.42  \vspace{0.3cm}
    9.43  \vspace{0.3cm}
    9.44  \vspace{0.3cm}
    9.45 -\subsubsection{RPC name:~create}
    9.46 -
    9.47 -{\bf Overview:} 
    9.48 -Create a new session instance, and return its handle.
    9.49 -
    9.50 - \noindent {\bf Signature:} 
    9.51 -\begin{verbatim} (session ref) create (session_id s, session record args)\end{verbatim}
    9.52 -
    9.53 -
    9.54 -\noindent{\bf Arguments:}
    9.55 -
    9.56 - 
    9.57 -\vspace{0.3cm}
    9.58 -\begin{tabular}{|c|c|p{7cm}|}
    9.59 - \hline
    9.60 -{\bf type} & {\bf name} & {\bf description} \\ \hline
    9.61 -{\tt session record } & args & All constructor arguments \\ \hline 
    9.62 -
    9.63 -\end{tabular}
    9.64 -
    9.65 -\vspace{0.3cm}
    9.66 -
    9.67 - \noindent {\bf Return Type:} 
    9.68 -{\tt 
    9.69 -session ref
    9.70 -}
    9.71 -
    9.72 -
    9.73 -reference to the newly created object
    9.74 -\vspace{0.3cm}
    9.75 -\vspace{0.3cm}
    9.76 -\vspace{0.3cm}
    9.77 -\subsubsection{RPC name:~destroy}
    9.78 -
    9.79 -{\bf Overview:} 
    9.80 -Destroy the specified session instance.
    9.81 -
    9.82 - \noindent {\bf Signature:} 
    9.83 -\begin{verbatim} void destroy (session_id s, session ref self)\end{verbatim}
    9.84 +\subsubsection{RPC name:~get\_last\_active}
    9.85 +
    9.86 +{\bf Overview:} 
    9.87 +Get the last\_active field of the given session.
    9.88 +
    9.89 + \noindent {\bf Signature:} 
    9.90 +\begin{verbatim} int get_last_active (session_id s, session ref self)\end{verbatim}
    9.91  
    9.92  
    9.93  \noindent{\bf Arguments:}
    9.94 @@ -508,11 +465,11 @@ Destroy the specified session instance.
    9.95  
    9.96   \noindent {\bf Return Type:} 
    9.97  {\tt 
    9.98 -void
    9.99 -}
   9.100 -
   9.101 -
   9.102 -
   9.103 +int
   9.104 +}
   9.105 +
   9.106 +
   9.107 +value of the field
   9.108  \vspace{0.3cm}
   9.109  \vspace{0.3cm}
   9.110  \vspace{0.3cm}
   9.111 @@ -608,7 +565,7 @@ Quals & Field & Type & Description \\
   9.112  \subsubsection{RPC name:~get\_all}
   9.113  
   9.114  {\bf Overview:} 
   9.115 -Return a list of all the tasks known to the system
   9.116 +Return a list of all the tasks known to the system.
   9.117  
   9.118   \noindent {\bf Signature:} 
   9.119  \begin{verbatim} ((task ref) Set) get_all (session_id s)\end{verbatim}
   9.120 @@ -1014,70 +971,6 @@ value of the field
   9.121  \vspace{0.3cm}
   9.122  \vspace{0.3cm}
   9.123  \vspace{0.3cm}
   9.124 -\subsubsection{RPC name:~create}
   9.125 -
   9.126 -{\bf Overview:} 
   9.127 -Create a new task instance, and return its handle.
   9.128 -
   9.129 - \noindent {\bf Signature:} 
   9.130 -\begin{verbatim} (task ref) create (session_id s, task record args)\end{verbatim}
   9.131 -
   9.132 -
   9.133 -\noindent{\bf Arguments:}
   9.134 -
   9.135 - 
   9.136 -\vspace{0.3cm}
   9.137 -\begin{tabular}{|c|c|p{7cm}|}
   9.138 - \hline
   9.139 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.140 -{\tt task record } & args & All constructor arguments \\ \hline 
   9.141 -
   9.142 -\end{tabular}
   9.143 -
   9.144 -\vspace{0.3cm}
   9.145 -
   9.146 - \noindent {\bf Return Type:} 
   9.147 -{\tt 
   9.148 -task ref
   9.149 -}
   9.150 -
   9.151 -
   9.152 -reference to the newly created object
   9.153 -\vspace{0.3cm}
   9.154 -\vspace{0.3cm}
   9.155 -\vspace{0.3cm}
   9.156 -\subsubsection{RPC name:~destroy}
   9.157 -
   9.158 -{\bf Overview:} 
   9.159 -Destroy the specified task instance.
   9.160 -
   9.161 - \noindent {\bf Signature:} 
   9.162 -\begin{verbatim} void destroy (session_id s, task ref self)\end{verbatim}
   9.163 -
   9.164 -
   9.165 -\noindent{\bf Arguments:}
   9.166 -
   9.167 - 
   9.168 -\vspace{0.3cm}
   9.169 -\begin{tabular}{|c|c|p{7cm}|}
   9.170 - \hline
   9.171 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.172 -{\tt task ref } & self & reference to the object \\ \hline 
   9.173 -
   9.174 -\end{tabular}
   9.175 -
   9.176 -\vspace{0.3cm}
   9.177 -
   9.178 - \noindent {\bf Return Type:} 
   9.179 -{\tt 
   9.180 -void
   9.181 -}
   9.182 -
   9.183 -
   9.184 -
   9.185 -\vspace{0.3cm}
   9.186 -\vspace{0.3cm}
   9.187 -\vspace{0.3cm}
   9.188  \subsubsection{RPC name:~get\_by\_uuid}
   9.189  
   9.190  {\bf Overview:} 
   9.191 @@ -1182,7 +1075,34 @@ references to objects with match names
   9.192  \begin{longtable}{|lllp{0.38\textwidth}|}
   9.193  \hline
   9.194  \multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf VM} \\
   9.195 -\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A virtual machine (or 'guest')}} \\
   9.196 +\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em A virtual machine (or 'guest').
   9.197 +
   9.198 +VM booting is controlled by setting one of the two mutually exclusive
   9.199 +groups: "PV", and "HVM".  If HVM.boot is the empty string, then paravirtual
   9.200 +domain building and booting will be used; otherwise the VM will be loaded
   9.201 +as an HVM domain, and booted using an emulated BIOS.
   9.202 +
   9.203 +When paravirtual booting is in use, the PV/bootloader field indicates the
   9.204 +bootloader to use.  It may be "pygrub", in which case the platform's
   9.205 +default installation of pygrub will be used, or a full path within the
   9.206 +control domain to some other bootloader.  The other fields, PV/kernel,
   9.207 +PV/ramdisk, PV/args and PV/bootloader\_args will be passed to the
   9.208 +bootloader unmodified, and interpretation of those fields is then specific
   9.209 +to the bootloader itself, including the possibility that the bootloader
   9.210 +will ignore some or all of those given values.
   9.211 +
   9.212 +If the bootloader is pygrub, then the menu.lst is parsed if present in the
   9.213 +guest's filesystem, otherwise the specified kernel and ramdisk are used, or
   9.214 +an autodetected kernel is used if nothing is specified and autodetection is
   9.215 +possible.  PV/args is appended to the kernel command line, no matter which
   9.216 +mechanism is used for finding the kernel.
   9.217 +
   9.218 +If PV/bootloader is empty but PV/kernel is specified, then the kernel and
   9.219 +ramdisk values will be treated as paths within the control domain.  If both
   9.220 +PV/bootloader and PV/kernel are empty, then the behaviour is as if
   9.221 +PV/bootloader was specified as "pygrub".
   9.222 +
   9.223 +When using HVM booting, HVM/boot specifies the order of the boot devices}} \\
   9.224  \hline
   9.225  Quals & Field & Type & Description \\
   9.226  \hline
   9.227 @@ -1215,18 +1135,17 @@ Quals & Field & Type & Description \\
   9.228  $\mathit{RO}_\mathit{run}$ &  {\tt VIFs} & (VIF ref) Set & virtual network interfaces \\
   9.229  $\mathit{RO}_\mathit{run}$ &  {\tt VBDs} & (VBD ref) Set & virtual block devices \\
   9.230  $\mathit{RO}_\mathit{run}$ &  {\tt VTPMs} & (VTPM ref) Set & virtual TPMs \\
   9.231 -$\mathit{RW}$ &  {\tt bios/boot} & string & device to boot the guest from \\
   9.232 +$\mathit{RW}$ &  {\tt PV/bootloader} & string & name of or path to bootloader \\
   9.233 +$\mathit{RW}$ &  {\tt PV/kernel} & string & path to the kernel \\
   9.234 +$\mathit{RW}$ &  {\tt PV/ramdisk} & string & path to the initrd \\
   9.235 +$\mathit{RW}$ &  {\tt PV/args} & string & kernel command-line arguments \\
   9.236 +$\mathit{RW}$ &  {\tt PV/bootloader\_args} & string & miscellaneous arguments for the bootloader \\
   9.237 +$\mathit{RW}$ &  {\tt HVM/boot} & string & device boot order \\
   9.238  $\mathit{RW}$ &  {\tt platform/std\_VGA} & bool & emulate standard VGA instead of cirrus logic \\
   9.239  $\mathit{RW}$ &  {\tt platform/serial} & string & redirect serial port to pty \\
   9.240  $\mathit{RW}$ &  {\tt platform/localtime} & bool & set RTC to local time \\
   9.241  $\mathit{RW}$ &  {\tt platform/clock\_offset} & bool & timeshift applied to guest's clock \\
   9.242  $\mathit{RW}$ &  {\tt platform/enable\_audio} & bool & emulate audio \\
   9.243 -$\mathit{RW}$ &  {\tt builder} & string & domain builder to use \\
   9.244 -$\mathit{RW}$ &  {\tt boot\_method} & boot\_type & select how this machine should boot \\
   9.245 -$\mathit{RW}$ &  {\tt kernel/kernel} & string & path to kernel e.g. /boot/vmlinuz \\
   9.246 -$\mathit{RW}$ &  {\tt kernel/initrd} & string & path to the initrd e.g. /boot/initrd.img \\
   9.247 -$\mathit{RW}$ &  {\tt kernel/args} & string & extra kernel command-line arguments \\
   9.248 -$\mathit{RW}$ &  {\tt grub/cmdline} & string & grub command-line \\
   9.249  $\mathit{RO}_\mathit{ins}$ &  {\tt PCI\_bus} & string & PCI bus path for pass-through devices \\
   9.250  $\mathit{RO}_\mathit{run}$ &  {\tt tools\_version} & (string $\rightarrow$ string) Map & versions of installed paravirtualised drivers \\
   9.251  $\mathit{RW}$ &  {\tt otherConfig} & (string $\rightarrow$ string) Map & additional configuration \\
   9.252 @@ -1265,8 +1184,10 @@ VM ref
   9.253  
   9.254  The ID of the newly created VM.
   9.255  \vspace{0.3cm}
   9.256 -\vspace{0.3cm}
   9.257 -\vspace{0.3cm}
   9.258 +
   9.259 +\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
   9.260 +
   9.261 +\vspace{0.6cm}
   9.262  \subsubsection{RPC name:~start}
   9.263  
   9.264  {\bf Overview:} 
   9.265 @@ -1299,8 +1220,10 @@ void
   9.266  
   9.267  
   9.268  \vspace{0.3cm}
   9.269 -\vspace{0.3cm}
   9.270 -\vspace{0.3cm}
   9.271 +
   9.272 +\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
   9.273 +
   9.274 +\vspace{0.6cm}
   9.275  \subsubsection{RPC name:~pause}
   9.276  
   9.277  {\bf Overview:} 
   9.278 @@ -1331,8 +1254,10 @@ void
   9.279  
   9.280  
   9.281  \vspace{0.3cm}
   9.282 -\vspace{0.3cm}
   9.283 -\vspace{0.3cm}
   9.284 +
   9.285 +\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
   9.286 +
   9.287 +\vspace{0.6cm}
   9.288  \subsubsection{RPC name:~unpause}
   9.289  
   9.290  {\bf Overview:} 
   9.291 @@ -1349,22 +1274,24 @@ Resume the specified VM. This can only b
   9.292  \begin{tabular}{|c|c|p{7cm}|}
   9.293   \hline
   9.294  {\bf type} & {\bf name} & {\bf description} \\ \hline
   9.295 -{\tt VM ref } & vm & The VM to pause \\ \hline 
   9.296 -
   9.297 -\end{tabular}
   9.298 -
   9.299 -\vspace{0.3cm}
   9.300 -
   9.301 - \noindent {\bf Return Type:} 
   9.302 -{\tt 
   9.303 -void
   9.304 -}
   9.305 -
   9.306 -
   9.307 -
   9.308 -\vspace{0.3cm}
   9.309 -\vspace{0.3cm}
   9.310 -\vspace{0.3cm}
   9.311 +{\tt VM ref } & vm & The VM to unpause \\ \hline 
   9.312 +
   9.313 +\end{tabular}
   9.314 +
   9.315 +\vspace{0.3cm}
   9.316 +
   9.317 + \noindent {\bf Return Type:} 
   9.318 +{\tt 
   9.319 +void
   9.320 +}
   9.321 +
   9.322 +
   9.323 +
   9.324 +\vspace{0.3cm}
   9.325 +
   9.326 +\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
   9.327 +
   9.328 +\vspace{0.6cm}
   9.329  \subsubsection{RPC name:~clean\_shutdown}
   9.330  
   9.331  {\bf Overview:} 
   9.332 @@ -1372,6 +1299,8 @@ Attempt to cleanly shutdown the specifie
   9.333  
   9.334  Once shutdown has been completed perform poweroff action specified in guest configuration.
   9.335  
   9.336 +This can only be called when the specified VM is in the Running state.
   9.337 +
   9.338   \noindent {\bf Signature:} 
   9.339  \begin{verbatim} void clean_shutdown (session_id s, VM ref vm)\end{verbatim}
   9.340  
   9.341 @@ -1397,8 +1326,10 @@ void
   9.342  
   9.343  
   9.344  \vspace{0.3cm}
   9.345 -\vspace{0.3cm}
   9.346 -\vspace{0.3cm}
   9.347 +
   9.348 +\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
   9.349 +
   9.350 +\vspace{0.6cm}
   9.351  \subsubsection{RPC name:~clean\_reboot}
   9.352  
   9.353  {\bf Overview:} 
   9.354 @@ -1406,6 +1337,8 @@ Attempt to cleanly shutdown the specifie
   9.355  
   9.356  Once shutdown has been completed perform reboot action specified in guest configuration.
   9.357  
   9.358 +This can only be called when the specified VM is in the Running state.
   9.359 +
   9.360   \noindent {\bf Signature:} 
   9.361  \begin{verbatim} void clean_reboot (session_id s, VM ref vm)\end{verbatim}
   9.362  
   9.363 @@ -1431,8 +1364,10 @@ void
   9.364  
   9.365  
   9.366  \vspace{0.3cm}
   9.367 -\vspace{0.3cm}
   9.368 -\vspace{0.3cm}
   9.369 +
   9.370 +\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
   9.371 +
   9.372 +\vspace{0.6cm}
   9.373  \subsubsection{RPC name:~hard\_shutdown}
   9.374  
   9.375  {\bf Overview:} 
   9.376 @@ -1500,7 +1435,7 @@ void
   9.377  \subsubsection{RPC name:~suspend}
   9.378  
   9.379  {\bf Overview:} 
   9.380 -Suspend the specified VM to disk.
   9.381 +Suspend the specified VM to disk.  This can only be called when the specified VM is in the Running state.
   9.382  
   9.383   \noindent {\bf Signature:} 
   9.384  \begin{verbatim} void suspend (session_id s, VM ref vm)\end{verbatim}
   9.385 @@ -1527,12 +1462,14 @@ void
   9.386  
   9.387  
   9.388  \vspace{0.3cm}
   9.389 -\vspace{0.3cm}
   9.390 -\vspace{0.3cm}
   9.391 +
   9.392 +\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
   9.393 +
   9.394 +\vspace{0.6cm}
   9.395  \subsubsection{RPC name:~resume}
   9.396  
   9.397  {\bf Overview:} 
   9.398 -Awaken the specified VM and resume it.
   9.399 +Awaken the specified VM and resume it.  This can only be called when the specified VM is in the Suspended state.
   9.400  
   9.401   \noindent {\bf Signature:} 
   9.402  \begin{verbatim} void resume (session_id s, VM ref vm, bool start_paused)\end{verbatim}
   9.403 @@ -1561,8 +1498,10 @@ void
   9.404  
   9.405  
   9.406  \vspace{0.3cm}
   9.407 -\vspace{0.3cm}
   9.408 -\vspace{0.3cm}
   9.409 +
   9.410 +\noindent{\bf Possible Error Codes:} {\tt VM\_BAD\_POWER\_STATE}
   9.411 +
   9.412 +\vspace{0.6cm}
   9.413  \subsubsection{RPC name:~get\_all}
   9.414  
   9.415  {\bf Overview:} 
   9.416 @@ -2601,7 +2540,7 @@ void
   9.417  \subsubsection{RPC name:~add\_VCPUs\_features\_force\_on}
   9.418  
   9.419  {\bf Overview:} 
   9.420 -set add message derived from field VCPUs/features/force\_on of object VM
   9.421 +Add the given value to the VCPUs/features/force\_on field of the given VM.  If the value is already in that Set, then do nothing.
   9.422  
   9.423   \noindent {\bf Signature:} 
   9.424  \begin{verbatim} void add_VCPUs_features_force_on (session_id s, VM ref self, cpu_feature value)\end{verbatim}
   9.425 @@ -2635,7 +2574,7 @@ void
   9.426  \subsubsection{RPC name:~remove\_VCPUs\_features\_force\_on}
   9.427  
   9.428  {\bf Overview:} 
   9.429 -set remove message derived from field VCPUs/features/force\_on of object VM
   9.430 +Remove the given value from the VCPUs/features/force\_on field of the given VM.  If the value is not in that Set, then do nothing.
   9.431  
   9.432   \noindent {\bf Signature:} 
   9.433  \begin{verbatim} void remove_VCPUs_features_force_on (session_id s, VM ref self, cpu_feature value)\end{verbatim}
   9.434 @@ -2735,7 +2674,7 @@ void
   9.435  \subsubsection{RPC name:~add\_VCPUs\_features\_force\_off}
   9.436  
   9.437  {\bf Overview:} 
   9.438 -set add message derived from field VCPUs/features/force\_off of object VM
   9.439 +Add the given value to the VCPUs/features/force\_off field of the given VM.  If the value is already in that Set, then do nothing.
   9.440  
   9.441   \noindent {\bf Signature:} 
   9.442  \begin{verbatim} void add_VCPUs_features_force_off (session_id s, VM ref self, cpu_feature value)\end{verbatim}
   9.443 @@ -2769,7 +2708,7 @@ void
   9.444  \subsubsection{RPC name:~remove\_VCPUs\_features\_force\_off}
   9.445  
   9.446  {\bf Overview:} 
   9.447 -set remove message derived from field VCPUs/features/force\_off of object VM
   9.448 +Remove the given value from the VCPUs/features/force\_off field of the given VM.  If the value is not in that Set, then do nothing.
   9.449  
   9.450   \noindent {\bf Signature:} 
   9.451  \begin{verbatim} void remove_VCPUs_features_force_off (session_id s, VM ref self, cpu_feature value)\end{verbatim}
   9.452 @@ -3192,13 +3131,145 @@ value of the field
   9.453  \vspace{0.3cm}
   9.454  \vspace{0.3cm}
   9.455  \vspace{0.3cm}
   9.456 -\subsubsection{RPC name:~get\_bios\_boot}
   9.457 -
   9.458 -{\bf Overview:} 
   9.459 -Get the bios/boot field of the given VM.
   9.460 -
   9.461 - \noindent {\bf Signature:} 
   9.462 -\begin{verbatim} string get_bios_boot (session_id s, VM ref self)\end{verbatim}
   9.463 +\subsubsection{RPC name:~get\_PV\_bootloader}
   9.464 +
   9.465 +{\bf Overview:} 
   9.466 +Get the PV/bootloader field of the given VM.
   9.467 +
   9.468 + \noindent {\bf Signature:} 
   9.469 +\begin{verbatim} string get_PV_bootloader (session_id s, VM ref self)\end{verbatim}
   9.470 +
   9.471 +
   9.472 +\noindent{\bf Arguments:}
   9.473 +
   9.474 + 
   9.475 +\vspace{0.3cm}
   9.476 +\begin{tabular}{|c|c|p{7cm}|}
   9.477 + \hline
   9.478 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.479 +{\tt VM ref } & self & reference to the object \\ \hline 
   9.480 +
   9.481 +\end{tabular}
   9.482 +
   9.483 +\vspace{0.3cm}
   9.484 +
   9.485 + \noindent {\bf Return Type:} 
   9.486 +{\tt 
   9.487 +string
   9.488 +}
   9.489 +
   9.490 +
   9.491 +value of the field
   9.492 +\vspace{0.3cm}
   9.493 +\vspace{0.3cm}
   9.494 +\vspace{0.3cm}
   9.495 +\subsubsection{RPC name:~set\_PV\_bootloader}
   9.496 +
   9.497 +{\bf Overview:} 
   9.498 +Set the PV/bootloader field of the given VM.
   9.499 +
   9.500 + \noindent {\bf Signature:} 
   9.501 +\begin{verbatim} void set_PV_bootloader (session_id s, VM ref self, string value)\end{verbatim}
   9.502 +
   9.503 +
   9.504 +\noindent{\bf Arguments:}
   9.505 +
   9.506 + 
   9.507 +\vspace{0.3cm}
   9.508 +\begin{tabular}{|c|c|p{7cm}|}
   9.509 + \hline
   9.510 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.511 +{\tt VM ref } & self & reference to the object \\ \hline 
   9.512 +
   9.513 +{\tt string } & value & New value to set \\ \hline 
   9.514 +
   9.515 +\end{tabular}
   9.516 +
   9.517 +\vspace{0.3cm}
   9.518 +
   9.519 + \noindent {\bf Return Type:} 
   9.520 +{\tt 
   9.521 +void
   9.522 +}
   9.523 +
   9.524 +
   9.525 +
   9.526 +\vspace{0.3cm}
   9.527 +\vspace{0.3cm}
   9.528 +\vspace{0.3cm}
   9.529 +\subsubsection{RPC name:~get\_PV\_kernel}
   9.530 +
   9.531 +{\bf Overview:} 
   9.532 +Get the PV/kernel field of the given VM.
   9.533 +
   9.534 + \noindent {\bf Signature:} 
   9.535 +\begin{verbatim} string get_PV_kernel (session_id s, VM ref self)\end{verbatim}
   9.536 +
   9.537 +
   9.538 +\noindent{\bf Arguments:}
   9.539 +
   9.540 + 
   9.541 +\vspace{0.3cm}
   9.542 +\begin{tabular}{|c|c|p{7cm}|}
   9.543 + \hline
   9.544 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.545 +{\tt VM ref } & self & reference to the object \\ \hline 
   9.546 +
   9.547 +\end{tabular}
   9.548 +
   9.549 +\vspace{0.3cm}
   9.550 +
   9.551 + \noindent {\bf Return Type:} 
   9.552 +{\tt 
   9.553 +string
   9.554 +}
   9.555 +
   9.556 +
   9.557 +value of the field
   9.558 +\vspace{0.3cm}
   9.559 +\vspace{0.3cm}
   9.560 +\vspace{0.3cm}
   9.561 +\subsubsection{RPC name:~set\_PV\_kernel}
   9.562 +
   9.563 +{\bf Overview:} 
   9.564 +Set the PV/kernel field of the given VM.
   9.565 +
   9.566 + \noindent {\bf Signature:} 
   9.567 +\begin{verbatim} void set_PV_kernel (session_id s, VM ref self, string value)\end{verbatim}
   9.568 +
   9.569 +
   9.570 +\noindent{\bf Arguments:}
   9.571 +
   9.572 + 
   9.573 +\vspace{0.3cm}
   9.574 +\begin{tabular}{|c|c|p{7cm}|}
   9.575 + \hline
   9.576 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.577 +{\tt VM ref } & self & reference to the object \\ \hline 
   9.578 +
   9.579 +{\tt string } & value & New value to set \\ \hline 
   9.580 +
   9.581 +\end{tabular}
   9.582 +
   9.583 +\vspace{0.3cm}
   9.584 +
   9.585 + \noindent {\bf Return Type:} 
   9.586 +{\tt 
   9.587 +void
   9.588 +}
   9.589 +
   9.590 +
   9.591 +
   9.592 +\vspace{0.3cm}
   9.593 +\vspace{0.3cm}
   9.594 +\vspace{0.3cm}
   9.595 +\subsubsection{RPC name:~get\_PV\_ramdisk}
   9.596 +
   9.597 +{\bf Overview:} 
   9.598 +Get the PV/ramdisk field of the given VM.
   9.599 +
   9.600 + \noindent {\bf Signature:} 
   9.601 +\begin{verbatim} string get_PV_ramdisk (session_id s, VM ref self)\end{verbatim}
   9.602  
   9.603  
   9.604  \noindent{\bf Arguments:}
   9.605 @@ -3224,13 +3295,211 @@ value of the field
   9.606  \vspace{0.3cm}
   9.607  \vspace{0.3cm}
   9.608  \vspace{0.3cm}
   9.609 -\subsubsection{RPC name:~set\_bios\_boot}
   9.610 -
   9.611 -{\bf Overview:} 
   9.612 -Set the bios/boot field of the given VM.
   9.613 -
   9.614 - \noindent {\bf Signature:} 
   9.615 -\begin{verbatim} void set_bios_boot (session_id s, VM ref self, string value)\end{verbatim}
   9.616 +\subsubsection{RPC name:~set\_PV\_ramdisk}
   9.617 +
   9.618 +{\bf Overview:} 
   9.619 +Set the PV/ramdisk field of the given VM.
   9.620 +
   9.621 + \noindent {\bf Signature:} 
   9.622 +\begin{verbatim} void set_PV_ramdisk (session_id s, VM ref self, string value)\end{verbatim}
   9.623 +
   9.624 +
   9.625 +\noindent{\bf Arguments:}
   9.626 +
   9.627 + 
   9.628 +\vspace{0.3cm}
   9.629 +\begin{tabular}{|c|c|p{7cm}|}
   9.630 + \hline
   9.631 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.632 +{\tt VM ref } & self & reference to the object \\ \hline 
   9.633 +
   9.634 +{\tt string } & value & New value to set \\ \hline 
   9.635 +
   9.636 +\end{tabular}
   9.637 +
   9.638 +\vspace{0.3cm}
   9.639 +
   9.640 + \noindent {\bf Return Type:} 
   9.641 +{\tt 
   9.642 +void
   9.643 +}
   9.644 +
   9.645 +
   9.646 +
   9.647 +\vspace{0.3cm}
   9.648 +\vspace{0.3cm}
   9.649 +\vspace{0.3cm}
   9.650 +\subsubsection{RPC name:~get\_PV\_args}
   9.651 +
   9.652 +{\bf Overview:} 
   9.653 +Get the PV/args field of the given VM.
   9.654 +
   9.655 + \noindent {\bf Signature:} 
   9.656 +\begin{verbatim} string get_PV_args (session_id s, VM ref self)\end{verbatim}
   9.657 +
   9.658 +
   9.659 +\noindent{\bf Arguments:}
   9.660 +
   9.661 + 
   9.662 +\vspace{0.3cm}
   9.663 +\begin{tabular}{|c|c|p{7cm}|}
   9.664 + \hline
   9.665 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.666 +{\tt VM ref } & self & reference to the object \\ \hline 
   9.667 +
   9.668 +\end{tabular}
   9.669 +
   9.670 +\vspace{0.3cm}
   9.671 +
   9.672 + \noindent {\bf Return Type:} 
   9.673 +{\tt 
   9.674 +string
   9.675 +}
   9.676 +
   9.677 +
   9.678 +value of the field
   9.679 +\vspace{0.3cm}
   9.680 +\vspace{0.3cm}
   9.681 +\vspace{0.3cm}
   9.682 +\subsubsection{RPC name:~set\_PV\_args}
   9.683 +
   9.684 +{\bf Overview:} 
   9.685 +Set the PV/args field of the given VM.
   9.686 +
   9.687 + \noindent {\bf Signature:} 
   9.688 +\begin{verbatim} void set_PV_args (session_id s, VM ref self, string value)\end{verbatim}
   9.689 +
   9.690 +
   9.691 +\noindent{\bf Arguments:}
   9.692 +
   9.693 + 
   9.694 +\vspace{0.3cm}
   9.695 +\begin{tabular}{|c|c|p{7cm}|}
   9.696 + \hline
   9.697 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.698 +{\tt VM ref } & self & reference to the object \\ \hline 
   9.699 +
   9.700 +{\tt string } & value & New value to set \\ \hline 
   9.701 +
   9.702 +\end{tabular}
   9.703 +
   9.704 +\vspace{0.3cm}
   9.705 +
   9.706 + \noindent {\bf Return Type:} 
   9.707 +{\tt 
   9.708 +void
   9.709 +}
   9.710 +
   9.711 +
   9.712 +
   9.713 +\vspace{0.3cm}
   9.714 +\vspace{0.3cm}
   9.715 +\vspace{0.3cm}
   9.716 +\subsubsection{RPC name:~get\_PV\_bootloader\_args}
   9.717 +
   9.718 +{\bf Overview:} 
   9.719 +Get the PV/bootloader\_args field of the given VM.
   9.720 +
   9.721 + \noindent {\bf Signature:} 
   9.722 +\begin{verbatim} string get_PV_bootloader_args (session_id s, VM ref self)\end{verbatim}
   9.723 +
   9.724 +
   9.725 +\noindent{\bf Arguments:}
   9.726 +
   9.727 + 
   9.728 +\vspace{0.3cm}
   9.729 +\begin{tabular}{|c|c|p{7cm}|}
   9.730 + \hline
   9.731 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.732 +{\tt VM ref } & self & reference to the object \\ \hline 
   9.733 +
   9.734 +\end{tabular}
   9.735 +
   9.736 +\vspace{0.3cm}
   9.737 +
   9.738 + \noindent {\bf Return Type:} 
   9.739 +{\tt 
   9.740 +string
   9.741 +}
   9.742 +
   9.743 +
   9.744 +value of the field
   9.745 +\vspace{0.3cm}
   9.746 +\vspace{0.3cm}
   9.747 +\vspace{0.3cm}
   9.748 +\subsubsection{RPC name:~set\_PV\_bootloader\_args}
   9.749 +
   9.750 +{\bf Overview:} 
   9.751 +Set the PV/bootloader\_args field of the given VM.
   9.752 +
   9.753 + \noindent {\bf Signature:} 
   9.754 +\begin{verbatim} void set_PV_bootloader_args (session_id s, VM ref self, string value)\end{verbatim}
   9.755 +
   9.756 +
   9.757 +\noindent{\bf Arguments:}
   9.758 +
   9.759 + 
   9.760 +\vspace{0.3cm}
   9.761 +\begin{tabular}{|c|c|p{7cm}|}
   9.762 + \hline
   9.763 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.764 +{\tt VM ref } & self & reference to the object \\ \hline 
   9.765 +
   9.766 +{\tt string } & value & New value to set \\ \hline 
   9.767 +
   9.768 +\end{tabular}
   9.769 +
   9.770 +\vspace{0.3cm}
   9.771 +
   9.772 + \noindent {\bf Return Type:} 
   9.773 +{\tt 
   9.774 +void
   9.775 +}
   9.776 +
   9.777 +
   9.778 +
   9.779 +\vspace{0.3cm}
   9.780 +\vspace{0.3cm}
   9.781 +\vspace{0.3cm}
   9.782 +\subsubsection{RPC name:~get\_HVM\_boot}
   9.783 +
   9.784 +{\bf Overview:} 
   9.785 +Get the HVM/boot field of the given VM.
   9.786 +
   9.787 + \noindent {\bf Signature:} 
   9.788 +\begin{verbatim} string get_HVM_boot (session_id s, VM ref self)\end{verbatim}
   9.789 +
   9.790 +
   9.791 +\noindent{\bf Arguments:}
   9.792 +
   9.793 + 
   9.794 +\vspace{0.3cm}
   9.795 +\begin{tabular}{|c|c|p{7cm}|}
   9.796 + \hline
   9.797 +{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.798 +{\tt VM ref } & self & reference to the object \\ \hline 
   9.799 +
   9.800 +\end{tabular}
   9.801 +
   9.802 +\vspace{0.3cm}
   9.803 +
   9.804 + \noindent {\bf Return Type:} 
   9.805 +{\tt 
   9.806 +string
   9.807 +}
   9.808 +
   9.809 +
   9.810 +value of the field
   9.811 +\vspace{0.3cm}
   9.812 +\vspace{0.3cm}
   9.813 +\vspace{0.3cm}
   9.814 +\subsubsection{RPC name:~set\_HVM\_boot}
   9.815 +
   9.816 +{\bf Overview:} 
   9.817 +Set the HVM/boot field of the given VM.
   9.818 +
   9.819 + \noindent {\bf Signature:} 
   9.820 +\begin{verbatim} void set_HVM_boot (session_id s, VM ref self, string value)\end{verbatim}
   9.821  
   9.822  
   9.823  \noindent{\bf Arguments:}
   9.824 @@ -3588,402 +3857,6 @@ void
   9.825  \vspace{0.3cm}
   9.826  \vspace{0.3cm}
   9.827  \vspace{0.3cm}
   9.828 -\subsubsection{RPC name:~get\_builder}
   9.829 -
   9.830 -{\bf Overview:} 
   9.831 -Get the builder field of the given VM.
   9.832 -
   9.833 - \noindent {\bf Signature:} 
   9.834 -\begin{verbatim} string get_builder (session_id s, VM ref self)\end{verbatim}
   9.835 -
   9.836 -
   9.837 -\noindent{\bf Arguments:}
   9.838 -
   9.839 - 
   9.840 -\vspace{0.3cm}
   9.841 -\begin{tabular}{|c|c|p{7cm}|}
   9.842 - \hline
   9.843 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.844 -{\tt VM ref } & self & reference to the object \\ \hline 
   9.845 -
   9.846 -\end{tabular}
   9.847 -
   9.848 -\vspace{0.3cm}
   9.849 -
   9.850 - \noindent {\bf Return Type:} 
   9.851 -{\tt 
   9.852 -string
   9.853 -}
   9.854 -
   9.855 -
   9.856 -value of the field
   9.857 -\vspace{0.3cm}
   9.858 -\vspace{0.3cm}
   9.859 -\vspace{0.3cm}
   9.860 -\subsubsection{RPC name:~set\_builder}
   9.861 -
   9.862 -{\bf Overview:} 
   9.863 -Set the builder field of the given VM.
   9.864 -
   9.865 - \noindent {\bf Signature:} 
   9.866 -\begin{verbatim} void set_builder (session_id s, VM ref self, string value)\end{verbatim}
   9.867 -
   9.868 -
   9.869 -\noindent{\bf Arguments:}
   9.870 -
   9.871 - 
   9.872 -\vspace{0.3cm}
   9.873 -\begin{tabular}{|c|c|p{7cm}|}
   9.874 - \hline
   9.875 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.876 -{\tt VM ref } & self & reference to the object \\ \hline 
   9.877 -
   9.878 -{\tt string } & value & New value to set \\ \hline 
   9.879 -
   9.880 -\end{tabular}
   9.881 -
   9.882 -\vspace{0.3cm}
   9.883 -
   9.884 - \noindent {\bf Return Type:} 
   9.885 -{\tt 
   9.886 -void
   9.887 -}
   9.888 -
   9.889 -
   9.890 -
   9.891 -\vspace{0.3cm}
   9.892 -\vspace{0.3cm}
   9.893 -\vspace{0.3cm}
   9.894 -\subsubsection{RPC name:~get\_boot\_method}
   9.895 -
   9.896 -{\bf Overview:} 
   9.897 -Get the boot\_method field of the given VM.
   9.898 -
   9.899 - \noindent {\bf Signature:} 
   9.900 -\begin{verbatim} (boot_type) get_boot_method (session_id s, VM ref self)\end{verbatim}
   9.901 -
   9.902 -
   9.903 -\noindent{\bf Arguments:}
   9.904 -
   9.905 - 
   9.906 -\vspace{0.3cm}
   9.907 -\begin{tabular}{|c|c|p{7cm}|}
   9.908 - \hline
   9.909 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.910 -{\tt VM ref } & self & reference to the object \\ \hline 
   9.911 -
   9.912 -\end{tabular}
   9.913 -
   9.914 -\vspace{0.3cm}
   9.915 -
   9.916 - \noindent {\bf Return Type:} 
   9.917 -{\tt 
   9.918 -boot\_type
   9.919 -}
   9.920 -
   9.921 -
   9.922 -value of the field
   9.923 -\vspace{0.3cm}
   9.924 -\vspace{0.3cm}
   9.925 -\vspace{0.3cm}
   9.926 -\subsubsection{RPC name:~set\_boot\_method}
   9.927 -
   9.928 -{\bf Overview:} 
   9.929 -Set the boot\_method field of the given VM.
   9.930 -
   9.931 - \noindent {\bf Signature:} 
   9.932 -\begin{verbatim} void set_boot_method (session_id s, VM ref self, boot_type value)\end{verbatim}
   9.933 -
   9.934 -
   9.935 -\noindent{\bf Arguments:}
   9.936 -
   9.937 - 
   9.938 -\vspace{0.3cm}
   9.939 -\begin{tabular}{|c|c|p{7cm}|}
   9.940 - \hline
   9.941 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.942 -{\tt VM ref } & self & reference to the object \\ \hline 
   9.943 -
   9.944 -{\tt boot\_type } & value & New value to set \\ \hline 
   9.945 -
   9.946 -\end{tabular}
   9.947 -
   9.948 -\vspace{0.3cm}
   9.949 -
   9.950 - \noindent {\bf Return Type:} 
   9.951 -{\tt 
   9.952 -void
   9.953 -}
   9.954 -
   9.955 -
   9.956 -
   9.957 -\vspace{0.3cm}
   9.958 -\vspace{0.3cm}
   9.959 -\vspace{0.3cm}
   9.960 -\subsubsection{RPC name:~get\_kernel\_kernel}
   9.961 -
   9.962 -{\bf Overview:} 
   9.963 -Get the kernel/kernel field of the given VM.
   9.964 -
   9.965 - \noindent {\bf Signature:} 
   9.966 -\begin{verbatim} string get_kernel_kernel (session_id s, VM ref self)\end{verbatim}
   9.967 -
   9.968 -
   9.969 -\noindent{\bf Arguments:}
   9.970 -
   9.971 - 
   9.972 -\vspace{0.3cm}
   9.973 -\begin{tabular}{|c|c|p{7cm}|}
   9.974 - \hline
   9.975 -{\bf type} & {\bf name} & {\bf description} \\ \hline
   9.976 -{\tt VM ref } & self & reference to the object \\ \hline 
   9.977 -
   9.978 -\end{tabular}
   9.979 -
   9.980 -\vspace{0.3cm}
   9.981 -
   9.982 - \noindent {\bf Return Type:} 
   9.983 -{\tt 
   9.984 -string
   9.985 -}
   9.986 -
   9.987 -
   9.988 -value of the field
   9.989 -\vspace{0.3cm}
   9.990 -\vspace{0.3cm}
   9.991 -\vspace{0.3cm}
   9.992 -\subsubsection{RPC name:~set\_kernel\_kernel}
   9.993 -
   9.994 -{\bf Overview:} 
   9.995 -Set the kernel/kernel field of the given VM.
   9.996 -
   9.997 - \noindent {\bf Signature:} 
   9.998 -\begin{verbatim} void set_kernel_kernel (session_id s, VM ref self, string value)\end{verbatim}
   9.999 -
  9.1000 -
  9.1001 -\noindent{\bf Arguments:}
  9.1002 -
  9.1003 - 
  9.1004 -\vspace{0.3cm}
  9.1005 -\begin{tabular}{|c|c|p{7cm}|}
  9.1006 - \hline
  9.1007 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  9.1008 -{\tt VM ref } & self & reference to the object \\ \hline 
  9.1009 -
  9.1010 -{\tt string } & value & New value to set \\ \hline 
  9.1011 -
  9.1012 -\end{tabular}
  9.1013 -
  9.1014 -\vspace{0.3cm}
  9.1015 -
  9.1016 - \noindent {\bf Return Type:} 
  9.1017 -{\tt 
  9.1018 -void
  9.1019 -}
  9.1020 -
  9.1021 -
  9.1022 -
  9.1023 -\vspace{0.3cm}
  9.1024 -\vspace{0.3cm}
  9.1025 -\vspace{0.3cm}
  9.1026 -\subsubsection{RPC name:~get\_kernel\_initrd}
  9.1027 -
  9.1028 -{\bf Overview:} 
  9.1029 -Get the kernel/initrd field of the given VM.
  9.1030 -
  9.1031 - \noindent {\bf Signature:} 
  9.1032 -\begin{verbatim} string get_kernel_initrd (session_id s, VM ref self)\end{verbatim}
  9.1033 -
  9.1034 -
  9.1035 -\noindent{\bf Arguments:}
  9.1036 -
  9.1037 - 
  9.1038 -\vspace{0.3cm}
  9.1039 -\begin{tabular}{|c|c|p{7cm}|}
  9.1040 - \hline
  9.1041 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  9.1042 -{\tt VM ref } & self & reference to the object \\ \hline 
  9.1043 -
  9.1044 -\end{tabular}
  9.1045 -
  9.1046 -\vspace{0.3cm}
  9.1047 -
  9.1048 - \noindent {\bf Return Type:} 
  9.1049 -{\tt 
  9.1050 -string
  9.1051 -}
  9.1052 -
  9.1053 -
  9.1054 -value of the field
  9.1055 -\vspace{0.3cm}
  9.1056 -\vspace{0.3cm}
  9.1057 -\vspace{0.3cm}
  9.1058 -\subsubsection{RPC name:~set\_kernel\_initrd}
  9.1059 -
  9.1060 -{\bf Overview:} 
  9.1061 -Set the kernel/initrd field of the given VM.
  9.1062 -
  9.1063 - \noindent {\bf Signature:} 
  9.1064 -\begin{verbatim} void set_kernel_initrd (session_id s, VM ref self, string value)\end{verbatim}
  9.1065 -
  9.1066 -
  9.1067 -\noindent{\bf Arguments:}
  9.1068 -
  9.1069 - 
  9.1070 -\vspace{0.3cm}
  9.1071 -\begin{tabular}{|c|c|p{7cm}|}
  9.1072 - \hline
  9.1073 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  9.1074 -{\tt VM ref } & self & reference to the object \\ \hline 
  9.1075 -
  9.1076 -{\tt string } & value & New value to set \\ \hline 
  9.1077 -
  9.1078 -\end{tabular}
  9.1079 -
  9.1080 -\vspace{0.3cm}
  9.1081 -
  9.1082 - \noindent {\bf Return Type:} 
  9.1083 -{\tt 
  9.1084 -void
  9.1085 -}
  9.1086 -
  9.1087 -
  9.1088 -
  9.1089 -\vspace{0.3cm}
  9.1090 -\vspace{0.3cm}
  9.1091 -\vspace{0.3cm}
  9.1092 -\subsubsection{RPC name:~get\_kernel\_args}
  9.1093 -
  9.1094 -{\bf Overview:} 
  9.1095 -Get the kernel/args field of the given VM.
  9.1096 -
  9.1097 - \noindent {\bf Signature:} 
  9.1098 -\begin{verbatim} string get_kernel_args (session_id s, VM ref self)\end{verbatim}
  9.1099 -
  9.1100 -
  9.1101 -\noindent{\bf Arguments:}
  9.1102 -
  9.1103 - 
  9.1104 -\vspace{0.3cm}
  9.1105 -\begin{tabular}{|c|c|p{7cm}|}
  9.1106 - \hline
  9.1107 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  9.1108 -{\tt VM ref } & self & reference to the object \\ \hline 
  9.1109 -
  9.1110 -\end{tabular}
  9.1111 -
  9.1112 -\vspace{0.3cm}
  9.1113 -
  9.1114 - \noindent {\bf Return Type:} 
  9.1115 -{\tt 
  9.1116 -string
  9.1117 -}
  9.1118 -
  9.1119 -
  9.1120 -value of the field
  9.1121 -\vspace{0.3cm}
  9.1122 -\vspace{0.3cm}
  9.1123 -\vspace{0.3cm}
  9.1124 -\subsubsection{RPC name:~set\_kernel\_args}
  9.1125 -
  9.1126 -{\bf Overview:} 
  9.1127 -Set the kernel/args field of the given VM.
  9.1128 -
  9.1129 - \noindent {\bf Signature:} 
  9.1130 -\begin{verbatim} void set_kernel_args (session_id s, VM ref self, string value)\end{verbatim}
  9.1131 -
  9.1132 -
  9.1133 -\noindent{\bf Arguments:}
  9.1134 -
  9.1135 - 
  9.1136 -\vspace{0.3cm}
  9.1137 -\begin{tabular}{|c|c|p{7cm}|}
  9.1138 - \hline
  9.1139 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  9.1140 -{\tt VM ref } & self & reference to the object \\ \hline 
  9.1141 -
  9.1142 -{\tt string } & value & New value to set \\ \hline 
  9.1143 -
  9.1144 -\end{tabular}
  9.1145 -
  9.1146 -\vspace{0.3cm}
  9.1147 -
  9.1148 - \noindent {\bf Return Type:} 
  9.1149 -{\tt 
  9.1150 -void
  9.1151 -}
  9.1152 -
  9.1153 -
  9.1154 -
  9.1155 -\vspace{0.3cm}
  9.1156 -\vspace{0.3cm}
  9.1157 -\vspace{0.3cm}
  9.1158 -\subsubsection{RPC name:~get\_grub\_cmdline}
  9.1159 -
  9.1160 -{\bf Overview:} 
  9.1161 -Get the grub/cmdline field of the given VM.
  9.1162 -
  9.1163 - \noindent {\bf Signature:} 
  9.1164 -\begin{verbatim} string get_grub_cmdline (session_id s, VM ref self)\end{verbatim}
  9.1165 -
  9.1166 -
  9.1167 -\noindent{\bf Arguments:}
  9.1168 -
  9.1169 - 
  9.1170 -\vspace{0.3cm}
  9.1171 -\begin{tabular}{|c|c|p{7cm}|}
  9.1172 - \hline
  9.1173 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  9.1174 -{\tt VM ref } & self & reference to the object \\ \hline 
  9.1175 -
  9.1176 -\end{tabular}
  9.1177 -
  9.1178 -\vspace{0.3cm}
  9.1179 -
  9.1180 - \noindent {\bf Return Type:} 
  9.1181 -{\tt 
  9.1182 -string
  9.1183 -}
  9.1184 -
  9.1185 -
  9.1186 -value of the field
  9.1187 -\vspace{0.3cm}
  9.1188 -\vspace{0.3cm}
  9.1189 -\vspace{0.3cm}
  9.1190 -\subsubsection{RPC name:~set\_grub\_cmdline}
  9.1191 -
  9.1192 -{\bf Overview:} 
  9.1193 -Set the grub/cmdline field of the given VM.
  9.1194 -
  9.1195 - \noindent {\bf Signature:} 
  9.1196 -\begin{verbatim} void set_grub_cmdline (session_id s, VM ref self, string value)\end{verbatim}
  9.1197 -
  9.1198 -
  9.1199 -\noindent{\bf Arguments:}
  9.1200 -
  9.1201 - 
  9.1202 -\vspace{0.3cm}
  9.1203 -\begin{tabular}{|c|c|p{7cm}|}
  9.1204 - \hline
  9.1205 -{\bf type} & {\bf name} & {\bf description} \\ \hline
  9.1206 -{\tt VM ref } & self & reference to the object \\ \hline 
  9.1207 -
  9.1208 -{\tt string } & value & New value to set \\ \hline 
  9.1209 -
  9.1210 -\end{tabular}
  9.1211 -
  9.1212 -\vspace{0.3cm}
  9.1213 -
  9.1214 - \noindent {\bf Return Type:} 
  9.1215 -{\tt 
  9.1216 -void
  9.1217 -}
  9.1218 -
  9.1219 -
  9.1220 -
  9.1221 -\vspace{0.3cm}
  9.1222 -\vspace{0.3cm}
  9.1223 -\vspace{0.3cm}
  9.1224  \subsubsection{RPC name:~get\_PCI\_bus}
  9.1225  
  9.1226  {\bf Overview:} 
  9.1227 @@ -10480,6 +10353,239 @@ all fields from the object
  9.1228  \vspace{0.3cm}
  9.1229  
  9.1230  \vspace{1cm}
  9.1231 +\newpage
  9.1232 +\section{Error Handling}
  9.1233 +When a low-level transport error occurs, or a request is malformed at the HTTP
  9.1234 +or XML-RPC level, the server may send an XML-RPC Fault response, or the client
  9.1235 +may simulate the same.  The client must be prepared to handle these errors,
  9.1236 +though they may be treated as fatal.  On the wire, these are transmitted in a
  9.1237 +form similar to this:
  9.1238 +
  9.1239 +\begin{verbatim}
  9.1240 +    <methodResponse>
  9.1241 +      <fault>
  9.1242 +        <value>
  9.1243 +          <struct>
  9.1244 +            <member>
  9.1245 +                <name>faultCode</name>
  9.1246 +                <value><int>-1</int></value>
  9.1247 +              </member>
  9.1248 +              <member>
  9.1249 +                <name>faultString</name>
  9.1250 +                <value><string>Malformed request</string></value>
  9.1251 +            </member>
  9.1252 +          </struct>
  9.1253 +        </value>
  9.1254 +      </fault>
  9.1255 +    </methodResponse>
  9.1256 +\end{verbatim}
  9.1257 +
  9.1258 +All other failures are reported with a more structured error response, to
  9.1259 +allow better automatic response to failures, proper internationalisation of
  9.1260 +any error message, and easier debugging.  On the wire, these are transmitted
  9.1261 +like this:
  9.1262 +
  9.1263 +\begin{verbatim}
  9.1264 +    <struct>
  9.1265 +      <member>
  9.1266 +        <name>Status</name>
  9.1267 +        <value>Failure</value>
  9.1268 +      </member>
  9.1269 +      <member>
  9.1270 +        <name>ErrorDescription</name>
  9.1271 +        <value>
  9.1272 +          <array>
  9.1273 +            <data>
  9.1274 +              <value>MAP_DUPLICATE_KEY</value>
  9.1275 +              <value>Customer</value>
  9.1276 +              <value>eSpeil Inc.</value>
  9.1277 +              <value>eSpeil Incorporated</value>
  9.1278 +            </data>
  9.1279 +          </array>
  9.1280 +        </value>
  9.1281 +      </member>
  9.1282 +    </struct>
  9.1283 +\end{verbatim}
  9.1284 +
  9.1285 +Note that {\tt ErrorDescription} value is an array of string values. The
  9.1286 +first element of the array is an error code; the remainder of the array are
  9.1287 +strings representing error parameters relating to that code.  In this case,
  9.1288 +the client has attempted to add the mapping {\tt Customer $\rightarrow$
  9.1289 +eSpiel Incorporated} to a Map, but it already contains the mapping
  9.1290 +{\tt Customer $\rightarrow$ eSpiel Inc.}, and so the request has failed.
  9.1291 +
  9.1292 +Each possible error code is documented in the following section.
  9.1293 +
  9.1294 +\subsection{Error Codes}
  9.1295 +
  9.1296 +\subsubsection{HOST\_CPU\_HANDLE\_INVALID}
  9.1297 +
  9.1298 +You gave an invalid host\_cpu handle.  The host\_cpu may have recently been
  9.1299 +deleted.  The handle parameter echoes the bad value given.
  9.1300 +
  9.1301 +\vspace{0.3cm}
  9.1302 +{\bf Signature:}
  9.1303 +\begin{verbatim}HOST_CPU_HANDLE_INVALID(handle)\end{verbatim}
  9.1304 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1305 +
  9.1306 +\subsubsection{HOST\_HANDLE\_INVALID}
  9.1307 +
  9.1308 +You gave an invalid host handle.  The host may have recently been deleted. 
  9.1309 +The handle parameter echoes the bad value given.
  9.1310 +
  9.1311 +\vspace{0.3cm}
  9.1312 +{\bf Signature:}
  9.1313 +\begin{verbatim}HOST_HANDLE_INVALID(handle)\end{verbatim}
  9.1314 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1315 +
  9.1316 +\subsubsection{INTERNAL\_ERROR}
  9.1317 +
  9.1318 +The server failed to handle your request, due to an internal error.  The
  9.1319 +given message may give details useful for debugging the problem.
  9.1320 +
  9.1321 +\vspace{0.3cm}
  9.1322 +{\bf Signature:}
  9.1323 +\begin{verbatim}INTERNAL_ERROR(message)\end{verbatim}
  9.1324 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1325 +
  9.1326 +\subsubsection{MAP\_DUPLICATE\_KEY}
  9.1327 +
  9.1328 +You tried to add a key-value pair to a map, but that key is already there. 
  9.1329 +The key, current value, and the new value that you tried to set are all
  9.1330 +echoed.
  9.1331 +
  9.1332 +\vspace{0.3cm}
  9.1333 +{\bf Signature:}
  9.1334 +\begin{verbatim}MAP_DUPLICATE_KEY(key, current value, new value)\end{verbatim}
  9.1335 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1336 +
  9.1337 +\subsubsection{MESSAGE\_METHOD\_UNKNOWN}
  9.1338 +
  9.1339 +You tried to call a method that does not exist.  The method name that you
  9.1340 +used is echoed.
  9.1341 +
  9.1342 +\vspace{0.3cm}
  9.1343 +{\bf Signature:}
  9.1344 +\begin{verbatim}MESSAGE_METHOD_UNKNOWN(method)\end{verbatim}
  9.1345 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1346 +
  9.1347 +\subsubsection{MESSAGE\_PARAMETER\_COUNT\_MISMATCH}
  9.1348 +
  9.1349 +You tried to call a method with the incorrect number of parameters.  The
  9.1350 +fully-qualified method name that you used, and the number of received and
  9.1351 +expected parameters are returned.
  9.1352 +
  9.1353 +\vspace{0.3cm}
  9.1354 +{\bf Signature:}
  9.1355 +\begin{verbatim}MESSAGE_PARAMETER_COUNT_MISMATCH(method, expected, received)\end{verbatim}
  9.1356 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1357 +
  9.1358 +\subsubsection{NETWORK\_ALREADY\_CONNECTED}
  9.1359 +
  9.1360 +You tried to create a PIF, but the network you tried to attach it to is
  9.1361 +already attached to some other PIF, and so the creation failed.
  9.1362 +
  9.1363 +\vspace{0.3cm}
  9.1364 +{\bf Signature:}
  9.1365 +\begin{verbatim}NETWORK_ALREADY_CONNECTED(network, connected PIF)\end{verbatim}
  9.1366 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1367 +
  9.1368 +\subsubsection{SESSION\_AUTHENTICATION\_FAILED}
  9.1369 +
  9.1370 +The credentials given by the user are incorrect, so access has been denied,
  9.1371 +and you have not been issued a session handle.
  9.1372 +
  9.1373 +\vspace{0.3cm}
  9.1374 +No parameters.
  9.1375 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1376 +
  9.1377 +\subsubsection{SESSION\_INVALID}
  9.1378 +
  9.1379 +You gave an invalid session handle.  It may have been invalidated by a
  9.1380 +server restart, or timed out.  You should get a new session handle, using
  9.1381 +one of the session.login\_ calls.  This error does not invalidate the
  9.1382 +current connection.  The handle parameter echoes the bad value given.
  9.1383 +
  9.1384 +\vspace{0.3cm}
  9.1385 +{\bf Signature:}
  9.1386 +\begin{verbatim}SESSION_INVALID(handle)\end{verbatim}
  9.1387 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1388 +
  9.1389 +\subsubsection{SR\_HANDLE\_INVALID}
  9.1390 +
  9.1391 +You gave an invalid SR handle.  The SR may have recently been deleted.  The
  9.1392 +handle parameter echoes the bad value given.
  9.1393 +
  9.1394 +\vspace{0.3cm}
  9.1395 +{\bf Signature:}
  9.1396 +\begin{verbatim}SR_HANDLE_INVALID(handle)\end{verbatim}
  9.1397 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1398 +
  9.1399 +\subsubsection{VBD\_HANDLE\_INVALID}
  9.1400 +
  9.1401 +You gave an invalid VBD handle.  The VBD may have recently been deleted. 
  9.1402 +The handle parameter echoes the bad value given.
  9.1403 +
  9.1404 +\vspace{0.3cm}
  9.1405 +{\bf Signature:}
  9.1406 +\begin{verbatim}VBD_HANDLE_INVALID(handle)\end{verbatim}
  9.1407 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1408 +
  9.1409 +\subsubsection{VDI\_HANDLE\_INVALID}
  9.1410 +
  9.1411 +You gave an invalid VDI handle.  The VDI may have recently been deleted. 
  9.1412 +The handle parameter echoes the bad value given.
  9.1413 +
  9.1414 +\vspace{0.3cm}
  9.1415 +{\bf Signature:}
  9.1416 +\begin{verbatim}VDI_HANDLE_INVALID(handle)\end{verbatim}
  9.1417 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1418 +
  9.1419 +\subsubsection{VIF\_HANDLE\_INVALID}
  9.1420 +
  9.1421 +You gave an invalid VIF handle.  The VIF may have recently been deleted. 
  9.1422 +The handle parameter echoes the bad value given.
  9.1423 +
  9.1424 +\vspace{0.3cm}
  9.1425 +{\bf Signature:}
  9.1426 +\begin{verbatim}VIF_HANDLE_INVALID(handle)\end{verbatim}
  9.1427 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1428 +
  9.1429 +\subsubsection{VM\_BAD\_POWER\_STATE}
  9.1430 +
  9.1431 +You attempted an operation on a VM that was not in an appropriate power
  9.1432 +state at the time; for example, you attempted to start a VM that was
  9.1433 +already running.  The parameters returned are the VM's UUID, and the
  9.1434 +expected and actual VM state at the time of the call.
  9.1435 +
  9.1436 +\vspace{0.3cm}
  9.1437 +{\bf Signature:}
  9.1438 +\begin{verbatim}VM_BAD_POWER_STATE(vm, expected, actual)\end{verbatim}
  9.1439 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1440 +
  9.1441 +\subsubsection{VM\_HANDLE\_INVALID}
  9.1442 +
  9.1443 +You gave an invalid VM handle.  The VM may have recently been deleted.  The
  9.1444 +handle parameter echoes the bad value given.
  9.1445 +
  9.1446 +\vspace{0.3cm}
  9.1447 +{\bf Signature:}
  9.1448 +\begin{verbatim}VM_HANDLE_INVALID(handle)\end{verbatim}
  9.1449 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1450 +
  9.1451 +\subsubsection{VTPM\_HANDLE\_INVALID}
  9.1452 +
  9.1453 +You gave an invalid VTPM handle.  The VTPM may have recently been deleted. 
  9.1454 +The handle parameter echoes the bad value given.
  9.1455 +
  9.1456 +\vspace{0.3cm}
  9.1457 +{\bf Signature:}
  9.1458 +\begin{verbatim}VTPM_HANDLE_INVALID(handle)\end{verbatim}
  9.1459 +\begin{center}\rule{10em}{0.1pt}\end{center}
  9.1460 +
  9.1461 +
  9.1462 +
  9.1463 +\newpage
  9.1464  \section{DTD}
  9.1465  General notes:
  9.1466  \begin{itemize}
    10.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c	Wed Jan 10 08:00:50 2007 -0700
    10.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/pci-dma-xen.c	Wed Jan 10 08:40:47 2007 -0700
    10.3 @@ -15,6 +15,7 @@
    10.4  #include <linux/version.h>
    10.5  #include <asm/io.h>
    10.6  #include <xen/balloon.h>
    10.7 +#include <asm/swiotlb.h>
    10.8  #include <asm/tlbflush.h>
    10.9  #include <asm-i386/mach-xen/asm/swiotlb.h>
   10.10  #include <asm/bug.h>
   10.11 @@ -183,8 +184,8 @@ void *dma_alloc_coherent(struct device *
   10.12  	ret = (void *)vstart;
   10.13  
   10.14  	if (ret != NULL) {
   10.15 -		/* NB. Hardcode 31 address bits for now: aacraid limitation. */
   10.16 -		if (xen_create_contiguous_region(vstart, order, 31) != 0) {
   10.17 +		if (xen_create_contiguous_region(vstart, order,
   10.18 +						 dma_bits) != 0) {
   10.19  			free_pages(vstart, order);
   10.20  			return NULL;
   10.21  		}
    11.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c	Wed Jan 10 08:00:50 2007 -0700
    11.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c	Wed Jan 10 08:40:47 2007 -0700
    11.3 @@ -101,8 +101,24 @@ void enable_hlt(void)
    11.4  
    11.5  EXPORT_SYMBOL(enable_hlt);
    11.6  
    11.7 -/* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */
    11.8 -void xen_idle(void)
    11.9 +/*
   11.10 + * On SMP it's slightly faster (but much more power-consuming!)
   11.11 + * to poll the ->work.need_resched flag instead of waiting for the
   11.12 + * cross-CPU IPI to arrive. Use this option with caution.
   11.13 + */
   11.14 +static void poll_idle(void)
   11.15 +{
   11.16 +	local_irq_enable();
   11.17 +
   11.18 +	asm volatile(
   11.19 +		"2:"
   11.20 +		"testl %0, %1;"
   11.21 +		"rep; nop;"
   11.22 +		"je 2b;"
   11.23 +		: : "i"(_TIF_NEED_RESCHED), "m" (current_thread_info()->flags));
   11.24 +}
   11.25 +
   11.26 +static void xen_idle(void)
   11.27  {
   11.28  	local_irq_disable();
   11.29  
   11.30 @@ -152,17 +168,22 @@ void cpu_idle(void)
   11.31  	/* endless idle loop with no priority at all */
   11.32  	while (1) {
   11.33  		while (!need_resched()) {
   11.34 +			void (*idle)(void);
   11.35  
   11.36  			if (__get_cpu_var(cpu_idle_state))
   11.37  				__get_cpu_var(cpu_idle_state) = 0;
   11.38  
   11.39  			rmb();
   11.40 +			idle = pm_idle;
   11.41 +
   11.42 +			if (!idle)
   11.43 +				idle = xen_idle;
   11.44  
   11.45  			if (cpu_is_offline(cpu))
   11.46  				play_dead();
   11.47  
   11.48  			__get_cpu_var(irq_stat).idle_timestamp = jiffies;
   11.49 -			xen_idle();
   11.50 +			idle();
   11.51  		}
   11.52  		preempt_enable_no_resched();
   11.53  		schedule();
   11.54 @@ -198,9 +219,22 @@ void cpu_idle_wait(void)
   11.55  }
   11.56  EXPORT_SYMBOL_GPL(cpu_idle_wait);
   11.57  
   11.58 -/* XXX XEN doesn't use mwait_idle(), select_idle_routine(), idle_setup(). */
   11.59 -/* Always use xen_idle() instead. */
   11.60 -void __devinit select_idle_routine(const struct cpuinfo_x86 *c) {}
   11.61 +void __devinit select_idle_routine(const struct cpuinfo_x86 *c)
   11.62 +{
   11.63 +}
   11.64 +
   11.65 +static int __init idle_setup (char *str)
   11.66 +{
   11.67 +	if (!strncmp(str, "poll", 4)) {
   11.68 +		printk("using polling idle threads.\n");
   11.69 +		pm_idle = poll_idle;
   11.70 +	}
   11.71 +
   11.72 +	boot_option_idle_override = 1;
   11.73 +	return 1;
   11.74 +}
   11.75 +
   11.76 +__setup("idle=", idle_setup);
   11.77  
   11.78  void show_regs(struct pt_regs * regs)
   11.79  {
    12.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Wed Jan 10 08:00:50 2007 -0700
    12.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/swiotlb.c	Wed Jan 10 08:40:47 2007 -0700
    12.3 @@ -47,8 +47,8 @@ EXPORT_SYMBOL(swiotlb);
    12.4   */
    12.5  #define IO_TLB_SHIFT 11
    12.6  
    12.7 -/* Width of DMA addresses in the IO TLB. 30 bits is a b44 limitation. */
    12.8 -#define DEFAULT_IO_TLB_DMA_BITS 30
    12.9 +/* Width of DMA addresses. 30 bits is a b44 limitation. */
   12.10 +#define DEFAULT_DMA_BITS 30
   12.11  
   12.12  static int swiotlb_force;
   12.13  static char *iotlb_virt_start;
   12.14 @@ -98,14 +98,14 @@ static struct phys_addr {
   12.15   */
   12.16  static DEFINE_SPINLOCK(io_tlb_lock);
   12.17  
   12.18 -static unsigned int io_tlb_dma_bits = DEFAULT_IO_TLB_DMA_BITS;
   12.19 +unsigned int dma_bits = DEFAULT_DMA_BITS;
   12.20  static int __init
   12.21 -setup_io_tlb_bits(char *str)
   12.22 +setup_dma_bits(char *str)
   12.23  {
   12.24 -	io_tlb_dma_bits = simple_strtoul(str, NULL, 0);
   12.25 +	dma_bits = simple_strtoul(str, NULL, 0);
   12.26  	return 0;
   12.27  }
   12.28 -__setup("swiotlb_bits=", setup_io_tlb_bits);
   12.29 +__setup("dma_bits=", setup_dma_bits);
   12.30  
   12.31  static int __init
   12.32  setup_io_tlb_npages(char *str)
   12.33 @@ -167,7 +167,7 @@ swiotlb_init_with_default_size (size_t d
   12.34  		int rc = xen_create_contiguous_region(
   12.35  			(unsigned long)iotlb_virt_start + (i << IO_TLB_SHIFT),
   12.36  			get_order(IO_TLB_SEGSIZE << IO_TLB_SHIFT),
   12.37 -			io_tlb_dma_bits);
   12.38 +			dma_bits);
   12.39  		BUG_ON(rc);
   12.40  	}
   12.41  
   12.42 @@ -197,7 +197,7 @@ swiotlb_init_with_default_size (size_t d
   12.43  	       bytes >> 20,
   12.44  	       (unsigned long)iotlb_virt_start,
   12.45  	       (unsigned long)iotlb_virt_start + bytes,
   12.46 -	       io_tlb_dma_bits);
   12.47 +	       dma_bits);
   12.48  }
   12.49  
   12.50  void
   12.51 @@ -665,7 +665,7 @@ swiotlb_dma_mapping_error(dma_addr_t dma
   12.52  int
   12.53  swiotlb_dma_supported (struct device *hwdev, u64 mask)
   12.54  {
   12.55 -	return (mask >= ((1UL << io_tlb_dma_bits) - 1));
   12.56 +	return (mask >= ((1UL << dma_bits) - 1));
   12.57  }
   12.58  
   12.59  EXPORT_SYMBOL(swiotlb_init);
    13.1 --- a/linux-2.6-xen-sparse/arch/i386/pci/irq-xen.c	Wed Jan 10 08:00:50 2007 -0700
    13.2 +++ b/linux-2.6-xen-sparse/arch/i386/pci/irq-xen.c	Wed Jan 10 08:40:47 2007 -0700
    13.3 @@ -110,7 +110,6 @@ static struct irq_routing_table * __init
    13.4  		if (rt)
    13.5  			return rt;
    13.6  	}
    13.7 -	
    13.8  	return NULL;
    13.9  }
   13.10  
   13.11 @@ -261,13 +260,13 @@ static int pirq_via_set(struct pci_dev *
   13.12   */
   13.13  static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
   13.14  {
   13.15 -	static unsigned int pirqmap[4] = { 3, 2, 5, 1 };
   13.16 +	static unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
   13.17  	return read_config_nybble(router, 0x55, pirqmap[pirq-1]);
   13.18  }
   13.19  
   13.20  static int pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
   13.21  {
   13.22 -	static unsigned int pirqmap[4] = { 3, 2, 5, 1 };
   13.23 +	static unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
   13.24  	write_config_nybble(router, 0x55, pirqmap[pirq-1], irq);
   13.25  	return 1;
   13.26  }
    14.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c	Wed Jan 10 08:00:50 2007 -0700
    14.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c	Wed Jan 10 08:40:47 2007 -0700
    14.3 @@ -119,8 +119,26 @@ void exit_idle(void)
    14.4  	__exit_idle();
    14.5  }
    14.6  
    14.7 -/* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */
    14.8 -void xen_idle(void)
    14.9 +/*
   14.10 + * On SMP it's slightly faster (but much more power-consuming!)
   14.11 + * to poll the ->need_resched flag instead of waiting for the
   14.12 + * cross-CPU IPI to arrive. Use this option with caution.
   14.13 + */
   14.14 +static void poll_idle(void)
   14.15 +{
   14.16 +	local_irq_enable();
   14.17 +
   14.18 +	asm volatile(
   14.19 +		"2:"
   14.20 +		"testl %0,%1;"
   14.21 +		"rep; nop;"
   14.22 +		"je 2b;"
   14.23 +		: :
   14.24 +		"i" (_TIF_NEED_RESCHED),
   14.25 +		"m" (current_thread_info()->flags));
   14.26 +}
   14.27 +
   14.28 +static void xen_idle(void)
   14.29  {
   14.30  	local_irq_disable();
   14.31  
   14.32 @@ -164,14 +182,18 @@ void cpu_idle (void)
   14.33  	/* endless idle loop with no priority at all */
   14.34  	while (1) {
   14.35  		while (!need_resched()) {
   14.36 +			void (*idle)(void);
   14.37 +
   14.38  			if (__get_cpu_var(cpu_idle_state))
   14.39  				__get_cpu_var(cpu_idle_state) = 0;
   14.40  			rmb();
   14.41 -			
   14.42 +			idle = pm_idle;
   14.43 +			if (!idle)
   14.44 +				idle = xen_idle;
   14.45  			if (cpu_is_offline(smp_processor_id()))
   14.46  				play_dead();
   14.47  			enter_idle();
   14.48 -			xen_idle();
   14.49 +			idle();
   14.50  			__exit_idle();
   14.51  		}
   14.52  
   14.53 @@ -210,9 +232,22 @@ void cpu_idle_wait(void)
   14.54  }
   14.55  EXPORT_SYMBOL_GPL(cpu_idle_wait);
   14.56  
   14.57 -/* XXX XEN doesn't use mwait_idle(), select_idle_routine(), idle_setup(). */
   14.58 -/* Always use xen_idle() instead. */
   14.59 -void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) {}
   14.60 +void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) 
   14.61 +{
   14.62 +}
   14.63 +
   14.64 +static int __init idle_setup (char *str)
   14.65 +{
   14.66 +	if (!strncmp(str, "poll", 4)) {
   14.67 +		printk("using polling idle threads.\n");
   14.68 +		pm_idle = poll_idle;
   14.69 +	}
   14.70 +
   14.71 +	boot_option_idle_override = 1;
   14.72 +	return 1;
   14.73 +}
   14.74 +
   14.75 +__setup("idle=", idle_setup);
   14.76  
   14.77  /* Prints also some state that isn't saved in the pt_regs */ 
   14.78  void __show_regs(struct pt_regs * regs)
    15.1 --- a/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Wed Jan 10 08:00:50 2007 -0700
    15.2 +++ b/linux-2.6-xen-sparse/drivers/char/tpm/tpm_xen.c	Wed Jan 10 08:40:47 2007 -0700
    15.3 @@ -54,7 +54,6 @@ struct tpm_private {
    15.4  
    15.5  	tpmif_tx_interface_t *tx;
    15.6  	atomic_t refcnt;
    15.7 -	unsigned int evtchn;
    15.8  	unsigned int irq;
    15.9  	u8 is_connected;
   15.10  	u8 is_suspended;
   15.11 @@ -271,7 +270,7 @@ static void destroy_tpmring(struct tpm_p
   15.12  	if (tp->irq)
   15.13  		unbind_from_irqhandler(tp->irq, tp);
   15.14  
   15.15 -	tp->evtchn = tp->irq = 0;
   15.16 +	tp->irq = 0;
   15.17  }
   15.18  
   15.19  
   15.20 @@ -302,8 +301,8 @@ again:
   15.21  		goto abort_transaction;
   15.22  	}
   15.23  
   15.24 -	err = xenbus_printf(xbt, dev->nodename,
   15.25 -			    "event-channel", "%u", tp->evtchn);
   15.26 +	err = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
   15.27 +			    irq_to_evtchn_port(tp->irq));
   15.28  	if (err) {
   15.29  		message = "writing event-channel";
   15.30  		goto abort_transaction;
   15.31 @@ -459,19 +458,15 @@ static int tpmif_connect(struct xenbus_d
   15.32  
   15.33  	tp->backend_id = domid;
   15.34  
   15.35 -	err = xenbus_alloc_evtchn(dev, &tp->evtchn);
   15.36 -	if (err)
   15.37 -		return err;
   15.38 -
   15.39 -	err = bind_evtchn_to_irqhandler(tp->evtchn,
   15.40 -					tpmif_int, SA_SAMPLE_RANDOM, "tpmif",
   15.41 -					tp);
   15.42 +	err = bind_listening_port_to_irqhandler(
   15.43 +		domid, tpmif_int, SA_SAMPLE_RANDOM, "tpmif", tp);
   15.44  	if (err <= 0) {
   15.45 -		WPRINTK("bind_evtchn_to_irqhandler failed (err=%d)\n", err);
   15.46 +		WPRINTK("bind_listening_port_to_irqhandler failed "
   15.47 +			"(err=%d)\n", err);
   15.48  		return err;
   15.49  	}
   15.50 +	tp->irq = err;
   15.51  
   15.52 -	tp->irq = err;
   15.53  	return 0;
   15.54  }
   15.55  
   15.56 @@ -656,9 +651,6 @@ static int tpm_xmit(struct tpm_private *
   15.57  
   15.58  	mb();
   15.59  
   15.60 -	DPRINTK("Notifying backend via event channel %d\n",
   15.61 -	        tp->evtchn);
   15.62 -
   15.63  	notify_remote_via_irq(tp->irq);
   15.64  
   15.65  	spin_unlock_irq(&tp->tx_lock);
    16.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Jan 10 08:00:50 2007 -0700
    16.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Jan 10 08:40:47 2007 -0700
    16.3 @@ -446,8 +446,10 @@ static struct notifier_block xenstore_no
    16.4  
    16.5  static int __init balloon_init(void)
    16.6  {
    16.7 +#ifdef CONFIG_X86
    16.8  	unsigned long pfn;
    16.9  	struct page *page;
   16.10 +#endif
   16.11  
   16.12  	if (!is_running_on_xen())
   16.13  		return -ENODEV;
   16.14 @@ -476,13 +478,15 @@ static int __init balloon_init(void)
   16.15  	balloon_pde->write_proc = balloon_write;
   16.16  #endif
   16.17  	balloon_sysfs_init();
   16.18 -    
   16.19 +
   16.20 +#ifdef CONFIG_X86
   16.21  	/* Initialise the balloon with excess memory space. */
   16.22  	for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
   16.23  		page = pfn_to_page(pfn);
   16.24  		if (!PageReserved(page))
   16.25  			balloon_append(page);
   16.26  	}
   16.27 +#endif
   16.28  
   16.29  	target_watch.callback = watch_target;
   16.30  	xenstore_notifier.notifier_call = balloon_init_watcher;
    17.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Wed Jan 10 08:00:50 2007 -0700
    17.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/common.h	Wed Jan 10 08:40:47 2007 -0700
    17.3 @@ -65,7 +65,6 @@ typedef struct blkif_st {
    17.4  	domid_t           domid;
    17.5  	unsigned int      handle;
    17.6  	/* Physical parameters of the comms window. */
    17.7 -	unsigned int      evtchn;
    17.8  	unsigned int      irq;
    17.9  	/* Comms information. */
   17.10  	blkif_back_ring_t blk_ring;
    18.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Wed Jan 10 08:00:50 2007 -0700
    18.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/interface.c	Wed Jan 10 08:40:47 2007 -0700
    18.3 @@ -97,7 +97,6 @@ int blkif_map(blkif_t *blkif, unsigned l
    18.4  {
    18.5  	blkif_sring_t *sring;
    18.6  	int err;
    18.7 -	struct evtchn_bind_interdomain bind_interdomain;
    18.8  
    18.9  	/* Already connected through? */
   18.10  	if (blkif->irq)
   18.11 @@ -112,24 +111,18 @@ int blkif_map(blkif_t *blkif, unsigned l
   18.12  		return err;
   18.13  	}
   18.14  
   18.15 -	bind_interdomain.remote_dom  = blkif->domid;
   18.16 -	bind_interdomain.remote_port = evtchn;
   18.17 +	sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
   18.18 +	BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
   18.19  
   18.20 -	err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
   18.21 -					  &bind_interdomain);
   18.22 -	if (err) {
   18.23 +	err = bind_interdomain_evtchn_to_irqhandler(
   18.24 +		blkif->domid, evtchn, blkif_be_int, 0, "blkif-backend", blkif);
   18.25 +	if (err < 0)
   18.26 +	{
   18.27  		unmap_frontend_page(blkif);
   18.28  		free_vm_area(blkif->blk_ring_area);
   18.29  		return err;
   18.30  	}
   18.31 -
   18.32 -	blkif->evtchn = bind_interdomain.local_port;
   18.33 -
   18.34 -	sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
   18.35 -	BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
   18.36 -
   18.37 -	blkif->irq = bind_evtchn_to_irqhandler(
   18.38 -		blkif->evtchn, blkif_be_int, 0, "blkif-backend", blkif);
   18.39 +	blkif->irq = err;
   18.40  
   18.41  	return 0;
   18.42  }
    19.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Wed Jan 10 08:00:50 2007 -0700
    19.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Wed Jan 10 08:40:47 2007 -0700
    19.3 @@ -174,8 +174,8 @@ again:
    19.4  		message = "writing ring-ref";
    19.5  		goto abort_transaction;
    19.6  	}
    19.7 -	err = xenbus_printf(xbt, dev->nodename,
    19.8 -			    "event-channel", "%u", info->evtchn);
    19.9 +	err = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
   19.10 +			    irq_to_evtchn_port(info->irq));
   19.11  	if (err) {
   19.12  		message = "writing event-channel";
   19.13  		goto abort_transaction;
   19.14 @@ -228,15 +228,11 @@ static int setup_blkring(struct xenbus_d
   19.15  	}
   19.16  	info->ring_ref = err;
   19.17  
   19.18 -	err = xenbus_alloc_evtchn(dev, &info->evtchn);
   19.19 -	if (err)
   19.20 -		goto fail;
   19.21 -
   19.22 -	err = bind_evtchn_to_irqhandler(
   19.23 -		info->evtchn, blkif_int, SA_SAMPLE_RANDOM, "blkif", info);
   19.24 +	err = bind_listening_port_to_irqhandler(
   19.25 +		dev->otherend_id, blkif_int, SA_SAMPLE_RANDOM, "blkif", info);
   19.26  	if (err <= 0) {
   19.27  		xenbus_dev_fatal(dev, err,
   19.28 -				 "bind_evtchn_to_irqhandler failed");
   19.29 +				 "bind_listening_port_to_irqhandler");
   19.30  		goto fail;
   19.31  	}
   19.32  	info->irq = err;
   19.33 @@ -310,7 +306,7 @@ static void connect(struct blkfront_info
   19.34  	DPRINTK("blkfront.c:connect:%s.\n", info->xbdev->otherend);
   19.35  
   19.36  	err = xenbus_gather(XBT_NIL, info->xbdev->otherend,
   19.37 -			    "sectors", "%llu", &sectors,
   19.38 +			    "sectors", "%Lu", &sectors,
   19.39  			    "info", "%u", &binfo,
   19.40  			    "sector-size", "%lu", &sector_size,
   19.41  			    NULL);
   19.42 @@ -775,8 +771,7 @@ static void blkif_free(struct blkfront_i
   19.43  	}
   19.44  	if (info->irq)
   19.45  		unbind_from_irqhandler(info->irq, info);
   19.46 -	info->evtchn = info->irq = 0;
   19.47 -
   19.48 +	info->irq = 0;
   19.49  }
   19.50  
   19.51  static void blkif_completion(struct blk_shadow *s)
    20.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h	Wed Jan 10 08:00:50 2007 -0700
    20.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/block.h	Wed Jan 10 08:40:47 2007 -0700
    20.3 @@ -119,7 +119,7 @@ struct blkfront_info
    20.4  	int connected;
    20.5  	int ring_ref;
    20.6  	blkif_front_ring_t ring;
    20.7 -	unsigned int evtchn, irq;
    20.8 +	unsigned int irq;
    20.9  	struct xlbd_major_info *mi;
   20.10  	request_queue_t *rq;
   20.11  	struct work_struct work;
    21.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/Makefile	Wed Jan 10 08:00:50 2007 -0700
    21.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/Makefile	Wed Jan 10 08:40:47 2007 -0700
    21.3 @@ -1,3 +1,5 @@
    21.4  LINUXINCLUDE += -I../xen/include/public/io
    21.5 -obj-y	:= xenbus.o interface.o blktap.o 
    21.6  
    21.7 +obj-$(CONFIG_XEN_BLKDEV_TAP) := xenblktap.o
    21.8 +
    21.9 +xenblktap-y := xenbus.o interface.o blktap.o 
    22.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/common.h	Wed Jan 10 08:00:50 2007 -0700
    22.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/common.h	Wed Jan 10 08:40:47 2007 -0700
    22.3 @@ -56,7 +56,6 @@ typedef struct blkif_st {
    22.4  	domid_t           domid;
    22.5  	unsigned int      handle;
    22.6  	/* Physical parameters of the comms window. */
    22.7 -	unsigned int      evtchn;
    22.8  	unsigned int      irq;
    22.9  	/* Comms information. */
   22.10  	blkif_back_ring_t blk_ring;
    23.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Wed Jan 10 08:00:50 2007 -0700
    23.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/interface.c	Wed Jan 10 08:40:47 2007 -0700
    23.3 @@ -98,7 +98,6 @@ int tap_blkif_map(blkif_t *blkif, unsign
    23.4  {
    23.5  	blkif_sring_t *sring;
    23.6  	int err;
    23.7 -	struct evtchn_bind_interdomain bind_interdomain;
    23.8  
    23.9  	/* Already connected through? */
   23.10  	if (blkif->irq)
   23.11 @@ -113,24 +112,18 @@ int tap_blkif_map(blkif_t *blkif, unsign
   23.12  		return err;
   23.13  	}
   23.14  
   23.15 -	bind_interdomain.remote_dom  = blkif->domid;
   23.16 -	bind_interdomain.remote_port = evtchn;
   23.17 +	sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
   23.18 +	BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
   23.19  
   23.20 -	err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
   23.21 -					  &bind_interdomain);
   23.22 -	if (err) {
   23.23 +	err = bind_interdomain_evtchn_to_irqhandler(
   23.24 +		blkif->domid, evtchn, tap_blkif_be_int,
   23.25 +		0, "blkif-backend", blkif);
   23.26 +	if (err < 0) {
   23.27  		unmap_frontend_page(blkif);
   23.28  		free_vm_area(blkif->blk_ring_area);
   23.29  		return err;
   23.30  	}
   23.31 -
   23.32 -	blkif->evtchn = bind_interdomain.local_port;
   23.33 -
   23.34 -	sring = (blkif_sring_t *)blkif->blk_ring_area->addr;
   23.35 -	BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
   23.36 -
   23.37 -	blkif->irq = bind_evtchn_to_irqhandler(
   23.38 -		blkif->evtchn, tap_blkif_be_int, 0, "blkif-backend", blkif);
   23.39 +	blkif->irq = err;
   23.40  
   23.41  	return 0;
   23.42  }
    24.1 --- a/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Wed Jan 10 08:00:50 2007 -0700
    24.2 +++ b/linux-2.6-xen-sparse/drivers/xen/console/xencons_ring.c	Wed Jan 10 08:40:47 2007 -0700
    24.3 @@ -121,7 +121,7 @@ int xencons_ring_init(void)
    24.4  	    !xen_start_info->console.domU.evtchn)
    24.5  		return -ENODEV;
    24.6  
    24.7 -	irq = bind_evtchn_to_irqhandler(
    24.8 +	irq = bind_caller_port_to_irqhandler(
    24.9  		xen_start_info->console.domU.evtchn,
   24.10  		handle_input, 0, "xencons", NULL);
   24.11  	if (irq < 0) {
    25.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Wed Jan 10 08:00:50 2007 -0700
    25.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Wed Jan 10 08:40:47 2007 -0700
    25.3 @@ -61,7 +61,14 @@ static int evtchn_to_irq[NR_EVENT_CHANNE
    25.4  static u32 irq_info[NR_IRQS];
    25.5  
    25.6  /* Binding types. */
    25.7 -enum { IRQT_UNBOUND, IRQT_PIRQ, IRQT_VIRQ, IRQT_IPI, IRQT_EVTCHN };
    25.8 +enum {
    25.9 +	IRQT_UNBOUND,
   25.10 +	IRQT_PIRQ,
   25.11 +	IRQT_VIRQ,
   25.12 +	IRQT_IPI,
   25.13 +	IRQT_LOCAL_PORT,
   25.14 +	IRQT_CALLER_PORT
   25.15 +};
   25.16  
   25.17  /* Constructor for packed IRQ information. */
   25.18  static inline u32 mk_irq_info(u32 type, u32 index, u32 evtchn)
   25.19 @@ -208,38 +215,51 @@ void force_evtchn_callback(void)
   25.20  /* Not a GPL symbol: used in ubiquitous macros, so too restrictive. */
   25.21  EXPORT_SYMBOL(force_evtchn_callback);
   25.22  
   25.23 +static DEFINE_PER_CPU(unsigned int, upcall_count) = { 0 };
   25.24 +
   25.25  /* NB. Interrupts are disabled on entry. */
   25.26  asmlinkage void evtchn_do_upcall(struct pt_regs *regs)
   25.27  {
   25.28  	unsigned long  l1, l2;
   25.29 -	unsigned int   l1i, l2i, port;
   25.30 +	unsigned int   l1i, l2i, port, count;
   25.31  	int            irq, cpu = smp_processor_id();
   25.32  	shared_info_t *s = HYPERVISOR_shared_info;
   25.33  	vcpu_info_t   *vcpu_info = &s->vcpu_info[cpu];
   25.34  
   25.35 -	vcpu_info->evtchn_upcall_pending = 0;
   25.36 +	do {
   25.37 +		/* Avoid a callback storm when we reenable delivery. */
   25.38 +		vcpu_info->evtchn_upcall_pending = 0;
   25.39 +
   25.40 +		/* Nested invocations bail immediately. */
   25.41 +		if (unlikely(per_cpu(upcall_count, cpu)++))
   25.42 +			return;
   25.43  
   25.44  #ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */
   25.45 -	/* Clear master pending flag /before/ clearing selector flag. */
   25.46 -	rmb();
   25.47 +		/* Clear master flag /before/ clearing selector flag. */
   25.48 +		rmb();
   25.49  #endif
   25.50 -	l1 = xchg(&vcpu_info->evtchn_pending_sel, 0);
   25.51 -	while (l1 != 0) {
   25.52 -		l1i = __ffs(l1);
   25.53 -		l1 &= ~(1UL << l1i);
   25.54 +		l1 = xchg(&vcpu_info->evtchn_pending_sel, 0);
   25.55 +		while (l1 != 0) {
   25.56 +			l1i = __ffs(l1);
   25.57 +			l1 &= ~(1UL << l1i);
   25.58  
   25.59 -		while ((l2 = active_evtchns(cpu, s, l1i)) != 0) {
   25.60 -			l2i = __ffs(l2);
   25.61 +			while ((l2 = active_evtchns(cpu, s, l1i)) != 0) {
   25.62 +				l2i = __ffs(l2);
   25.63  
   25.64 -			port = (l1i * BITS_PER_LONG) + l2i;
   25.65 -			if ((irq = evtchn_to_irq[port]) != -1)
   25.66 -				do_IRQ(irq, regs);
   25.67 -			else {
   25.68 -				exit_idle();
   25.69 -				evtchn_device_upcall(port);
   25.70 +				port = (l1i * BITS_PER_LONG) + l2i;
   25.71 +				if ((irq = evtchn_to_irq[port]) != -1)
   25.72 +					do_IRQ(irq, regs);
   25.73 +				else {
   25.74 +					exit_idle();
   25.75 +					evtchn_device_upcall(port);
   25.76 +				}
   25.77  			}
   25.78  		}
   25.79 -	}
   25.80 +
   25.81 +		/* If there were nested callbacks then we have more to do. */
   25.82 +		count = per_cpu(upcall_count, cpu);
   25.83 +		per_cpu(upcall_count, cpu) = 0;
   25.84 +	} while (unlikely(count != 1));
   25.85  }
   25.86  
   25.87  static int find_unbound_irq(void)
   25.88 @@ -262,18 +282,18 @@ static int find_unbound_irq(void)
   25.89  	return -ENOSPC;
   25.90  }
   25.91  
   25.92 -static int bind_evtchn_to_irq(unsigned int evtchn)
   25.93 +static int bind_caller_port_to_irq(unsigned int caller_port)
   25.94  {
   25.95  	int irq;
   25.96  
   25.97  	spin_lock(&irq_mapping_update_lock);
   25.98  
   25.99 -	if ((irq = evtchn_to_irq[evtchn]) == -1) {
  25.100 +	if ((irq = evtchn_to_irq[caller_port]) == -1) {
  25.101  		if ((irq = find_unbound_irq()) < 0)
  25.102  			goto out;
  25.103  
  25.104 -		evtchn_to_irq[evtchn] = irq;
  25.105 -		irq_info[irq] = mk_irq_info(IRQT_EVTCHN, 0, evtchn);
  25.106 +		evtchn_to_irq[caller_port] = irq;
  25.107 +		irq_info[irq] = mk_irq_info(IRQT_CALLER_PORT, 0, caller_port);
  25.108  	}
  25.109  
  25.110  	irq_bindcount[irq]++;
  25.111 @@ -283,6 +303,59 @@ static int bind_evtchn_to_irq(unsigned i
  25.112  	return irq;
  25.113  }
  25.114  
  25.115 +static int bind_local_port_to_irq(unsigned int local_port)
  25.116 +{
  25.117 +	int irq;
  25.118 +
  25.119 +	spin_lock(&irq_mapping_update_lock);
  25.120 +
  25.121 +	BUG_ON(evtchn_to_irq[local_port] != -1);
  25.122 +
  25.123 +	if ((irq = find_unbound_irq()) < 0) {
  25.124 +		struct evtchn_close close = { .port = local_port };
  25.125 +		if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
  25.126 +			BUG();
  25.127 +		goto out;
  25.128 +	}
  25.129 +
  25.130 +	evtchn_to_irq[local_port] = irq;
  25.131 +	irq_info[irq] = mk_irq_info(IRQT_LOCAL_PORT, 0, local_port);
  25.132 +	irq_bindcount[irq]++;
  25.133 +
  25.134 + out:
  25.135 +	spin_unlock(&irq_mapping_update_lock);
  25.136 +	return irq;
  25.137 +}
  25.138 +
  25.139 +static int bind_listening_port_to_irq(unsigned int remote_domain)
  25.140 +{
  25.141 +	struct evtchn_alloc_unbound alloc_unbound;
  25.142 +	int err;
  25.143 +
  25.144 +	alloc_unbound.dom        = DOMID_SELF;
  25.145 +	alloc_unbound.remote_dom = remote_domain;
  25.146 +
  25.147 +	err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
  25.148 +					  &alloc_unbound);
  25.149 +
  25.150 +	return err ? : bind_local_port_to_irq(alloc_unbound.port);
  25.151 +}
  25.152 +
  25.153 +static int bind_interdomain_evtchn_to_irq(unsigned int remote_domain,
  25.154 +					  unsigned int remote_port)
  25.155 +{
  25.156 +	struct evtchn_bind_interdomain bind_interdomain;
  25.157 +	int err;
  25.158 +
  25.159 +	bind_interdomain.remote_dom  = remote_domain;
  25.160 +	bind_interdomain.remote_port = remote_port;
  25.161 +
  25.162 +	err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
  25.163 +					  &bind_interdomain);
  25.164 +
  25.165 +	return err ? : bind_local_port_to_irq(bind_interdomain.local_port);
  25.166 +}
  25.167 +
  25.168  static int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
  25.169  {
  25.170  	struct evtchn_bind_virq bind_virq;
  25.171 @@ -357,7 +430,8 @@ static void unbind_from_irq(unsigned int
  25.172  
  25.173  	if ((--irq_bindcount[irq] == 0) && VALID_EVTCHN(evtchn)) {
  25.174  		close.port = evtchn;
  25.175 -		if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
  25.176 +		if ((type_from_irq(irq) != IRQT_CALLER_PORT) &&
  25.177 +		    HYPERVISOR_event_channel_op(EVTCHNOP_close, &close))
  25.178  			BUG();
  25.179  
  25.180  		switch (type_from_irq(irq)) {
  25.181 @@ -383,17 +457,16 @@ static void unbind_from_irq(unsigned int
  25.182  	spin_unlock(&irq_mapping_update_lock);
  25.183  }
  25.184  
  25.185 -int bind_evtchn_to_irqhandler(
  25.186 -	unsigned int evtchn,
  25.187 +int bind_caller_port_to_irqhandler(
  25.188 +	unsigned int caller_port,
  25.189  	irqreturn_t (*handler)(int, void *, struct pt_regs *),
  25.190  	unsigned long irqflags,
  25.191  	const char *devname,
  25.192  	void *dev_id)
  25.193  {
  25.194 -	unsigned int irq;
  25.195 -	int retval;
  25.196 +	int irq, retval;
  25.197  
  25.198 -	irq = bind_evtchn_to_irq(evtchn);
  25.199 +	irq = bind_caller_port_to_irq(caller_port);
  25.200  	if (irq < 0)
  25.201  		return irq;
  25.202  
  25.203 @@ -405,7 +478,54 @@ int bind_evtchn_to_irqhandler(
  25.204  
  25.205  	return irq;
  25.206  }
  25.207 -EXPORT_SYMBOL_GPL(bind_evtchn_to_irqhandler);
  25.208 +EXPORT_SYMBOL_GPL(bind_caller_port_to_irqhandler);
  25.209 +
  25.210 +int bind_listening_port_to_irqhandler(
  25.211 +	unsigned int remote_domain,
  25.212 +	irqreturn_t (*handler)(int, void *, struct pt_regs *),
  25.213 +	unsigned long irqflags,
  25.214 +	const char *devname,
  25.215 +	void *dev_id)
  25.216 +{
  25.217 +	int irq, retval;
  25.218 +
  25.219 +	irq = bind_listening_port_to_irq(remote_domain);
  25.220 +	if (irq < 0)
  25.221 +		return irq;
  25.222 +
  25.223 +	retval = request_irq(irq, handler, irqflags, devname, dev_id);
  25.224 +	if (retval != 0) {
  25.225 +		unbind_from_irq(irq);
  25.226 +		return retval;
  25.227 +	}
  25.228 +
  25.229 +	return irq;
  25.230 +}
  25.231 +EXPORT_SYMBOL_GPL(bind_listening_port_to_irqhandler);
  25.232 +
  25.233 +int bind_interdomain_evtchn_to_irqhandler(
  25.234 +	unsigned int remote_domain,
  25.235 +	unsigned int remote_port,
  25.236 +	irqreturn_t (*handler)(int, void *, struct pt_regs *),
  25.237 +	unsigned long irqflags,
  25.238 +	const char *devname,
  25.239 +	void *dev_id)
  25.240 +{
  25.241 +	int irq, retval;
  25.242 +
  25.243 +	irq = bind_interdomain_evtchn_to_irq(remote_domain, remote_port);
  25.244 +	if (irq < 0)
  25.245 +		return irq;
  25.246 +
  25.247 +	retval = request_irq(irq, handler, irqflags, devname, dev_id);
  25.248 +	if (retval != 0) {
  25.249 +		unbind_from_irq(irq);
  25.250 +		return retval;
  25.251 +	}
  25.252 +
  25.253 +	return irq;
  25.254 +}
  25.255 +EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irqhandler);
  25.256  
  25.257  int bind_virq_to_irqhandler(
  25.258  	unsigned int virq,
  25.259 @@ -415,8 +535,7 @@ int bind_virq_to_irqhandler(
  25.260  	const char *devname,
  25.261  	void *dev_id)
  25.262  {
  25.263 -	unsigned int irq;
  25.264 -	int retval;
  25.265 +	int irq, retval;
  25.266  
  25.267  	irq = bind_virq_to_irq(virq, cpu);
  25.268  	if (irq < 0)
  25.269 @@ -440,8 +559,7 @@ int bind_ipi_to_irqhandler(
  25.270  	const char *devname,
  25.271  	void *dev_id)
  25.272  {
  25.273 -	unsigned int irq;
  25.274 -	int retval;
  25.275 +	int irq, retval;
  25.276  
  25.277  	irq = bind_ipi_to_irq(ipi, cpu);
  25.278  	if (irq < 0)
  25.279 @@ -716,6 +834,12 @@ void notify_remote_via_irq(int irq)
  25.280  }
  25.281  EXPORT_SYMBOL_GPL(notify_remote_via_irq);
  25.282  
  25.283 +int irq_to_evtchn_port(int irq)
  25.284 +{
  25.285 +	return evtchn_from_irq(irq);
  25.286 +}
  25.287 +EXPORT_SYMBOL_GPL(irq_to_evtchn_port);
  25.288 +
  25.289  void mask_evtchn(int port)
  25.290  {
  25.291  	shared_info_t *s = HYPERVISOR_shared_info;
    26.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c	Wed Jan 10 08:00:50 2007 -0700
    26.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/machine_kexec.c	Wed Jan 10 08:40:47 2007 -0700
    26.3 @@ -98,8 +98,8 @@ void xen_machine_kexec_setup_resources(v
    26.4   err:
    26.5  	/*
    26.6  	 * It isn't possible to free xen_phys_cpus this early in the
    26.7 -	 * boot. Since failure at this stage is unexpected and the
    26.8 -	 * amount is small we leak the memory.
    26.9 +	 * boot. Failure at this stage is unexpected and the amount of
   26.10 +	 * memory is small therefore we tolerate the potential leak.
   26.11           */
   26.12  	xen_max_nr_phys_cpus = 0;
   26.13  	return;
    27.1 --- a/linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c	Wed Jan 10 08:00:50 2007 -0700
    27.2 +++ b/linux-2.6-xen-sparse/drivers/xen/fbfront/xenfb.c	Wed Jan 10 08:40:47 2007 -0700
    27.3 @@ -56,7 +56,6 @@ struct xenfb_info
    27.4  	struct page		**pages;
    27.5  	struct list_head	mappings; /* protected by mm_lock */
    27.6  
    27.7 -	unsigned		evtchn;
    27.8  	int			irq;
    27.9  	struct xenfb_page	*page;
   27.10  	unsigned long 		*mfns;
   27.11 @@ -156,7 +155,7 @@ static void xenfb_do_update(struct xenfb
   27.12  	wmb();			/* ensure ring contents visible */
   27.13  	info->page->out_prod = prod + 1;
   27.14  
   27.15 -	notify_remote_via_evtchn(info->evtchn);
   27.16 +	notify_remote_via_irq(info->irq);
   27.17  }
   27.18  
   27.19  static int xenfb_queue_full(struct xenfb_info *info)
   27.20 @@ -429,7 +428,7 @@ static irqreturn_t xenfb_event_handler(i
   27.21  
   27.22  	if (page->in_cons != page->in_prod) {
   27.23  		info->page->in_cons = info->page->in_prod;
   27.24 -		notify_remote_via_evtchn(info->evtchn);
   27.25 +		notify_remote_via_irq(info->irq);
   27.26  	}
   27.27  	return IRQ_HANDLED;
   27.28  }
   27.29 @@ -618,14 +617,11 @@ static int xenfb_connect_backend(struct 
   27.30  	int ret;
   27.31  	struct xenbus_transaction xbt;
   27.32  
   27.33 -	ret = xenbus_alloc_evtchn(dev, &info->evtchn);
   27.34 -	if (ret)
   27.35 -		return ret;
   27.36 -	ret = bind_evtchn_to_irqhandler(info->evtchn, xenfb_event_handler,
   27.37 -					0, "xenfb", info);
   27.38 +	ret = bind_listening_port_to_irqhandler(
   27.39 +		dev->otherend_id, xenfb_event_handler, 0, "xenfb", info);
   27.40  	if (ret < 0) {
   27.41 -		xenbus_free_evtchn(dev, info->evtchn);
   27.42 -		xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
   27.43 +		xenbus_dev_fatal(dev, ret,
   27.44 +				 "bind_listening_port_to_irqhandler");
   27.45  		return ret;
   27.46  	}
   27.47  	info->irq = ret;
   27.48 @@ -641,7 +637,7 @@ static int xenfb_connect_backend(struct 
   27.49  	if (ret)
   27.50  		goto error_xenbus;
   27.51  	ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
   27.52 -			    info->evtchn);
   27.53 +			    irq_to_evtchn_port(info->irq));
   27.54  	if (ret)
   27.55  		goto error_xenbus;
   27.56  	ret = xenbus_printf(xbt, dev->nodename, "feature-update", "1");
    28.1 --- a/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c	Wed Jan 10 08:00:50 2007 -0700
    28.2 +++ b/linux-2.6-xen-sparse/drivers/xen/fbfront/xenkbd.c	Wed Jan 10 08:40:47 2007 -0700
    28.3 @@ -31,7 +31,6 @@ struct xenkbd_info
    28.4  {
    28.5  	struct input_dev *dev;
    28.6  	struct xenkbd_page *page;
    28.7 -	unsigned evtchn;
    28.8  	int irq;
    28.9  	struct xenbus_device *xbdev;
   28.10  };
   28.11 @@ -76,7 +75,7 @@ static irqreturn_t input_handler(int rq,
   28.12  	input_sync(info->dev);
   28.13  	mb();			/* ensure we got ring contents */
   28.14  	page->in_cons = cons;
   28.15 -	notify_remote_via_evtchn(info->evtchn);
   28.16 +	notify_remote_via_irq(info->irq);
   28.17  
   28.18  	return IRQ_HANDLED;
   28.19  }
   28.20 @@ -168,14 +167,11 @@ static int xenkbd_connect_backend(struct
   28.21  	int ret;
   28.22  	struct xenbus_transaction xbt;
   28.23  
   28.24 -	ret = xenbus_alloc_evtchn(dev, &info->evtchn);
   28.25 -	if (ret)
   28.26 -		return ret;
   28.27 -	ret = bind_evtchn_to_irqhandler(info->evtchn, input_handler, 0,
   28.28 -					"xenkbd", info);
   28.29 +	ret = bind_listening_port_to_irqhandler(
   28.30 +		dev->otherend_id, input_handler, 0, "xenkbd", info);
   28.31  	if (ret < 0) {
   28.32 -		xenbus_free_evtchn(dev, info->evtchn);
   28.33 -		xenbus_dev_fatal(dev, ret, "bind_evtchn_to_irqhandler");
   28.34 +		xenbus_dev_fatal(dev, ret,
   28.35 +				 "bind_listening_port_to_irqhandler");
   28.36  		return ret;
   28.37  	}
   28.38  	info->irq = ret;
   28.39 @@ -191,7 +187,7 @@ static int xenkbd_connect_backend(struct
   28.40  	if (ret)
   28.41  		goto error_xenbus;
   28.42  	ret = xenbus_printf(xbt, dev->nodename, "event-channel", "%u",
   28.43 -			    info->evtchn);
   28.44 +			    irq_to_evtchn_port(info->irq));
   28.45  	if (ret)
   28.46  		goto error_xenbus;
   28.47  	ret = xenbus_transaction_end(xbt, 0);
    29.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Wed Jan 10 08:00:50 2007 -0700
    29.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Wed Jan 10 08:40:47 2007 -0700
    29.3 @@ -67,7 +67,6 @@ typedef struct netif_st {
    29.4  	grant_ref_t      tx_shmem_ref;
    29.5  	grant_handle_t   rx_shmem_handle;
    29.6  	grant_ref_t      rx_shmem_ref;
    29.7 -	unsigned int     evtchn;
    29.8  	unsigned int     irq;
    29.9  
   29.10  	/* The shared rings and indexes. */
    30.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Wed Jan 10 08:00:50 2007 -0700
    30.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Wed Jan 10 08:40:47 2007 -0700
    30.3 @@ -259,7 +259,6 @@ int netif_map(netif_t *netif, unsigned l
    30.4  	int err = -ENOMEM;
    30.5  	netif_tx_sring_t *txs;
    30.6  	netif_rx_sring_t *rxs;
    30.7 -	struct evtchn_bind_interdomain bind_interdomain;
    30.8  
    30.9  	/* Already connected through? */
   30.10  	if (netif->irq)
   30.11 @@ -276,18 +275,12 @@ int netif_map(netif_t *netif, unsigned l
   30.12  	if (err)
   30.13  		goto err_map;
   30.14  
   30.15 -	bind_interdomain.remote_dom = netif->domid;
   30.16 -	bind_interdomain.remote_port = evtchn;
   30.17 -
   30.18 -	err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
   30.19 -					  &bind_interdomain);
   30.20 -	if (err)
   30.21 +	err = bind_interdomain_evtchn_to_irqhandler(
   30.22 +		netif->domid, evtchn, netif_be_int, 0,
   30.23 +		netif->dev->name, netif);
   30.24 +	if (err < 0)
   30.25  		goto err_hypervisor;
   30.26 -
   30.27 -	netif->evtchn = bind_interdomain.local_port;
   30.28 -
   30.29 -	netif->irq = bind_evtchn_to_irqhandler(
   30.30 -		netif->evtchn, netif_be_int, 0, netif->dev->name, netif);
   30.31 +	netif->irq = err;
   30.32  	disable_irq(netif->irq);
   30.33  
   30.34  	txs = (netif_tx_sring_t *)netif->tx_comms_area->addr;
    31.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Jan 10 08:00:50 2007 -0700
    31.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Jan 10 08:40:47 2007 -0700
    31.3 @@ -153,7 +153,7 @@ struct netfront_info {
    31.4  	spinlock_t   tx_lock;
    31.5  	spinlock_t   rx_lock;
    31.6  
    31.7 -	unsigned int evtchn, irq;
    31.8 +	unsigned int irq;
    31.9  	unsigned int copying_receiver;
   31.10  
   31.11  	/* Receive-ring batched refills. */
   31.12 @@ -244,12 +244,8 @@ static inline grant_ref_t xennet_get_rx_
   31.13  static int setup_device(struct xenbus_device *, struct netfront_info *);
   31.14  static struct net_device *create_netdev(struct xenbus_device *);
   31.15  
   31.16 -static void netfront_closing(struct xenbus_device *);
   31.17 -
   31.18  static void end_access(int, void *);
   31.19  static void netif_disconnect_backend(struct netfront_info *);
   31.20 -static int open_netdev(struct netfront_info *);
   31.21 -static void close_netdev(struct netfront_info *);
   31.22  
   31.23  static int network_connect(struct net_device *);
   31.24  static void network_tx_buf_gc(struct net_device *);
   31.25 @@ -293,9 +289,20 @@ static int __devinit netfront_probe(stru
   31.26  	info = netdev_priv(netdev);
   31.27  	dev->dev.driver_data = info;
   31.28  
   31.29 -	err = open_netdev(info);
   31.30 -	if (err)
   31.31 +	err = register_netdev(info->netdev);
   31.32 +	if (err) {
   31.33 +		printk(KERN_WARNING "%s: register_netdev err=%d\n",
   31.34 +		       __FUNCTION__, err);
   31.35  		goto fail;
   31.36 +	}
   31.37 +
   31.38 +	err = xennet_sysfs_addif(info->netdev);
   31.39 +	if (err) {
   31.40 +		unregister_netdev(info->netdev);
   31.41 +		printk(KERN_WARNING "%s: add sysfs failed err=%d\n",
   31.42 +		       __FUNCTION__, err);
   31.43 +		goto fail;
   31.44 +	}
   31.45  
   31.46  	return 0;
   31.47  
   31.48 @@ -305,6 +312,24 @@ static int __devinit netfront_probe(stru
   31.49  	return err;
   31.50  }
   31.51  
   31.52 +static int __devexit netfront_remove(struct xenbus_device *dev)
   31.53 +{
   31.54 +	struct netfront_info *info = dev->dev.driver_data;
   31.55 +
   31.56 +	DPRINTK("%s\n", dev->nodename);
   31.57 +
   31.58 +	netif_disconnect_backend(info);
   31.59 +
   31.60 +	del_timer_sync(&info->rx_refill_timer);
   31.61 +
   31.62 +	xennet_sysfs_delif(info->netdev);
   31.63 +
   31.64 +	unregister_netdev(info->netdev);
   31.65 +
   31.66 +	free_netdev(info->netdev);
   31.67 +
   31.68 +	return 0;
   31.69 +}
   31.70  
   31.71  /**
   31.72   * We are reconnecting to the backend, due to a suspend/resume, or a backend
   31.73 @@ -383,7 +408,8 @@ again:
   31.74  		goto abort_transaction;
   31.75  	}
   31.76  	err = xenbus_printf(xbt, dev->nodename,
   31.77 -			    "event-channel", "%u", info->evtchn);
   31.78 +			    "event-channel", "%u",
   31.79 +			    irq_to_evtchn_port(info->irq));
   31.80  	if (err) {
   31.81  		message = "writing event-channel";
   31.82  		goto abort_transaction;
   31.83 @@ -488,17 +514,15 @@ static int setup_device(struct xenbus_de
   31.84  	}
   31.85  	info->rx_ring_ref = err;
   31.86  
   31.87 -	err = xenbus_alloc_evtchn(dev, &info->evtchn);
   31.88 -	if (err)
   31.89 -		goto fail;
   31.90 +	memcpy(netdev->dev_addr, info->mac, ETH_ALEN);
   31.91  
   31.92 -	memcpy(netdev->dev_addr, info->mac, ETH_ALEN);
   31.93 -	err = bind_evtchn_to_irqhandler(info->evtchn, netif_int,
   31.94 -					SA_SAMPLE_RANDOM, netdev->name,
   31.95 -					netdev);
   31.96 +	err = bind_listening_port_to_irqhandler(
   31.97 +		dev->otherend_id, netif_int, SA_SAMPLE_RANDOM, netdev->name,
   31.98 +		netdev);
   31.99  	if (err < 0)
  31.100  		goto fail;
  31.101  	info->irq = err;
  31.102 +
  31.103  	return 0;
  31.104  
  31.105   fail:
  31.106 @@ -534,9 +558,7 @@ static void backend_changed(struct xenbu
  31.107  		break;
  31.108  
  31.109  	case XenbusStateClosing:
  31.110 -		if (dev->state == XenbusStateClosed)
  31.111 -			break;
  31.112 -		netfront_closing(dev);
  31.113 +		xenbus_frontend_closed(dev);
  31.114  		break;
  31.115  	}
  31.116  }
  31.117 @@ -1995,70 +2017,6 @@ inetdev_notify(struct notifier_block *th
  31.118  }
  31.119  
  31.120  
  31.121 -/* ** Close down ** */
  31.122 -
  31.123 -
  31.124 -/**
  31.125 - * Handle the change of state of the backend to Closing.  We must delete our
  31.126 - * device-layer structures now, to ensure that writes are flushed through to
  31.127 - * the backend.  Once is this done, we can switch to Closed in
  31.128 - * acknowledgement.
  31.129 - */
  31.130 -static void netfront_closing(struct xenbus_device *dev)
  31.131 -{
  31.132 -	struct netfront_info *info = dev->dev.driver_data;
  31.133 -
  31.134 -	DPRINTK("%s\n", dev->nodename);
  31.135 -
  31.136 -	close_netdev(info);
  31.137 -	xenbus_frontend_closed(dev);
  31.138 -}
  31.139 -
  31.140 -
  31.141 -static int __devexit netfront_remove(struct xenbus_device *dev)
  31.142 -{
  31.143 -	struct netfront_info *info = dev->dev.driver_data;
  31.144 -
  31.145 -	DPRINTK("%s\n", dev->nodename);
  31.146 -
  31.147 -	netif_disconnect_backend(info);
  31.148 -	free_netdev(info->netdev);
  31.149 -
  31.150 -	return 0;
  31.151 -}
  31.152 -
  31.153 -
  31.154 -static int open_netdev(struct netfront_info *info)
  31.155 -{
  31.156 -	int err;
  31.157 -	
  31.158 -	err = register_netdev(info->netdev);
  31.159 -	if (err) {
  31.160 -		printk(KERN_WARNING "%s: register_netdev err=%d\n",
  31.161 -		       __FUNCTION__, err);
  31.162 -		return err;
  31.163 -	}
  31.164 -
  31.165 -	err = xennet_sysfs_addif(info->netdev);
  31.166 -	if (err) {
  31.167 -		unregister_netdev(info->netdev);
  31.168 -		printk(KERN_WARNING "%s: add sysfs failed err=%d\n",
  31.169 -		       __FUNCTION__, err);
  31.170 -		return err;
  31.171 -	}
  31.172 -
  31.173 -	return 0;
  31.174 -}
  31.175 -
  31.176 -static void close_netdev(struct netfront_info *info)
  31.177 -{
  31.178 -	del_timer_sync(&info->rx_refill_timer);
  31.179 -
  31.180 -	xennet_sysfs_delif(info->netdev);
  31.181 -	unregister_netdev(info->netdev);
  31.182 -}
  31.183 -
  31.184 -
  31.185  static void netif_disconnect_backend(struct netfront_info *info)
  31.186  {
  31.187  	/* Stop old i/f to prevent errors whilst we rebuild the state. */
  31.188 @@ -2070,7 +2028,7 @@ static void netif_disconnect_backend(str
  31.189  
  31.190  	if (info->irq)
  31.191  		unbind_from_irqhandler(info->irq, info->netdev);
  31.192 -	info->evtchn = info->irq = 0;
  31.193 +	info->irq = 0;
  31.194  
  31.195  	end_access(info->tx_ring_ref, info->tx.sring);
  31.196  	end_access(info->rx_ring_ref, info->rx.sring);
    32.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c	Wed Jan 10 08:00:50 2007 -0700
    32.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/xenbus.c	Wed Jan 10 08:40:47 2007 -0700
    32.3 @@ -71,7 +71,6 @@ static int pciback_do_attach(struct pcib
    32.4  			     int remote_evtchn)
    32.5  {
    32.6  	int err = 0;
    32.7 -	int evtchn;
    32.8  	struct vm_struct *area;
    32.9  
   32.10  	dev_dbg(&pdev->xdev->dev,
   32.11 @@ -86,12 +85,9 @@ static int pciback_do_attach(struct pcib
   32.12  	pdev->sh_area = area;
   32.13  	pdev->sh_info = area->addr;
   32.14  
   32.15 -	err = xenbus_bind_evtchn(pdev->xdev, remote_evtchn, &evtchn);
   32.16 -	if (err)
   32.17 -		goto out;
   32.18 -
   32.19 -	err = bind_evtchn_to_irqhandler(evtchn, pciback_handle_event,
   32.20 -					SA_SAMPLE_RANDOM, "pciback", pdev);
   32.21 +	err = bind_interdomain_evtchn_to_irqhandler(
   32.22 +		pdev->xdev->otherend_id, remote_evtchn, pciback_handle_event,
   32.23 +		SA_SAMPLE_RANDOM, "pciback", pdev);
   32.24  	if (err < 0) {
   32.25  		xenbus_dev_fatal(pdev->xdev, err,
   32.26  				 "Error binding event channel to IRQ");
    33.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h	Wed Jan 10 08:00:50 2007 -0700
    33.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/common.h	Wed Jan 10 08:40:47 2007 -0700
    33.3 @@ -30,7 +30,6 @@ typedef struct tpmif_st {
    33.4  	unsigned int handle;
    33.5  
    33.6  	/* Physical parameters of the comms window. */
    33.7 -	unsigned int evtchn;
    33.8  	unsigned int irq;
    33.9  
   33.10  	/* The shared rings and indexes. */
    34.1 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Wed Jan 10 08:00:50 2007 -0700
    34.2 +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/interface.c	Wed Jan 10 08:40:47 2007 -0700
    34.3 @@ -118,11 +118,9 @@ static void unmap_frontend_page(tpmif_t 
    34.4  int tpmif_map(tpmif_t *tpmif, unsigned long shared_page, unsigned int evtchn)
    34.5  {
    34.6  	int err;
    34.7 -	struct evtchn_bind_interdomain bind_interdomain;
    34.8  
    34.9 -	if (tpmif->irq) {
   34.10 +	if (tpmif->irq)
   34.11  		return 0;
   34.12 -	}
   34.13  
   34.14  	if ((tpmif->tx_area = alloc_vm_area(PAGE_SIZE)) == NULL)
   34.15  		return -ENOMEM;
   34.16 @@ -133,24 +131,17 @@ int tpmif_map(tpmif_t *tpmif, unsigned l
   34.17  		return err;
   34.18  	}
   34.19  
   34.20 -
   34.21 -	bind_interdomain.remote_dom  = tpmif->domid;
   34.22 -	bind_interdomain.remote_port = evtchn;
   34.23 +	tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
   34.24  
   34.25 -	err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
   34.26 -					  &bind_interdomain);
   34.27 -	if (err) {
   34.28 +	err = bind_interdomain_evtchn_to_irqhandler(
   34.29 +		tpmif->domid, evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);
   34.30 +	if (err < 0) {
   34.31  		unmap_frontend_page(tpmif);
   34.32  		free_vm_area(tpmif->tx_area);
   34.33  		return err;
   34.34  	}
   34.35 -
   34.36 -	tpmif->evtchn = bind_interdomain.local_port;
   34.37 +	tpmif->irq = err;
   34.38  
   34.39 -	tpmif->tx = (tpmif_tx_interface_t *)tpmif->tx_area->addr;
   34.40 -
   34.41 -	tpmif->irq = bind_evtchn_to_irqhandler(
   34.42 -		tpmif->evtchn, tpmif_be_int, 0, tpmif->devname, tpmif);
   34.43  	tpmif->shmem_ref = shared_page;
   34.44  	tpmif->active = 1;
   34.45  
    35.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Wed Jan 10 08:00:50 2007 -0700
    35.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c	Wed Jan 10 08:40:47 2007 -0700
    35.3 @@ -254,28 +254,6 @@ int xenbus_alloc_evtchn(struct xenbus_de
    35.4  EXPORT_SYMBOL_GPL(xenbus_alloc_evtchn);
    35.5  
    35.6  
    35.7 -int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port)
    35.8 -{
    35.9 -	struct evtchn_bind_interdomain bind_interdomain;
   35.10 -	int err;
   35.11 -
   35.12 -	bind_interdomain.remote_dom  = dev->otherend_id;
   35.13 -	bind_interdomain.remote_port = remote_port,
   35.14 -
   35.15 -	err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
   35.16 -					  &bind_interdomain);
   35.17 -	if (err)
   35.18 -		xenbus_dev_fatal(dev, err,
   35.19 -				 "binding to event channel %d from domain %d",
   35.20 -				 remote_port, dev->otherend_id);
   35.21 -	else
   35.22 -		*port = bind_interdomain.local_port;
   35.23 -
   35.24 -	return err;
   35.25 -}
   35.26 -EXPORT_SYMBOL_GPL(xenbus_bind_evtchn);
   35.27 -
   35.28 -
   35.29  int xenbus_free_evtchn(struct xenbus_device *dev, int port)
   35.30  {
   35.31  	struct evtchn_close close;
    36.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Wed Jan 10 08:00:50 2007 -0700
    36.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_comms.c	Wed Jan 10 08:40:47 2007 -0700
    36.3 @@ -196,7 +196,7 @@ int xb_init_comms(void)
    36.4  	if (xenbus_irq)
    36.5  		unbind_from_irqhandler(xenbus_irq, &xb_waitq);
    36.6  
    36.7 -	err = bind_evtchn_to_irqhandler(
    36.8 +	err = bind_caller_port_to_irqhandler(
    36.9  		xen_store_evtchn, wake_waiting,
   36.10  		0, "xenbus", &xb_waitq);
   36.11  	if (err <= 0) {
    37.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h	Wed Jan 10 08:00:50 2007 -0700
    37.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/swiotlb.h	Wed Jan 10 08:40:47 2007 -0700
    37.3 @@ -34,6 +34,8 @@ extern void swiotlb_unmap_page(struct de
    37.4  extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
    37.5  extern void swiotlb_init(void);
    37.6  
    37.7 +extern unsigned int dma_bits;
    37.8 +
    37.9  #ifdef CONFIG_SWIOTLB
   37.10  extern int swiotlb;
   37.11  #else
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/linux-2.6-xen-sparse/include/asm-ia64/swiotlb.h	Wed Jan 10 08:40:47 2007 -0700
    38.3 @@ -0,0 +1,45 @@
    38.4 +#ifndef _ASM_SWIOTLB_H
    38.5 +#define _ASM_SWIOTLB_H 1
    38.6 +
    38.7 +#include <linux/config.h>
    38.8 +
    38.9 +/* SWIOTLB interface */
   38.10 +
   38.11 +extern dma_addr_t swiotlb_map_single(struct device *hwdev, void *ptr, size_t size,
   38.12 +				      int dir);
   38.13 +extern void swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr,
   38.14 +				  size_t size, int dir);
   38.15 +extern void swiotlb_sync_single_for_cpu(struct device *hwdev,
   38.16 +					 dma_addr_t dev_addr,
   38.17 +					 size_t size, int dir);
   38.18 +extern void swiotlb_sync_single_for_device(struct device *hwdev,
   38.19 +					    dma_addr_t dev_addr,
   38.20 +					    size_t size, int dir);
   38.21 +extern void swiotlb_sync_sg_for_cpu(struct device *hwdev,
   38.22 +				     struct scatterlist *sg, int nelems,
   38.23 +				     int dir);
   38.24 +extern void swiotlb_sync_sg_for_device(struct device *hwdev,
   38.25 +					struct scatterlist *sg, int nelems,
   38.26 +					int dir);
   38.27 +extern int swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg,
   38.28 +		      int nents, int direction);
   38.29 +extern void swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg,
   38.30 +			 int nents, int direction);
   38.31 +extern int swiotlb_dma_mapping_error(dma_addr_t dma_addr);
   38.32 +extern dma_addr_t swiotlb_map_page(struct device *hwdev, struct page *page,
   38.33 +                                   unsigned long offset, size_t size,
   38.34 +                                   enum dma_data_direction direction);
   38.35 +extern void swiotlb_unmap_page(struct device *hwdev, dma_addr_t dma_address,
   38.36 +                               size_t size, enum dma_data_direction direction);
   38.37 +extern int swiotlb_dma_supported(struct device *hwdev, u64 mask);
   38.38 +extern void swiotlb_init(void);
   38.39 +
   38.40 +extern unsigned int dma_bits;
   38.41 +
   38.42 +#ifdef CONFIG_SWIOTLB
   38.43 +extern int swiotlb;
   38.44 +#else
   38.45 +#define swiotlb 0
   38.46 +#endif
   38.47 +
   38.48 +#endif
    39.1 --- a/linux-2.6-xen-sparse/include/xen/evtchn.h	Wed Jan 10 08:00:50 2007 -0700
    39.2 +++ b/linux-2.6-xen-sparse/include/xen/evtchn.h	Wed Jan 10 08:40:47 2007 -0700
    39.3 @@ -52,22 +52,34 @@
    39.4   * The IRQ argument passed to the callback handler is the same as returned
    39.5   * from the bind call. It may not correspond to a Linux IRQ number.
    39.6   * Returns IRQ or negative errno.
    39.7 - * UNBIND: Takes IRQ to unbind from; automatically closes the event channel.
    39.8   */
    39.9 -extern int bind_evtchn_to_irqhandler(
   39.10 -	unsigned int evtchn,
   39.11 +int bind_caller_port_to_irqhandler(
   39.12 +	unsigned int caller_port,
   39.13  	irqreturn_t (*handler)(int, void *, struct pt_regs *),
   39.14  	unsigned long irqflags,
   39.15  	const char *devname,
   39.16  	void *dev_id);
   39.17 -extern int bind_virq_to_irqhandler(
   39.18 +int bind_listening_port_to_irqhandler(
   39.19 +	unsigned int remote_domain,
   39.20 +	irqreturn_t (*handler)(int, void *, struct pt_regs *),
   39.21 +	unsigned long irqflags,
   39.22 +	const char *devname,
   39.23 +	void *dev_id);
   39.24 +int bind_interdomain_evtchn_to_irqhandler(
   39.25 +	unsigned int remote_domain,
   39.26 +	unsigned int remote_port,
   39.27 +	irqreturn_t (*handler)(int, void *, struct pt_regs *),
   39.28 +	unsigned long irqflags,
   39.29 +	const char *devname,
   39.30 +	void *dev_id);
   39.31 +int bind_virq_to_irqhandler(
   39.32  	unsigned int virq,
   39.33  	unsigned int cpu,
   39.34  	irqreturn_t (*handler)(int, void *, struct pt_regs *),
   39.35  	unsigned long irqflags,
   39.36  	const char *devname,
   39.37  	void *dev_id);
   39.38 -extern int bind_ipi_to_irqhandler(
   39.39 +int bind_ipi_to_irqhandler(
   39.40  	unsigned int ipi,
   39.41  	unsigned int cpu,
   39.42  	irqreturn_t (*handler)(int, void *, struct pt_regs *),
   39.43 @@ -77,21 +89,21 @@ extern int bind_ipi_to_irqhandler(
   39.44  
   39.45  /*
   39.46   * Common unbind function for all event sources. Takes IRQ to unbind from.
   39.47 - * Automatically closes the underlying event channel (even for bindings
   39.48 - * made with bind_evtchn_to_irqhandler()).
   39.49 + * Automatically closes the underlying event channel (except for bindings
   39.50 + * made with bind_caller_port_to_irqhandler()).
   39.51   */
   39.52 -extern void unbind_from_irqhandler(unsigned int irq, void *dev_id);
   39.53 +void unbind_from_irqhandler(unsigned int irq, void *dev_id);
   39.54  
   39.55 -extern void irq_resume(void);
   39.56 +void irq_resume(void);
   39.57  
   39.58  /* Entry point for notifications into Linux subsystems. */
   39.59  asmlinkage void evtchn_do_upcall(struct pt_regs *regs);
   39.60  
   39.61  /* Entry point for notifications into the userland character device. */
   39.62 -extern void evtchn_device_upcall(int port);
   39.63 +void evtchn_device_upcall(int port);
   39.64  
   39.65 -extern void mask_evtchn(int port);
   39.66 -extern void unmask_evtchn(int port);
   39.67 +void mask_evtchn(int port);
   39.68 +void unmask_evtchn(int port);
   39.69  
   39.70  static inline void clear_evtchn(int port)
   39.71  {
   39.72 @@ -106,9 +118,10 @@ static inline void notify_remote_via_evt
   39.73  }
   39.74  
   39.75  /*
   39.76 - * Unlike notify_remote_via_evtchn(), this is safe to use across
   39.77 - * save/restore. Notifications on a broken connection are silently dropped.
   39.78 + * Use these to access the event channel underlying the IRQ handle returned
   39.79 + * by bind_*_to_irqhandler().
   39.80   */
   39.81 -extern void notify_remote_via_irq(int irq);
   39.82 +void notify_remote_via_irq(int irq);
   39.83 +int irq_to_evtchn_port(int irq);
   39.84  
   39.85  #endif /* __ASM_EVTCHN_H__ */
    40.1 --- a/linux-2.6-xen-sparse/include/xen/xenbus.h	Wed Jan 10 08:00:50 2007 -0700
    40.2 +++ b/linux-2.6-xen-sparse/include/xen/xenbus.h	Wed Jan 10 08:40:47 2007 -0700
    40.3 @@ -262,14 +262,6 @@ int xenbus_alloc_evtchn(struct xenbus_de
    40.4  
    40.5  
    40.6  /**
    40.7 - * Bind to an existing interdomain event channel in another domain. Returns 0
    40.8 - * on success and stores the local port in *port. On error, returns -errno,
    40.9 - * switches the device to XenbusStateClosing, and saves the error in XenStore.
   40.10 - */
   40.11 -int xenbus_bind_evtchn(struct xenbus_device *dev, int remote_port, int *port);
   40.12 -
   40.13 -
   40.14 -/**
   40.15   * Free an existing event channel. Returns 0 on success or -errno on error.
   40.16   */
   40.17  int xenbus_free_evtchn(struct xenbus_device *dev, int port);
    41.1 --- a/linux-2.6-xen-sparse/kernel/kexec.c	Wed Jan 10 08:00:50 2007 -0700
    41.2 +++ b/linux-2.6-xen-sparse/kernel/kexec.c	Wed Jan 10 08:40:47 2007 -0700
    41.3 @@ -1012,9 +1012,11 @@ asmlinkage long sys_kexec_load(unsigned 
    41.4  			goto out;
    41.5  	}
    41.6  #ifdef CONFIG_XEN
    41.7 -	result = xen_machine_kexec_load(image);
    41.8 -	if (result)
    41.9 -		goto out;
   41.10 +	if (image) {
   41.11 +		result = xen_machine_kexec_load(image);
   41.12 +		if (result)
   41.13 +			goto out;
   41.14 +	}
   41.15  #endif
   41.16  	/* Install the new kernel, and  Uninstall the old */
   41.17  	image = xchg(dest_image, image);
    42.1 --- a/linux-2.6-xen-sparse/net/core/dev.c	Wed Jan 10 08:00:50 2007 -0700
    42.2 +++ b/linux-2.6-xen-sparse/net/core/dev.c	Wed Jan 10 08:40:47 2007 -0700
    42.3 @@ -1248,14 +1248,13 @@ static int dev_gso_segment(struct sk_buf
    42.4  	/* Verifying header integrity only. */
    42.5  	if (!segs)
    42.6  		return 0;
    42.7 -
    42.8 +  
    42.9  	if (unlikely(IS_ERR(segs)))
   42.10  		return PTR_ERR(segs);
   42.11  
   42.12  	skb->next = segs;
   42.13  	DEV_GSO_CB(skb)->destructor = skb->destructor;
   42.14  	skb->destructor = dev_gso_skb_destructor;
   42.15 -
   42.16  	return 0;
   42.17  }
   42.18  
    43.1 --- a/patches/linux-2.6.16.33/vsnprintf.patch	Wed Jan 10 08:00:50 2007 -0700
    43.2 +++ b/patches/linux-2.6.16.33/vsnprintf.patch	Wed Jan 10 08:40:47 2007 -0700
    43.3 @@ -203,7 +203,7 @@ index b07db5c..f595947 100644
    43.4  +		if (str < end)
    43.5  +			*str = '\0';
    43.6  +		else
    43.7 -+			*end = '\0';
    43.8 ++			end[-1] = '\0';
    43.9  +	}
   43.10  +	/* the trailing null byte doesn't count towards the total */
   43.11   	return str-buf;
    44.1 --- a/tools/Rules.mk	Wed Jan 10 08:00:50 2007 -0700
    44.2 +++ b/tools/Rules.mk	Wed Jan 10 08:40:47 2007 -0700
    44.3 @@ -50,5 +50,7 @@ mk-symlinks-xen:
    44.4  	( cd xen/hvm && ln -sf ../../$(XEN_ROOT)/xen/include/public/hvm/*.h . )
    44.5  	mkdir -p xen/io
    44.6  	( cd xen/io && ln -sf ../../$(XEN_ROOT)/xen/include/public/io/*.h . )
    44.7 +	mkdir -p xen/arch-x86
    44.8 +	( cd xen/arch-x86 && ln -sf ../../$(XEN_ROOT)/xen/include/public/arch-x86/*.h . )
    44.9  
   44.10  mk-symlinks: mk-symlinks-xen mk-symlinks-$(XEN_OS)
    45.1 --- a/tools/blktap/drivers/block-qcow.c	Wed Jan 10 08:00:50 2007 -0700
    45.2 +++ b/tools/blktap/drivers/block-qcow.c	Wed Jan 10 08:40:47 2007 -0700
    45.3 @@ -47,6 +47,11 @@
    45.4  #define ASSERT(_p) ((void)0)
    45.5  #endif
    45.6  
    45.7 +#define ROUNDUP(l, s) \
    45.8 +({ \
    45.9 +    (uint64_t)( \
   45.10 +        (l + (s - 1)) - ((l + (s - 1)) % s)); \
   45.11 +})
   45.12  
   45.13  /******AIO DEFINES******/
   45.14  #define REQUEST_ASYNC_FD 1
   45.15 @@ -76,9 +81,9 @@ struct pending_aio {
   45.16  
   45.17  #define QCOW_CRYPT_NONE 0x00
   45.18  #define QCOW_CRYPT_AES  0x01
   45.19 -#define QCOW_SPARSE_FILE 0x02
   45.20  
   45.21  #define QCOW_OFLAG_COMPRESSED (1LL << 63)
   45.22 +#define SPARSE_FILE 0x01
   45.23  
   45.24  #ifndef O_BINARY
   45.25  #define O_BINARY 0
   45.26 @@ -418,8 +423,9 @@ static void encrypt_sectors(struct tdqco
   45.27  
   45.28  static int qtruncate(int fd, off_t length, int sparse)
   45.29  {
   45.30 -	int current, ret, i; 
   45.31 -	int sectors = length/DEFAULT_SECTOR_SIZE;
   45.32 +	int ret, i; 
   45.33 +	int current = 0, rem = 0;
   45.34 +	int sectors = (length + DEFAULT_SECTOR_SIZE - 1)/DEFAULT_SECTOR_SIZE;
   45.35  	struct stat st;
   45.36  	char buf[DEFAULT_SECTOR_SIZE];
   45.37  
   45.38 @@ -429,22 +435,45 @@ static int qtruncate(int fd, off_t lengt
   45.39  	 */
   45.40  	memset(buf, 0x00, DEFAULT_SECTOR_SIZE);
   45.41  	ret = fstat(fd, &st);
   45.42 -	if((ret == -1) || S_ISBLK(st.st_mode))
   45.43 +	if (ret == -1)
   45.44  		return -1;
   45.45 +	if (S_ISBLK(st.st_mode))
   45.46 +		return 0;
   45.47 +
   45.48 +	current = (st.st_size + DEFAULT_SECTOR_SIZE - 1)/DEFAULT_SECTOR_SIZE;
   45.49 +	rem = st.st_size % DEFAULT_SECTOR_SIZE;
   45.50  
   45.51 -	if(st.st_size < length) {
   45.52 +	/* If we are extending this file, we write zeros to the end --
   45.53 +	 * this tries to ensure that the extents allocated wind up being
   45.54 +	 * contiguous on disk.
   45.55 +	 */
   45.56 +	if(st.st_size < sectors * DEFAULT_SECTOR_SIZE) {
   45.57  		/*We are extending the file*/
   45.58 -		lseek(fd, 0, SEEK_END);
   45.59 -		for (i = 0; i < sectors; i++ ) {
   45.60 +		if (lseek(fd, 0, SEEK_END)==-1) {
   45.61 +			fprintf(stderr, 
   45.62 +				"Lseek EOF failed (%d), internal error\n",
   45.63 +				errno);
   45.64 +			return -1;
   45.65 +		}
   45.66 +		if (rem) {
   45.67 +			ret = write(fd, buf, rem);
   45.68 +			if (ret != rem)
   45.69 +				return -1;
   45.70 +		}
   45.71 +		for (i = current; i < sectors; i++ ) {
   45.72  			ret = write(fd, buf, DEFAULT_SECTOR_SIZE);
   45.73  			if (ret != DEFAULT_SECTOR_SIZE)
   45.74  				return -1;
   45.75  		}
   45.76  		
   45.77 -	} else if(sparse && (st.st_size > length))
   45.78 -		ftruncate(fd, length);
   45.79 -
   45.80 -	return 1;
   45.81 +	} else if(sparse && (st.st_size > sectors * DEFAULT_SECTOR_SIZE))
   45.82 +		if (ftruncate(fd, sectors * DEFAULT_SECTOR_SIZE)==-1) {
   45.83 +			fprintf(stderr,
   45.84 +				"Ftruncate failed (%d), internal error\n",
   45.85 +                                errno);
   45.86 +			return -1;
   45.87 +		}
   45.88 +	return 0;
   45.89  }
   45.90  
   45.91  
   45.92 @@ -497,7 +526,12 @@ static uint64_t get_cluster_offset(struc
   45.93  		
   45.94  		/*Truncate file for L2 table 
   45.95  		 *(initialised to zero in case we crash)*/
   45.96 -		qtruncate(s->fd, l2_offset + (s->l2_size * sizeof(uint64_t)), s->sparse);
   45.97 +		if (qtruncate(s->fd, 
   45.98 +			      l2_offset + (s->l2_size * sizeof(uint64_t)),
   45.99 +			      s->sparse) != 0) {
  45.100 +			DPRINTF("ERROR truncating file\n");
  45.101 +			return 0;
  45.102 +		}
  45.103  		s->fd_end = l2_offset + (s->l2_size * sizeof(uint64_t));
  45.104  
  45.105  		/*Update the L1 table entry on disk
  45.106 @@ -564,8 +598,12 @@ cache_miss:
  45.107  				(s->l2_size * sizeof(uint64_t));
  45.108  			cluster_offset = (cluster_offset + s->cluster_size - 1)
  45.109  				& ~(s->cluster_size - 1);
  45.110 -			qtruncate(s->fd, cluster_offset + 
  45.111 -				  (s->cluster_size * s->l2_size), s->sparse);
  45.112 +			if (qtruncate(s->fd, cluster_offset + 
  45.113 +				  (s->cluster_size * s->l2_size), 
  45.114 +				      s->sparse) != 0) {
  45.115 +				DPRINTF("ERROR truncating file\n");
  45.116 +				return 0;
  45.117 +			}
  45.118  			s->fd_end = cluster_offset + 
  45.119  				(s->cluster_size * s->l2_size);
  45.120  			for (i = 0; i < s->l2_size; i++) {
  45.121 @@ -623,8 +661,11 @@ found:
  45.122  				cluster_offset = 
  45.123  					(cluster_offset + s->cluster_size - 1) 
  45.124  					& ~(s->cluster_size - 1);
  45.125 -				qtruncate(s->fd, cluster_offset + 
  45.126 -					  s->cluster_size, s->sparse);
  45.127 +				if (qtruncate(s->fd, cluster_offset + 
  45.128 +					      s->cluster_size, s->sparse)!=0) {
  45.129 +					DPRINTF("ERROR truncating file\n");
  45.130 +					return 0;
  45.131 +				}
  45.132  				s->fd_end = (cluster_offset + s->cluster_size);
  45.133  				/* if encrypted, we must initialize the cluster
  45.134  				   content which won't be written */
  45.135 @@ -909,15 +950,14 @@ int tdqcow_open (struct td_state *bs, co
  45.136  
  45.137  		/*Finally check the L1 table cksum*/
  45.138  		be32_to_cpus(&exthdr->cksum);
  45.139 -		cksum = gen_cksum((char *)s->l1_table, s->l1_size * sizeof(uint64_t));
  45.140 -		if(exthdr->cksum != cksum) {
  45.141 +		cksum = gen_cksum((char *)s->l1_table, 
  45.142 +				  s->l1_size * sizeof(uint64_t));
  45.143 +		if(exthdr->cksum != cksum)
  45.144  			goto end_xenhdr;
  45.145 -		}
  45.146  			
  45.147  		be32_to_cpus(&exthdr->min_cluster_alloc);
  45.148  		be32_to_cpus(&exthdr->flags);
  45.149 -		if (exthdr->flags & QCOW_SPARSE_FILE)
  45.150 -			s->sparse = 1;
  45.151 +		s->sparse = (exthdr->flags & SPARSE_FILE);
  45.152  		s->min_cluster_alloc = exthdr->min_cluster_alloc; 
  45.153  	}
  45.154  
  45.155 @@ -1210,10 +1250,10 @@ int tdqcow_do_callbacks(struct td_state 
  45.156  }
  45.157  
  45.158  int qcow_create(const char *filename, uint64_t total_size,
  45.159 -                      const char *backing_file, int flags)
  45.160 +                      const char *backing_file, int sparse)
  45.161  {
  45.162  	int fd, header_size, backing_filename_len, l1_size, i;
  45.163 -	int shift, length, adjust, ret = 0;
  45.164 +	int shift, length, adjust, flags = 0, ret = 0;
  45.165  	QCowHeader header;
  45.166  	QCowHeader_ext exthdr;
  45.167  	char backing_filename[1024], *ptr;
  45.168 @@ -1305,41 +1345,41 @@ int qcow_create(const char *filename, ui
  45.169  	DPRINTF("L1 Table offset: %d, size %d\n",
  45.170  		header_size,
  45.171  		(int)(l1_size * sizeof(uint64_t)));
  45.172 -	if (flags & QCOW_CRYPT_AES) {
  45.173 -		header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
  45.174 -	} else {
  45.175 -		header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
  45.176 -	}
  45.177 +	header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
  45.178  
  45.179  	ptr = calloc(1, l1_size * sizeof(uint64_t));
  45.180  	exthdr.cksum = cpu_to_be32(gen_cksum(ptr, l1_size * sizeof(uint64_t)));
  45.181  	printf("Created cksum: %d\n",exthdr.cksum);
  45.182  	free(ptr);
  45.183  
  45.184 -	/*adjust file length to 4 KByte boundary*/
  45.185 -	length = header_size + l1_size * sizeof(uint64_t);
  45.186 -	if (length % 4096 > 0) {
  45.187 -		length = ((length >> 12) + 1) << 12;
  45.188 -		qtruncate(fd, length, 0);
  45.189 -		DPRINTF("Adjusted filelength to %d for 4 "
  45.190 -			"Kbyte alignment\n",length);
  45.191 +	/*adjust file length to system page size boundary*/
  45.192 +	length = ROUNDUP(header_size + (l1_size * sizeof(uint64_t)),
  45.193 +		getpagesize());
  45.194 +	if (qtruncate(fd, length, 0)!=0) {
  45.195 +		DPRINTF("ERROR truncating file\n");
  45.196 +		return -1;
  45.197  	}
  45.198  
  45.199 -	if (!(flags & QCOW_SPARSE_FILE)) {
  45.200 -		/*Filesize is length + 	l1_size * (1 << s->l2_bits) + (size*512)*/
  45.201 +	if (sparse == 0) {
  45.202 +		/*Filesize is length+l1_size*(1 << s->l2_bits)+(size*512)*/
  45.203  		total_length = length + (l1_size * (1 << 9)) + (size * 512);
  45.204 -		qtruncate(fd, total_length, 0);
  45.205 +		if (qtruncate(fd, total_length, 0)!=0) {
  45.206 +                        DPRINTF("ERROR truncating file\n");
  45.207 +                        return -1;
  45.208 +		}
  45.209  		printf("File truncated to length %"PRIu64"\n",total_length);
  45.210 -	}
  45.211 +	} else
  45.212 +		flags = SPARSE_FILE;
  45.213 +
  45.214  	exthdr.flags = cpu_to_be32(flags);
  45.215  	
  45.216  	/* write all the data */
  45.217  	lseek(fd, 0, SEEK_SET);
  45.218  	ret += write(fd, &header, sizeof(header));
  45.219  	ret += write(fd, &exthdr, sizeof(exthdr));
  45.220 -	if (backing_file) {
  45.221 +	if (backing_file)
  45.222  		ret += write(fd, backing_filename, backing_filename_len);
  45.223 -	}
  45.224 +
  45.225  	lseek(fd, header_size, SEEK_SET);
  45.226  	tmp = 0;
  45.227  	for (i = 0;i < l1_size; i++) {
  45.228 @@ -1360,7 +1400,10 @@ int qcow_make_empty(struct td_state *bs)
  45.229  	lseek(s->fd, s->l1_table_offset, SEEK_SET);
  45.230  	if (write(s->fd, s->l1_table, l1_length) < 0)
  45.231  		return -1;
  45.232 -	qtruncate(s->fd, s->l1_table_offset + l1_length, s->sparse);
  45.233 +	if (qtruncate(s->fd, s->l1_table_offset + l1_length, s->sparse)!=0) {
  45.234 +		DPRINTF("ERROR truncating file\n");
  45.235 +		return -1;
  45.236 +	}
  45.237  
  45.238  	memset(s->l2_cache, 0, s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));
  45.239  	memset(s->l2_cache_offsets, 0, L2_CACHE_SIZE * sizeof(uint64_t));
    46.1 --- a/tools/blktap/drivers/qcow-create.c	Wed Jan 10 08:00:50 2007 -0700
    46.2 +++ b/tools/blktap/drivers/qcow-create.c	Wed Jan 10 08:40:47 2007 -0700
    46.3 @@ -47,15 +47,13 @@
    46.4  #define DFPRINTF(_f, _a...) ((void)0)
    46.5  #endif
    46.6  
    46.7 -#define QCOW_NONSPARSE_FILE 0x00
    46.8 -#define QCOW_SPARSE_FILE 0x02
    46.9  #define MAX_NAME_LEN 1000
   46.10  
   46.11  void help(void)
   46.12  {
   46.13  	fprintf(stderr, "Qcow-utils: v1.0.0\n");
   46.14  	fprintf(stderr, 
   46.15 -		"usage: qcow-create [-h help] [-p reserve] <SIZE(MB)> <FILENAME> "
   46.16 +		"usage: qcow-create [-h help] [-r reserve] <SIZE(MB)> <FILENAME> "
   46.17  		"[<BACKING_FILENAME>]\n"); 
   46.18  	exit(-1);
   46.19  }
   46.20 @@ -63,12 +61,12 @@ void help(void)
   46.21  int main(int argc, char *argv[])
   46.22  {
   46.23  	int ret = -1, c, backed = 0;
   46.24 -	int flags =  QCOW_SPARSE_FILE;
   46.25 +	int sparse =  1;
   46.26  	uint64_t size;
   46.27  	char filename[MAX_NAME_LEN], bfilename[MAX_NAME_LEN];
   46.28  
   46.29          for(;;) {
   46.30 -                c = getopt(argc, argv, "hp");
   46.31 +                c = getopt(argc, argv, "hr");
   46.32                  if (c == -1)
   46.33                          break;
   46.34                  switch(c) {
   46.35 @@ -76,9 +74,12 @@ int main(int argc, char *argv[])
   46.36                          help();
   46.37                          exit(0);
   46.38                          break;
   46.39 -                case 'p':
   46.40 -			flags = QCOW_NONSPARSE_FILE;
   46.41 +                case 'r':
   46.42 +			sparse = 0;
   46.43  			break;
   46.44 +		default:
   46.45 +			fprintf(stderr, "Unknown option\n");
   46.46 +			help();
   46.47  		}
   46.48  	}
   46.49  
   46.50 @@ -96,6 +97,7 @@ int main(int argc, char *argv[])
   46.51  	}
   46.52  
   46.53  	if (optind != argc) {
   46.54 +		/*Backing file argument*/
   46.55  		backed = 1;
   46.56  		if (snprintf(bfilename, MAX_NAME_LEN, "%s",argv[optind++]) >=
   46.57  			MAX_NAME_LEN) {
   46.58 @@ -106,12 +108,14 @@ int main(int argc, char *argv[])
   46.59  
   46.60  	DFPRINTF("Creating file size %llu, name %s\n",(long long unsigned)size, filename);
   46.61  	if (!backed)
   46.62 -		ret = qcow_create(filename,size,NULL,flags);
   46.63 +		ret = qcow_create(filename,size,NULL,sparse);
   46.64  	else
   46.65 -		ret = qcow_create(filename,size,bfilename,flags);
   46.66 +		ret = qcow_create(filename,size,bfilename,sparse);
   46.67  
   46.68 -	if (ret < 0) DPRINTF("Unable to create QCOW file\n");
   46.69 -	else DPRINTF("QCOW file successfully created\n");
   46.70 +	if (ret < 0)
   46.71 +		DPRINTF("Unable to create QCOW file\n");
   46.72 +	else
   46.73 +		DPRINTF("QCOW file successfully created\n");
   46.74  
   46.75  	return 0;
   46.76  }
    47.1 --- a/tools/examples/Makefile	Wed Jan 10 08:00:50 2007 -0700
    47.2 +++ b/tools/examples/Makefile	Wed Jan 10 08:40:47 2007 -0700
    47.3 @@ -9,6 +9,7 @@ XENDOMAINS_SYSCONFIG = init.d/sysconfig.
    47.4  # Xen configuration dir and configs to go there.
    47.5  XEN_CONFIG_DIR = /etc/xen
    47.6  XEN_CONFIGS = xend-config.sxp
    47.7 +XEN_CONFIGS += xm-config.xml
    47.8  XEN_CONFIGS += xmexample1 
    47.9  XEN_CONFIGS += xmexample2
   47.10  XEN_CONFIGS += xmexample.hvm
    48.1 --- a/tools/examples/blktap	Wed Jan 10 08:00:50 2007 -0700
    48.2 +++ b/tools/examples/blktap	Wed Jan 10 08:40:47 2007 -0700
    48.3 @@ -1,4 +1,4 @@
    48.4 -#!/bin/sh
    48.5 +#!/bin/bash
    48.6  
    48.7  # Copyright (c) 2005, XenSource Ltd.
    48.8  
    49.1 --- a/tools/examples/block	Wed Jan 10 08:00:50 2007 -0700
    49.2 +++ b/tools/examples/block	Wed Jan 10 08:40:47 2007 -0700
    49.3 @@ -1,4 +1,4 @@
    49.4 -#!/bin/sh
    49.5 +#!/bin/bash
    49.6  
    49.7  dir=$(dirname "$0")
    49.8  . "$dir/block-common.sh"
    50.1 --- a/tools/examples/block-enbd	Wed Jan 10 08:00:50 2007 -0700
    50.2 +++ b/tools/examples/block-enbd	Wed Jan 10 08:40:47 2007 -0700
    50.3 @@ -1,4 +1,4 @@
    50.4 -#!/bin/sh
    50.5 +#!/bin/bash
    50.6  
    50.7  # Usage: block-enbd [bind server ctl_port |unbind node]
    50.8  #
    51.1 --- a/tools/examples/block-nbd	Wed Jan 10 08:00:50 2007 -0700
    51.2 +++ b/tools/examples/block-nbd	Wed Jan 10 08:40:47 2007 -0700
    51.3 @@ -1,4 +1,4 @@
    51.4 -#!/bin/sh
    51.5 +#!/bin/bash
    51.6  
    51.7  # Usage: block-nbd [bind server ctl_port |unbind node]
    51.8  #
    52.1 --- a/tools/examples/external-device-migrate	Wed Jan 10 08:00:50 2007 -0700
    52.2 +++ b/tools/examples/external-device-migrate	Wed Jan 10 08:40:47 2007 -0700
    52.3 @@ -1,4 +1,4 @@
    52.4 -#!/bin/sh
    52.5 +#!/bin/bash
    52.6  
    52.7  # Copyright (c) 2005 IBM Corporation
    52.8  #
    53.1 --- a/tools/examples/network-bridge	Wed Jan 10 08:00:50 2007 -0700
    53.2 +++ b/tools/examples/network-bridge	Wed Jan 10 08:40:47 2007 -0700
    53.3 @@ -1,4 +1,4 @@
    53.4 -#!/bin/sh
    53.5 +#!/bin/bash
    53.6  #============================================================================
    53.7  # Default Xen network start/stop script.
    53.8  # Xend calls a network script when it starts.
    54.1 --- a/tools/examples/network-nat	Wed Jan 10 08:00:50 2007 -0700
    54.2 +++ b/tools/examples/network-nat	Wed Jan 10 08:40:47 2007 -0700
    54.3 @@ -1,4 +1,4 @@
    54.4 -#!/bin/sh
    54.5 +#!/bin/bash
    54.6  #============================================================================
    54.7  # Default Xen network start/stop script when using NAT.
    54.8  # Xend calls a network script when it starts.
    55.1 --- a/tools/examples/network-route	Wed Jan 10 08:00:50 2007 -0700
    55.2 +++ b/tools/examples/network-route	Wed Jan 10 08:40:47 2007 -0700
    55.3 @@ -1,4 +1,4 @@
    55.4 -#!/bin/sh
    55.5 +#!/bin/bash
    55.6  #============================================================================
    55.7  # Default Xen network start/stop script.
    55.8  # Xend calls a network script when it starts.
    56.1 --- a/tools/examples/vif-bridge	Wed Jan 10 08:00:50 2007 -0700
    56.2 +++ b/tools/examples/vif-bridge	Wed Jan 10 08:40:47 2007 -0700
    56.3 @@ -1,4 +1,4 @@
    56.4 -#!/bin/sh
    56.5 +#!/bin/bash
    56.6  #============================================================================
    56.7  # /etc/xen/vif-bridge
    56.8  #
    57.1 --- a/tools/examples/vif-common.sh	Wed Jan 10 08:00:50 2007 -0700
    57.2 +++ b/tools/examples/vif-common.sh	Wed Jan 10 08:40:47 2007 -0700
    57.3 @@ -64,7 +64,7 @@ then
    57.4  fi
    57.5  
    57.6  
    57.7 -function frob_iptable()
    57.8 +frob_iptable()
    57.9  {
   57.10    if [ "$command" == "online" ]
   57.11    then
   57.12 @@ -89,7 +89,7 @@ If you are using iptables, this may affe
   57.13  # to those coming from the specified networks, though we allow DHCP requests
   57.14  # as well.
   57.15  #
   57.16 -function handle_iptable()
   57.17 +handle_iptable()
   57.18  {
   57.19    # Check for a working iptables installation.  Checking for the iptables
   57.20    # binary is not sufficient, because the user may not have the appropriate
   57.21 @@ -123,7 +123,7 @@ function handle_iptable()
   57.22  # Print the IP address currently in use at the given interface, or nothing if
   57.23  # the interface is not up.
   57.24  #
   57.25 -function ip_of()
   57.26 +ip_of()
   57.27  {
   57.28    ip addr show "$1" | awk "/^.*inet.*$1\$/{print \$2}" | sed -n '1 s,/.*,,p'
   57.29  }
   57.30 @@ -137,7 +137,7 @@ function ip_of()
   57.31  # to these scripts, or eth0 by default.  This function will call fatal if no
   57.32  # such interface could be found.
   57.33  #
   57.34 -function dom0_ip()
   57.35 +dom0_ip()
   57.36  {
   57.37    local nd=${netdev:-eth0}
   57.38    local result=$(ip_of "$nd")
    58.1 --- a/tools/examples/vif-nat	Wed Jan 10 08:00:50 2007 -0700
    58.2 +++ b/tools/examples/vif-nat	Wed Jan 10 08:40:47 2007 -0700
    58.3 @@ -1,4 +1,4 @@
    58.4 -#!/bin/sh
    58.5 +#!/bin/bash
    58.6  #============================================================================
    58.7  # /etc/xen/vif-nat
    58.8  #
    59.1 --- a/tools/examples/vif-route	Wed Jan 10 08:00:50 2007 -0700
    59.2 +++ b/tools/examples/vif-route	Wed Jan 10 08:40:47 2007 -0700
    59.3 @@ -1,4 +1,4 @@
    59.4 -#!/bin/sh
    59.5 +#!/bin/bash
    59.6  #============================================================================
    59.7  # /etc/xen/vif-route
    59.8  #
    60.1 --- a/tools/examples/vtpm	Wed Jan 10 08:00:50 2007 -0700
    60.2 +++ b/tools/examples/vtpm	Wed Jan 10 08:40:47 2007 -0700
    60.3 @@ -1,4 +1,4 @@
    60.4 -#!/bin/sh
    60.5 +#!/bin/bash
    60.6  
    60.7  dir=$(dirname "$0")
    60.8  . "$dir/vtpm-hotplug-common.sh"
    61.1 --- a/tools/examples/vtpm-delete	Wed Jan 10 08:00:50 2007 -0700
    61.2 +++ b/tools/examples/vtpm-delete	Wed Jan 10 08:40:47 2007 -0700
    61.3 @@ -1,4 +1,4 @@
    61.4 -#!/bin/sh
    61.5 +#!/bin/bash
    61.6  
    61.7  # This scripts must be called the following way:
    61.8  # vtpm-delete <domain name>
    62.1 --- a/tools/examples/xen-backend.agent	Wed Jan 10 08:00:50 2007 -0700
    62.2 +++ b/tools/examples/xen-backend.agent	Wed Jan 10 08:40:47 2007 -0700
    62.3 @@ -1,4 +1,4 @@
    62.4 -#! /bin/sh
    62.5 +#! /bin/bash
    62.6  
    62.7  PATH=/etc/xen/scripts:$PATH
    62.8  
    63.1 --- a/tools/examples/xen-hotplug-cleanup	Wed Jan 10 08:00:50 2007 -0700
    63.2 +++ b/tools/examples/xen-hotplug-cleanup	Wed Jan 10 08:40:47 2007 -0700
    63.3 @@ -1,4 +1,4 @@
    63.4 -#! /bin/sh
    63.5 +#! /bin/bash
    63.6  
    63.7  dir=$(dirname "$0")
    63.8  . "$dir/xen-hotplug-common.sh"
    64.1 --- a/tools/examples/xm-config.xml	Wed Jan 10 08:00:50 2007 -0700
    64.2 +++ b/tools/examples/xm-config.xml	Wed Jan 10 08:40:47 2007 -0700
    64.3 @@ -36,8 +36,10 @@ most useful for experimenting with the X
    64.4         The username and password attributes will be used to log in if Xen-API
    64.5         is being used.
    64.6      -->
    64.7 +  <!--
    64.8    <server type='Xen-API'
    64.9            uri='http://localhost:9363/'
   64.10            username='me'
   64.11            password='mypassword' />
   64.12 +   -->
   64.13  </xm>
    65.1 --- a/tools/examples/xmexample.hvm	Wed Jan 10 08:00:50 2007 -0700
    65.2 +++ b/tools/examples/xmexample.hvm	Wed Jan 10 08:40:47 2007 -0700
    65.3 @@ -29,7 +29,7 @@ memory = 128
    65.4  
    65.5  # Shadow pagetable memory for the domain, in MB.
    65.6  # Should be at least 2KB per MB of domain memory, plus a few MB per vcpu.
    65.7 -shadow_memory = 8
    65.8 +# shadow_memory = 8
    65.9  
   65.10  # A name for your domain. All domains must have different names.
   65.11  name = "ExampleHVMDomain"
   65.12 @@ -116,7 +116,7 @@ disk = [ 'file:/var/images/min-el3-i386.
   65.13  device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
   65.14  
   65.15  #-----------------------------------------------------------------------------
   65.16 -# boot on floppy (a), hard disk (c) or CD-ROM (d) 
   65.17 +# boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d) 
   65.18  # default: hard disk, cd-rom, floppy
   65.19  #boot="cda"
   65.20  
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/tools/firmware/etherboot/README	Wed Jan 10 08:40:47 2007 -0700
    66.3 @@ -0,0 +1,7 @@
    66.4 +
    66.5 +This is an Etherboot option ROM for the rtl8139 NIC.  It has a few
    66.6 +non-standard settings, just to do with timeouts and when to give up.
    66.7 +
    66.8 +Rom-o-matic.net will provide this image at the following URL:
    66.9 +
   66.10 +http://rom-o-matic.net/5.4.2/build.php?version=5.4.2&F=ignore&nic=rtl8139%3Artl8139+--+%5B0x10ec%2C0x8139%5D&ofmt=Binary+ROM+Image%28.zrom%29&arch=i386&ASK_BOOT=-1&BOOT_FIRST=BOOT_NIC&BOOT_SECOND=BOOT_NOTHING&BOOT_THIRD=BOOT_NOTHING&BOOT_INDEX=0&STATIC_CLIENT_IP=&STATIC_SUBNET_MASK=&STATIC_SERVER_IP=&STATIC_GATEWAY_IP=&STATIC_BOOTFILE=&EXIT_ON_FILE_LOAD_ERROR=on&DHCP_CLIENT_ID=&DHCP_CLIENT_ID_LEN=&DHCP_CLIENT_ID_TYPE=&DHCP_USER_CLASS=&DHCP_USER_CLASS_LEN=&ALLOW_ONLY_ENCAPSULATED=on&DEFAULT_BOOTFILE=&CONGESTED=on&BACKOFF_LIMIT=7&TIMEOUT=180&TRY_FLOPPY_FIRST=0&EXIT_IF_NO_OFFER=on&TAGGED_IMAGE=on&ELF_IMAGE=on&PXE_IMAGE=on&DOWNLOAD_PROTO_TFTP=on&COMCONSOLE=0x3F8&CONSPEED=9600&COMPARM=0x03&PXE_EXPORT=on&CONFIG_PCI=on&CONFIG_ISA=on&BUILD_ID=&PCBIOS=on&A=Get+ROM
    67.1 Binary file tools/firmware/etherboot/eb-rtl8139.zrom has changed
    68.1 --- a/tools/firmware/hvmloader/Makefile	Wed Jan 10 08:00:50 2007 -0700
    68.2 +++ b/tools/firmware/hvmloader/Makefile	Wed Jan 10 08:40:47 2007 -0700
    68.3 @@ -51,11 +51,12 @@ hvmloader: roms.h acpi/acpi.a $(SRCS)
    68.4  acpi/acpi.a:
    68.5  	$(MAKE) -C acpi
    68.6  
    68.7 -roms.h:	../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../vmxassist/vmxassist.bin
    68.8 +roms.h:	../rombios/BIOS-bochs-latest ../vgabios/VGABIOS-lgpl-latest.bin ../vgabios/VGABIOS-lgpl-latest.cirrus.bin ../vmxassist/vmxassist.bin ../etherboot/eb-rtl8139.zrom
    68.9  	sh ./mkhex rombios ../rombios/BIOS-bochs-latest > roms.h
   68.10  	sh ./mkhex vgabios_stdvga ../vgabios/VGABIOS-lgpl-latest.bin >> roms.h
   68.11  	sh ./mkhex vgabios_cirrusvga ../vgabios/VGABIOS-lgpl-latest.cirrus.bin >> roms.h
   68.12  	sh ./mkhex vmxassist ../vmxassist/vmxassist.bin >> roms.h
   68.13 +	sh ./mkhex etherboot ../etherboot/eb-rtl8139.zrom >> roms.h
   68.14  
   68.15  .PHONY: clean
   68.16  clean:
    69.1 --- a/tools/firmware/hvmloader/acpi/Makefile	Wed Jan 10 08:00:50 2007 -0700
    69.2 +++ b/tools/firmware/hvmloader/acpi/Makefile	Wed Jan 10 08:40:47 2007 -0700
    69.3 @@ -24,7 +24,7 @@ C_SRC = build.c dsdt.c static_tables.c
    69.4  H_SRC = $(wildcard *.h)
    69.5  OBJS  = $(patsubst %.c,%.o,$(C_SRC))
    69.6  
    69.7 -IASL_VER = acpica-unix-20050513
    69.8 +IASL_VER = acpica-unix-20060707
    69.9  IASL_URL = http://developer.intel.com/technology/iapc/acpi/downloads/$(IASL_VER).tar.gz
   69.10  
   69.11  # Disable PIE/SSP if GCC supports them. They can break us.
    70.1 --- a/tools/firmware/hvmloader/acpi/acpi2_0.h	Wed Jan 10 08:00:50 2007 -0700
    70.2 +++ b/tools/firmware/hvmloader/acpi/acpi2_0.h	Wed Jan 10 08:40:47 2007 -0700
    70.3 @@ -50,17 +50,18 @@ struct acpi_header {
    70.4      uint8_t  revision;
    70.5      uint8_t  checksum;
    70.6      uint8_t  oem_id[6];
    70.7 -    uint64_t oem_table_id;
    70.8 +    uint8_t  oem_table_id[8];
    70.9      uint32_t oem_revision;
   70.10      uint32_t creator_id;
   70.11      uint32_t creator_revision;
   70.12  };
   70.13  
   70.14 -#define ACPI_OEM_ID             {'I','N','T','E','L',' '}
   70.15 -#define ACPI_OEM_TABLE_ID       ASCII32(' ','T','B','D')
   70.16 -#define ACPI_OEM_REVISION       0x00000002
   70.17 -#define ACPI_CREATOR_ID         0x00       /* TBD */
   70.18 -#define ACPI_CREATOR_REVISION   0x00000002
   70.19 +#define ACPI_OEM_ID             "Xen"
   70.20 +#define ACPI_OEM_TABLE_ID       "HVM"
   70.21 +#define ACPI_OEM_REVISION       0
   70.22 +
   70.23 +#define ACPI_CREATOR_ID         ASCII32('H','V','M','L') /* HVMLoader */
   70.24 +#define ACPI_CREATOR_REVISION   0
   70.25  
   70.26  /*
   70.27   * ACPI 2.0 Generic Address Space definition.
   70.28 @@ -121,7 +122,6 @@ struct acpi_20_rsdt {
   70.29      struct acpi_header header;
   70.30      uint32_t entry[1];
   70.31  };
   70.32 -#define ACPI_2_0_RSDT_REVISION 0x01
   70.33  
   70.34  /*
   70.35   * Extended System Description Table (XSDT).
   70.36 @@ -130,7 +130,6 @@ struct acpi_20_xsdt {
   70.37      struct acpi_header header;
   70.38      uint64_t entry[1];
   70.39  };
   70.40 -#define ACPI_2_0_XSDT_REVISION 0x01
   70.41  
   70.42  /*
   70.43   * TCG Hardware Interface Table (TCPA)
   70.44 @@ -141,8 +140,6 @@ struct acpi_20_tcpa {
   70.45      uint32_t laml;
   70.46      uint64_t lasa;
   70.47  };
   70.48 -
   70.49 -#define ACPI_2_0_TCPA_REVISION 0x02
   70.50  #define ACPI_2_0_TCPA_LAML_SIZE (64*1024)
   70.51  
   70.52  /*
   70.53 @@ -202,7 +199,6 @@ struct acpi_20_fadt {
   70.54      struct acpi_20_generic_address x_gpe0_blk;
   70.55      struct acpi_20_generic_address x_gpe1_blk;
   70.56  };
   70.57 -#define ACPI_2_0_FADT_REVISION 0x03
   70.58  
   70.59  /*
   70.60   * FADT Boot Architecture Flags.
   70.61 @@ -254,7 +250,19 @@ struct acpi_20_madt {
   70.62      uint32_t flags;
   70.63  };
   70.64  
   70.65 -#define ACPI_2_0_MADT_REVISION 0x01
   70.66 +
   70.67 +/*
   70.68 + * HPET Description Table
   70.69 + */
   70.70 +struct acpi_20_hpet {
   70.71 +    struct acpi_header header;
   70.72 +    uint32_t           timer_block_id;
   70.73 +    struct acpi_20_generic_address addr;
   70.74 +    uint8_t            hpet_number;
   70.75 +    uint16_t           min_tick;
   70.76 +    uint8_t            page_protect;
   70.77 +};
   70.78 +#define ACPI_HPET_ADDRESS 0xFED00000UL
   70.79  
   70.80  /*
   70.81   * Multiple APIC Flags.
   70.82 @@ -325,6 +333,18 @@ struct acpi_20_madt_intsrcovr {
   70.83  #define ACPI_2_0_RSDT_SIGNATURE ASCII32('R','S','D','T')
   70.84  #define ACPI_2_0_XSDT_SIGNATURE ASCII32('X','S','D','T')
   70.85  #define ACPI_2_0_TCPA_SIGNATURE ASCII32('T','C','P','A')
   70.86 +#define ACPI_2_0_HPET_SIGNATURE ASCII32('H','P','E','T')
   70.87 +
   70.88 +/*
   70.89 + * Table revision numbers.
   70.90 + */
   70.91 +#define ACPI_2_0_RSDP_REVISION 0x02
   70.92 +#define ACPI_2_0_FADT_REVISION 0x04
   70.93 +#define ACPI_2_0_MADT_REVISION 0x02
   70.94 +#define ACPI_2_0_RSDT_REVISION 0x01
   70.95 +#define ACPI_2_0_XSDT_REVISION 0x01
   70.96 +#define ACPI_2_0_TCPA_REVISION 0x02
   70.97 +#define ACPI_2_0_HPET_REVISION 0x01
   70.98  
   70.99  #pragma pack ()
  70.100  
    71.1 --- a/tools/firmware/hvmloader/acpi/build.c	Wed Jan 10 08:00:50 2007 -0700
    71.2 +++ b/tools/firmware/hvmloader/acpi/build.c	Wed Jan 10 08:40:47 2007 -0700
    71.3 @@ -57,8 +57,8 @@ int construct_madt(struct acpi_20_madt *
    71.4      memset(madt, 0, sizeof(*madt));
    71.5      madt->header.signature    = ACPI_2_0_MADT_SIGNATURE;
    71.6      madt->header.revision     = ACPI_2_0_MADT_REVISION;
    71.7 -    strncpy(madt->header.oem_id, "INTEL ", 6);
    71.8 -    madt->header.oem_table_id = ACPI_OEM_TABLE_ID;
    71.9 +    strncpy(madt->header.oem_id, ACPI_OEM_ID, 6);
   71.10 +    strncpy(madt->header.oem_table_id, ACPI_OEM_TABLE_ID, 8);
   71.11      madt->header.oem_revision = ACPI_OEM_REVISION;
   71.12      madt->header.creator_id   = ACPI_CREATOR_ID;
   71.13      madt->header.creator_revision = ACPI_CREATOR_REVISION;
   71.14 @@ -69,16 +69,28 @@ int construct_madt(struct acpi_20_madt *
   71.15      intsrcovr = (struct acpi_20_madt_intsrcovr *)(madt + 1);
   71.16      for ( i = 0; i < 16; i++ )
   71.17      {
   71.18 -        if ( !(PCI_ISA_IRQ_MASK & (1U << i)) )
   71.19 -            continue;
   71.20 -
   71.21 -        /* PCI: active-low level-triggered */
   71.22          memset(intsrcovr, 0, sizeof(*intsrcovr));
   71.23          intsrcovr->type   = ACPI_INTERRUPT_SOURCE_OVERRIDE;
   71.24          intsrcovr->length = sizeof(*intsrcovr);
   71.25          intsrcovr->source = i;
   71.26 -        intsrcovr->gsi    = i;
   71.27 -        intsrcovr->flags  = 0xf;
   71.28 +
   71.29 +        if ( i == 0 )
   71.30 +        {
   71.31 +            /* ISA IRQ0 routed to IOAPIC GSI 2. */
   71.32 +            intsrcovr->gsi    = 2;
   71.33 +            intsrcovr->flags  = 0x0;
   71.34 +        }
   71.35 +        else if ( PCI_ISA_IRQ_MASK & (1U << i) )
   71.36 +        {
   71.37 +            /* PCI: active-low level-triggered. */
   71.38 +            intsrcovr->gsi    = i;
   71.39 +            intsrcovr->flags  = 0xf;
   71.40 +        }
   71.41 +        else
   71.42 +        {
   71.43 +            /* No need for a INT source override structure. */
   71.44 +            continue;
   71.45 +        }
   71.46  
   71.47          offset += sizeof(*intsrcovr);
   71.48          intsrcovr++;
   71.49 @@ -98,7 +110,7 @@ int construct_madt(struct acpi_20_madt *
   71.50          memset(lapic, 0, sizeof(*lapic));
   71.51          lapic->type    = ACPI_PROCESSOR_LOCAL_APIC;
   71.52          lapic->length  = sizeof(*lapic);
   71.53 -        lapic->acpi_processor_id = lapic->apic_id = i + 1;
   71.54 +        lapic->acpi_processor_id = lapic->apic_id = LAPIC_ID(i);
   71.55          lapic->flags   = ACPI_LOCAL_APIC_ENABLED;
   71.56          offset += sizeof(*lapic);
   71.57          lapic++;
   71.58 @@ -110,10 +122,33 @@ int construct_madt(struct acpi_20_madt *
   71.59      return align16(offset);
   71.60  }
   71.61  
   71.62 +int construct_hpet(struct acpi_20_hpet *hpet)
   71.63 +{
   71.64 +    int offset;
   71.65 +
   71.66 +    memset(hpet, 0, sizeof(*hpet));
   71.67 +    hpet->header.signature    = ACPI_2_0_HPET_SIGNATURE;
   71.68 +    hpet->header.revision     = ACPI_2_0_HPET_REVISION;
   71.69 +    strncpy(hpet->header.oem_id, ACPI_OEM_ID, 6);
   71.70 +    strncpy(hpet->header.oem_table_id, ACPI_OEM_TABLE_ID, 8);
   71.71 +    hpet->header.oem_revision = ACPI_OEM_REVISION;
   71.72 +    hpet->header.creator_id   = ACPI_CREATOR_ID;
   71.73 +    hpet->header.creator_revision = ACPI_CREATOR_REVISION;
   71.74 +    hpet->timer_block_id      = 0x8086a201;
   71.75 +    hpet->addr.address        = ACPI_HPET_ADDRESS;
   71.76 +    offset = sizeof(*hpet);
   71.77 +
   71.78 +    hpet->header.length = offset;
   71.79 +    set_checksum(hpet, offsetof(struct acpi_header, checksum), offset);
   71.80 +
   71.81 +    return offset;
   71.82 +}
   71.83 +
   71.84  int construct_secondary_tables(uint8_t *buf, unsigned long *table_ptrs)
   71.85  {
   71.86      int offset = 0, nr_tables = 0;
   71.87      struct acpi_20_madt *madt;
   71.88 +    struct acpi_20_hpet *hpet;
   71.89      struct acpi_20_tcpa *tcpa;
   71.90      static const uint16_t tis_signature[] = {0x0001, 0x0001, 0x0001};
   71.91      uint16_t *tis_hdr;
   71.92 @@ -126,6 +161,11 @@ int construct_secondary_tables(uint8_t *
   71.93          table_ptrs[nr_tables++] = (unsigned long)madt;
   71.94      }
   71.95  
   71.96 +    /* HPET. */
   71.97 +    hpet = (struct acpi_20_hpet *)&buf[offset];
   71.98 +    offset += construct_hpet(hpet);
   71.99 +    table_ptrs[nr_tables++] = (unsigned long)hpet;
  71.100 +
  71.101      /* TPM TCPA and SSDT. */
  71.102      tis_hdr = (uint16_t *)0xFED40F00;
  71.103      if ( (tis_hdr[0] == tis_signature[0]) &&
  71.104 @@ -144,12 +184,11 @@ int construct_secondary_tables(uint8_t *
  71.105          tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
  71.106          tcpa->header.length    = sizeof(*tcpa);
  71.107          tcpa->header.revision  = ACPI_2_0_TCPA_REVISION;
  71.108 -        strncpy(tcpa->header.oem_id, "IBM   ", 6);
  71.109 -        tcpa->header.oem_table_id = ASCII64(' ', ' ', ' ', ' ',
  71.110 -                                            ' ', 'x', 'e', 'n');
  71.111 -        tcpa->header.oem_revision = 1;
  71.112 -        tcpa->header.creator_id   = ASCII32('I', 'B', 'M', ' ');
  71.113 -        tcpa->header.creator_revision = 1;
  71.114 +        strncpy(tcpa->header.oem_id, ACPI_OEM_ID, 6);
  71.115 +        strncpy(tcpa->header.oem_table_id, ACPI_OEM_TABLE_ID, 8);
  71.116 +        tcpa->header.oem_revision = ACPI_OEM_REVISION;
  71.117 +        tcpa->header.creator_id   = ACPI_CREATOR_ID;
  71.118 +        tcpa->header.creator_revision = ACPI_CREATOR_REVISION;
  71.119          tcpa->lasa = e820_malloc(
  71.120              ACPI_2_0_TCPA_LAML_SIZE, E820_RESERVED, (uint32_t)~0);
  71.121          if ( tcpa->lasa )
    72.1 --- a/tools/firmware/hvmloader/acpi/dsdt.asl	Wed Jan 10 08:00:50 2007 -0700
    72.2 +++ b/tools/firmware/hvmloader/acpi/dsdt.asl	Wed Jan 10 08:40:47 2007 -0700
    72.3 @@ -17,7 +17,7 @@
    72.4   * Place - Suite 330, Boston, MA 02111-1307 USA.
    72.5   */
    72.6  
    72.7 -DefinitionBlock ("DSDT.aml", "DSDT", 1, "INTEL","int-xen", 2006)
    72.8 +DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0)
    72.9  {
   72.10      Name (\PMBS, 0x0C00)
   72.11      Name (\PMLN, 0x08)
   72.12 @@ -280,6 +280,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
   72.13                  }
   72.14              }
   72.15  
   72.16 +            Device(HPET) {
   72.17 +                Name(_HID,  EISAID("PNP0103"))
   72.18 +                Name(_UID, 0)
   72.19 +                Name(_CRS, ResourceTemplate() {
   72.20 +                    DWordMemory(
   72.21 +                        ResourceConsumer, PosDecode, MinFixed, MaxFixed,
   72.22 +                        NonCacheable, ReadWrite,
   72.23 +                        0x00000000,
   72.24 +                        0xFED00000,
   72.25 +                        0xFED003FF,
   72.26 +                        0x00000000,
   72.27 +                        0x00000400 /* 1K memory: FED00000 - FED003FF */
   72.28 +                    )
   72.29 +                })
   72.30 +            }
   72.31 +
   72.32              Method(_PRT,0) {
   72.33                  If(PICD) {
   72.34                      Return(PRTA)
    73.1 --- a/tools/firmware/hvmloader/acpi/dsdt.c	Wed Jan 10 08:00:50 2007 -0700
    73.2 +++ b/tools/firmware/hvmloader/acpi/dsdt.c	Wed Jan 10 08:40:47 2007 -0700
    73.3 @@ -1,22 +1,22 @@
    73.4  /*
    73.5   * 
    73.6   * Intel ACPI Component Architecture
    73.7 - * ASL Optimizing Compiler / AML Disassembler version 20050513 [Nov 16 2006]
    73.8 - * Copyright (C) 2000 - 2005 Intel Corporation
    73.9 - * Supports ACPI Specification Revision 3.0
   73.10 + * ASL Optimizing Compiler version 20060707 [Dec 30 2006]
   73.11 + * Copyright (C) 2000 - 2006 Intel Corporation
   73.12 + * Supports ACPI Specification Revision 3.0a
   73.13   * 
   73.14 - * Compilation of "dsdt.asl" - Wed Nov 22 18:26:19 2006
   73.15 + * Compilation of "dsdt.asl" - Sat Dec 30 15:31:23 2006
   73.16   * 
   73.17   * C source code output
   73.18   *
   73.19   */
   73.20 -unsigned char AmlCode[] = 
   73.21 +unsigned char AmlCode[] =
   73.22  {
   73.23 -    0x44,0x53,0x44,0x54,0x9D,0x0D,0x00,0x00,  /* 00000000    "DSDT...." */
   73.24 -    0x01,0x83,0x49,0x4E,0x54,0x45,0x4C,0x00,  /* 00000008    "..INTEL." */
   73.25 -    0x69,0x6E,0x74,0x2D,0x78,0x65,0x6E,0x00,  /* 00000010    "int-xen." */
   73.26 -    0xD6,0x07,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
   73.27 -    0x13,0x05,0x05,0x20,0x08,0x50,0x4D,0x42,  /* 00000020    "... .PMB" */
   73.28 +    0x44,0x53,0x44,0x54,0xD9,0x0D,0x00,0x00,  /* 00000000    "DSDT...." */
   73.29 +    0x02,0xFB,0x58,0x65,0x6E,0x00,0x00,0x00,  /* 00000008    "..Xen..." */
   73.30 +    0x48,0x56,0x4D,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "HVM....." */
   73.31 +    0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
   73.32 +    0x07,0x07,0x06,0x20,0x08,0x50,0x4D,0x42,  /* 00000020    "... .PMB" */
   73.33      0x53,0x0B,0x00,0x0C,0x08,0x50,0x4D,0x4C,  /* 00000028    "S....PML" */
   73.34      0x4E,0x0A,0x08,0x08,0x49,0x4F,0x42,0x31,  /* 00000030    "N...IOB1" */
   73.35      0x00,0x08,0x49,0x4F,0x4C,0x31,0x00,0x08,  /* 00000038    "..IOL1.." */
   73.36 @@ -34,7 +34,7 @@ unsigned char AmlCode[] =
   73.37      0x12,0x08,0x04,0x0A,0x07,0x0A,0x07,0x00,  /* 00000098    "........" */
   73.38      0x00,0x08,0x50,0x49,0x43,0x44,0x00,0x14,  /* 000000A0    "..PICD.." */
   73.39      0x0C,0x5F,0x50,0x49,0x43,0x01,0x70,0x68,  /* 000000A8    "._PIC.ph" */
   73.40 -    0x50,0x49,0x43,0x44,0x10,0x48,0xCE,0x5F,  /* 000000B0    "PICD.H._" */
   73.41 +    0x50,0x49,0x43,0x44,0x10,0x44,0xD2,0x5F,  /* 000000B0    "PICD.D._" */
   73.42      0x53,0x42,0x5F,0x5B,0x82,0x49,0x04,0x4D,  /* 000000B8    "SB_[.I.M" */
   73.43      0x45,0x4D,0x30,0x08,0x5F,0x48,0x49,0x44,  /* 000000C0    "EM0._HID" */
   73.44      0x0C,0x41,0xD0,0x0C,0x02,0x08,0x5F,0x43,  /* 000000C8    ".A...._C" */
   73.45 @@ -45,7 +45,7 @@ unsigned char AmlCode[] =
   73.46      0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000F0    "........" */
   73.47      0x00,0x00,0x00,0x00,0x00,0x00,0x0A,0x00,  /* 000000F8    "........" */
   73.48      0x00,0x00,0x00,0x00,0x79,0x00,0x5B,0x82,  /* 00000100    "....y.[." */
   73.49 -    0x45,0xC9,0x50,0x43,0x49,0x30,0x08,0x5F,  /* 00000108    "E.PCI0._" */
   73.50 +    0x41,0xCD,0x50,0x43,0x49,0x30,0x08,0x5F,  /* 00000108    "A.PCI0._" */
   73.51      0x48,0x49,0x44,0x0C,0x41,0xD0,0x0A,0x03,  /* 00000110    "HID.A..." */
   73.52      0x08,0x5F,0x55,0x49,0x44,0x00,0x08,0x5F,  /* 00000118    "._UID.._" */
   73.53      0x41,0x44,0x52,0x00,0x08,0x5F,0x42,0x42,  /* 00000120    "ADR.._BB" */
   73.54 @@ -140,313 +140,321 @@ unsigned char AmlCode[] =
   73.55      0x5F,0x53,0x52,0x53,0x01,0x8B,0x68,0x01,  /* 000003E8    "_SRS..h." */
   73.56      0x49,0x52,0x51,0x31,0x82,0x49,0x52,0x51,  /* 000003F0    "IRQ1.IRQ" */
   73.57      0x31,0x60,0x76,0x60,0x70,0x60,0x50,0x49,  /* 000003F8    "1`v`p`PI" */
   73.58 -    0x52,0x44,0x14,0x16,0x5F,0x50,0x52,0x54,  /* 00000400    "RD.._PRT" */
   73.59 -    0x00,0xA0,0x0A,0x50,0x49,0x43,0x44,0xA4,  /* 00000408    "...PICD." */
   73.60 -    0x50,0x52,0x54,0x41,0xA4,0x50,0x52,0x54,  /* 00000410    "PRTA.PRT" */
   73.61 -    0x50,0x08,0x50,0x52,0x54,0x50,0x12,0x49,  /* 00000418    "P.PRTP.I" */
   73.62 -    0x36,0x3C,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000420    "6<......" */
   73.63 -    0x01,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000428    "...LNKB." */
   73.64 -    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x01,0x00,  /* 00000430    "........" */
   73.65 -    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 00000438    ".LNKC..." */
   73.66 -    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x02,  /* 00000440    "........" */
   73.67 -    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 00000448    "LNKD...." */
   73.68 -    0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x03,0x4C,  /* 00000450    ".......L" */
   73.69 -    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 00000458    "NKA....." */
   73.70 -    0xFF,0xFF,0x02,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000460    ".....LNK" */
   73.71 -    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000468    "C......." */
   73.72 -    0x02,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000470    "...LNKD." */
   73.73 -    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 00000478    "........" */
   73.74 -    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 00000480    "..LNKA.." */
   73.75 -    0x0E,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x0A,  /* 00000488    "........" */
   73.76 -    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 00000490    ".LNKB..." */
   73.77 -    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x00,0x4C,  /* 00000498    ".......L" */
   73.78 -    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 000004A0    "NKD....." */
   73.79 -    0xFF,0xFF,0x03,0x00,0x01,0x4C,0x4E,0x4B,  /* 000004A8    ".....LNK" */
   73.80 -    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 000004B0    "A......." */
   73.81 -    0x03,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 000004B8    "....LNKB" */
   73.82 -    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x03,  /* 000004C0    "........" */
   73.83 -    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 000004C8    "...LNKC." */
   73.84 -    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 000004D0    "........" */
   73.85 -    0x00,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 000004D8    ".LNKA..." */
   73.86 -    0x04,0x0C,0xFF,0xFF,0x04,0x00,0x01,0x4C,  /* 000004E0    ".......L" */
   73.87 -    0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,  /* 000004E8    "NKB....." */
   73.88 -    0xFF,0xFF,0x04,0x00,0x0A,0x02,0x4C,0x4E,  /* 000004F0    "......LN" */
   73.89 -    0x4B,0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000004F8    "KC......" */
   73.90 -    0xFF,0x04,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000500    ".....LNK" */
   73.91 -    0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000508    "D......." */
   73.92 -    0x05,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000510    "...LNKB." */
   73.93 -    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x05,0x00,  /* 00000518    "........" */
   73.94 -    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 00000520    ".LNKC..." */
   73.95 -    0x04,0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x02,  /* 00000528    "........" */
   73.96 -    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 00000530    "LNKD...." */
   73.97 -    0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x03,0x4C,  /* 00000538    ".......L" */
   73.98 -    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 00000540    "NKA....." */
   73.99 -    0xFF,0xFF,0x06,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000548    ".....LNK" */
  73.100 -    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000550    "C......." */
  73.101 -    0x06,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000558    "...LNKD." */
  73.102 -    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x06,0x00,  /* 00000560    "........" */
  73.103 -    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 00000568    "..LNKA.." */
  73.104 -    0x0E,0x04,0x0C,0xFF,0xFF,0x06,0x00,0x0A,  /* 00000570    "........" */
  73.105 -    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 00000578    ".LNKB..." */
  73.106 -    0x04,0x0C,0xFF,0xFF,0x07,0x00,0x00,0x4C,  /* 00000580    ".......L" */
  73.107 -    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000588    "NKD....." */
  73.108 -    0xFF,0xFF,0x07,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000590    ".....LNK" */
  73.109 -    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000598    "A......." */
  73.110 -    0x07,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 000005A0    "....LNKB" */
  73.111 -    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x07,  /* 000005A8    "........" */
  73.112 -    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 000005B0    "...LNKC." */
  73.113 -    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x08,0x00,  /* 000005B8    "........" */
  73.114 -    0x00,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 000005C0    ".LNKA..." */
  73.115 -    0x04,0x0C,0xFF,0xFF,0x08,0x00,0x01,0x4C,  /* 000005C8    ".......L" */
  73.116 -    0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,  /* 000005D0    "NKB....." */
  73.117 -    0xFF,0xFF,0x08,0x00,0x0A,0x02,0x4C,0x4E,  /* 000005D8    "......LN" */
  73.118 -    0x4B,0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000005E0    "KC......" */
  73.119 -    0xFF,0x08,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000005E8    ".....LNK" */
  73.120 -    0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000005F0    "D......." */
  73.121 -    0x09,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 000005F8    "...LNKB." */
  73.122 -    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x09,0x00,  /* 00000600    "........" */
  73.123 -    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 00000608    ".LNKC..." */
  73.124 -    0x04,0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x02,  /* 00000610    "........" */
  73.125 -    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 00000618    "LNKD...." */
  73.126 -    0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x03,0x4C,  /* 00000620    ".......L" */
  73.127 -    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 00000628    "NKA....." */
  73.128 -    0xFF,0xFF,0x0A,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000630    ".....LNK" */
  73.129 -    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000638    "C......." */
  73.130 -    0x0A,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000640    "...LNKD." */
  73.131 -    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0A,0x00,  /* 00000648    "........" */
  73.132 -    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 00000650    "..LNKA.." */
  73.133 -    0x0E,0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x0A,  /* 00000658    "........" */
  73.134 -    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 00000660    ".LNKB..." */
  73.135 -    0x04,0x0C,0xFF,0xFF,0x0B,0x00,0x00,0x4C,  /* 00000668    ".......L" */
  73.136 -    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000670    "NKD....." */
  73.137 -    0xFF,0xFF,0x0B,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000678    ".....LNK" */
  73.138 -    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000680    "A......." */
  73.139 -    0x0B,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 00000688    "....LNKB" */
  73.140 -    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0B,  /* 00000690    "........" */
  73.141 -    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000698    "...LNKC." */
  73.142 -    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0C,0x00,  /* 000006A0    "........" */
  73.143 -    0x00,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,  /* 000006A8    ".LNKA..." */
  73.144 -    0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x01,0x4C,  /* 000006B0    ".......L" */
  73.145 -    0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,0x0C,  /* 000006B8    "NKB....." */
  73.146 -    0xFF,0xFF,0x0C,0x00,0x0A,0x02,0x4C,0x4E,  /* 000006C0    "......LN" */
  73.147 -    0x4B,0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000006C8    "KC......" */
  73.148 -    0xFF,0x0C,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000006D0    ".....LNK" */
  73.149 -    0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000006D8    "D......." */
  73.150 -    0x0D,0x00,0x00,0x4C,0x4E,0x4B,0x42,0x00,  /* 000006E0    "...LNKB." */
  73.151 -    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0D,0x00,  /* 000006E8    "........" */
  73.152 -    0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0E,  /* 000006F0    ".LNKC..." */
  73.153 -    0x04,0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x02,  /* 000006F8    "........" */
  73.154 -    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,  /* 00000700    "LNKD...." */
  73.155 -    0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x03,0x4C,  /* 00000708    ".......L" */
  73.156 -    0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,0x0C,  /* 00000710    "NKA....." */
  73.157 -    0xFF,0xFF,0x0E,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000718    ".....LNK" */
  73.158 -    0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000720    "C......." */
  73.159 -    0x0E,0x00,0x01,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000728    "...LNKD." */
  73.160 -    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0E,0x00,  /* 00000730    "........" */
  73.161 -    0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,0x12,  /* 00000738    "..LNKA.." */
  73.162 -    0x0E,0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x0A,  /* 00000740    "........" */
  73.163 -    0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0D,  /* 00000748    ".LNKB..." */
  73.164 -    0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x00,0x4C,  /* 00000750    ".......L" */
  73.165 -    0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,  /* 00000758    "NKD....." */
  73.166 -    0xFF,0xFF,0x0F,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000760    ".....LNK" */
  73.167 -    0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000768    "A......." */
  73.168 -    0x0F,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x42,  /* 00000770    "....LNKB" */
  73.169 -    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0F,  /* 00000778    "........" */
  73.170 -    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,0x00,  /* 00000780    "...LNKC." */
  73.171 -    0x08,0x50,0x52,0x54,0x41,0x12,0x41,0x2F,  /* 00000788    ".PRTA.A/" */
  73.172 -    0x3C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x01,  /* 00000790    "<......." */
  73.173 -    0x00,0x00,0x00,0x0A,0x14,0x12,0x0B,0x04,  /* 00000798    "........" */
  73.174 -    0x0C,0xFF,0xFF,0x01,0x00,0x01,0x00,0x0A,  /* 000007A0    "........" */
  73.175 -    0x15,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x01,  /* 000007A8    "........" */
  73.176 -    0x00,0x0A,0x02,0x00,0x0A,0x16,0x12,0x0C,  /* 000007B0    "........" */
  73.177 -    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x03,  /* 000007B8    "........" */
  73.178 -    0x00,0x0A,0x17,0x12,0x0B,0x04,0x0C,0xFF,  /* 000007C0    "........" */
  73.179 -    0xFF,0x02,0x00,0x00,0x00,0x0A,0x18,0x12,  /* 000007C8    "........" */
  73.180 -    0x0B,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x01,  /* 000007D0    "........" */
  73.181 -    0x00,0x0A,0x19,0x12,0x0C,0x04,0x0C,0xFF,  /* 000007D8    "........" */
  73.182 -    0xFF,0x02,0x00,0x0A,0x02,0x00,0x0A,0x1A,  /* 000007E0    "........" */
  73.183 -    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 000007E8    "........" */
  73.184 -    0x0A,0x03,0x00,0x0A,0x1B,0x12,0x0B,0x04,  /* 000007F0    "........" */
  73.185 -    0x0C,0xFF,0xFF,0x03,0x00,0x00,0x00,0x0A,  /* 000007F8    "........" */
  73.186 -    0x1C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x03,  /* 00000800    "........" */
  73.187 -    0x00,0x01,0x00,0x0A,0x1D,0x12,0x0C,0x04,  /* 00000808    "........" */
  73.188 -    0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x02,0x00,  /* 00000810    "........" */
  73.189 -    0x0A,0x1E,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000818    "........" */
  73.190 -    0x03,0x00,0x0A,0x03,0x00,0x0A,0x1F,0x12,  /* 00000820    "........" */
  73.191 -    0x0B,0x04,0x0C,0xFF,0xFF,0x04,0x00,0x00,  /* 00000828    "........" */
  73.192 -    0x00,0x0A,0x20,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000830    ".. ....." */
  73.193 -    0xFF,0x04,0x00,0x01,0x00,0x0A,0x21,0x12,  /* 00000838    "......!." */
  73.194 -    0x0C,0x04,0x0C,0xFF,0xFF,0x04,0x00,0x0A,  /* 00000840    "........" */
  73.195 -    0x02,0x00,0x0A,0x22,0x12,0x0C,0x04,0x0C,  /* 00000848    "..."...." */
  73.196 -    0xFF,0xFF,0x04,0x00,0x0A,0x03,0x00,0x0A,  /* 00000850    "........" */
  73.197 -    0x23,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x05,  /* 00000858    "#......." */
  73.198 -    0x00,0x00,0x00,0x0A,0x24,0x12,0x0B,0x04,  /* 00000860    "....$..." */
  73.199 -    0x0C,0xFF,0xFF,0x05,0x00,0x01,0x00,0x0A,  /* 00000868    "........" */
  73.200 -    0x25,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x05,  /* 00000870    "%......." */
  73.201 -    0x00,0x0A,0x02,0x00,0x0A,0x26,0x12,0x0C,  /* 00000878    ".....&.." */
  73.202 -    0x04,0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x03,  /* 00000880    "........" */
  73.203 -    0x00,0x0A,0x27,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000888    "..'....." */
  73.204 -    0xFF,0x06,0x00,0x00,0x00,0x0A,0x28,0x12,  /* 00000890    "......(." */
  73.205 -    0x0B,0x04,0x0C,0xFF,0xFF,0x06,0x00,0x01,  /* 00000898    "........" */
  73.206 -    0x00,0x0A,0x29,0x12,0x0C,0x04,0x0C,0xFF,  /* 000008A0    "..)....." */
  73.207 -    0xFF,0x06,0x00,0x0A,0x02,0x00,0x0A,0x2A,  /* 000008A8    ".......*" */
  73.208 -    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x06,0x00,  /* 000008B0    "........" */
  73.209 -    0x0A,0x03,0x00,0x0A,0x2B,0x12,0x0B,0x04,  /* 000008B8    "....+..." */
  73.210 -    0x0C,0xFF,0xFF,0x07,0x00,0x00,0x00,0x0A,  /* 000008C0    "........" */
  73.211 -    0x2C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x07,  /* 000008C8    ",......." */
  73.212 -    0x00,0x01,0x00,0x0A,0x2D,0x12,0x0C,0x04,  /* 000008D0    "....-..." */
  73.213 -    0x0C,0xFF,0xFF,0x07,0x00,0x0A,0x02,0x00,  /* 000008D8    "........" */
  73.214 -    0x0A,0x2E,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 000008E0    "........" */
  73.215 -    0x07,0x00,0x0A,0x03,0x00,0x0A,0x2F,0x12,  /* 000008E8    "....../." */
  73.216 -    0x0B,0x04,0x0C,0xFF,0xFF,0x08,0x00,0x00,  /* 000008F0    "........" */
  73.217 -    0x00,0x0A,0x11,0x12,0x0B,0x04,0x0C,0xFF,  /* 000008F8    "........" */
  73.218 -    0xFF,0x08,0x00,0x01,0x00,0x0A,0x12,0x12,  /* 00000900    "........" */
  73.219 -    0x0C,0x04,0x0C,0xFF,0xFF,0x08,0x00,0x0A,  /* 00000908    "........" */
  73.220 -    0x02,0x00,0x0A,0x13,0x12,0x0C,0x04,0x0C,  /* 00000910    "........" */
  73.221 -    0xFF,0xFF,0x08,0x00,0x0A,0x03,0x00,0x0A,  /* 00000918    "........" */
  73.222 -    0x14,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x09,  /* 00000920    "........" */
  73.223 -    0x00,0x00,0x00,0x0A,0x15,0x12,0x0B,0x04,  /* 00000928    "........" */
  73.224 -    0x0C,0xFF,0xFF,0x09,0x00,0x01,0x00,0x0A,  /* 00000930    "........" */
  73.225 -    0x16,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x09,  /* 00000938    "........" */
  73.226 -    0x00,0x0A,0x02,0x00,0x0A,0x17,0x12,0x0C,  /* 00000940    "........" */
  73.227 -    0x04,0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x03,  /* 00000948    "........" */
  73.228 -    0x00,0x0A,0x18,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000950    "........" */
  73.229 -    0xFF,0x0A,0x00,0x00,0x00,0x0A,0x19,0x12,  /* 00000958    "........" */
  73.230 -    0x0B,0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x01,  /* 00000960    "........" */
  73.231 -    0x00,0x0A,0x1A,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000968    "........" */
  73.232 -    0xFF,0x0A,0x00,0x0A,0x02,0x00,0x0A,0x1B,  /* 00000970    "........" */
  73.233 -    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0A,0x00,  /* 00000978    "........" */
  73.234 -    0x0A,0x03,0x00,0x0A,0x1C,0x12,0x0B,0x04,  /* 00000980    "........" */
  73.235 -    0x0C,0xFF,0xFF,0x0B,0x00,0x00,0x00,0x0A,  /* 00000988    "........" */
  73.236 -    0x1D,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0B,  /* 00000990    "........" */
  73.237 -    0x00,0x01,0x00,0x0A,0x1E,0x12,0x0C,0x04,  /* 00000998    "........" */
  73.238 -    0x0C,0xFF,0xFF,0x0B,0x00,0x0A,0x02,0x00,  /* 000009A0    "........" */
  73.239 -    0x0A,0x1F,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 000009A8    "........" */
  73.240 -    0x0B,0x00,0x0A,0x03,0x00,0x0A,0x20,0x12,  /* 000009B0    "...... ." */
  73.241 -    0x0B,0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x00,  /* 000009B8    "........" */
  73.242 -    0x00,0x0A,0x21,0x12,0x0B,0x04,0x0C,0xFF,  /* 000009C0    "..!....." */
  73.243 -    0xFF,0x0C,0x00,0x01,0x00,0x0A,0x22,0x12,  /* 000009C8    "......"." */
  73.244 -    0x0C,0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x0A,  /* 000009D0    "........" */
  73.245 -    0x02,0x00,0x0A,0x23,0x12,0x0C,0x04,0x0C,  /* 000009D8    "...#...." */
  73.246 -    0xFF,0xFF,0x0C,0x00,0x0A,0x03,0x00,0x0A,  /* 000009E0    "........" */
  73.247 -    0x24,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0D,  /* 000009E8    "$......." */
  73.248 -    0x00,0x00,0x00,0x0A,0x25,0x12,0x0B,0x04,  /* 000009F0    "....%..." */
  73.249 -    0x0C,0xFF,0xFF,0x0D,0x00,0x01,0x00,0x0A,  /* 000009F8    "........" */
  73.250 -    0x26,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0D,  /* 00000A00    "&......." */
  73.251 -    0x00,0x0A,0x02,0x00,0x0A,0x27,0x12,0x0C,  /* 00000A08    ".....'.." */
  73.252 -    0x04,0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x03,  /* 00000A10    "........" */
  73.253 -    0x00,0x0A,0x28,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000A18    "..(....." */
  73.254 -    0xFF,0x0E,0x00,0x00,0x00,0x0A,0x29,0x12,  /* 00000A20    "......)." */
  73.255 -    0x0B,0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x01,  /* 00000A28    "........" */
  73.256 -    0x00,0x0A,0x2A,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000A30    "..*....." */
  73.257 -    0xFF,0x0E,0x00,0x0A,0x02,0x00,0x0A,0x2B,  /* 00000A38    ".......+" */
  73.258 -    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0E,0x00,  /* 00000A40    "........" */
  73.259 -    0x0A,0x03,0x00,0x0A,0x2C,0x12,0x0B,0x04,  /* 00000A48    "....,..." */
  73.260 -    0x0C,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x0A,  /* 00000A50    "........" */
  73.261 -    0x2D,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0F,  /* 00000A58    "-......." */
  73.262 -    0x00,0x01,0x00,0x0A,0x2E,0x12,0x0C,0x04,  /* 00000A60    "........" */
  73.263 -    0x0C,0xFF,0xFF,0x0F,0x00,0x0A,0x02,0x00,  /* 00000A68    "........" */
  73.264 -    0x0A,0x2F,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000A70    "./......" */
  73.265 -    0x0F,0x00,0x0A,0x03,0x00,0x0A,0x10,0x5B,  /* 00000A78    ".......[" */
  73.266 -    0x82,0x4C,0x31,0x49,0x53,0x41,0x5F,0x08,  /* 00000A80    ".L1ISA_." */
  73.267 -    0x5F,0x41,0x44,0x52,0x0C,0x00,0x00,0x01,  /* 00000A88    "_ADR...." */
  73.268 -    0x00,0x5B,0x80,0x50,0x49,0x52,0x51,0x02,  /* 00000A90    ".[.PIRQ." */
  73.269 -    0x0A,0x60,0x0A,0x04,0x10,0x2E,0x5C,0x00,  /* 00000A98    ".`....\." */
  73.270 -    0x5B,0x81,0x29,0x5C,0x2F,0x04,0x5F,0x53,  /* 00000AA0    "[.)\/._S" */
  73.271 -    0x42,0x5F,0x50,0x43,0x49,0x30,0x49,0x53,  /* 00000AA8    "B_PCI0IS" */
  73.272 -    0x41,0x5F,0x50,0x49,0x52,0x51,0x01,0x50,  /* 00000AB0    "A_PIRQ.P" */
  73.273 -    0x49,0x52,0x41,0x08,0x50,0x49,0x52,0x42,  /* 00000AB8    "IRA.PIRB" */
  73.274 -    0x08,0x50,0x49,0x52,0x43,0x08,0x50,0x49,  /* 00000AC0    ".PIRC.PI" */
  73.275 -    0x52,0x44,0x08,0x5B,0x82,0x46,0x0B,0x53,  /* 00000AC8    "RD.[.F.S" */
  73.276 -    0x59,0x53,0x52,0x08,0x5F,0x48,0x49,0x44,  /* 00000AD0    "YSR._HID" */
  73.277 -    0x0C,0x41,0xD0,0x0C,0x02,0x08,0x5F,0x55,  /* 00000AD8    ".A...._U" */
  73.278 -    0x49,0x44,0x01,0x08,0x43,0x52,0x53,0x5F,  /* 00000AE0    "ID..CRS_" */
  73.279 -    0x11,0x4E,0x08,0x0A,0x8A,0x47,0x01,0x10,  /* 00000AE8    ".N...G.." */
  73.280 -    0x00,0x10,0x00,0x00,0x10,0x47,0x01,0x22,  /* 00000AF0    ".....G."" */
  73.281 -    0x00,0x22,0x00,0x00,0x0C,0x47,0x01,0x30,  /* 00000AF8    "."...G.0" */
  73.282 -    0x00,0x30,0x00,0x00,0x10,0x47,0x01,0x44,  /* 00000B00    ".0...G.D" */
  73.283 -    0x00,0x44,0x00,0x00,0x1C,0x47,0x01,0x62,  /* 00000B08    ".D...G.b" */
  73.284 -    0x00,0x62,0x00,0x00,0x02,0x47,0x01,0x65,  /* 00000B10    ".b...G.e" */
  73.285 -    0x00,0x65,0x00,0x00,0x0B,0x47,0x01,0x72,  /* 00000B18    ".e...G.r" */
  73.286 -    0x00,0x72,0x00,0x00,0x0E,0x47,0x01,0x80,  /* 00000B20    ".r...G.." */
  73.287 -    0x00,0x80,0x00,0x00,0x01,0x47,0x01,0x84,  /* 00000B28    ".....G.." */
  73.288 -    0x00,0x84,0x00,0x00,0x03,0x47,0x01,0x88,  /* 00000B30    ".....G.." */
  73.289 -    0x00,0x88,0x00,0x00,0x01,0x47,0x01,0x8C,  /* 00000B38    ".....G.." */
  73.290 -    0x00,0x8C,0x00,0x00,0x03,0x47,0x01,0x90,  /* 00000B40    ".....G.." */
  73.291 -    0x00,0x90,0x00,0x00,0x10,0x47,0x01,0xA2,  /* 00000B48    ".....G.." */
  73.292 -    0x00,0xA2,0x00,0x00,0x1C,0x47,0x01,0xE0,  /* 00000B50    ".....G.." */
  73.293 -    0x00,0xE0,0x00,0x00,0x10,0x47,0x01,0xA0,  /* 00000B58    ".....G.." */
  73.294 -    0x08,0xA0,0x08,0x00,0x04,0x47,0x01,0xC0,  /* 00000B60    ".....G.." */
  73.295 -    0x0C,0xC0,0x0C,0x00,0x10,0x47,0x01,0xD0,  /* 00000B68    ".....G.." */
  73.296 -    0x04,0xD0,0x04,0x00,0x02,0x79,0x00,0x14,  /* 00000B70    ".....y.." */
  73.297 -    0x0B,0x5F,0x43,0x52,0x53,0x00,0xA4,0x43,  /* 00000B78    "._CRS..C" */
  73.298 -    0x52,0x53,0x5F,0x5B,0x82,0x2B,0x50,0x49,  /* 00000B80    "RS_[.+PI" */
  73.299 -    0x43,0x5F,0x08,0x5F,0x48,0x49,0x44,0x0B,  /* 00000B88    "C_._HID." */
  73.300 -    0x41,0xD0,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000B90    "A.._CRS." */
  73.301 -    0x18,0x0A,0x15,0x47,0x01,0x20,0x00,0x20,  /* 00000B98    "...G. . " */
  73.302 -    0x00,0x01,0x02,0x47,0x01,0xA0,0x00,0xA0,  /* 00000BA0    "...G...." */
  73.303 -    0x00,0x01,0x02,0x22,0x04,0x00,0x79,0x00,  /* 00000BA8    "..."..y." */
  73.304 -    0x5B,0x82,0x47,0x05,0x44,0x4D,0x41,0x30,  /* 00000BB0    "[.G.DMA0" */
  73.305 -    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000BB8    "._HID.A." */
  73.306 -    0x02,0x00,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000BC0    "..._CRS." */
  73.307 -    0x41,0x04,0x0A,0x3D,0x2A,0x10,0x04,0x47,  /* 00000BC8    "A..=*..G" */
  73.308 -    0x01,0x00,0x00,0x00,0x00,0x00,0x10,0x47,  /* 00000BD0    ".......G" */
  73.309 -    0x01,0x81,0x00,0x81,0x00,0x00,0x03,0x47,  /* 00000BD8    ".......G" */
  73.310 -    0x01,0x87,0x00,0x87,0x00,0x00,0x01,0x47,  /* 00000BE0    ".......G" */
  73.311 -    0x01,0x89,0x00,0x89,0x00,0x00,0x03,0x47,  /* 00000BE8    ".......G" */
  73.312 -    0x01,0x8F,0x00,0x8F,0x00,0x00,0x01,0x47,  /* 00000BF0    ".......G" */
  73.313 -    0x01,0xC0,0x00,0xC0,0x00,0x00,0x20,0x47,  /* 00000BF8    "...... G" */
  73.314 -    0x01,0x80,0x04,0x80,0x04,0x00,0x10,0x79,  /* 00000C00    ".......y" */
  73.315 -    0x00,0x5B,0x82,0x25,0x54,0x4D,0x52,0x5F,  /* 00000C08    ".[.%TMR_" */
  73.316 -    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000C10    "._HID.A." */
  73.317 -    0x01,0x00,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 00000C18    "..._CRS." */
  73.318 -    0x10,0x0A,0x0D,0x47,0x01,0x40,0x00,0x40,  /* 00000C20    "...G.@.@" */
  73.319 -    0x00,0x00,0x04,0x22,0x01,0x00,0x79,0x00,  /* 00000C28    "..."..y." */
  73.320 -    0x5B,0x82,0x25,0x52,0x54,0x43,0x5F,0x08,  /* 00000C30    "[.%RTC_." */
  73.321 -    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x0B,  /* 00000C38    "_HID.A.." */
  73.322 -    0x00,0x08,0x5F,0x43,0x52,0x53,0x11,0x10,  /* 00000C40    ".._CRS.." */
  73.323 -    0x0A,0x0D,0x47,0x01,0x70,0x00,0x70,0x00,  /* 00000C48    "..G.p.p." */
  73.324 -    0x00,0x02,0x22,0x00,0x01,0x79,0x00,0x5B,  /* 00000C50    ".."..y.[" */
  73.325 -    0x82,0x22,0x53,0x50,0x4B,0x52,0x08,0x5F,  /* 00000C58    "."SPKR._" */
  73.326 -    0x48,0x49,0x44,0x0C,0x41,0xD0,0x08,0x00,  /* 00000C60    "HID.A..." */
  73.327 -    0x08,0x5F,0x43,0x52,0x53,0x11,0x0D,0x0A,  /* 00000C68    "._CRS..." */
  73.328 -    0x0A,0x47,0x01,0x61,0x00,0x61,0x00,0x00,  /* 00000C70    ".G.a.a.." */
  73.329 -    0x01,0x79,0x00,0x5B,0x82,0x31,0x50,0x53,  /* 00000C78    ".y.[.1PS" */
  73.330 -    0x32,0x4D,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000C80    "2M._HID." */
  73.331 -    0x41,0xD0,0x0F,0x13,0x08,0x5F,0x43,0x49,  /* 00000C88    "A...._CI" */
  73.332 -    0x44,0x0C,0x41,0xD0,0x0F,0x13,0x14,0x09,  /* 00000C90    "D.A....." */
  73.333 -    0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,  /* 00000C98    "_STA...." */
  73.334 -    0x08,0x5F,0x43,0x52,0x53,0x11,0x08,0x0A,  /* 00000CA0    "._CRS..." */
  73.335 -    0x05,0x22,0x00,0x10,0x79,0x00,0x5B,0x82,  /* 00000CA8    "."..y.[." */
  73.336 -    0x42,0x04,0x50,0x53,0x32,0x4B,0x08,0x5F,  /* 00000CB0    "B.PS2K._" */
  73.337 -    0x48,0x49,0x44,0x0C,0x41,0xD0,0x03,0x03,  /* 00000CB8    "HID.A..." */
  73.338 -    0x08,0x5F,0x43,0x49,0x44,0x0C,0x41,0xD0,  /* 00000CC0    "._CID.A." */
  73.339 -    0x03,0x0B,0x14,0x09,0x5F,0x53,0x54,0x41,  /* 00000CC8    "...._STA" */
  73.340 -    0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,  /* 00000CD0    "....._CR" */
  73.341 -    0x53,0x11,0x18,0x0A,0x15,0x47,0x01,0x60,  /* 00000CD8    "S....G.`" */
  73.342 -    0x00,0x60,0x00,0x00,0x01,0x47,0x01,0x64,  /* 00000CE0    ".`...G.d" */
  73.343 -    0x00,0x64,0x00,0x00,0x01,0x22,0x02,0x00,  /* 00000CE8    ".d...".." */
  73.344 -    0x79,0x00,0x5B,0x82,0x3A,0x46,0x44,0x43,  /* 00000CF0    "y.[.:FDC" */
  73.345 -    0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000CF8    "0._HID.A" */
  73.346 -    0xD0,0x07,0x00,0x14,0x09,0x5F,0x53,0x54,  /* 00000D00    "....._ST" */
  73.347 -    0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,  /* 00000D08    "A....._C" */
  73.348 -    0x52,0x53,0x11,0x1B,0x0A,0x18,0x47,0x01,  /* 00000D10    "RS....G." */
  73.349 -    0xF0,0x03,0xF0,0x03,0x01,0x06,0x47,0x01,  /* 00000D18    "......G." */
  73.350 -    0xF7,0x03,0xF7,0x03,0x01,0x01,0x22,0x40,  /* 00000D20    "......"@" */
  73.351 -    0x00,0x2A,0x04,0x00,0x79,0x00,0x5B,0x82,  /* 00000D28    ".*..y.[." */
  73.352 -    0x35,0x55,0x41,0x52,0x31,0x08,0x5F,0x48,  /* 00000D30    "5UAR1._H" */
  73.353 -    0x49,0x44,0x0C,0x41,0xD0,0x05,0x01,0x08,  /* 00000D38    "ID.A...." */
  73.354 -    0x5F,0x55,0x49,0x44,0x01,0x14,0x09,0x5F,  /* 00000D40    "_UID..._" */
  73.355 -    0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,  /* 00000D48    "STA....." */
  73.356 -    0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,  /* 00000D50    "_CRS...." */
  73.357 -    0x47,0x01,0xF8,0x03,0xF8,0x03,0x01,0x08,  /* 00000D58    "G......." */
  73.358 -    0x22,0x10,0x00,0x79,0x00,0x5B,0x82,0x36,  /* 00000D60    ""..y.[.6" */
  73.359 -    0x4C,0x54,0x50,0x31,0x08,0x5F,0x48,0x49,  /* 00000D68    "LTP1._HI" */
  73.360 -    0x44,0x0C,0x41,0xD0,0x04,0x00,0x08,0x5F,  /* 00000D70    "D.A...._" */
  73.361 -    0x55,0x49,0x44,0x0A,0x02,0x14,0x09,0x5F,  /* 00000D78    "UID...._" */
  73.362 -    0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,  /* 00000D80    "STA....." */
  73.363 -    0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,  /* 00000D88    "_CRS...." */
  73.364 -    0x47,0x01,0x78,0x03,0x78,0x03,0x08,0x08,  /* 00000D90    "G.x.x..." */
  73.365 -    0x22,0x80,0x00,0x79,0x00,
  73.366 +    0x52,0x44,0x5B,0x82,0x3A,0x48,0x50,0x45,  /* 00000400    "RD[.:HPE" */
  73.367 +    0x54,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000408    "T._HID.A" */
  73.368 +    0xD0,0x01,0x03,0x08,0x5F,0x55,0x49,0x44,  /* 00000410    "...._UID" */
  73.369 +    0x00,0x08,0x5F,0x43,0x52,0x53,0x11,0x1F,  /* 00000418    ".._CRS.." */
  73.370 +    0x0A,0x1C,0x87,0x17,0x00,0x00,0x0D,0x01,  /* 00000420    "........" */
  73.371 +    0x00,0x00,0x00,0x00,0x00,0x00,0xD0,0xFE,  /* 00000428    "........" */
  73.372 +    0xFF,0x03,0xD0,0xFE,0x00,0x00,0x00,0x00,  /* 00000430    "........" */
  73.373 +    0x00,0x04,0x00,0x00,0x79,0x00,0x14,0x16,  /* 00000438    "....y..." */
  73.374 +    0x5F,0x50,0x52,0x54,0x00,0xA0,0x0A,0x50,  /* 00000440    "_PRT...P" */
  73.375 +    0x49,0x43,0x44,0xA4,0x50,0x52,0x54,0x41,  /* 00000448    "ICD.PRTA" */
  73.376 +    0xA4,0x50,0x52,0x54,0x50,0x08,0x50,0x52,  /* 00000450    ".PRTP.PR" */
  73.377 +    0x54,0x50,0x12,0x49,0x36,0x3C,0x12,0x0D,  /* 00000458    "TP.I6<.." */
  73.378 +    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x00,0x4C,  /* 00000460    ".......L" */
  73.379 +    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000468    "NKB....." */
  73.380 +    0xFF,0xFF,0x01,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000470    ".....LNK" */
  73.381 +    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000478    "C......." */
  73.382 +    0x01,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000480    "....LNKD" */
  73.383 +    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x01,  /* 00000488    "........" */
  73.384 +    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000490    "...LNKA." */
  73.385 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 00000498    "........" */
  73.386 +    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 000004A0    ".LNKC..." */
  73.387 +    0x04,0x0C,0xFF,0xFF,0x02,0x00,0x01,0x4C,  /* 000004A8    ".......L" */
  73.388 +    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 000004B0    "NKD....." */
  73.389 +    0xFF,0xFF,0x02,0x00,0x0A,0x02,0x4C,0x4E,  /* 000004B8    "......LN" */
  73.390 +    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000004C0    "KA......" */
  73.391 +    0xFF,0x02,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000004C8    ".....LNK" */
  73.392 +    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000004D0    "B......." */
  73.393 +    0x03,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 000004D8    "...LNKD." */
  73.394 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x03,0x00,  /* 000004E0    "........" */
  73.395 +    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 000004E8    ".LNKA..." */
  73.396 +    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x02,  /* 000004F0    "........" */
  73.397 +    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000004F8    "LNKB...." */
  73.398 +    0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x03,0x4C,  /* 00000500    ".......L" */
  73.399 +    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 00000508    "NKC....." */
  73.400 +    0xFF,0xFF,0x04,0x00,0x00,0x4C,0x4E,0x4B,  /* 00000510    ".....LNK" */
  73.401 +    0x41,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000518    "A......." */
  73.402 +    0x04,0x00,0x01,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000520    "...LNKB." */
  73.403 +    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 00000528    "........" */
  73.404 +    0x0A,0x02,0x4C,0x4E,0x4B,0x43,0x00,0x12,  /* 00000530    "..LNKC.." */
  73.405 +    0x0E,0x04,0x0C,0xFF,0xFF,0x04,0x00,0x0A,  /* 00000538    "........" */
  73.406 +    0x03,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000540    ".LNKD..." */
  73.407 +    0x04,0x0C,0xFF,0xFF,0x05,0x00,0x00,0x4C,  /* 00000548    ".......L" */
  73.408 +    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000550    "NKB....." */
  73.409 +    0xFF,0xFF,0x05,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000558    ".....LNK" */
  73.410 +    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000560    "C......." */
  73.411 +    0x05,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000568    "....LNKD" */
  73.412 +    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x05,  /* 00000570    "........" */
  73.413 +    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000578    "...LNKA." */
  73.414 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x06,0x00,  /* 00000580    "........" */
  73.415 +    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 00000588    ".LNKC..." */
  73.416 +    0x04,0x0C,0xFF,0xFF,0x06,0x00,0x01,0x4C,  /* 00000590    ".......L" */
  73.417 +    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 00000598    "NKD....." */
  73.418 +    0xFF,0xFF,0x06,0x00,0x0A,0x02,0x4C,0x4E,  /* 000005A0    "......LN" */
  73.419 +    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 000005A8    "KA......" */
  73.420 +    0xFF,0x06,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 000005B0    ".....LNK" */
  73.421 +    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000005B8    "B......." */
  73.422 +    0x07,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 000005C0    "...LNKD." */
  73.423 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x07,0x00,  /* 000005C8    "........" */
  73.424 +    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 000005D0    ".LNKA..." */
  73.425 +    0x04,0x0C,0xFF,0xFF,0x07,0x00,0x0A,0x02,  /* 000005D8    "........" */
  73.426 +    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000005E0    "LNKB...." */
  73.427 +    0x0C,0xFF,0xFF,0x07,0x00,0x0A,0x03,0x4C,  /* 000005E8    ".......L" */
  73.428 +    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 000005F0    "NKC....." */
  73.429 +    0xFF,0xFF,0x08,0x00,0x00,0x4C,0x4E,0x4B,  /* 000005F8    ".....LNK" */
  73.430 +    0x41,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000600    "A......." */
  73.431 +    0x08,0x00,0x01,0x4C,0x4E,0x4B,0x42,0x00,  /* 00000608    "...LNKB." */
  73.432 +    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x08,0x00,  /* 00000610    "........" */
  73.433 +    0x0A,0x02,0x4C,0x4E,0x4B,0x43,0x00,0x12,  /* 00000618    "..LNKC.." */
  73.434 +    0x0E,0x04,0x0C,0xFF,0xFF,0x08,0x00,0x0A,  /* 00000620    "........" */
  73.435 +    0x03,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000628    ".LNKD..." */
  73.436 +    0x04,0x0C,0xFF,0xFF,0x09,0x00,0x00,0x4C,  /* 00000630    ".......L" */
  73.437 +    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000638    "NKB....." */
  73.438 +    0xFF,0xFF,0x09,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000640    ".....LNK" */
  73.439 +    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000648    "C......." */
  73.440 +    0x09,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000650    "....LNKD" */
  73.441 +    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x09,  /* 00000658    "........" */
  73.442 +    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000660    "...LNKA." */
  73.443 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0A,0x00,  /* 00000668    "........" */
  73.444 +    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 00000670    ".LNKC..." */
  73.445 +    0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x01,0x4C,  /* 00000678    ".......L" */
  73.446 +    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 00000680    "NKD....." */
  73.447 +    0xFF,0xFF,0x0A,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000688    "......LN" */
  73.448 +    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000690    "KA......" */
  73.449 +    0xFF,0x0A,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000698    ".....LNK" */
  73.450 +    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000006A0    "B......." */
  73.451 +    0x0B,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 000006A8    "...LNKD." */
  73.452 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0B,0x00,  /* 000006B0    "........" */
  73.453 +    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 000006B8    ".LNKA..." */
  73.454 +    0x04,0x0C,0xFF,0xFF,0x0B,0x00,0x0A,0x02,  /* 000006C0    "........" */
  73.455 +    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000006C8    "LNKB...." */
  73.456 +    0x0C,0xFF,0xFF,0x0B,0x00,0x0A,0x03,0x4C,  /* 000006D0    ".......L" */
  73.457 +    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 000006D8    "NKC....." */
  73.458 +    0xFF,0xFF,0x0C,0x00,0x00,0x4C,0x4E,0x4B,  /* 000006E0    ".....LNK" */
  73.459 +    0x41,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000006E8    "A......." */
  73.460 +    0x0C,0x00,0x01,0x4C,0x4E,0x4B,0x42,0x00,  /* 000006F0    "...LNKB." */
  73.461 +    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0C,0x00,  /* 000006F8    "........" */
  73.462 +    0x0A,0x02,0x4C,0x4E,0x4B,0x43,0x00,0x12,  /* 00000700    "..LNKC.." */
  73.463 +    0x0E,0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x0A,  /* 00000708    "........" */
  73.464 +    0x03,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000710    ".LNKD..." */
  73.465 +    0x04,0x0C,0xFF,0xFF,0x0D,0x00,0x00,0x4C,  /* 00000718    ".......L" */
  73.466 +    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000720    "NKB....." */
  73.467 +    0xFF,0xFF,0x0D,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000728    ".....LNK" */
  73.468 +    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000730    "C......." */
  73.469 +    0x0D,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000738    "....LNKD" */
  73.470 +    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x0D,  /* 00000740    "........" */
  73.471 +    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000748    "...LNKA." */
  73.472 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0E,0x00,  /* 00000750    "........" */
  73.473 +    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 00000758    ".LNKC..." */
  73.474 +    0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x01,0x4C,  /* 00000760    ".......L" */
  73.475 +    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 00000768    "NKD....." */
  73.476 +    0xFF,0xFF,0x0E,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000770    "......LN" */
  73.477 +    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000778    "KA......" */
  73.478 +    0xFF,0x0E,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000780    ".....LNK" */
  73.479 +    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000788    "B......." */
  73.480 +    0x0F,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000790    "...LNKD." */
  73.481 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x0F,0x00,  /* 00000798    "........" */
  73.482 +    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 000007A0    ".LNKA..." */
  73.483 +    0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x0A,0x02,  /* 000007A8    "........" */
  73.484 +    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000007B0    "LNKB...." */
  73.485 +    0x0C,0xFF,0xFF,0x0F,0x00,0x0A,0x03,0x4C,  /* 000007B8    ".......L" */
  73.486 +    0x4E,0x4B,0x43,0x00,0x08,0x50,0x52,0x54,  /* 000007C0    "NKC..PRT" */
  73.487 +    0x41,0x12,0x41,0x2F,0x3C,0x12,0x0B,0x04,  /* 000007C8    "A.A/<..." */
  73.488 +    0x0C,0xFF,0xFF,0x01,0x00,0x00,0x00,0x0A,  /* 000007D0    "........" */
  73.489 +    0x14,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x01,  /* 000007D8    "........" */
  73.490 +    0x00,0x01,0x00,0x0A,0x15,0x12,0x0C,0x04,  /* 000007E0    "........" */
  73.491 +    0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x02,0x00,  /* 000007E8    "........" */
  73.492 +    0x0A,0x16,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 000007F0    "........" */
  73.493 +    0x01,0x00,0x0A,0x03,0x00,0x0A,0x17,0x12,  /* 000007F8    "........" */
  73.494 +    0x0B,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x00,  /* 00000800    "........" */
  73.495 +    0x00,0x0A,0x18,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000808    "........" */
  73.496 +    0xFF,0x02,0x00,0x01,0x00,0x0A,0x19,0x12,  /* 00000810    "........" */
  73.497 +    0x0C,0x04,0x0C,0xFF,0xFF,0x02,0x00,0x0A,  /* 00000818    "........" */
  73.498 +    0x02,0x00,0x0A,0x1A,0x12,0x0C,0x04,0x0C,  /* 00000820    "........" */
  73.499 +    0xFF,0xFF,0x02,0x00,0x0A,0x03,0x00,0x0A,  /* 00000828    "........" */
  73.500 +    0x1B,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x03,  /* 00000830    "........" */
  73.501 +    0x00,0x00,0x00,0x0A,0x1C,0x12,0x0B,0x04,  /* 00000838    "........" */
  73.502 +    0x0C,0xFF,0xFF,0x03,0x00,0x01,0x00,0x0A,  /* 00000840    "........" */
  73.503 +    0x1D,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x03,  /* 00000848    "........" */
  73.504 +    0x00,0x0A,0x02,0x00,0x0A,0x1E,0x12,0x0C,  /* 00000850    "........" */
  73.505 +    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x03,  /* 00000858    "........" */
  73.506 +    0x00,0x0A,0x1F,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000860    "........" */
  73.507 +    0xFF,0x04,0x00,0x00,0x00,0x0A,0x20,0x12,  /* 00000868    "...... ." */
  73.508 +    0x0B,0x04,0x0C,0xFF,0xFF,0x04,0x00,0x01,  /* 00000870    "........" */
  73.509 +    0x00,0x0A,0x21,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000878    "..!....." */
  73.510 +    0xFF,0x04,0x00,0x0A,0x02,0x00,0x0A,0x22,  /* 00000880    "......."" */
  73.511 +    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 00000888    "........" */
  73.512 +    0x0A,0x03,0x00,0x0A,0x23,0x12,0x0B,0x04,  /* 00000890    "....#..." */
  73.513 +    0x0C,0xFF,0xFF,0x05,0x00,0x00,0x00,0x0A,  /* 00000898    "........" */
  73.514 +    0x24,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x05,  /* 000008A0    "$......." */
  73.515 +    0x00,0x01,0x00,0x0A,0x25,0x12,0x0C,0x04,  /* 000008A8    "....%..." */
  73.516 +    0x0C,0xFF,0xFF,0x05,0x00,0x0A,0x02,0x00,  /* 000008B0    "........" */
  73.517 +    0x0A,0x26,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 000008B8    ".&......" */
  73.518 +    0x05,0x00,0x0A,0x03,0x00,0x0A,0x27,0x12,  /* 000008C0    "......'." */
  73.519 +    0x0B,0x04,0x0C,0xFF,0xFF,0x06,0x00,0x00,  /* 000008C8    "........" */
  73.520 +    0x00,0x0A,0x28,0x12,0x0B,0x04,0x0C,0xFF,  /* 000008D0    "..(....." */
  73.521 +    0xFF,0x06,0x00,0x01,0x00,0x0A,0x29,0x12,  /* 000008D8    "......)." */
  73.522 +    0x0C,0x04,0x0C,0xFF,0xFF,0x06,0x00,0x0A,  /* 000008E0    "........" */
  73.523 +    0x02,0x00,0x0A,0x2A,0x12,0x0C,0x04,0x0C,  /* 000008E8    "...*...." */
  73.524 +    0xFF,0xFF,0x06,0x00,0x0A,0x03,0x00,0x0A,  /* 000008F0    "........" */
  73.525 +    0x2B,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x07,  /* 000008F8    "+......." */
  73.526 +    0x00,0x00,0x00,0x0A,0x2C,0x12,0x0B,0x04,  /* 00000900    "....,..." */
  73.527 +    0x0C,0xFF,0xFF,0x07,0x00,0x01,0x00,0x0A,  /* 00000908    "........" */
  73.528 +    0x2D,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x07,  /* 00000910    "-......." */
  73.529 +    0x00,0x0A,0x02,0x00,0x0A,0x2E,0x12,0x0C,  /* 00000918    "........" */
  73.530 +    0x04,0x0C,0xFF,0xFF,0x07,0x00,0x0A,0x03,  /* 00000920    "........" */
  73.531 +    0x00,0x0A,0x2F,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000928    "../....." */
  73.532 +    0xFF,0x08,0x00,0x00,0x00,0x0A,0x11,0x12,  /* 00000930    "........" */
  73.533 +    0x0B,0x04,0x0C,0xFF,0xFF,0x08,0x00,0x01,  /* 00000938    "........" */
  73.534 +    0x00,0x0A,0x12,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000940    "........" */
  73.535 +    0xFF,0x08,0x00,0x0A,0x02,0x00,0x0A,0x13,  /* 00000948    "........" */
  73.536 +    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x08,0x00,  /* 00000950    "........" */
  73.537 +    0x0A,0x03,0x00,0x0A,0x14,0x12,0x0B,0x04,  /* 00000958    "........" */
  73.538 +    0x0C,0xFF,0xFF,0x09,0x00,0x00,0x00,0x0A,  /* 00000960    "........" */
  73.539 +    0x15,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x09,  /* 00000968    "........" */
  73.540 +    0x00,0x01,0x00,0x0A,0x16,0x12,0x0C,0x04,  /* 00000970    "........" */
  73.541 +    0x0C,0xFF,0xFF,0x09,0x00,0x0A,0x02,0x00,  /* 00000978    "........" */
  73.542 +    0x0A,0x17,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000980    "........" */
  73.543 +    0x09,0x00,0x0A,0x03,0x00,0x0A,0x18,0x12,  /* 00000988    "........" */
  73.544 +    0x0B,0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x00,  /* 00000990    "........" */
  73.545 +    0x00,0x0A,0x19,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000998    "........" */
  73.546 +    0xFF,0x0A,0x00,0x01,0x00,0x0A,0x1A,0x12,  /* 000009A0    "........" */
  73.547 +    0x0C,0x04,0x0C,0xFF,0xFF,0x0A,0x00,0x0A,  /* 000009A8    "........" */
  73.548 +    0x02,0x00,0x0A,0x1B,0x12,0x0C,0x04,0x0C,  /* 000009B0    "........" */
  73.549 +    0xFF,0xFF,0x0A,0x00,0x0A,0x03,0x00,0x0A,  /* 000009B8    "........" */
  73.550 +    0x1C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0B,  /* 000009C0    "........" */
  73.551 +    0x00,0x00,0x00,0x0A,0x1D,0x12,0x0B,0x04,  /* 000009C8    "........" */
  73.552 +    0x0C,0xFF,0xFF,0x0B,0x00,0x01,0x00,0x0A,  /* 000009D0    "........" */
  73.553 +    0x1E,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0B,  /* 000009D8    "........" */
  73.554 +    0x00,0x0A,0x02,0x00,0x0A,0x1F,0x12,0x0C,  /* 000009E0    "........" */
  73.555 +    0x04,0x0C,0xFF,0xFF,0x0B,0x00,0x0A,0x03,  /* 000009E8    "........" */
  73.556 +    0x00,0x0A,0x20,0x12,0x0B,0x04,0x0C,0xFF,  /* 000009F0    ".. ....." */
  73.557 +    0xFF,0x0C,0x00,0x00,0x00,0x0A,0x21,0x12,  /* 000009F8    "......!." */
  73.558 +    0x0B,0x04,0x0C,0xFF,0xFF,0x0C,0x00,0x01,  /* 00000A00    "........" */
  73.559 +    0x00,0x0A,0x22,0x12,0x0C,0x04,0x0C,0xFF,  /* 00000A08    ".."....." */
  73.560 +    0xFF,0x0C,0x00,0x0A,0x02,0x00,0x0A,0x23,  /* 00000A10    ".......#" */
  73.561 +    0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0C,0x00,  /* 00000A18    "........" */
  73.562 +    0x0A,0x03,0x00,0x0A,0x24,0x12,0x0B,0x04,  /* 00000A20    "....$..." */
  73.563 +    0x0C,0xFF,0xFF,0x0D,0x00,0x00,0x00,0x0A,  /* 00000A28    "........" */
  73.564 +    0x25,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0D,  /* 00000A30    "%......." */
  73.565 +    0x00,0x01,0x00,0x0A,0x26,0x12,0x0C,0x04,  /* 00000A38    "....&..." */
  73.566 +    0x0C,0xFF,0xFF,0x0D,0x00,0x0A,0x02,0x00,  /* 00000A40    "........" */
  73.567 +    0x0A,0x27,0x12,0x0C,0x04,0x0C,0xFF,0xFF,  /* 00000A48    ".'......" */
  73.568 +    0x0D,0x00,0x0A,0x03,0x00,0x0A,0x28,0x12,  /* 00000A50    "......(." */
  73.569 +    0x0B,0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x00,  /* 00000A58    "........" */
  73.570 +    0x00,0x0A,0x29,0x12,0x0B,0x04,0x0C,0xFF,  /* 00000A60    "..)....." */
  73.571 +    0xFF,0x0E,0x00,0x01,0x00,0x0A,0x2A,0x12,  /* 00000A68    "......*." */
  73.572 +    0x0C,0x04,0x0C,0xFF,0xFF,0x0E,0x00,0x0A,  /* 00000A70    "........" */
  73.573 +    0x02,0x00,0x0A,0x2B,0x12,0x0C,0x04,0x0C,  /* 00000A78    "...+...." */
  73.574 +    0xFF,0xFF,0x0E,0x00,0x0A,0x03,0x00,0x0A,  /* 00000A80    "........" */
  73.575 +    0x2C,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x0F,  /* 00000A88    ",......." */
  73.576 +    0x00,0x00,0x00,0x0A,0x2D,0x12,0x0B,0x04,  /* 00000A90    "....-..." */
  73.577 +    0x0C,0xFF,0xFF,0x0F,0x00,0x01,0x00,0x0A,  /* 00000A98    "........" */
  73.578 +    0x2E,0x12,0x0C,0x04,0x0C,0xFF,0xFF,0x0F,  /* 00000AA0    "........" */
  73.579 +    0x00,0x0A,0x02,0x00,0x0A,0x2F,0x12,0x0C,  /* 00000AA8    "...../.." */
  73.580 +    0x04,0x0C,0xFF,0xFF,0x0F,0x00,0x0A,0x03,  /* 00000AB0    "........" */
  73.581 +    0x00,0x0A,0x10,0x5B,0x82,0x4C,0x31,0x49,  /* 00000AB8    "...[.L1I" */
  73.582 +    0x53,0x41,0x5F,0x08,0x5F,0x41,0x44,0x52,  /* 00000AC0    "SA_._ADR" */
  73.583 +    0x0C,0x00,0x00,0x01,0x00,0x5B,0x80,0x50,  /* 00000AC8    ".....[.P" */
  73.584 +    0x49,0x52,0x51,0x02,0x0A,0x60,0x0A,0x04,  /* 00000AD0    "IRQ..`.." */
  73.585 +    0x10,0x2E,0x5C,0x00,0x5B,0x81,0x29,0x5C,  /* 00000AD8    "..\.[.)\" */
  73.586 +    0x2F,0x04,0x5F,0x53,0x42,0x5F,0x50,0x43,  /* 00000AE0    "/._SB_PC" */
  73.587 +    0x49,0x30,0x49,0x53,0x41,0x5F,0x50,0x49,  /* 00000AE8    "I0ISA_PI" */
  73.588 +    0x52,0x51,0x01,0x50,0x49,0x52,0x41,0x08,  /* 00000AF0    "RQ.PIRA." */
  73.589 +    0x50,0x49,0x52,0x42,0x08,0x50,0x49,0x52,  /* 00000AF8    "PIRB.PIR" */
  73.590 +    0x43,0x08,0x50,0x49,0x52,0x44,0x08,0x5B,  /* 00000B00    "C.PIRD.[" */
  73.591 +    0x82,0x46,0x0B,0x53,0x59,0x53,0x52,0x08,  /* 00000B08    ".F.SYSR." */
  73.592 +    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x0C,  /* 00000B10    "_HID.A.." */
  73.593 +    0x02,0x08,0x5F,0x55,0x49,0x44,0x01,0x08,  /* 00000B18    ".._UID.." */
  73.594 +    0x43,0x52,0x53,0x5F,0x11,0x4E,0x08,0x0A,  /* 00000B20    "CRS_.N.." */
  73.595 +    0x8A,0x47,0x01,0x10,0x00,0x10,0x00,0x00,  /* 00000B28    ".G......" */
  73.596 +    0x10,0x47,0x01,0x22,0x00,0x22,0x00,0x00,  /* 00000B30    ".G.".".." */
  73.597 +    0x0C,0x47,0x01,0x30,0x00,0x30,0x00,0x00,  /* 00000B38    ".G.0.0.." */
  73.598 +    0x10,0x47,0x01,0x44,0x00,0x44,0x00,0x00,  /* 00000B40    ".G.D.D.." */
  73.599 +    0x1C,0x47,0x01,0x62,0x00,0x62,0x00,0x00,  /* 00000B48    ".G.b.b.." */
  73.600 +    0x02,0x47,0x01,0x65,0x00,0x65,0x00,0x00,  /* 00000B50    ".G.e.e.." */
  73.601 +    0x0B,0x47,0x01,0x72,0x00,0x72,0x00,0x00,  /* 00000B58    ".G.r.r.." */
  73.602 +    0x0E,0x47,0x01,0x80,0x00,0x80,0x00,0x00,  /* 00000B60    ".G......" */
  73.603 +    0x01,0x47,0x01,0x84,0x00,0x84,0x00,0x00,  /* 00000B68    ".G......" */
  73.604 +    0x03,0x47,0x01,0x88,0x00,0x88,0x00,0x00,  /* 00000B70    ".G......" */
  73.605 +    0x01,0x47,0x01,0x8C,0x00,0x8C,0x00,0x00,  /* 00000B78    ".G......" */
  73.606 +    0x03,0x47,0x01,0x90,0x00,0x90,0x00,0x00,  /* 00000B80    ".G......" */
  73.607 +    0x10,0x47,0x01,0xA2,0x00,0xA2,0x00,0x00,  /* 00000B88    ".G......" */
  73.608 +    0x1C,0x47,0x01,0xE0,0x00,0xE0,0x00,0x00,  /* 00000B90    ".G......" */
  73.609 +    0x10,0x47,0x01,0xA0,0x08,0xA0,0x08,0x00,  /* 00000B98    ".G......" */
  73.610 +    0x04,0x47,0x01,0xC0,0x0C,0xC0,0x0C,0x00,  /* 00000BA0    ".G......" */
  73.611 +    0x10,0x47,0x01,0xD0,0x04,0xD0,0x04,0x00,  /* 00000BA8    ".G......" */
  73.612 +    0x02,0x79,0x00,0x14,0x0B,0x5F,0x43,0x52,  /* 00000BB0    ".y..._CR" */
  73.613 +    0x53,0x00,0xA4,0x43,0x52,0x53,0x5F,0x5B,  /* 00000BB8    "S..CRS_[" */
  73.614 +    0x82,0x2B,0x50,0x49,0x43,0x5F,0x08,0x5F,  /* 00000BC0    ".+PIC_._" */
  73.615 +    0x48,0x49,0x44,0x0B,0x41,0xD0,0x08,0x5F,  /* 00000BC8    "HID.A.._" */
  73.616 +    0x43,0x52,0x53,0x11,0x18,0x0A,0x15,0x47,  /* 00000BD0    "CRS....G" */
  73.617 +    0x01,0x20,0x00,0x20,0x00,0x01,0x02,0x47,  /* 00000BD8    ". . ...G" */
  73.618 +    0x01,0xA0,0x00,0xA0,0x00,0x01,0x02,0x22,  /* 00000BE0    "......."" */
  73.619 +    0x04,0x00,0x79,0x00,0x5B,0x82,0x47,0x05,  /* 00000BE8    "..y.[.G." */
  73.620 +    0x44,0x4D,0x41,0x30,0x08,0x5F,0x48,0x49,  /* 00000BF0    "DMA0._HI" */
  73.621 +    0x44,0x0C,0x41,0xD0,0x02,0x00,0x08,0x5F,  /* 00000BF8    "D.A...._" */
  73.622 +    0x43,0x52,0x53,0x11,0x41,0x04,0x0A,0x3D,  /* 00000C00    "CRS.A..=" */
  73.623 +    0x2A,0x10,0x04,0x47,0x01,0x00,0x00,0x00,  /* 00000C08    "*..G...." */
  73.624 +    0x00,0x00,0x10,0x47,0x01,0x81,0x00,0x81,  /* 00000C10    "...G...." */
  73.625 +    0x00,0x00,0x03,0x47,0x01,0x87,0x00,0x87,  /* 00000C18    "...G...." */
  73.626 +    0x00,0x00,0x01,0x47,0x01,0x89,0x00,0x89,  /* 00000C20    "...G...." */
  73.627 +    0x00,0x00,0x03,0x47,0x01,0x8F,0x00,0x8F,  /* 00000C28    "...G...." */
  73.628 +    0x00,0x00,0x01,0x47,0x01,0xC0,0x00,0xC0,  /* 00000C30    "...G...." */
  73.629 +    0x00,0x00,0x20,0x47,0x01,0x80,0x04,0x80,  /* 00000C38    ".. G...." */
  73.630 +    0x04,0x00,0x10,0x79,0x00,0x5B,0x82,0x25,  /* 00000C40    "...y.[.%" */
  73.631 +    0x54,0x4D,0x52,0x5F,0x08,0x5F,0x48,0x49,  /* 00000C48    "TMR_._HI" */
  73.632 +    0x44,0x0C,0x41,0xD0,0x01,0x00,0x08,0x5F,  /* 00000C50    "D.A...._" */
  73.633 +    0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,0x47,  /* 00000C58    "CRS....G" */
  73.634 +    0x01,0x40,0x00,0x40,0x00,0x00,0x04,0x22,  /* 00000C60    ".@.@..."" */
  73.635 +    0x01,0x00,0x79,0x00,0x5B,0x82,0x25,0x52,  /* 00000C68    "..y.[.%R" */
  73.636 +    0x54,0x43,0x5F,0x08,0x5F,0x48,0x49,0x44,  /* 00000C70    "TC_._HID" */
  73.637 +    0x0C,0x41,0xD0,0x0B,0x00,0x08,0x5F,0x43,  /* 00000C78    ".A...._C" */
  73.638 +    0x52,0x53,0x11,0x10,0x0A,0x0D,0x47,0x01,  /* 00000C80    "RS....G." */
  73.639 +    0x70,0x00,0x70,0x00,0x00,0x02,0x22,0x00,  /* 00000C88    "p.p..."." */
  73.640 +    0x01,0x79,0x00,0x5B,0x82,0x22,0x53,0x50,  /* 00000C90    ".y.[."SP" */
  73.641 +    0x4B,0x52,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000C98    "KR._HID." */
  73.642 +    0x41,0xD0,0x08,0x00,0x08,0x5F,0x43,0x52,  /* 00000CA0    "A...._CR" */
  73.643 +    0x53,0x11,0x0D,0x0A,0x0A,0x47,0x01,0x61,  /* 00000CA8    "S....G.a" */
  73.644 +    0x00,0x61,0x00,0x00,0x01,0x79,0x00,0x5B,  /* 00000CB0    ".a...y.[" */
  73.645 +    0x82,0x31,0x50,0x53,0x32,0x4D,0x08,0x5F,  /* 00000CB8    ".1PS2M._" */
  73.646 +    0x48,0x49,0x44,0x0C,0x41,0xD0,0x0F,0x13,  /* 00000CC0    "HID.A..." */
  73.647 +    0x08,0x5F,0x43,0x49,0x44,0x0C,0x41,0xD0,  /* 00000CC8    "._CID.A." */
  73.648 +    0x0F,0x13,0x14,0x09,0x5F,0x53,0x54,0x41,  /* 00000CD0    "...._STA" */
  73.649 +    0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,  /* 00000CD8    "....._CR" */
  73.650 +    0x53,0x11,0x08,0x0A,0x05,0x22,0x00,0x10,  /* 00000CE0    "S....".." */
  73.651 +    0x79,0x00,0x5B,0x82,0x42,0x04,0x50,0x53,  /* 00000CE8    "y.[.B.PS" */
  73.652 +    0x32,0x4B,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000CF0    "2K._HID." */
  73.653 +    0x41,0xD0,0x03,0x03,0x08,0x5F,0x43,0x49,  /* 00000CF8    "A...._CI" */
  73.654 +    0x44,0x0C,0x41,0xD0,0x03,0x0B,0x14,0x09,  /* 00000D00    "D.A....." */
  73.655 +    0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,  /* 00000D08    "_STA...." */
  73.656 +    0x08,0x5F,0x43,0x52,0x53,0x11,0x18,0x0A,  /* 00000D10    "._CRS..." */
  73.657 +    0x15,0x47,0x01,0x60,0x00,0x60,0x00,0x00,  /* 00000D18    ".G.`.`.." */
  73.658 +    0x01,0x47,0x01,0x64,0x00,0x64,0x00,0x00,  /* 00000D20    ".G.d.d.." */
  73.659 +    0x01,0x22,0x02,0x00,0x79,0x00,0x5B,0x82,  /* 00000D28    "."..y.[." */
  73.660 +    0x3A,0x46,0x44,0x43,0x30,0x08,0x5F,0x48,  /* 00000D30    ":FDC0._H" */
  73.661 +    0x49,0x44,0x0C,0x41,0xD0,0x07,0x00,0x14,  /* 00000D38    "ID.A...." */
  73.662 +    0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,  /* 00000D40    "._STA..." */
  73.663 +    0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x1B,  /* 00000D48    ".._CRS.." */
  73.664 +    0x0A,0x18,0x47,0x01,0xF0,0x03,0xF0,0x03,  /* 00000D50    "..G....." */
  73.665 +    0x01,0x06,0x47,0x01,0xF7,0x03,0xF7,0x03,  /* 00000D58    "..G....." */
  73.666 +    0x01,0x01,0x22,0x40,0x00,0x2A,0x04,0x00,  /* 00000D60    ".."@.*.." */
  73.667 +    0x79,0x00,0x5B,0x82,0x35,0x55,0x41,0x52,  /* 00000D68    "y.[.5UAR" */
  73.668 +    0x31,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000D70    "1._HID.A" */
  73.669 +    0xD0,0x05,0x01,0x08,0x5F,0x55,0x49,0x44,  /* 00000D78    "...._UID" */
  73.670 +    0x01,0x14,0x09,0x5F,0x53,0x54,0x41,0x00,  /* 00000D80    "..._STA." */
  73.671 +    0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,  /* 00000D88    "...._CRS" */
  73.672 +    0x11,0x10,0x0A,0x0D,0x47,0x01,0xF8,0x03,  /* 00000D90    "....G..." */
  73.673 +    0xF8,0x03,0x01,0x08,0x22,0x10,0x00,0x79,  /* 00000D98    "...."..y" */
  73.674 +    0x00,0x5B,0x82,0x36,0x4C,0x54,0x50,0x31,  /* 00000DA0    ".[.6LTP1" */
  73.675 +    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000DA8    "._HID.A." */
  73.676 +    0x04,0x00,0x08,0x5F,0x55,0x49,0x44,0x0A,  /* 00000DB0    "..._UID." */
  73.677 +    0x02,0x14,0x09,0x5F,0x53,0x54,0x41,0x00,  /* 00000DB8    "..._STA." */
  73.678 +    0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,  /* 00000DC0    "...._CRS" */
  73.679 +    0x11,0x10,0x0A,0x0D,0x47,0x01,0x78,0x03,  /* 00000DC8    "....G.x." */
  73.680 +    0x78,0x03,0x08,0x08,0x22,0x80,0x00,0x79,  /* 00000DD0    "x..."..y" */
  73.681 +    0x00,
  73.682  };
  73.683  int DsdtLen=sizeof(AmlCode);
    74.1 --- a/tools/firmware/hvmloader/acpi/ssdt_tpm.asl	Wed Jan 10 08:00:50 2007 -0700
    74.2 +++ b/tools/firmware/hvmloader/acpi/ssdt_tpm.asl	Wed Jan 10 08:40:47 2007 -0700
    74.3 @@ -17,7 +17,7 @@
    74.4  
    74.5  //*  SSDT for TPM TIS Interface for Xen with Qemu device model
    74.6  
    74.7 -DefinitionBlock ("SSDT_TPM.aml", "SSDT", 1, "IBM","xen", 2006)
    74.8 +DefinitionBlock ("SSDT_TPM.aml", "SSDT", 2, "Xen", "HVM", 0)
    74.9  {
   74.10      Device (TPM) {
   74.11          Name (_HID, EisaId ("PNP0C31"))
   74.12 @@ -26,4 +26,4 @@ DefinitionBlock ("SSDT_TPM.aml", "SSDT",
   74.13              Memory32Fixed (ReadWrite, 0xFED40000, 0x5000,)
   74.14          })
   74.15      }
   74.16 -}
   74.17 \ No newline at end of file
   74.18 +}
    75.1 --- a/tools/firmware/hvmloader/acpi/ssdt_tpm.h	Wed Jan 10 08:00:50 2007 -0700
    75.2 +++ b/tools/firmware/hvmloader/acpi/ssdt_tpm.h	Wed Jan 10 08:40:47 2007 -0700
    75.3 @@ -1,11 +1,11 @@
    75.4  /*
    75.5   * 
    75.6   * Intel ACPI Component Architecture
    75.7 - * ASL Optimizing Compiler version 20060707 [Sep 11 2006]
    75.8 + * ASL Optimizing Compiler version 20060707 [Dec 30 2006]
    75.9   * Copyright (C) 2000 - 2006 Intel Corporation
   75.10   * Supports ACPI Specification Revision 3.0a
   75.11   * 
   75.12 - * Compilation of "acpi_ssdt_tpm.asl" - Mon Oct 30 11:28:27 2006
   75.13 + * Compilation of "ssdt_tpm.asl" - Sat Dec 30 15:31:27 2006
   75.14   * 
   75.15   * C source code output
   75.16   *
   75.17 @@ -13,9 +13,9 @@
   75.18  unsigned char AmlCode_TPM[] =
   75.19  {
   75.20      0x53,0x53,0x44,0x54,0x4C,0x00,0x00,0x00,  /* 00000000    "SSDTL..." */
   75.21 -    0x01,0x6D,0x49,0x42,0x4D,0x00,0x00,0x00,  /* 00000008    ".mIBM..." */
   75.22 -    0x78,0x65,0x6E,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "xen....." */
   75.23 -    0xD6,0x07,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
   75.24 +    0x02,0x56,0x58,0x65,0x6E,0x00,0x00,0x00,  /* 00000008    ".VXen..." */
   75.25 +    0x48,0x56,0x4D,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "HVM....." */
   75.26 +    0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
   75.27      0x07,0x07,0x06,0x20,0x5B,0x82,0x26,0x54,  /* 00000020    "... [.&T" */
   75.28      0x50,0x4D,0x5F,0x08,0x5F,0x48,0x49,0x44,  /* 00000028    "PM_._HID" */
   75.29      0x0C,0x41,0xD0,0x0C,0x31,0x08,0x5F,0x43,  /* 00000030    ".A..1._C" */
    76.1 --- a/tools/firmware/hvmloader/acpi/static_tables.c	Wed Jan 10 08:00:50 2007 -0700
    76.2 +++ b/tools/firmware/hvmloader/acpi/static_tables.c	Wed Jan 10 08:40:47 2007 -0700
    76.3 @@ -118,7 +118,7 @@ struct acpi_20_xsdt Xsdt = {
    76.4          .signature    = ACPI_2_0_XSDT_SIGNATURE,
    76.5          .length       = sizeof(struct acpi_header),
    76.6          .revision     = ACPI_2_0_XSDT_REVISION,
    76.7 -        .oem_id       = ACPI_OEM_ID, 
    76.8 +        .oem_id       = ACPI_OEM_ID,
    76.9          .oem_table_id = ACPI_OEM_TABLE_ID,
   76.10          .oem_revision = ACPI_OEM_REVISION,
   76.11          .creator_id   = ACPI_CREATOR_ID,
   76.12 @@ -130,7 +130,7 @@ struct acpi_20_xsdt Xsdt = {
   76.13  struct acpi_20_rsdp Rsdp = {
   76.14      .signature = ACPI_2_0_RSDP_SIGNATURE,
   76.15      .oem_id    = ACPI_OEM_ID,
   76.16 -    .revision  = ACPI_OEM_REVISION, 
   76.17 +    .revision  = ACPI_2_0_RSDP_REVISION,
   76.18      .length    = sizeof(struct acpi_20_rsdp)
   76.19  };
   76.20  
    77.1 --- a/tools/firmware/hvmloader/config.h	Wed Jan 10 08:00:50 2007 -0700
    77.2 +++ b/tools/firmware/hvmloader/config.h	Wed Jan 10 08:40:47 2007 -0700
    77.3 @@ -2,10 +2,11 @@
    77.4  #define __HVMLOADER_CONFIG_H__
    77.5  
    77.6  #define IOAPIC_BASE_ADDRESS 0xfec00000
    77.7 -#define IOAPIC_ID           0x00
    77.8 +#define IOAPIC_ID           0x01
    77.9  #define IOAPIC_VERSION      0x11
   77.10  
   77.11  #define LAPIC_BASE_ADDRESS  0xfee00000
   77.12 +#define LAPIC_ID(vcpu_id)   ((vcpu_id) * 2)
   77.13  
   77.14  #define PCI_ISA_DEVFN       0x08    /* dev 1, fn 0 */
   77.15  #define PCI_ISA_IRQ_MASK    0x0c60U /* ISA IRQs 5,6,10,11 are PCI connected */
    78.1 --- a/tools/firmware/hvmloader/hvmloader.c	Wed Jan 10 08:00:50 2007 -0700
    78.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Wed Jan 10 08:40:47 2007 -0700
    78.3 @@ -34,6 +34,7 @@
    78.4  /* memory map */
    78.5  #define HYPERCALL_PHYSICAL_ADDRESS    0x00080000
    78.6  #define VGABIOS_PHYSICAL_ADDRESS      0x000C0000
    78.7 +#define ETHERBOOT_PHYSICAL_ADDRESS    0x000C8000
    78.8  #define VMXASSIST_PHYSICAL_ADDRESS    0x000D0000
    78.9  #define ROMBIOS_PHYSICAL_ADDRESS      0x000F0000
   78.10  
   78.11 @@ -279,6 +280,27 @@ static void pci_setup(void)
   78.12      }
   78.13  }
   78.14  
   78.15 +static 
   78.16 +int must_load_nic(void) 
   78.17 +{
   78.18 +    /* If the network card is in the boot order, load the Etherboot 
   78.19 +     * option ROM.  Read the boot order bytes from CMOS and check 
   78.20 +     * if any of them are 0x4. */
   78.21 +    uint8_t boot_order;
   78.22 +
   78.23 +    /* Read CMOS register 0x3d (boot choices 0 and 1) */
   78.24 +    outb(0x70, 0x3d);
   78.25 +    boot_order = inb(0x71);
   78.26 +    if ( (boot_order & 0xf) == 0x4 || (boot_order & 0xf0) == 0x40 ) 
   78.27 +        return 1;
   78.28 +    /* Read CMOS register 0x38 (boot choice 2 and FDD test flag) */
   78.29 +    outb(0x70, 0x38);
   78.30 +    boot_order = inb(0x71);
   78.31 +    if ( (boot_order & 0xf0) == 0x40 ) 
   78.32 +        return 1;
   78.33 +    return 0;
   78.34 +}
   78.35 +
   78.36  int main(void)
   78.37  {
   78.38      int acpi_sz;
   78.39 @@ -312,6 +334,13 @@ int main(void)
   78.40                 vgabios_stdvga, sizeof(vgabios_stdvga));
   78.41      }
   78.42  
   78.43 +    if ( must_load_nic() )
   78.44 +    {
   78.45 +        printf("Loading ETHERBOOT ...\n");
   78.46 +        memcpy((void *)ETHERBOOT_PHYSICAL_ADDRESS,
   78.47 +               etherboot, sizeof(etherboot));
   78.48 +    }
   78.49 +
   78.50      if ( get_acpi_enabled() != 0 )
   78.51      {
   78.52          printf("Loading ACPI ...\n");
    79.1 --- a/tools/firmware/hvmloader/mp_tables.c	Wed Jan 10 08:00:50 2007 -0700
    79.2 +++ b/tools/firmware/hvmloader/mp_tables.c	Wed Jan 10 08:40:47 2007 -0700
    79.3 @@ -222,7 +222,7 @@ void fill_mp_config_table(struct mp_conf
    79.4  void fill_mp_proc_entry(struct mp_proc_entry *mppe, int vcpu_id)
    79.5  {
    79.6      mppe->type = ENTRY_TYPE_PROCESSOR;
    79.7 -    mppe->lapic_id = vcpu_id + 1;
    79.8 +    mppe->lapic_id = LAPIC_ID(vcpu_id);
    79.9      mppe->lapic_version = 0x11;
   79.10      mppe->cpu_flags = CPU_FLAG_ENABLED;
   79.11      if ( vcpu_id == 0 )
   79.12 @@ -373,7 +373,7 @@ void create_mp_tables(void)
   79.13      {
   79.14          if ( i == 2 ) continue; /* skip the slave PIC connection */
   79.15          fill_mp_io_intr_entry((struct mp_io_intr_entry *)p, 
   79.16 -                              BUS_ID_ISA, i, IOAPIC_ID, i);
   79.17 +                              BUS_ID_ISA, i, IOAPIC_ID, (i == 0) ? 2 : i);
   79.18          p += sizeof(struct mp_io_intr_entry);
   79.19      }
   79.20  
    80.1 --- a/tools/firmware/rombios/rombios.c	Wed Jan 10 08:00:50 2007 -0700
    80.2 +++ b/tools/firmware/rombios/rombios.c	Wed Jan 10 08:40:47 2007 -0700
    80.3 @@ -278,7 +278,6 @@ typedef unsigned short Bit16u;
    80.4  typedef unsigned short bx_bool;
    80.5  typedef unsigned long  Bit32u;
    80.6  
    80.7 -#if BX_USE_ATADRV
    80.8  
    80.9    void memsetb(seg,offset,value,count);
   80.10    void memcpyb(dseg,doffset,sseg,soffset,count);
   80.11 @@ -418,7 +417,6 @@ typedef unsigned long  Bit32u;
   80.12    ASM_END
   80.13    }
   80.14  #endif
   80.15 -#endif //BX_USE_ATADRV
   80.16  
   80.17    // read_dword and write_dword functions
   80.18    static Bit32u         read_dword();
   80.19 @@ -728,6 +726,8 @@ typedef struct {
   80.20    //     The EBDA structure should conform to 
   80.21    //     http://www.cybertrails.com/~fys/rombios.htm document
   80.22    //     I made the ata and cdemu structs begin at 0x121 in the EBDA seg
   80.23 +  // EBDA must be at most 768 bytes; it lives at 0x9fc00, and the boot 
   80.24 +  // device tables are at 0x9ff00 -- 0x9ffff
   80.25    typedef struct {
   80.26      unsigned char filler1[0x3D];
   80.27  
   80.28 @@ -885,7 +885,7 @@ static void           int14_function();
   80.29  static void           int15_function();
   80.30  static void           int16_function();
   80.31  static void           int17_function();
   80.32 -static Bit32u         int19_function();
   80.33 +static void           int19_function();
   80.34  static void           int1a_function();
   80.35  static void           int70_function();
   80.36  static void           int74_function();
   80.37 @@ -1435,10 +1435,17 @@ void
   80.38  copy_e820_table()
   80.39  {
   80.40    Bit8u nr_entries = read_byte(0x9000, 0x1e8);
   80.41 +  Bit32u base_mem;
   80.42    if (nr_entries > 32)
   80.43    	nr_entries = 32;
   80.44    write_word(0xe000, 0x8, nr_entries);
   80.45    memcpyb(0xe000, 0x10, 0x9000, 0x2d0, nr_entries * 0x14);
   80.46 +  /* Report the proper base memory size at address 0x0413: otherwise
   80.47 +   * non-e820 code will clobber things if BASE_MEM_IN_K is bigger than
   80.48 +   * the first e820 entry.  Get the size by reading the second 64bit 
   80.49 +   * field of the first e820 slot. */ 
   80.50 +  base_mem = read_dword(0x9000, 0x2d0 + 8);
   80.51 +  write_word(0x40, 0x13, base_mem >> 10);
   80.52  }
   80.53  #endif /* HVMASSIST */
   80.54  
   80.55 @@ -1847,28 +1854,100 @@ print_bios_banner()
   80.56    printf("\n");
   80.57  }
   80.58  
   80.59 +
   80.60 +//--------------------------------------------------------------------------
   80.61 +// BIOS Boot Specification 1.0.1 compatibility
   80.62 +//
   80.63 +// Very basic support for the BIOS Boot Specification, which allows expansion 
   80.64 +// ROMs to register themselves as boot devices, instead of just stealing the 
   80.65 +// INT 19h boot vector.
   80.66 +// 
   80.67 +// This is a hack: to do it properly requires a proper PnP BIOS and we aren't
   80.68 +// one; we just lie to the option ROMs to make them behave correctly. 
   80.69 +// We also don't support letting option ROMs register as bootable disk 
   80.70 +// drives (BCVs), only as bootable devices (BEVs). 
   80.71 +//
   80.72 +// http://www.phoenix.com/en/Customer+Services/White+Papers-Specs/pc+industry+specifications.htm
   80.73 +//--------------------------------------------------------------------------
   80.74 +
   80.75 +/* 256 bytes at 0x9ff00 -- 0x9ffff is used for the IPL boot table. */
   80.76 +#define IPL_SEG              0x9ff0
   80.77 +#define IPL_TABLE_OFFSET     0x0000
   80.78 +#define IPL_TABLE_ENTRIES    8
   80.79 +#define IPL_COUNT_OFFSET     0x0080  /* u16: number of valid table entries */
   80.80 +#define IPL_SEQUENCE_OFFSET  0x0082  /* u16: next boot device */
   80.81 +
   80.82 +struct ipl_entry {
   80.83 +  Bit16u type;
   80.84 +  Bit16u flags;
   80.85 +  Bit32u vector;
   80.86 +  Bit32u description;
   80.87 +  Bit32u reserved;
   80.88 +};
   80.89 +
   80.90 +static void 
   80.91 +init_boot_vectors() 
   80.92 +{
   80.93 +  struct ipl_entry e; 
   80.94 +  Bit16u count = 0;
   80.95 +  Bit16u ss = get_SS();
   80.96 +
   80.97 +  /* Clear out the IPL table. */
   80.98 +  memsetb(IPL_SEG, IPL_TABLE_OFFSET, 0, 0xff);
   80.99 +
  80.100 +  /* Floppy drive */
  80.101 +  e.type = 1; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0;
  80.102 +  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
  80.103 +  count++;
  80.104 +
  80.105 +  /* First HDD */
  80.106 +  e.type = 2; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0;
  80.107 +  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
  80.108 +  count++;
  80.109 +
  80.110 +#if BX_ELTORITO_BOOT
  80.111 +  /* CDROM */
  80.112 +  e.type = 3; e.flags = 0; e.vector = 0; e.description = 0; e.reserved = 0;
  80.113 +  memcpyb(IPL_SEG, IPL_TABLE_OFFSET + count * sizeof (e), ss, &e, sizeof (e));
  80.114 +  count++;
  80.115 +#endif  
  80.116 +
  80.117 +  /* Remember how many devices we have */
  80.118 +  write_word(IPL_SEG, IPL_COUNT_OFFSET, count);
  80.119 +  /* Not tried booting anything yet */
  80.120 +  write_word(IPL_SEG, IPL_SEQUENCE_OFFSET, 0xffff);
  80.121 +}
  80.122 +
  80.123 +static Bit8u
  80.124 +get_boot_vector(i, e)
  80.125 +Bit16u i; struct ipl_entry *e; 
  80.126 +{
  80.127 +  Bit16u count;
  80.128 +  Bit16u ss = get_SS();
  80.129 +  /* Get the count of boot devices, and refuse to overrun the array */
  80.130 +  count = read_word(IPL_SEG, IPL_COUNT_OFFSET);
  80.131 +  if (i >= count) return 0;
  80.132 +  /* OK to read this device */
  80.133 +  memcpyb(ss, e, IPL_SEG, IPL_TABLE_OFFSET + i * sizeof (*e), sizeof (*e));
  80.134 +  return 1;
  80.135 +}
  80.136 +
  80.137 +
  80.138  //--------------------------------------------------------------------------
  80.139  // print_boot_device
  80.140  //   displays the boot device
  80.141  //--------------------------------------------------------------------------
  80.142  
  80.143 -static char drivetypes[][10]={"Floppy","Hard Disk","CD-Rom"};
  80.144 +static char drivetypes[][10]={"", "Floppy","Hard Disk","CD-Rom", "Network"};
  80.145  
  80.146  void
  80.147 -print_boot_device(cdboot, drive)
  80.148 -  Bit8u cdboot; Bit16u drive;
  80.149 +print_boot_device(type)
  80.150 +  Bit16u type;
  80.151  {
  80.152 -  Bit8u i;
  80.153 -
  80.154 -  // cdboot contains 0 if floppy/harddisk, 1 otherwise
  80.155 -  // drive contains real/emulated boot drive
  80.156 -
  80.157 -  if(cdboot)i=2;                    // CD-Rom
  80.158 -  else if((drive&0x0080)==0x00)i=0; // Floppy
  80.159 -  else if((drive&0x0080)==0x80)i=1; // Hard drive
  80.160 -  else return;
  80.161 -  
  80.162 -  printf("Booting from %s...\n",drivetypes[i]);
  80.163 +  /* NIC appears as type 0x80 */ 
  80.164 +  if (type == 0x80 ) type = 0x4;
  80.165 +  if (type == 0 || type > 0x4) BX_PANIC("Bad drive type\n"); 
  80.166 +  printf("Booting from %s...\n", drivetypes[type]);
  80.167  }
  80.168  
  80.169  //--------------------------------------------------------------------------
  80.170 @@ -1876,29 +1955,20 @@ print_boot_device(cdboot, drive)
  80.171  //   displays the reason why boot failed
  80.172  //--------------------------------------------------------------------------
  80.173    void
  80.174 -print_boot_failure(cdboot, drive, reason, lastdrive)
  80.175 -  Bit8u cdboot; Bit8u drive; Bit8u lastdrive;
  80.176 +print_boot_failure(type, reason)
  80.177 +  Bit16u type; Bit8u reason;
  80.178  {
  80.179 -  Bit16u drivenum = drive&0x7f;
  80.180 -
  80.181 -  // cdboot: 1 if boot from cd, 0 otherwise
  80.182 -  // drive : drive number
  80.183 -  // reason: 0 signature check failed, 1 read error
  80.184 -  // lastdrive: 1 boot drive is the last one in boot sequence
  80.185 - 
  80.186 -  if (cdboot)
  80.187 -    bios_printf(BIOS_PRINTF_INFO | BIOS_PRINTF_SCREEN, "Boot from %s failed\n",drivetypes[2]);
  80.188 -  else if (drive & 0x80)
  80.189 -    bios_printf(BIOS_PRINTF_INFO | BIOS_PRINTF_SCREEN, "Boot from %s %d failed\n", drivetypes[1],drivenum);
  80.190 +  if (type == 0 || type > 0x3) BX_PANIC("Bad drive type\n"); 
  80.191 +
  80.192 +  printf("Boot from %s failed", drivetypes[type]);
  80.193 +  if (type < 4) {
  80.194 +    /* Report the reason too */
  80.195 +  if (reason==0) 
  80.196 +    printf(": not a bootable disk");
  80.197    else
  80.198 -    bios_printf(BIOS_PRINTF_INFO | BIOS_PRINTF_SCREEN, "Boot from %s %d failed\n", drivetypes[0],drivenum);
  80.199 -
  80.200 -  if (lastdrive==1) {
  80.201 -    if (reason==0)
  80.202 -      BX_PANIC("Not a bootable disk\n");
  80.203 -    else
  80.204 -      BX_PANIC("Could not read the boot disk\n");
  80.205 +    printf(": could not read the boot disk");
  80.206    }
  80.207 +  printf("\n");
  80.208  }
  80.209  
  80.210  //--------------------------------------------------------------------------
  80.211 @@ -7546,19 +7616,19 @@ int17_function(regs, ds, iret_addr)
  80.212    }
  80.213  }
  80.214  
  80.215 -// returns bootsegment in ax, drive in bl
  80.216 -  Bit32u 
  80.217 -int19_function(bseqnr)
  80.218 -Bit8u bseqnr;
  80.219 +void
  80.220 +int19_function(seq_nr)
  80.221 +Bit16u seq_nr;
  80.222  {
  80.223    Bit16u ebda_seg=read_word(0x0040,0x000E);
  80.224 -  Bit16u bootseq;
  80.225 +  Bit16u bootdev;
  80.226    Bit8u  bootdrv;
  80.227 -  Bit8u  bootcd;
  80.228    Bit8u  bootchk;
  80.229    Bit16u bootseg;
  80.230 +  Bit16u bootip;
  80.231    Bit16u status;
  80.232 -  Bit8u  lastdrive=0;
  80.233 +
  80.234 +  struct ipl_entry e;
  80.235  
  80.236    // if BX_ELTORITO_BOOT is not defined, old behavior
  80.237    //   check bit 5 in CMOS reg 0x2d.  load either 0x00 or 0x80 into DL
  80.238 @@ -7575,62 +7645,54 @@ Bit8u bseqnr;
  80.239    //     0x01 : first floppy 
  80.240    //     0x02 : first harddrive
  80.241    //     0x03 : first cdrom
  80.242 +  //     0x04 - 0x0f : PnP expansion ROMs (e.g. Etherboot)
  80.243    //     else : boot failure
  80.244  
  80.245    // Get the boot sequence
  80.246  #if BX_ELTORITO_BOOT
  80.247 -  bootseq=inb_cmos(0x3d);
  80.248 -  bootseq|=((inb_cmos(0x38) & 0xf0) << 4);
  80.249 -
  80.250 -  if (bseqnr==2) bootseq >>= 4;
  80.251 -  if (bseqnr==3) bootseq >>= 8;
  80.252 -  if (bootseq<0x10) lastdrive = 1;
  80.253 -  bootdrv=0x00; bootcd=0;
  80.254 -  switch(bootseq & 0x0f) {
  80.255 -    case 0x01: bootdrv=0x00; bootcd=0; break;
  80.256 -    case 0x02: bootdrv=0x80; bootcd=0; break;
  80.257 -    case 0x03: bootdrv=0x00; bootcd=1; break;
  80.258 -    default:   return 0x00000000;
  80.259 -    }
  80.260 -#else
  80.261 -  bootseq=inb_cmos(0x2d);
  80.262 -
  80.263 -  if (bseqnr==2) {
  80.264 -    bootseq ^= 0x20;
  80.265 -    lastdrive = 1;
  80.266 +  bootdev = inb_cmos(0x3d);
  80.267 +  bootdev |= ((inb_cmos(0x38) & 0xf0) << 4);
  80.268 +  bootdev >>= 4 * seq_nr;
  80.269 +  bootdev &= 0xf;
  80.270 +  if (bootdev == 0) BX_PANIC("No bootable device.\n");
  80.271 +  
  80.272 +  /* Translate from CMOS runes to an IPL table offset by subtracting 1 */
  80.273 +  bootdev -= 1;
  80.274 +#else  
  80.275 +  if (seq_nr ==2) BX_PANIC("No more boot devices.");
  80.276 +  if (!!(inb_cmos(0x2d) & 0x20) ^ (seq_nr == 1)) 
  80.277 +      /* Boot from floppy if the bit is set or it's the second boot */
  80.278 +    bootdev = 0x00;
  80.279 +  else 
  80.280 +    bootdev = 0x01;
  80.281 +#endif
  80.282 +
  80.283 +  /* Read the boot device from the IPL table */
  80.284 +  if (get_boot_vector(bootdev, &e) == 0) {
  80.285 +    BX_INFO("Invalid boot device (0x%x)\n", bootdev);
  80.286 +    return;
  80.287    }
  80.288 -  bootdrv=0x00; bootcd=0;
  80.289 -  if((bootseq&0x20)==0) bootdrv=0x80;
  80.290 -#endif // BX_ELTORITO_BOOT
  80.291 -
  80.292 -#if BX_ELTORITO_BOOT
  80.293 -  // We have to boot from cd
  80.294 -  if (bootcd != 0) {
  80.295 -    status = cdrom_boot();
  80.296 -
  80.297 -    // If failure
  80.298 -    if ( (status & 0x00ff) !=0 ) {
  80.299 -      print_cdromboot_failure(status);
  80.300 -      print_boot_failure(bootcd, bootdrv, 1, lastdrive);
  80.301 -      return 0x00000000;
  80.302 -      }
  80.303 -
  80.304 -    bootseg = read_word(ebda_seg,&EbdaData->cdemu.load_segment);
  80.305 -    bootdrv = (Bit8u)(status>>8);
  80.306 -    }
  80.307 -
  80.308 -#endif // BX_ELTORITO_BOOT
  80.309 -
  80.310 -  // We have to boot from harddisk or floppy
  80.311 -  if (bootcd == 0) {
  80.312 -    bootseg=0x07c0;
  80.313 +
  80.314 +  /* Do the loading, and set up vector as a far pointer to the boot
  80.315 +   * address, and bootdrv as the boot drive */
  80.316 +  print_boot_device(e.type);
  80.317 +
  80.318 +  switch(e.type) {
  80.319 +  case 0x01: /* FDD */
  80.320 +  case 0x02: /* HDD */
  80.321 +
  80.322 +    bootdrv = (e.type == 0x02) ? 0x80 : 0x00;
  80.323 +    bootseg = 0x07c0;
  80.324 +    status = 0;
  80.325  
  80.326  ASM_START
  80.327      push bp
  80.328      mov  bp, sp
  80.329 -
  80.330 -    mov  ax, #0x0000
  80.331 -    mov  _int19_function.status + 2[bp], ax
  80.332 +    push ax
  80.333 +    push bx
  80.334 +    push cx
  80.335 +    push dx
  80.336 +
  80.337      mov  dl, _int19_function.bootdrv + 2[bp]
  80.338      mov  ax, _int19_function.bootseg + 2[bp]
  80.339      mov  es, ax         ;; segment
  80.340 @@ -7646,43 +7708,83 @@ ASM_START
  80.341      mov  _int19_function.status + 2[bp], ax
  80.342  
  80.343  int19_load_done:
  80.344 +    pop  dx
  80.345 +    pop  cx
  80.346 +    pop  bx
  80.347 +    pop  ax
  80.348      pop  bp
  80.349  ASM_END
  80.350      
  80.351      if (status != 0) {
  80.352 -      print_boot_failure(bootcd, bootdrv, 1, lastdrive);
  80.353 -      return 0x00000000;
  80.354 +      print_boot_failure(e.type, 1);
  80.355 +      return;
  80.356 +    }
  80.357 +
  80.358 +    /* Always check the signature on a HDD boot sector; on FDD, only do
  80.359 +     * the check if the CMOS doesn't tell us to skip it */
  80.360 +    if (e.type != 0x00 || !((inb_cmos(0x38) & 0x01))) {
  80.361 +      if (read_word(bootseg,0x1fe) != 0xaa55) {
  80.362 +        print_boot_failure(e.type, 0);
  80.363 +        return;
  80.364        }
  80.365      }
  80.366  
  80.367 -  // check signature if instructed by cmos reg 0x38, only for floppy
  80.368 -  // bootchk = 1 : signature check disabled
  80.369 -  // bootchk = 0 : signature check enabled
  80.370 -  if (bootdrv != 0) bootchk = 0;
  80.371 -  else bootchk = inb_cmos(0x38) & 0x01;
  80.372 +    /* Canonicalize bootseg:bootip */
  80.373 +    bootip = (bootseg & 0x0fff) << 4;
  80.374 +    bootseg &= 0xf000;
  80.375 +  break;
  80.376  
  80.377  #if BX_ELTORITO_BOOT
  80.378 -  // if boot from cd, no signature check
  80.379 -  if (bootcd != 0)
  80.380 -    bootchk = 1;
  80.381 -#endif // BX_ELTORITO_BOOT
  80.382 -
  80.383 -  if (bootchk == 0) {
  80.384 -    if (read_word(bootseg,0x1fe) != 0xaa55) {
  80.385 -      print_boot_failure(bootcd, bootdrv, 0, lastdrive);
  80.386 -      return 0x00000000;
  80.387 -      }
  80.388 +  case 0x03: /* CD-ROM */
  80.389 +    status = cdrom_boot();
  80.390 +
  80.391 +    // If failure
  80.392 +    if ( (status & 0x00ff) !=0 ) {
  80.393 +      print_cdromboot_failure(status);
  80.394 +      print_boot_failure(e.type, 1);
  80.395 +      return;
  80.396      }
  80.397 +
  80.398 +    bootdrv = (Bit8u)(status>>8);
  80.399 +    bootseg = read_word(ebda_seg,&EbdaData->cdemu.load_segment);
  80.400 +    /* Canonicalize bootseg:bootip */
  80.401 +    bootip = (bootseg & 0x0fff) << 4;
  80.402 +    bootseg &= 0xf000;
  80.403 +    break;
  80.404 +#endif
  80.405 +
  80.406 +  case 0x80: /* Expansion ROM with a Bootstrap Entry Vector (a far pointer) */
  80.407 +    bootseg = e.vector >> 16;
  80.408 +    bootip = e.vector & 0xffff;
  80.409 +    break;
  80.410 +
  80.411 +  default: return;
  80.412 +  }
  80.413 +
  80.414 +  /* Debugging info */
  80.415 +  printf("Booting from %x:%x\n", bootseg, bootip);
  80.416    
  80.417 -#if BX_ELTORITO_BOOT
  80.418 -  // Print out the boot string
  80.419 -  print_boot_device(bootcd, bootdrv);
  80.420 -#else // BX_ELTORITO_BOOT
  80.421 -  print_boot_device(0, bootdrv);
  80.422 -#endif // BX_ELTORITO_BOOT
  80.423 -
  80.424 -  // return the boot segment
  80.425 -  return (((Bit32u)bootdrv) << 16) + bootseg;
  80.426 +  /* Jump to the boot vector */
  80.427 +ASM_START
  80.428 +    mov  bp, sp
  80.429 +    ;; Build an iret stack frame that will take us to the boot vector.
  80.430 +    ;; iret pops ip, then cs, then flags, so push them in the opposite order.
  80.431 +    pushf
  80.432 +    mov  ax, _int19_function.bootseg + 0[bp] 
  80.433 +    push ax
  80.434 +    mov  ax, _int19_function.bootip + 0[bp] 
  80.435 +    push ax
  80.436 +    ;; Set the magic number in ax and the boot drive in dl.
  80.437 +    mov  ax, #0xaa55
  80.438 +    mov  dl, _int19_function.bootdrv + 0[bp]
  80.439 +    ;; Zero some of the other registers.
  80.440 +    xor  bx, bx
  80.441 +    mov  ds, bx
  80.442 +    mov  es, bx
  80.443 +    mov  bp, bx
  80.444 +    ;; Go!
  80.445 +    iret
  80.446 +ASM_END
  80.447  }
  80.448  
  80.449    void
  80.450 @@ -8139,14 +8241,29 @@ int13_out:
  80.451    popa
  80.452    iret 
  80.453  
  80.454 -
  80.455  ;----------
  80.456  ;- INT18h -
  80.457  ;----------
  80.458 -int18_handler: ;; Boot Failure routing
  80.459 -  call _int18_panic_msg
  80.460 -  hlt
  80.461 -  iret
  80.462 +int18_handler: ;; Boot Failure recovery: try the next device.
  80.463 +
  80.464 +  ;; Reset SP and SS
  80.465 +  mov  ax, #0xfffe
  80.466 +  mov  sp, ax
  80.467 +  xor  ax, ax
  80.468 +  mov  ss, ax
  80.469 +
  80.470 +  ;; Get the boot sequence number out of the IPL memory
  80.471 +  mov  bx, #IPL_SEG 
  80.472 +  mov  ds, bx                     ;; Set segment
  80.473 +  mov  bx, IPL_SEQUENCE_OFFSET    ;; BX is now the sequence number
  80.474 +  inc  bx                         ;; ++
  80.475 +  mov  IPL_SEQUENCE_OFFSET, bx    ;; Write it back
  80.476 +  mov  ds, ax                     ;; and reset the segment to zero. 
  80.477 +
  80.478 +  ;; Carry on in the INT 19h handler, using the new sequence number
  80.479 +  push bx
  80.480 +
  80.481 +  jmp  int19_next_boot
  80.482  
  80.483  ;----------
  80.484  ;- INT19h -
  80.485 @@ -8154,62 +8271,32 @@ int18_handler: ;; Boot Failure routing
  80.486  int19_relocated: ;; Boot function, relocated
  80.487  
  80.488    ;; int19 was beginning to be really complex, so now it
  80.489 -  ;; just calls an C function, that does the work
  80.490 -  ;; it returns in BL the boot drive, and in AX the boot segment
  80.491 -  ;; the boot segment will be 0x0000 if something has failed
  80.492 +  ;; just calls a C function that does the work
  80.493  
  80.494    push bp
  80.495    mov  bp, sp
  80.496 -
  80.497 -  ;; drop ds
  80.498 +  
  80.499 +  ;; Reset SS and SP
  80.500 +  mov  ax, #0xfffe
  80.501 +  mov  sp, ax
  80.502    xor  ax, ax
  80.503 -  mov  ds, ax
  80.504 -
  80.505 -  ;; 1st boot device
  80.506 -  mov  ax, #0x0001
  80.507 +  mov  ss, ax
  80.508 +
  80.509 +  ;; Start from the first boot device (0, in AX)
  80.510 +  mov  bx, #IPL_SEG 
  80.511 +  mov  ds, bx                     ;; Set segment to write to the IPL memory
  80.512 +  mov  IPL_SEQUENCE_OFFSET, ax    ;; Save the sequence number 
  80.513 +  mov  ds, ax                     ;; and reset the segment.
  80.514 +
  80.515    push ax
  80.516 -  call _int19_function
  80.517 -  inc  sp
  80.518 -  inc  sp
  80.519 -  ;; bl contains the boot drive
  80.520 -  ;; ax contains the boot segment or 0 if failure
  80.521 -
  80.522 -  test       ax, ax  ;; if ax is 0 try next boot device
  80.523 -  jnz        boot_setup
  80.524 -
  80.525 -  ;; 2nd boot device
  80.526 -  mov  ax, #0x0002
  80.527 -  push ax
  80.528 +
  80.529 +int19_next_boot:
  80.530 +
  80.531 +  ;; Call the C code for the next boot device
  80.532    call _int19_function
  80.533 -  inc  sp
  80.534 -  inc  sp
  80.535 -  test       ax, ax  ;; if ax is 0 try next boot device
  80.536 -  jnz        boot_setup
  80.537 -
  80.538 -  ;; 3rd boot device
  80.539 -  mov  ax, #0x0003
  80.540 -  push ax
  80.541 -  call _int19_function
  80.542 -  inc  sp
  80.543 -  inc  sp
  80.544 -  test       ax, ax  ;; if ax is 0 call int18
  80.545 -  jz         int18_handler
  80.546 -
  80.547 -boot_setup:
  80.548 -  mov dl,    bl      ;; set drive so guest os find it
  80.549 -  shl eax,   #0x04   ;; convert seg to ip
  80.550 -  mov 2[bp], ax      ;; set ip
  80.551 -
  80.552 -  shr eax,   #0x04   ;; get cs back
  80.553 -  and ax,    #0xF000 ;; remove what went in ip
  80.554 -  mov 4[bp], ax      ;; set cs
  80.555 -  xor ax,    ax
  80.556 -  mov es,    ax      ;; set es to zero fixes [ 549815 ]
  80.557 -  mov [bp],  ax      ;; set bp to zero
  80.558 -  mov ax,    #0xaa55 ;; set ok flag
  80.559 -
  80.560 -  pop bp
  80.561 -  iret               ;; Beam me up Scotty
  80.562 +
  80.563 +  ;; Boot failed: invoke the boot recovery function
  80.564 +  int  #0x18
  80.565  
  80.566  ;----------
  80.567  ;- INT1Ch -
  80.568 @@ -9387,6 +9474,15 @@ checksum_loop:
  80.569    pop  ax
  80.570    ret
  80.571  
  80.572 +
  80.573 +;; We need a copy of this string, but we are not actually a PnP BIOS, 
  80.574 +;; so make sure it is *not* aligned, so OSes will not see it if they scan.
  80.575 +.align 16
  80.576 +  db 0
  80.577 +pnp_string:
  80.578 +  .ascii "$PnP"
  80.579 +
  80.580 +
  80.581  rom_scan:
  80.582    ;; Scan for existence of valid expansion ROMS.
  80.583    ;;   Video ROM:   from 0xC0000..0xC7FFF in 2k increments
  80.584 @@ -9421,9 +9517,17 @@ block_count_rounded:
  80.585    xor  bx, bx   ;; Restore DS back to 0000:
  80.586    mov  ds, bx
  80.587    push ax       ;; Save AX
  80.588 +  push di       ;; Save DI
  80.589    ;; Push addr of ROM entry point
  80.590    push cx       ;; Push seg
  80.591    push #0x0003  ;; Push offset
  80.592 +
  80.593 +  ;; Point ES:DI at "$PnP", which tells the ROM that we are a PnP BIOS.  
  80.594 +  ;; That should stop it grabbing INT 19h; we will use its BEV instead.
  80.595 +  mov  ax, #0xf000
  80.596 +  mov  es, ax
  80.597 +  lea  di, pnp_string 
  80.598 +
  80.599    mov  bp, sp   ;; Call ROM init routine using seg:off on stack
  80.600    db   0xff     ;; call_far ss:[bp+0]
  80.601    db   0x5e
  80.602 @@ -9431,6 +9535,38 @@ block_count_rounded:
  80.603    cli           ;; In case expansion ROM BIOS turns IF on
  80.604    add  sp, #2   ;; Pop offset value
  80.605    pop  cx       ;; Pop seg value (restore CX)
  80.606 +
  80.607 +  ;; Look at the ROM's PnP Expansion header.  Properly, we're supposed 
  80.608 +  ;; to init all the ROMs and then go back and build an IPL table of 
  80.609 +  ;; all the bootable devices, but we can get away with one pass.
  80.610 +  mov  ds, cx       ;; ROM base
  80.611 +  mov  bx, 0x001a   ;; 0x1A is the offset into ROM header that contains...
  80.612 +  mov  ax, [bx]     ;; the offset of PnP expansion header, where...
  80.613 +  cmp  ax, #0x5024  ;; we look for signature "$PnP"
  80.614 +  jne  no_bev
  80.615 +  mov  ax, 2[bx]
  80.616 +  cmp  ax, #0x506e 
  80.617 +  jne  no_bev
  80.618 +  mov  ax, 0x1a[bx] ;; 0x1A is also the offset into the expansion header of...
  80.619 +  cmp  ax, #0x0000  ;; the Bootstrap Entry Vector, or zero if there is none.
  80.620 +  je   no_bev
  80.621 +
  80.622 +  ;; Found a device that thinks it can boot the system.  Record its BEV.
  80.623 +  mov  bx, #IPL_SEG            ;; Go to the segment where the IPL table lives 
  80.624 +  mov  ds, bx
  80.625 +  mov  bx, IPL_COUNT_OFFSET    ;; Read the number of entries so far
  80.626 +  cmp  bx, #IPL_TABLE_ENTRIES
  80.627 +  je   no_bev                  ;; Get out if the table is full
  80.628 +  shl  bx, #0x4                ;; Turn count into offset (entries are 16 bytes)
  80.629 +  mov  0[bx], #0x80            ;; This entry is a BEV device
  80.630 +  mov  6[bx], cx               ;; Build a far pointer from the segment...
  80.631 +  mov  4[bx], ax               ;; and the offset
  80.632 +  shr  bx, #0x4                ;; Turn the offset back into a count
  80.633 +  inc  bx                      ;; We have one more entry now
  80.634 +  mov  IPL_COUNT_OFFSET, bx    ;; Remember that.
  80.635 +
  80.636 +no_bev:
  80.637 +  pop  di       ;; Restore DI
  80.638    pop  ax       ;; Restore AX
  80.639  rom_scan_increment:
  80.640    shl  ax, #5   ;; convert 512-bytes blocks to 16-byte increments
  80.641 @@ -9764,6 +9900,8 @@ post_default_ints:
  80.642    call smbios_init
  80.643  #endif
  80.644  
  80.645 +  call _init_boot_vectors
  80.646 +
  80.647    call rom_scan
  80.648  
  80.649    call _print_bios_banner 
    81.1 --- a/tools/firmware/vmxassist/vm86.c	Wed Jan 10 08:00:50 2007 -0700
    81.2 +++ b/tools/firmware/vmxassist/vm86.c	Wed Jan 10 08:40:47 2007 -0700
    81.3 @@ -297,7 +297,7 @@ getreg32(struct regs *regs, int r)
    81.4  	case 1: return regs->ecx;
    81.5  	case 2: return regs->edx;
    81.6  	case 3: return regs->ebx;
    81.7 -	case 4: return regs->esp;
    81.8 +	case 4: return regs->uesp;
    81.9  	case 5: return regs->ebp;
   81.10  	case 6: return regs->esi;
   81.11  	case 7: return regs->edi;
   81.12 @@ -319,10 +319,10 @@ getreg8(struct regs *regs, int r)
   81.13  	case 1: return regs->ecx & 0xFF; /* cl */
   81.14  	case 2: return regs->edx & 0xFF; /* dl */
   81.15  	case 3: return regs->ebx & 0xFF; /* bl */
   81.16 -	case 4: return (regs->esp >> 8) & 0xFF; /* ah */
   81.17 -	case 5: return (regs->ebp >> 8) & 0xFF; /* ch */
   81.18 -	case 6: return (regs->esi >> 8) & 0xFF; /* dh */
   81.19 -	case 7: return (regs->edi >> 8) & 0xFF; /* bh */
   81.20 +	case 4: return (regs->eax >> 8) & 0xFF; /* ah */
   81.21 +	case 5: return (regs->ecx >> 8) & 0xFF; /* ch */
   81.22 +	case 6: return (regs->edx >> 8) & 0xFF; /* dh */
   81.23 +	case 7: return (regs->ebx >> 8) & 0xFF; /* bh */
   81.24  	}
   81.25  	return ~0;
   81.26  }
   81.27 @@ -335,7 +335,7 @@ setreg32(struct regs *regs, int r, unsig
   81.28  	case 1: regs->ecx = v; break;
   81.29  	case 2: regs->edx = v; break;
   81.30  	case 3: regs->ebx = v; break;
   81.31 -	case 4: regs->esp = v; break;
   81.32 +	case 4: regs->uesp = v; break;
   81.33  	case 5: regs->ebp = v; break;
   81.34  	case 6: regs->esi = v; break;
   81.35  	case 7: regs->edi = v; break;
   81.36 @@ -357,10 +357,10 @@ setreg8(struct regs *regs, int r, unsign
   81.37  	case 1: regs->ecx = (regs->ecx & ~0xFF) | v; break;
   81.38  	case 2: regs->edx = (regs->edx & ~0xFF) | v; break;
   81.39  	case 3: regs->ebx = (regs->ebx & ~0xFF) | v; break;
   81.40 -	case 4: regs->esp = (regs->esp & ~0xFF00) | (v << 8); break;
   81.41 -	case 5: regs->ebp = (regs->ebp & ~0xFF00) | (v << 8); break;
   81.42 -	case 6: regs->esi = (regs->esi & ~0xFF00) | (v << 8); break;
   81.43 -	case 7: regs->edi = (regs->edi & ~0xFF00) | (v << 8); break;
   81.44 +	case 4: regs->eax = (regs->eax & ~0xFF00) | (v << 8); break;
   81.45 +	case 5: regs->ecx = (regs->ecx & ~0xFF00) | (v << 8); break;
   81.46 +	case 6: regs->edx = (regs->edx & ~0xFF00) | (v << 8); break;
   81.47 +	case 7: regs->ebx = (regs->ebx & ~0xFF00) | (v << 8); break;
   81.48  	}
   81.49  }
   81.50  
   81.51 @@ -961,9 +961,9 @@ protected_mode(struct regs *regs)
   81.52  
   81.53  	/* initialize jump environment to warp back to protected mode */
   81.54  	regs->uss = DATA_SELECTOR;
   81.55 -	regs->uesp = stack_top;
   81.56 +	regs->uesp = (unsigned long)stack_top;
   81.57  	regs->cs = CODE_SELECTOR;
   81.58 -	regs->eip = (unsigned) switch_to_protected_mode;
   81.59 +	regs->eip = (unsigned long)switch_to_protected_mode;
   81.60  
   81.61  	/* this should get us into 32-bit mode */
   81.62  }
    82.1 --- a/tools/ioemu/hw/pc.c	Wed Jan 10 08:00:50 2007 -0700
    82.2 +++ b/tools/ioemu/hw/pc.c	Wed Jan 10 08:40:47 2007 -0700
    82.3 @@ -168,6 +168,8 @@ static int get_bios_disk(char *boot_devi
    82.4              return 0x02;            /* hard drive */
    82.5          case 'd':
    82.6              return 0x03;            /* cdrom */
    82.7 +        case 'n':
    82.8 +            return 0x04;            /* network */
    82.9          }
   82.10      }
   82.11      return 0x00;                /* no device */
    83.1 --- a/tools/ioemu/hw/vga.c	Wed Jan 10 08:00:50 2007 -0700
    83.2 +++ b/tools/ioemu/hw/vga.c	Wed Jan 10 08:40:47 2007 -0700
    83.3 @@ -2002,7 +2002,10 @@ void vga_common_init(VGAState *s, Displa
    83.4      s->vram_shadow = (uint8_t *)((long)(s->vram_shadow + TARGET_PAGE_SIZE - 1)
    83.5                                   & ~(TARGET_PAGE_SIZE - 1));
    83.6  
    83.7 -    s->vram_ptr = qemu_malloc(vga_ram_size);
    83.8 +    /* Video RAM must be 128-bit aligned for SSE optimizations later */
    83.9 +    s->vram_alloc = qemu_malloc(vga_ram_size + 15);
   83.10 +    s->vram_ptr = (uint8_t *)((long)(s->vram_alloc + 15) & ~15L);
   83.11 +
   83.12      s->vram_offset = vga_ram_offset;
   83.13      s->vram_size = vga_ram_size;
   83.14      s->ds = ds;
   83.15 @@ -2126,7 +2129,7 @@ void *vga_update_vram(VGAState *s, void 
   83.16      }
   83.17  
   83.18      if (!vga_ram_base) {
   83.19 -        vga_ram_base = qemu_malloc(vga_ram_size);
   83.20 +        vga_ram_base = qemu_malloc(vga_ram_size + TARGET_PAGE_SIZE + 1);
   83.21          if (!vga_ram_base) {
   83.22              fprintf(stderr, "reallocate error\n");
   83.23              return NULL;
   83.24 @@ -2134,8 +2137,10 @@ void *vga_update_vram(VGAState *s, void 
   83.25      }
   83.26  
   83.27      /* XXX lock needed? */
   83.28 +    old_pointer = s->vram_alloc;
   83.29 +    s->vram_alloc = vga_ram_base;
   83.30 +    vga_ram_base = (uint8_t *)((long)(vga_ram_base + 15) & ~15L);
   83.31      memcpy(vga_ram_base, s->vram_ptr, vga_ram_size);
   83.32 -    old_pointer = s->vram_ptr;
   83.33      s->vram_ptr = vga_ram_base;
   83.34  
   83.35      return old_pointer;
    84.1 --- a/tools/ioemu/hw/vga_int.h	Wed Jan 10 08:00:50 2007 -0700
    84.2 +++ b/tools/ioemu/hw/vga_int.h	Wed Jan 10 08:40:47 2007 -0700
    84.3 @@ -78,6 +78,7 @@
    84.4  #define VGA_MAX_HEIGHT 2048
    84.5  
    84.6  #define VGA_STATE_COMMON                                                \
    84.7 +    uint8_t *vram_alloc;                                                \
    84.8      uint8_t *vram_ptr;                                                  \
    84.9      uint8_t *vram_shadow;                                               \
   84.10      unsigned long vram_offset;                                          \
    85.1 --- a/tools/ioemu/patches/domain-timeoffset	Wed Jan 10 08:00:50 2007 -0700
    85.2 +++ b/tools/ioemu/patches/domain-timeoffset	Wed Jan 10 08:40:47 2007 -0700
    85.3 @@ -1,7 +1,7 @@
    85.4  Index: ioemu/hw/mc146818rtc.c
    85.5  ===================================================================
    85.6 ---- ioemu.orig/hw/mc146818rtc.c	2006-12-08 18:36:31.000000000 +0000
    85.7 -+++ ioemu/hw/mc146818rtc.c	2006-12-08 18:36:36.000000000 +0000
    85.8 +--- ioemu.orig/hw/mc146818rtc.c	2006-12-20 15:21:33.000000000 +0000
    85.9 ++++ ioemu/hw/mc146818rtc.c	2006-12-20 15:21:50.000000000 +0000
   85.10  @@ -178,10 +178,27 @@
   85.11       }
   85.12   }
   85.13 @@ -46,8 +46,8 @@ Index: ioemu/hw/mc146818rtc.c
   85.14   static void rtc_copy_date(RTCState *s)
   85.15  Index: ioemu/hw/pc.c
   85.16  ===================================================================
   85.17 ---- ioemu.orig/hw/pc.c	2006-12-08 18:36:35.000000000 +0000
   85.18 -+++ ioemu/hw/pc.c	2006-12-08 18:36:36.000000000 +0000
   85.19 +--- ioemu.orig/hw/pc.c	2006-12-20 15:21:49.000000000 +0000
   85.20 ++++ ioemu/hw/pc.c	2006-12-20 15:21:50.000000000 +0000
   85.21  @@ -159,7 +159,7 @@
   85.22   }
   85.23   
   85.24 @@ -117,8 +117,8 @@ Index: ioemu/hw/pc.c
   85.25   QEMUMachine pc_machine = {
   85.26  Index: ioemu/vl.c
   85.27  ===================================================================
   85.28 ---- ioemu.orig/vl.c	2006-12-08 18:36:35.000000000 +0000
   85.29 -+++ ioemu/vl.c	2006-12-08 18:36:36.000000000 +0000
   85.30 +--- ioemu.orig/vl.c	2006-12-20 15:21:49.000000000 +0000
   85.31 ++++ ioemu/vl.c	2006-12-20 15:21:50.000000000 +0000
   85.32  @@ -163,6 +163,8 @@
   85.33   
   85.34   int xc_handle;
   85.35 @@ -162,7 +162,7 @@ Index: ioemu/vl.c
   85.36               }
   85.37           }
   85.38       }
   85.39 -@@ -6492,7 +6500,8 @@
   85.40 +@@ -6484,7 +6492,8 @@
   85.41   
   85.42       machine->init(ram_size, vga_ram_size, boot_device,
   85.43                     ds, fd_filename, snapshot,
   85.44 @@ -174,8 +174,8 @@ Index: ioemu/vl.c
   85.45       if (usb_enabled) {
   85.46  Index: ioemu/vl.h
   85.47  ===================================================================
   85.48 ---- ioemu.orig/vl.h	2006-12-08 18:36:35.000000000 +0000
   85.49 -+++ ioemu/vl.h	2006-12-08 18:36:36.000000000 +0000
   85.50 +--- ioemu.orig/vl.h	2006-12-20 15:21:49.000000000 +0000
   85.51 ++++ ioemu/vl.h	2006-12-20 15:21:50.000000000 +0000
   85.52  @@ -576,7 +576,7 @@
   85.53                                    int boot_device,
   85.54                DisplayState *ds, const char **fd_filename, int snapshot,
    86.1 --- a/tools/ioemu/patches/fix-interrupt-routing	Wed Jan 10 08:00:50 2007 -0700
    86.2 +++ b/tools/ioemu/patches/fix-interrupt-routing	Wed Jan 10 08:40:47 2007 -0700
    86.3 @@ -17,23 +17,21 @@ Signed-off-by: Keir Fraser <keir@xensour
    86.4  
    86.5  Index: ioemu/Makefile.target
    86.6  ===================================================================
    86.7 ---- ioemu.orig/Makefile.target	2006-12-08 18:21:56.000000000 +0000
    86.8 -+++ ioemu/Makefile.target	2006-12-08 18:22:35.000000000 +0000
    86.9 -@@ -298,7 +298,7 @@
   86.10 +--- ioemu.orig/Makefile.target	2006-12-20 15:04:55.000000000 +0000
   86.11 ++++ ioemu/Makefile.target	2006-12-20 15:08:16.000000000 +0000
   86.12 +@@ -296,9 +296,9 @@
   86.13 + 
   86.14 + # qemu-dm objects
   86.15   ifeq ($(ARCH),ia64)
   86.16 - LIBOBJS=helper2.o exec-dm.o i8259-dm.o
   86.17 +-LIBOBJS=helper2.o exec-dm.o i8259-dm.o
   86.18 ++LIBOBJS=helper2.o exec-dm.o i8259-dm.o piix_pci-dm.o
   86.19   else
   86.20  -LIBOBJS=helper2.o exec-dm.o i8259-dm.o rtc-dm.o
   86.21  +LIBOBJS=helper2.o exec-dm.o i8259-dm.o rtc-dm.o piix_pci-dm.o
   86.22   endif
   86.23   
   86.24   all: $(PROGS)
   86.25 -@@ -360,11 +360,11 @@
   86.26 - # Hardware support
   86.27 - VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
   86.28 - ifeq ($(ARCH),ia64)
   86.29 --VL_OBJS+= fdc.o mc146818rtc.o serial.o pc.o
   86.30 -+VL_OBJS+= fdc.o mc146818rtc.o serial.o pc.o piix_pci.o
   86.31 +@@ -364,7 +364,7 @@
   86.32   else
   86.33   VL_OBJS+= fdc.o serial.o pc.o
   86.34   endif
   86.35 @@ -44,8 +42,8 @@ Index: ioemu/Makefile.target
   86.36   VL_OBJS+= xenstore.o
   86.37  Index: ioemu/target-i386-dm/i8259-dm.c
   86.38  ===================================================================
   86.39 ---- ioemu.orig/target-i386-dm/i8259-dm.c	2006-12-08 18:21:36.000000000 +0000
   86.40 -+++ ioemu/target-i386-dm/i8259-dm.c	2006-12-08 18:22:35.000000000 +0000
   86.41 +--- ioemu.orig/target-i386-dm/i8259-dm.c	2006-12-20 15:04:54.000000000 +0000
   86.42 ++++ ioemu/target-i386-dm/i8259-dm.c	2006-12-20 15:04:55.000000000 +0000
   86.43  @@ -33,7 +33,7 @@
   86.44   
   86.45   void pic_set_irq_new(void *opaque, int irq, int level)
   86.46 @@ -58,7 +56,7 @@ Index: ioemu/target-i386-dm/i8259-dm.c
   86.47  Index: ioemu/target-i386-dm/piix_pci-dm.c
   86.48  ===================================================================
   86.49  --- /dev/null	1970-01-01 00:00:00.000000000 +0000
   86.50 -+++ ioemu/target-i386-dm/piix_pci-dm.c	2006-12-08 18:22:35.000000000 +0000
   86.51 ++++ ioemu/target-i386-dm/piix_pci-dm.c	2006-12-20 15:08:13.000000000 +0000
   86.52  @@ -0,0 +1,397 @@
   86.53  +/*
   86.54  + * QEMU i440FX/PIIX3 PCI Bridge Emulation
    87.1 --- a/tools/ioemu/patches/ioemu-ia64	Wed Jan 10 08:00:50 2007 -0700
    87.2 +++ b/tools/ioemu/patches/ioemu-ia64	Wed Jan 10 08:40:47 2007 -0700
    87.3 @@ -1,7 +1,7 @@
    87.4  Index: ioemu/hw/iommu.c
    87.5  ===================================================================
    87.6 ---- ioemu.orig/hw/iommu.c	2006-12-08 02:02:07.000000000 +0000
    87.7 -+++ ioemu/hw/iommu.c	2006-12-08 02:02:34.000000000 +0000
    87.8 +--- ioemu.orig/hw/iommu.c	2006-12-20 15:04:54.000000000 +0000
    87.9 ++++ ioemu/hw/iommu.c	2006-12-20 15:04:54.000000000 +0000
   87.10  @@ -82,7 +82,11 @@
   87.11   #define IOPTE_VALID         0x00000002 /* IOPTE is valid */
   87.12   #define IOPTE_WAZ           0x00000001 /* Write as zeros */
   87.13 @@ -16,8 +16,8 @@ Index: ioemu/hw/iommu.c
   87.14   
   87.15  Index: ioemu/cpu-all.h
   87.16  ===================================================================
   87.17 ---- ioemu.orig/cpu-all.h	2006-12-08 02:02:07.000000000 +0000
   87.18 -+++ ioemu/cpu-all.h	2006-12-08 02:02:34.000000000 +0000
   87.19 +--- ioemu.orig/cpu-all.h	2006-12-20 15:04:54.000000000 +0000
   87.20 ++++ ioemu/cpu-all.h	2006-12-20 15:04:54.000000000 +0000
   87.21  @@ -835,6 +835,31 @@
   87.22                   :"=m" (*(volatile long *)addr)
   87.23                   :"dIr" (nr));
   87.24 @@ -52,13 +52,17 @@ Index: ioemu/cpu-all.h
   87.25   /* memory API */
   87.26  Index: ioemu/vl.c
   87.27  ===================================================================
   87.28 ---- ioemu.orig/vl.c	2006-12-08 02:02:28.000000000 +0000
   87.29 -+++ ioemu/vl.c	2006-12-08 02:02:34.000000000 +0000
   87.30 -@@ -6137,6 +6137,11 @@
   87.31 +--- ioemu.orig/vl.c	2006-12-20 15:04:54.000000000 +0000
   87.32 ++++ ioemu/vl.c	2006-12-20 15:12:00.000000000 +0000
   87.33 +@@ -6137,6 +6137,15 @@
   87.34               exit(1);
   87.35       }
   87.36   
   87.37  +#if defined (__ia64__)
   87.38 ++    /* ram_size passed from xend has added on GFW memory,
   87.39 ++       so we must subtract it here */
   87.40 ++    ram_size -= 16 * MEM_M;
   87.41 ++
   87.42  +    if (ram_size > MMIO_START)
   87.43  +        ram_size += 1 * MEM_G; /* skip 3G-4G MMIO, LEGACY_IO_SPACE etc. */
   87.44  +#endif
   87.45 @@ -66,7 +70,7 @@ Index: ioemu/vl.c
   87.46       /* init the memory */
   87.47       phys_ram_size = ram_size + vga_ram_size + bios_size;
   87.48   
   87.49 -@@ -6161,6 +6166,7 @@
   87.50 +@@ -6161,6 +6170,7 @@
   87.51           exit(-1);
   87.52       }
   87.53   
   87.54 @@ -74,41 +78,29 @@ Index: ioemu/vl.c
   87.55       for ( i = 0; i < tmp_nr_pages; i++)
   87.56           page_array[i] = i;
   87.57   
   87.58 -@@ -6185,6 +6191,48 @@
   87.59 +@@ -6185,6 +6195,36 @@
   87.60   
   87.61       free(page_array);
   87.62   
   87.63  +#elif defined(__ia64__)
   87.64  +  
   87.65 -+    if (xc_ia64_get_pfn_list(xc_handle, domid, page_array,
   87.66 -+                             IO_PAGE_START >> PAGE_SHIFT, 3) != 3) {
   87.67 -+        fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
   87.68 -+        exit(-1);
   87.69 -+    }
   87.70 -+
   87.71  +    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
   87.72  +                                       PROT_READ|PROT_WRITE,
   87.73 -+                                       page_array[0]);
   87.74 -+
   87.75 -+    fprintf(logfile, "shared page at pfn:%lx, mfn: %016lx\n",
   87.76 -+            IO_PAGE_START >> PAGE_SHIFT, page_array[0]);
   87.77 ++                                       IO_PAGE_START >> PAGE_SHIFT);
   87.78  +
   87.79  +    buffered_io_page =xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
   87.80  +                                       PROT_READ|PROT_WRITE,
   87.81 -+                                       page_array[2]);
   87.82 -+    fprintf(logfile, "Buffered IO page at pfn:%lx, mfn: %016lx\n",
   87.83 -+            BUFFER_IO_PAGE_START >> PAGE_SHIFT, page_array[2]);
   87.84 ++                                       BUFFER_IO_PAGE_START >> PAGE_SHIFT);
   87.85  +
   87.86 -+    if (xc_ia64_get_pfn_list(xc_handle, domid,
   87.87 -+                             page_array, 0, nr_pages) != nr_pages) {
   87.88 -+        fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
   87.89 -+        exit(-1);
   87.90 -+    }
   87.91 -+
   87.92 ++    for (i = 0; i < tmp_nr_pages; i++)
   87.93 ++        page_array[i] = i;
   87.94 ++	
   87.95 ++    /* VTI will not use memory between 3G~4G, so we just pass a legal pfn
   87.96 ++       to make QEMU map continuous virtual memory space */
   87.97  +    if (ram_size > MMIO_START) {	
   87.98  +        for (i = 0 ; i < (MEM_G >> PAGE_SHIFT); i++)
   87.99  +            page_array[(MMIO_START >> PAGE_SHIFT) + i] =
  87.100 -+                page_array[(IO_PAGE_START >> PAGE_SHIFT) + 1];
  87.101 ++                (STORE_PAGE_START >> PAGE_SHIFT); 
  87.102  +    }
  87.103  +
  87.104  +    phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
  87.105 @@ -125,8 +117,8 @@ Index: ioemu/vl.c
  87.106       phys_ram_base = qemu_vmalloc(phys_ram_size);
  87.107  Index: ioemu/exec-all.h
  87.108  ===================================================================
  87.109 ---- ioemu.orig/exec-all.h	2006-12-08 02:02:07.000000000 +0000
  87.110 -+++ ioemu/exec-all.h	2006-12-08 02:02:34.000000000 +0000
  87.111 +--- ioemu.orig/exec-all.h	2006-12-20 15:04:54.000000000 +0000
  87.112 ++++ ioemu/exec-all.h	2006-12-20 15:04:54.000000000 +0000
  87.113  @@ -462,12 +462,13 @@
  87.114   }
  87.115   #endif
  87.116 @@ -146,8 +138,8 @@ Index: ioemu/exec-all.h
  87.117   
  87.118  Index: ioemu/target-i386-dm/cpu.h
  87.119  ===================================================================
  87.120 ---- ioemu.orig/target-i386-dm/cpu.h	2006-12-08 02:02:07.000000000 +0000
  87.121 -+++ ioemu/target-i386-dm/cpu.h	2006-12-08 02:02:34.000000000 +0000
  87.122 +--- ioemu.orig/target-i386-dm/cpu.h	2006-12-20 15:04:54.000000000 +0000
  87.123 ++++ ioemu/target-i386-dm/cpu.h	2006-12-20 15:10:13.000000000 +0000
  87.124  @@ -78,7 +78,11 @@
  87.125   /* helper2.c */
  87.126   int main_loop(void);
  87.127 @@ -163,7 +155,7 @@ Index: ioemu/target-i386-dm/cpu.h
  87.128  Index: ioemu/ia64_intrinsic.h
  87.129  ===================================================================
  87.130  --- /dev/null	1970-01-01 00:00:00.000000000 +0000
  87.131 -+++ ioemu/ia64_intrinsic.h	2006-12-08 02:02:34.000000000 +0000
  87.132 ++++ ioemu/ia64_intrinsic.h	2006-12-20 15:04:54.000000000 +0000
  87.133  @@ -0,0 +1,276 @@
  87.134  +#ifndef IA64_INTRINSIC_H
  87.135  +#define IA64_INTRINSIC_H
    88.1 --- a/tools/ioemu/patches/qemu-bootorder	Wed Jan 10 08:00:50 2007 -0700
    88.2 +++ b/tools/ioemu/patches/qemu-bootorder	Wed Jan 10 08:40:47 2007 -0700
    88.3 @@ -1,7 +1,7 @@
    88.4  Index: ioemu/vl.c
    88.5  ===================================================================
    88.6 ---- ioemu.orig/vl.c	2006-12-08 02:02:38.000000000 +0000
    88.7 -+++ ioemu/vl.c	2006-12-08 02:02:38.000000000 +0000
    88.8 +--- ioemu.orig/vl.c	2006-12-20 15:12:08.000000000 +0000
    88.9 ++++ ioemu/vl.c	2006-12-20 15:21:19.000000000 +0000
   88.10  @@ -125,7 +125,7 @@
   88.11   struct sockaddr_in vnclisten_addr;
   88.12   const char* keyboard_layout = NULL;
   88.13 @@ -17,15 +17,17 @@ Index: ioemu/vl.c
   88.14               case QEMU_OPTION_boot:
   88.15  -                boot_device = optarg[0];
   88.16  -                if (boot_device != 'a' && 
   88.17 -+                boot_device = strdup(optarg);
   88.18 -+                if (strspn(boot_device, "acd"
   88.19 - #ifdef TARGET_SPARC
   88.20 +-#ifdef TARGET_SPARC
   88.21  -		    // Network boot
   88.22  -		    boot_device != 'n' &&
   88.23 -+                           "n"
   88.24 - #endif
   88.25 +-#endif
   88.26  -                    boot_device != 'c' && boot_device != 'd') {
   88.27  -                    fprintf(stderr, "qemu: invalid boot device '%c'\n", boot_device);
   88.28 ++                boot_device = strdup(optarg);
   88.29 ++                if (strspn(boot_device, "acd"
   88.30 ++#if defined(TARGET_SPARC) || defined(TARGET_I386)
   88.31 ++                           "n"
   88.32 ++#endif
   88.33  +                        ) != strlen(boot_device)) {
   88.34  +                    fprintf(stderr, "qemu: invalid boot device in '%s'\n",
   88.35  +                            boot_device);
   88.36 @@ -48,7 +50,7 @@ Index: ioemu/vl.c
   88.37   #endif /* !CONFIG_DM */
   88.38   
   88.39       setvbuf(stdout, NULL, _IOLBF, 0);
   88.40 -@@ -6598,6 +6600,7 @@
   88.41 +@@ -6590,6 +6592,7 @@
   88.42                     ds, fd_filename, snapshot,
   88.43                     kernel_filename, kernel_cmdline, initrd_filename,
   88.44                     timeoffset);
   88.45 @@ -58,8 +60,8 @@ Index: ioemu/vl.c
   88.46       if (usb_enabled) {
   88.47  Index: ioemu/vl.h
   88.48  ===================================================================
   88.49 ---- ioemu.orig/vl.h	2006-12-08 02:02:38.000000000 +0000
   88.50 -+++ ioemu/vl.h	2006-12-08 02:02:38.000000000 +0000
   88.51 +--- ioemu.orig/vl.h	2006-12-20 15:12:08.000000000 +0000
   88.52 ++++ ioemu/vl.h	2006-12-20 15:21:14.000000000 +0000
   88.53  @@ -578,7 +578,7 @@
   88.54   #ifndef QEMU_TOOL
   88.55   
   88.56 @@ -80,9 +82,9 @@ Index: ioemu/vl.h
   88.57                             uint32_t initrd_image, uint32_t initrd_size,
   88.58  Index: ioemu/hw/pc.c
   88.59  ===================================================================
   88.60 ---- ioemu.orig/hw/pc.c	2006-12-08 02:02:38.000000000 +0000
   88.61 -+++ ioemu/hw/pc.c	2006-12-08 02:02:38.000000000 +0000
   88.62 -@@ -158,8 +158,23 @@
   88.63 +--- ioemu.orig/hw/pc.c	2006-12-20 15:12:08.000000000 +0000
   88.64 ++++ ioemu/hw/pc.c	2006-12-20 15:21:19.000000000 +0000
   88.65 +@@ -158,8 +158,25 @@
   88.66       rtc_set_memory(s, info_ofs + 8, sectors);
   88.67   }
   88.68   
   88.69 @@ -96,6 +98,8 @@ Index: ioemu/hw/pc.c
   88.70  +            return 0x02;            /* hard drive */
   88.71  +        case 'd':
   88.72  +            return 0x03;            /* cdrom */
   88.73 ++        case 'n':
   88.74 ++            return 0x04;            /* network */
   88.75  +        }
   88.76  +    }
   88.77  +    return 0x00;                /* no device */
   88.78 @@ -107,7 +111,7 @@ Index: ioemu/hw/pc.c
   88.79   {
   88.80       RTCState *s = rtc_state;
   88.81       int val;
   88.82 -@@ -205,21 +220,14 @@
   88.83 +@@ -205,21 +222,14 @@
   88.84       rtc_set_memory(s, 0x34, val);
   88.85       rtc_set_memory(s, 0x35, val >> 8);
   88.86       
   88.87 @@ -137,7 +141,7 @@ Index: ioemu/hw/pc.c
   88.88   
   88.89       /* floppy type */
   88.90   
   88.91 -@@ -617,7 +625,7 @@
   88.92 +@@ -617,7 +627,7 @@
   88.93   #define NOBIOS 1
   88.94   
   88.95   /* PC hardware initialisation */
   88.96 @@ -146,7 +150,7 @@ Index: ioemu/hw/pc.c
   88.97                        DisplayState *ds, const char **fd_filename, int snapshot,
   88.98                        const char *kernel_filename, const char *kernel_cmdline,
   88.99                        const char *initrd_filename, time_t timeoffset,
  88.100 -@@ -919,7 +927,7 @@
  88.101 +@@ -919,7 +929,7 @@
  88.102       }
  88.103   }
  88.104   
  88.105 @@ -155,7 +159,7 @@ Index: ioemu/hw/pc.c
  88.106                           DisplayState *ds, const char **fd_filename, 
  88.107                           int snapshot, 
  88.108                           const char *kernel_filename, 
  88.109 -@@ -933,7 +941,7 @@
  88.110 +@@ -933,7 +943,7 @@
  88.111                initrd_filename, timeoffset, 1);
  88.112   }
  88.113   
    89.1 --- a/tools/ioemu/patches/series	Wed Jan 10 08:00:50 2007 -0700
    89.2 +++ b/tools/ioemu/patches/series	Wed Jan 10 08:40:47 2007 -0700
    89.3 @@ -67,5 +67,5 @@ usb-uhci-buffer-size
    89.4  vnc-monitor-shift-key-processing
    89.5  ide-error-reporting
    89.6  vnc-numpad-handling
    89.7 -xen-mapcache -p3
    89.8 +xen-mapcache
    89.9  usb-mouse-tablet-status-check -p3
    90.1 --- a/tools/ioemu/patches/tpm-tis-device	Wed Jan 10 08:00:50 2007 -0700
    90.2 +++ b/tools/ioemu/patches/tpm-tis-device	Wed Jan 10 08:40:47 2007 -0700
    90.3 @@ -22,8 +22,8 @@ Signed-off-by: Stefan Berger <stefanb@us
    90.4  
    90.5  Index: ioemu/Makefile.target
    90.6  ===================================================================
    90.7 ---- ioemu.orig/Makefile.target	2006-12-08 18:33:48.000000000 +0000
    90.8 -+++ ioemu/Makefile.target	2006-12-08 18:35:14.000000000 +0000
    90.9 +--- ioemu.orig/Makefile.target	2006-12-20 15:21:55.000000000 +0000
   90.10 ++++ ioemu/Makefile.target	2006-12-20 15:21:55.000000000 +0000
   90.11  @@ -369,6 +369,7 @@
   90.12   VL_OBJS+= piix4acpi.o
   90.13   VL_OBJS+= xenstore.o
   90.14 @@ -34,9 +34,9 @@ Index: ioemu/Makefile.target
   90.15   ifeq ($(TARGET_BASE_ARCH), ppc)
   90.16  Index: ioemu/hw/pc.c
   90.17  ===================================================================
   90.18 ---- ioemu.orig/hw/pc.c	2006-12-08 18:33:47.000000000 +0000
   90.19 -+++ ioemu/hw/pc.c	2006-12-08 18:33:48.000000000 +0000
   90.20 -@@ -875,6 +875,9 @@
   90.21 +--- ioemu.orig/hw/pc.c	2006-12-20 15:21:54.000000000 +0000
   90.22 ++++ ioemu/hw/pc.c	2006-12-20 15:21:55.000000000 +0000
   90.23 +@@ -877,6 +877,9 @@
   90.24           }
   90.25       }
   90.26   
   90.27 @@ -49,7 +49,7 @@ Index: ioemu/hw/pc.c
   90.28  Index: ioemu/hw/tpm_tis.c
   90.29  ===================================================================
   90.30  --- /dev/null	1970-01-01 00:00:00.000000000 +0000
   90.31 -+++ ioemu/hw/tpm_tis.c	2006-12-08 18:35:25.000000000 +0000
   90.32 ++++ ioemu/hw/tpm_tis.c	2006-12-20 15:21:55.000000000 +0000
   90.33  @@ -0,0 +1,1120 @@
   90.34  +/*
   90.35  + * tpm_tis.c - QEMU emulator for a 1.2 TPM with TIS interface
   90.36 @@ -1173,8 +1173,8 @@ Index: ioemu/hw/tpm_tis.c
   90.37  +}
   90.38  Index: ioemu/vl.h
   90.39  ===================================================================
   90.40 ---- ioemu.orig/vl.h	2006-12-08 18:33:48.000000000 +0000
   90.41 -+++ ioemu/vl.h	2006-12-08 18:35:14.000000000 +0000
   90.42 +--- ioemu.orig/vl.h	2006-12-20 15:21:55.000000000 +0000
   90.43 ++++ ioemu/vl.h	2006-12-20 15:21:55.000000000 +0000
   90.44  @@ -932,6 +932,10 @@
   90.45   void piix4_pm_init(PCIBus *bus, int devfn);
   90.46   void acpi_bios_init(void);
    91.1 --- a/tools/ioemu/patches/vnc-display-find-unused	Wed Jan 10 08:00:50 2007 -0700
    91.2 +++ b/tools/ioemu/patches/vnc-display-find-unused	Wed Jan 10 08:40:47 2007 -0700
    91.3 @@ -1,7 +1,7 @@
    91.4  Index: ioemu/vnc.c
    91.5  ===================================================================
    91.6 ---- ioemu.orig/vnc.c	2006-12-08 02:02:36.000000000 +0000
    91.7 -+++ ioemu/vnc.c	2006-12-08 02:02:37.000000000 +0000
    91.8 +--- ioemu.orig/vnc.c	2006-12-20 15:21:52.000000000 +0000
    91.9 ++++ ioemu/vnc.c	2006-12-20 15:21:52.000000000 +0000
   91.10  @@ -1197,7 +1197,7 @@
   91.11       }
   91.12   }
   91.13 @@ -50,8 +50,8 @@ Index: ioemu/vnc.c
   91.14   int vnc_start_viewer(int port)
   91.15  Index: ioemu/vl.c
   91.16  ===================================================================
   91.17 ---- ioemu.orig/vl.c	2006-12-08 02:02:36.000000000 +0000
   91.18 -+++ ioemu/vl.c	2006-12-08 02:02:37.000000000 +0000
   91.19 +--- ioemu.orig/vl.c	2006-12-20 15:21:51.000000000 +0000
   91.20 ++++ ioemu/vl.c	2006-12-20 15:21:52.000000000 +0000
   91.21  @@ -121,6 +121,7 @@
   91.22   static DisplayState display_state;
   91.23   int nographic;
   91.24 @@ -104,7 +104,7 @@ Index: ioemu/vl.c
   91.25               }
   91.26           }
   91.27       }
   91.28 -@@ -6468,7 +6478,7 @@
   91.29 +@@ -6460,7 +6470,7 @@
   91.30       if (nographic) {
   91.31           dumb_display_init(ds);
   91.32       } else if (vnc_display != -1) {
   91.33 @@ -115,8 +115,8 @@ Index: ioemu/vl.c
   91.34       } else {
   91.35  Index: ioemu/vl.h
   91.36  ===================================================================
   91.37 ---- ioemu.orig/vl.h	2006-12-08 02:02:36.000000000 +0000
   91.38 -+++ ioemu/vl.h	2006-12-08 02:02:37.000000000 +0000
   91.39 +--- ioemu.orig/vl.h	2006-12-20 15:21:51.000000000 +0000
   91.40 ++++ ioemu/vl.h	2006-12-20 15:21:52.000000000 +0000
   91.41  @@ -785,7 +785,7 @@
   91.42   void cocoa_display_init(DisplayState *ds, int full_screen);
   91.43   
    92.1 --- a/tools/ioemu/patches/vnc-fixes	Wed Jan 10 08:00:50 2007 -0700
    92.2 +++ b/tools/ioemu/patches/vnc-fixes	Wed Jan 10 08:40:47 2007 -0700
    92.3 @@ -1,8 +1,8 @@
    92.4  Index: ioemu/vl.c
    92.5  ===================================================================
    92.6 ---- ioemu.orig/vl.c	2006-12-08 02:02:36.000000000 +0000
    92.7 -+++ ioemu/vl.c	2006-12-08 02:02:36.000000000 +0000
    92.8 -@@ -6519,8 +6519,10 @@
    92.9 +--- ioemu.orig/vl.c	2006-12-20 15:21:51.000000000 +0000
   92.10 ++++ ioemu/vl.c	2006-12-20 15:21:51.000000000 +0000
   92.11 +@@ -6511,8 +6511,10 @@
   92.12           }
   92.13       }
   92.14   
   92.15 @@ -17,8 +17,8 @@ Index: ioemu/vl.c
   92.16       if (use_gdbstub) {
   92.17  Index: ioemu/vnc.c
   92.18  ===================================================================
   92.19 ---- ioemu.orig/vnc.c	2006-12-08 02:02:36.000000000 +0000
   92.20 -+++ ioemu/vnc.c	2006-12-08 02:02:36.000000000 +0000
   92.21 +--- ioemu.orig/vnc.c	2006-12-20 15:21:51.000000000 +0000
   92.22 ++++ ioemu/vnc.c	2006-12-20 15:21:51.000000000 +0000
   92.23  @@ -3,6 +3,7 @@
   92.24    * 
   92.25    * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
   92.26 @@ -531,8 +531,8 @@ Index: ioemu/vnc.c
   92.27   }
   92.28  Index: ioemu/vl.h
   92.29  ===================================================================
   92.30 ---- ioemu.orig/vl.h	2006-12-08 02:02:36.000000000 +0000
   92.31 -+++ ioemu/vl.h	2006-12-08 02:02:36.000000000 +0000
   92.32 +--- ioemu.orig/vl.h	2006-12-20 15:21:51.000000000 +0000
   92.33 ++++ ioemu/vl.h	2006-12-20 15:21:51.000000000 +0000
   92.34  @@ -319,6 +319,7 @@
   92.35   int is_graphic_console(void);
   92.36   CharDriverState *text_console_init(DisplayState *ds);
    93.1 --- a/tools/ioemu/patches/vnc-listen-specific-interface	Wed Jan 10 08:00:50 2007 -0700
    93.2 +++ b/tools/ioemu/patches/vnc-listen-specific-interface	Wed Jan 10 08:40:47 2007 -0700
    93.3 @@ -20,8 +20,8 @@ Signed-off-by:  Daniel P. Berrange <berr
    93.4  
    93.5  Index: ioemu/vl.c
    93.6  ===================================================================
    93.7 ---- ioemu.orig/vl.c	2006-12-08 02:02:37.000000000 +0000
    93.8 -+++ ioemu/vl.c	2006-12-08 02:02:37.000000000 +0000
    93.9 +--- ioemu.orig/vl.c	2006-12-20 15:21:52.000000000 +0000
   93.10 ++++ ioemu/vl.c	2006-12-20 15:21:52.000000000 +0000
   93.11  @@ -122,6 +122,7 @@
   93.12   int nographic;
   93.13   int vncviewer;
   93.14 @@ -114,7 +114,7 @@ Index: ioemu/vl.c
   93.15               }
   93.16           }
   93.17       }
   93.18 -@@ -6478,7 +6493,7 @@
   93.19 +@@ -6470,7 +6485,7 @@
   93.20       if (nographic) {
   93.21           dumb_display_init(ds);
   93.22       } else if (vnc_display != -1) {
   93.23 @@ -125,8 +125,8 @@ Index: ioemu/vl.c
   93.24       } else {
   93.25  Index: ioemu/vl.h
   93.26  ===================================================================
   93.27 ---- ioemu.orig/vl.h	2006-12-08 02:02:37.000000000 +0000
   93.28 -+++ ioemu/vl.h	2006-12-08 02:02:37.000000000 +0000
   93.29 +--- ioemu.orig/vl.h	2006-12-20 15:21:52.000000000 +0000
   93.30 ++++ ioemu/vl.h	2006-12-20 15:21:52.000000000 +0000
   93.31  @@ -37,6 +37,8 @@
   93.32   #include <unistd.h>
   93.33   #include <fcntl.h>
   93.34 @@ -147,8 +147,8 @@ Index: ioemu/vl.h
   93.35   /* ide.c */
   93.36  Index: ioemu/vnc.c
   93.37  ===================================================================
   93.38 ---- ioemu.orig/vnc.c	2006-12-08 02:02:37.000000000 +0000
   93.39 -+++ ioemu/vnc.c	2006-12-08 02:02:37.000000000 +0000
   93.40 +--- ioemu.orig/vnc.c	2006-12-20 15:21:52.000000000 +0000
   93.41 ++++ ioemu/vnc.c	2006-12-20 15:21:52.000000000 +0000
   93.42  @@ -1197,9 +1197,8 @@
   93.43       }
   93.44   }
    94.1 --- a/tools/ioemu/patches/vnc-password	Wed Jan 10 08:00:50 2007 -0700
    94.2 +++ b/tools/ioemu/patches/vnc-password	Wed Jan 10 08:40:47 2007 -0700
    94.3 @@ -17,8 +17,8 @@ Signed-off-by: Masami Watanabe <masami.w
    94.4  
    94.5  Index: ioemu/Makefile.target
    94.6  ===================================================================
    94.7 ---- ioemu.orig/Makefile.target	2006-12-08 18:20:53.000000000 +0000
    94.8 -+++ ioemu/Makefile.target	2006-12-08 18:20:53.000000000 +0000
    94.9 +--- ioemu.orig/Makefile.target	2006-12-20 15:21:55.000000000 +0000
   94.10 ++++ ioemu/Makefile.target	2006-12-20 15:21:55.000000000 +0000
   94.11  @@ -407,6 +407,7 @@
   94.12   VL_OBJS+=sdl.o
   94.13   endif
   94.14 @@ -39,8 +39,8 @@ Index: ioemu/Makefile.target
   94.15   
   94.16  Index: ioemu/vl.c
   94.17  ===================================================================
   94.18 ---- ioemu.orig/vl.c	2006-12-08 18:20:52.000000000 +0000
   94.19 -+++ ioemu/vl.c	2006-12-08 18:20:53.000000000 +0000
   94.20 +--- ioemu.orig/vl.c	2006-12-20 15:21:54.000000000 +0000
   94.21 ++++ ioemu/vl.c	2006-12-20 15:21:55.000000000 +0000
   94.22  @@ -171,6 +171,9 @@
   94.23   char domain_name[1024] = { 'H','V', 'M', 'X', 'E', 'N', '-'};
   94.24   extern int domid;
   94.25 @@ -59,7 +59,7 @@ Index: ioemu/vl.c
   94.26   #ifndef CONFIG_DM
   94.27   #ifdef TARGET_PPC
   94.28       cdrom_index = 1;
   94.29 -@@ -6543,6 +6547,10 @@
   94.30 +@@ -6535,6 +6539,10 @@
   94.31   
   94.32       init_ioports();
   94.33   
   94.34 @@ -72,8 +72,8 @@ Index: ioemu/vl.c
   94.35           dumb_display_init(ds);
   94.36  Index: ioemu/vl.h
   94.37  ===================================================================
   94.38 ---- ioemu.orig/vl.h	2006-12-08 18:20:52.000000000 +0000
   94.39 -+++ ioemu/vl.h	2006-12-08 18:20:53.000000000 +0000
   94.40 +--- ioemu.orig/vl.h	2006-12-20 15:21:54.000000000 +0000
   94.41 ++++ ioemu/vl.h	2006-12-20 15:21:55.000000000 +0000
   94.42  @@ -1214,6 +1214,7 @@
   94.43   void xenstore_process_event(void *opaque);
   94.44   void xenstore_check_new_media_present(int timeout);
   94.45 @@ -92,8 +92,8 @@ Index: ioemu/vl.h
   94.46   #endif /* VL_H */
   94.47  Index: ioemu/vnc.c
   94.48  ===================================================================
   94.49 ---- ioemu.orig/vnc.c	2006-12-08 18:20:52.000000000 +0000
   94.50 -+++ ioemu/vnc.c	2006-12-08 18:20:53.000000000 +0000
   94.51 +--- ioemu.orig/vnc.c	2006-12-20 15:21:52.000000000 +0000
   94.52 ++++ ioemu/vnc.c	2006-12-20 15:21:55.000000000 +0000
   94.53  @@ -44,6 +44,7 @@
   94.54   
   94.55   #include "vnc_keysym.h"
   94.56 @@ -244,8 +244,8 @@ Index: ioemu/vnc.c
   94.57  +}
   94.58  Index: ioemu/xenstore.c
   94.59  ===================================================================
   94.60 ---- ioemu.orig/xenstore.c	2006-12-08 18:20:52.000000000 +0000
   94.61 -+++ ioemu/xenstore.c	2006-12-08 18:20:53.000000000 +0000
   94.62 +--- ioemu.orig/xenstore.c	2006-12-20 15:21:54.000000000 +0000
   94.63 ++++ ioemu/xenstore.c	2006-12-20 15:21:55.000000000 +0000
   94.64  @@ -213,3 +213,54 @@
   94.65       free(portstr);
   94.66       free(buf);
   94.67 @@ -304,7 +304,7 @@ Index: ioemu/xenstore.c
   94.68  Index: ioemu/d3des.c
   94.69  ===================================================================
   94.70  --- /dev/null	1970-01-01 00:00:00.000000000 +0000
   94.71 -+++ ioemu/d3des.c	2006-12-08 18:20:53.000000000 +0000
   94.72 ++++ ioemu/d3des.c	2006-12-20 15:21:55.000000000 +0000
   94.73  @@ -0,0 +1,434 @@
   94.74  +/*
   94.75  + * This is D3DES (V5.09) by Richard Outerbridge with the double and
   94.76 @@ -743,7 +743,7 @@ Index: ioemu/d3des.c
   94.77  Index: ioemu/d3des.h
   94.78  ===================================================================
   94.79  --- /dev/null	1970-01-01 00:00:00.000000000 +0000
   94.80 -+++ ioemu/d3des.h	2006-12-08 18:20:53.000000000 +0000
   94.81 ++++ ioemu/d3des.h	2006-12-20 15:21:55.000000000 +0000
   94.82  @@ -0,0 +1,51 @@
   94.83  +/*
   94.84  + * This is D3DES (V5.09) by Richard Outerbridge with the double and
    95.1 --- a/tools/ioemu/patches/vnc-start-vncviewer	Wed Jan 10 08:00:50 2007 -0700
    95.2 +++ b/tools/ioemu/patches/vnc-start-vncviewer	Wed Jan 10 08:40:47 2007 -0700
    95.3 @@ -1,7 +1,7 @@
    95.4  Index: ioemu/vnc.c
    95.5  ===================================================================
    95.6 ---- ioemu.orig/vnc.c	2006-12-08 02:02:36.000000000 +0000
    95.7 -+++ ioemu/vnc.c	2006-12-08 02:02:36.000000000 +0000
    95.8 +--- ioemu.orig/vnc.c	2006-12-20 15:21:51.000000000 +0000
    95.9 ++++ ioemu/vnc.c	2006-12-20 15:21:51.000000000 +0000
   95.10  @@ -1189,3 +1189,25 @@
   95.11   
   95.12       vnc_dpy_resize(vs->ds, 640, 400);
   95.13 @@ -30,8 +30,8 @@ Index: ioemu/vnc.c
   95.14  +}
   95.15  Index: ioemu/vl.c
   95.16  ===================================================================
   95.17 ---- ioemu.orig/vl.c	2006-12-08 02:02:36.000000000 +0000
   95.18 -+++ ioemu/vl.c	2006-12-08 02:02:36.000000000 +0000
   95.19 +--- ioemu.orig/vl.c	2006-12-20 15:21:51.000000000 +0000
   95.20 ++++ ioemu/vl.c	2006-12-20 15:21:51.000000000 +0000
   95.21  @@ -120,6 +120,7 @@
   95.22   int bios_size;
   95.23   static DisplayState display_state;
   95.24 @@ -82,7 +82,7 @@ Index: ioemu/vl.c
   95.25               }
   95.26           }
   95.27       }
   95.28 -@@ -6461,6 +6469,8 @@
   95.29 +@@ -6453,6 +6461,8 @@
   95.30           dumb_display_init(ds);
   95.31       } else if (vnc_display != -1) {
   95.32   	vnc_display_init(ds, vnc_display);
   95.33 @@ -93,8 +93,8 @@ Index: ioemu/vl.c
   95.34           sdl_display_init(ds, full_screen);
   95.35  Index: ioemu/vl.h
   95.36  ===================================================================
   95.37 ---- ioemu.orig/vl.h	2006-12-08 02:02:36.000000000 +0000
   95.38 -+++ ioemu/vl.h	2006-12-08 02:02:36.000000000 +0000
   95.39 +--- ioemu.orig/vl.h	2006-12-20 15:21:51.000000000 +0000
   95.40 ++++ ioemu/vl.h	2006-12-20 15:21:51.000000000 +0000
   95.41  @@ -786,6 +786,7 @@
   95.42   
   95.43   /* vnc.c */
    96.1 --- a/tools/ioemu/patches/xen-mapcache	Wed Jan 10 08:00:50 2007 -0700
    96.2 +++ b/tools/ioemu/patches/xen-mapcache	Wed Jan 10 08:40:47 2007 -0700
    96.3 @@ -15,84 +15,15 @@ Signed-off-by: Jun Nakajima <jun.nakajim
    96.4  Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
    96.5  Signed-off-by: Keir Fraser <keir@xensource.com>
    96.6  
    96.7 -diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/target-i386-dm/cpu.h
    96.8 ---- a/tools/ioemu/target-i386-dm/cpu.h	Thu Dec 07 10:54:43 2006 +0000
    96.9 -+++ b/tools/ioemu/target-i386-dm/cpu.h	Thu Dec 07 11:12:52 2006 +0000
   96.10 -@@ -25,7 +25,8 @@
   96.11 - #ifdef TARGET_X86_64
   96.12 - #define TARGET_LONG_BITS 64
   96.13 - #else
   96.14 --#define TARGET_LONG_BITS 32
   96.15 -+/* #define TARGET_LONG_BITS 32 */
   96.16 -+#define TARGET_LONG_BITS 64 /* for Qemu map cache */
   96.17 - #endif
   96.18 - 
   96.19 - /* target supports implicit self modifying code */
   96.20 -diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/target-i386-dm/exec-dm.c
   96.21 ---- a/tools/ioemu/target-i386-dm/exec-dm.c	Thu Dec 07 10:54:43 2006 +0000
   96.22 -+++ b/tools/ioemu/target-i386-dm/exec-dm.c	Thu Dec 07 11:12:52 2006 +0000
   96.23 -@@ -36,6 +36,7 @@
   96.24 - 
   96.25 - #include "cpu.h"
   96.26 - #include "exec-all.h"
   96.27 -+#include "vl.h"
   96.28 - 
   96.29 - //#define DEBUG_TB_INVALIDATE
   96.30 - //#define DEBUG_FLUSH
   96.31 -@@ -426,6 +427,12 @@ static inline int paddr_is_ram(target_ph
   96.32 - #endif
   96.33 +Index: ioemu/vl.c
   96.34 +===================================================================
   96.35 +--- ioemu.orig/vl.c	2006-12-20 15:21:55.000000000 +0000
   96.36 ++++ ioemu/vl.c	2006-12-20 15:21:56.000000000 +0000
   96.37 +@@ -5808,6 +5808,91 @@
   96.38 +     return 0;
   96.39   }
   96.40   
   96.41  +#if defined(__i386__) || defined(__x86_64__)
   96.42 -+#define phys_ram_addr(x) (qemu_map_cache(x))
   96.43 -+#elif defined(__ia64__)
   96.44 -+#define phys_ram_addr(x) (phys_ram_base + (x))
   96.45 -+#endif
   96.46 -+
   96.47 - void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, 
   96.48 -                             int len, int is_write)
   96.49 - {
   96.50 -@@ -438,7 +445,7 @@ void cpu_physical_memory_rw(target_phys_
   96.51 -         l = TARGET_PAGE_SIZE - (addr & ~TARGET_PAGE_MASK); 
   96.52 -         if (l > len)
   96.53 -             l = len;
   96.54 --	
   96.55 -+
   96.56 -         io_index = iomem_index(addr);
   96.57 -         if (is_write) {
   96.58 -             if (io_index) {
   96.59 -@@ -460,9 +467,10 @@ void cpu_physical_memory_rw(target_phys_
   96.60 -                 }
   96.61 -             } else if (paddr_is_ram(addr)) {
   96.62 -                 /* Reading from RAM */
   96.63 --                memcpy(phys_ram_base + addr, buf, l);
   96.64 -+                ptr = phys_ram_addr(addr);
   96.65 -+                memcpy(ptr, buf, l);
   96.66 - #ifdef __ia64__
   96.67 --                sync_icache((unsigned long)(phys_ram_base + addr), l);
   96.68 -+                sync_icache(ptr, l);
   96.69 - #endif 
   96.70 -             }
   96.71 -         } else {
   96.72 -@@ -485,7 +493,8 @@ void cpu_physical_memory_rw(target_phys_
   96.73 -                 }
   96.74 -             } else if (paddr_is_ram(addr)) {
   96.75 -                 /* Reading from RAM */
   96.76 --                memcpy(buf, phys_ram_base + addr, l);
   96.77 -+                ptr = phys_ram_addr(addr);
   96.78 -+                memcpy(buf, ptr, l);
   96.79 -             } else {
   96.80 -                 /* Neither RAM nor known MMIO space */
   96.81 -                 memset(buf, 0xff, len); 
   96.82 -diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/vl.c
   96.83 ---- a/tools/ioemu/vl.c	Thu Dec 07 10:54:43 2006 +0000
   96.84 -+++ b/tools/ioemu/vl.c	Thu Dec 07 11:12:52 2006 +0000
   96.85 -@@ -5807,6 +5807,92 @@ int set_mm_mapping(int xc_handle, uint32
   96.86 - 
   96.87 -     return 0;
   96.88 - }
   96.89 -+
   96.90 -+#if defined(__i386__) || defined(__x86_64__)
   96.91  +static struct map_cache *mapcache_entry;
   96.92  +static unsigned long nr_buckets;
   96.93  +
   96.94 @@ -104,8 +35,8 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
   96.95  +    if (nr_pages < max_pages)
   96.96  +        max_pages = nr_pages;
   96.97  +
   96.98 -+    nr_buckets = (max_pages << PAGE_SHIFT) >> MCACHE_BUCKET_SHIFT;
   96.99 -+
  96.100 ++    nr_buckets   = max_pages + (1UL << (MCACHE_BUCKET_SHIFT - PAGE_SHIFT)) - 1;
  96.101 ++    nr_buckets >>= (MCACHE_BUCKET_SHIFT - PAGE_SHIFT);
  96.102  +    fprintf(logfile, "qemu_map_cache_init nr_buckets = %lx\n", nr_buckets);
  96.103  +
  96.104  +    mapcache_entry = malloc(nr_buckets * sizeof(struct map_cache));
  96.105 @@ -141,8 +72,7 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
  96.106  +
  96.107  +    entry = &mapcache_entry[address_index % nr_buckets];
  96.108  +
  96.109 -+    if (entry->vaddr_base == NULL || entry->paddr_index != address_index)
  96.110 -+    { 
  96.111 ++    if (entry->vaddr_base == NULL || entry->paddr_index != address_index) {
  96.112  +        /* We need to remap a bucket. */
  96.113  +        uint8_t *vaddr_base;
  96.114  +        unsigned long pfns[MCACHE_BUCKET_SIZE >> PAGE_SHIFT];
  96.115 @@ -177,10 +107,11 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
  96.116  +    return last_address_vaddr + address_offset;
  96.117  +}
  96.118  +#endif
  96.119 - 
  96.120 ++
  96.121   int main(int argc, char **argv)
  96.122   {
  96.123 -@@ -6130,6 +6216,7 @@ int main(int argc, char **argv)
  96.124 + #ifdef CONFIG_GDBSTUB
  96.125 +@@ -6130,6 +6215,7 @@
  96.126                   break;
  96.127               case QEMU_OPTION_m:
  96.128                   ram_size = atol(optarg) * 1024 * 1024;
  96.129 @@ -188,90 +119,195 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
  96.130                   if (ram_size <= 0)
  96.131                       help();
  96.132   #ifndef CONFIG_DM
  96.133 -@@ -6400,50 +6487,41 @@ int main(int argc, char **argv)
  96.134 +@@ -6404,50 +6490,41 @@
  96.135           shared_page_nr = nr_pages - 1;
  96.136   #endif
  96.137   
  96.138 -+#if defined(__i386__) || defined(__x86_64__)
  96.139 -+
  96.140 -+    if ( qemu_map_cache_init(tmp_nr_pages) )
  96.141 -+    {
  96.142 -+        fprintf(logfile, "qemu_map_cache_init returned: error %d\n", errno);
  96.143 -+        exit(-1);
  96.144 -+    }
  96.145 -+
  96.146 -+    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
  96.147 -+                                       PROT_READ|PROT_WRITE, shared_page_nr);
  96.148 -+    if (shared_page == NULL) {
  96.149 -+        fprintf(logfile, "map shared IO page returned error %d\n", errno);
  96.150 -+        exit(-1);
  96.151 -+    }
  96.152 -+
  96.153 -+    fprintf(logfile, "shared page at pfn:%lx\n", shared_page_nr);
  96.154 -+
  96.155 -+    buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
  96.156 -+                                            PROT_READ|PROT_WRITE,
  96.157 -+                                            shared_page_nr - 2);
  96.158 -+    if (buffered_io_page == NULL) {
  96.159 -+        fprintf(logfile, "map buffered IO page returned error %d\n", errno);
  96.160 -+        exit(-1);
  96.161 -+    }
  96.162 -+
  96.163 -+    fprintf(logfile, "buffered io page at pfn:%lx\n", shared_page_nr - 2);
  96.164 -+
  96.165 -+#elif defined(__ia64__)
  96.166 -+
  96.167 -     page_array = (xen_pfn_t *)malloc(tmp_nr_pages * sizeof(xen_pfn_t));
  96.168 -     if (page_array == NULL) {
  96.169 -         fprintf(logfile, "malloc returned error %d\n", errno);
  96.170 -         exit(-1);
  96.171 -     }
  96.172 - 
  96.173 --#if defined(__i386__) || defined(__x86_64__)
  96.174 +-    page_array = (xen_pfn_t *)malloc(tmp_nr_pages * sizeof(xen_pfn_t));
  96.175 +-    if (page_array == NULL) {
  96.176 +-        fprintf(logfile, "malloc returned error %d\n", errno);
  96.177 +-        exit(-1);
  96.178 +-    }
  96.179 +-
  96.180 + #if defined(__i386__) || defined(__x86_64__)
  96.181  -    for ( i = 0; i < tmp_nr_pages; i++)
  96.182  -        page_array[i] = i;
  96.183 --
  96.184 + 
  96.185  -    phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
  96.186  -                                         PROT_READ|PROT_WRITE, page_array,
  96.187  -                                         tmp_nr_pages);
  96.188  -    if (phys_ram_base == NULL) {
  96.189  -        fprintf(logfile, "batch map guest memory returned error %d\n", errno);
  96.190 --        exit(-1);
  96.191 --    }
  96.192 --
  96.193 --    shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
  96.194 ++    if ( qemu_map_cache_init(tmp_nr_pages) )
  96.195 ++    {
  96.196 ++        fprintf(logfile, "qemu_map_cache_init returned: error %d\n", errno);
  96.197 +         exit(-1);
  96.198 +     }
  96.199 + 
  96.200 +     shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
  96.201  -                                       PROT_READ|PROT_WRITE,
  96.202  -                                       page_array[shared_page_nr]);
  96.203 --    if (shared_page == NULL) {
  96.204 --        fprintf(logfile, "map shared IO page returned error %d\n", errno);
  96.205 --        exit(-1);
  96.206 --    }
  96.207 --
  96.208 ++                                       PROT_READ|PROT_WRITE, shared_page_nr);
  96.209 +     if (shared_page == NULL) {
  96.210 +         fprintf(logfile, "map shared IO page returned error %d\n", errno);
  96.211 +         exit(-1);
  96.212 +     }
  96.213 + 
  96.214  -    fprintf(logfile, "shared page at pfn:%lx, mfn: %"PRIx64"\n",
  96.215  -            shared_page_nr, (uint64_t)(page_array[shared_page_nr]));
  96.216 --
  96.217 --    buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
  96.218 --                                            PROT_READ|PROT_WRITE,
  96.219 ++    fprintf(logfile, "shared page at pfn:%lx\n", shared_page_nr);
  96.220 + 
  96.221 +     buffered_io_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
  96.222 +                                             PROT_READ|PROT_WRITE,
  96.223  -                                            page_array[shared_page_nr - 2]);
  96.224 --    if (buffered_io_page == NULL) {
  96.225 --        fprintf(logfile, "map buffered IO page returned error %d\n", errno);
  96.226 --        exit(-1);
  96.227 --    }
  96.228 --
  96.229 ++                                            shared_page_nr - 2);
  96.230 +     if (buffered_io_page == NULL) {
  96.231 +         fprintf(logfile, "map buffered IO page returned error %d\n", errno);
  96.232 +         exit(-1);
  96.233 +     }
  96.234 + 
  96.235  -    fprintf(logfile, "buffered io page at pfn:%lx, mfn: %"PRIx64"\n",
  96.236  -            shared_page_nr - 2, (uint64_t)(page_array[shared_page_nr - 2]));
  96.237  -
  96.238  -    free(page_array);
  96.239 --
  96.240 --#elif defined(__ia64__)
  96.241 ++    fprintf(logfile, "buffered io page at pfn:%lx\n", shared_page_nr - 2);
  96.242 + 
  96.243 + #elif defined(__ia64__)
  96.244  -  
  96.245 -     if (xc_ia64_get_pfn_list(xc_handle, domid, page_array,
  96.246 -                              IO_PAGE_START >> PAGE_SHIFT, 3) != 3) {
  96.247 -         fprintf(logfile, "xc_ia64_get_pfn_list returned error %d\n", errno);
  96.248 -diff -r 3f0ca90351e2 -r 67a06a9b7b1d tools/ioemu/vl.h
  96.249 ---- a/tools/ioemu/vl.h	Thu Dec 07 10:54:43 2006 +0000
  96.250 -+++ b/tools/ioemu/vl.h	Thu Dec 07 11:12:52 2006 +0000
  96.251 -@@ -156,6 +156,26 @@ extern void *shared_vram;
  96.252 ++
  96.253 ++    page_array = (xen_pfn_t *)malloc(tmp_nr_pages * sizeof(xen_pfn_t));
  96.254 ++    if (page_array == NULL) {
  96.255 ++        fprintf(logfile, "malloc returned error %d\n", errno);
  96.256 ++        exit(-1);
  96.257 ++    }
  96.258 ++
  96.259 +     shared_page = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
  96.260 +                                        PROT_READ|PROT_WRITE,
  96.261 +                                        IO_PAGE_START >> PAGE_SHIFT);
  96.262 +Index: ioemu/target-i386-dm/exec-dm.c
  96.263 +===================================================================
  96.264 +--- ioemu.orig/target-i386-dm/exec-dm.c	2006-12-20 15:21:42.000000000 +0000
  96.265 ++++ ioemu/target-i386-dm/exec-dm.c	2006-12-21 11:32:29.000000000 +0000
  96.266 +@@ -36,6 +36,7 @@
  96.267 + 
  96.268 + #include "cpu.h"
  96.269 + #include "exec-all.h"
  96.270 ++#include "vl.h"
  96.271 + 
  96.272 + //#define DEBUG_TB_INVALIDATE
  96.273 + //#define DEBUG_FLUSH
  96.274 +@@ -127,10 +128,29 @@
  96.275 + FILE *logfile;
  96.276 + int loglevel;
  96.277 + 
  96.278 ++
  96.279 ++#if defined(__i386__) || defined(__x86_64__)
  96.280 ++#define MAPCACHE
  96.281 ++#endif
  96.282 ++
  96.283 ++#ifdef MAPCACHE
  96.284 ++#include <pthread.h>
  96.285 ++static pthread_mutex_t mapcache_mutex;
  96.286 ++#define mapcache_lock() pthread_mutex_lock(&mapcache_mutex)
  96.287 ++#define mapcache_unlock() pthread_mutex_unlock(&mapcache_mutex)
  96.288 ++#else 
  96.289 ++#define mapcache_lock() ( (void)0 )
  96.290 ++#define mapcache_unlock() ( (void)0 )
  96.291 ++#endif
  96.292 ++
  96.293 ++
  96.294 + void cpu_exec_init(CPUState *env)
  96.295 + {
  96.296 +     CPUState **penv;
  96.297 +     int cpu_index;
  96.298 ++#ifdef MAPCACHE
  96.299 ++    pthread_mutexattr_t mxattr; 
  96.300 ++#endif
  96.301 + 
  96.302 +     env->next_cpu = NULL;
  96.303 +     penv = &first_cpu;
  96.304 +@@ -144,6 +164,14 @@
  96.305 + 
  96.306 +     /* alloc dirty bits array */
  96.307 +     phys_ram_dirty = qemu_malloc(phys_ram_size >> TARGET_PAGE_BITS);
  96.308 ++
  96.309 ++#ifdef MAPCACHE
  96.310 ++    /* setup memory access mutex to protect mapcache */
  96.311 ++    pthread_mutexattr_init(&mxattr); 
  96.312 ++    pthread_mutexattr_settype(&mxattr, PTHREAD_MUTEX_RECURSIVE);
  96.313 ++    pthread_mutex_init(&mapcache_mutex, &mxattr); 
  96.314 ++    pthread_mutexattr_destroy(&mxattr); 
  96.315 ++#endif
  96.316 + }
  96.317 + 
  96.318 + /* enable or disable low levels log */
  96.319 +@@ -426,19 +454,27 @@
  96.320 + #endif
  96.321 + }
  96.322 + 
  96.323 ++#if defined(__i386__) || defined(__x86_64__)
  96.324 ++#define phys_ram_addr(x) (qemu_map_cache(x))
  96.325 ++#elif defined(__ia64__)
  96.326 ++#define phys_ram_addr(x) (phys_ram_base + (x))
  96.327 ++#endif
  96.328 ++
  96.329 + void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, 
  96.330 +                             int len, int is_write)
  96.331 + {
  96.332 +     int l, io_index;
  96.333 +     uint8_t *ptr;
  96.334 +     uint32_t val;
  96.335 +-    
  96.336 ++
  96.337 ++    mapcache_lock();
  96.338 ++
  96.339 +     while (len > 0) {
  96.340 +         /* How much can we copy before the next page boundary? */
  96.341 +         l = TARGET_PAGE_SIZE - (addr & ~TARGET_PAGE_MASK); 
  96.342 +         if (l > len)
  96.343 +             l = len;
  96.344 +-	
  96.345 ++
  96.346 +         io_index = iomem_index(addr);
  96.347 +         if (is_write) {
  96.348 +             if (io_index) {
  96.349 +@@ -460,9 +496,10 @@
  96.350 +                 }
  96.351 +             } else if (paddr_is_ram(addr)) {
  96.352 +                 /* Reading from RAM */
  96.353 +-                memcpy(phys_ram_base + addr, buf, l);
  96.354 ++                ptr = phys_ram_addr(addr);
  96.355 ++                memcpy(ptr, buf, l);
  96.356 + #ifdef __ia64__
  96.357 +-                sync_icache((unsigned long)(phys_ram_base + addr), l);
  96.358 ++                sync_icache(ptr, l);
  96.359 + #endif 
  96.360 +             }
  96.361 +         } else {
  96.362 +@@ -485,7 +522,8 @@
  96.363 +                 }
  96.364 +             } else if (paddr_is_ram(addr)) {
  96.365 +                 /* Reading from RAM */
  96.366 +-                memcpy(buf, phys_ram_base + addr, l);
  96.367 ++                ptr = phys_ram_addr(addr);
  96.368 ++                memcpy(buf, ptr, l);
  96.369 +             } else {
  96.370 +                 /* Neither RAM nor known MMIO space */
  96.371 +                 memset(buf, 0xff, len); 
  96.372 +@@ -495,6 +533,8 @@
  96.373 +         buf += l;
  96.374 +         addr += l;
  96.375 +     }
  96.376 ++
  96.377 ++    mapcache_unlock();
  96.378 + }
  96.379 + #endif
  96.380 + 
  96.381 +Index: ioemu/vl.h
  96.382 +===================================================================
  96.383 +--- ioemu.orig/vl.h	2006-12-20 15:21:55.000000000 +0000
  96.384 ++++ ioemu/vl.h	2006-12-20 15:21:56.000000000 +0000
  96.385 +@@ -156,6 +156,26 @@
  96.386   
  96.387   extern FILE *logfile;
  96.388   
  96.389 @@ -298,3 +334,17 @@ diff -r 3f0ca90351e2 -r 67a06a9b7b1d too
  96.390   extern int xc_handle;
  96.391   extern int domid;
  96.392   
  96.393 +Index: ioemu/target-i386-dm/cpu.h
  96.394 +===================================================================
  96.395 +--- ioemu.orig/target-i386-dm/cpu.h	2006-12-20 15:21:45.000000000 +0000
  96.396 ++++ ioemu/target-i386-dm/cpu.h	2006-12-20 15:21:56.000000000 +0000
  96.397 +@@ -25,7 +25,8 @@
  96.398 + #ifdef TARGET_X86_64
  96.399 + #define TARGET_LONG_BITS 64
  96.400 + #else
  96.401 +-#define TARGET_LONG_BITS 32
  96.402 ++/* #define TARGET_LONG_BITS 32 */
  96.403 ++#define TARGET_LONG_BITS 64 /* for Qemu map cache */
  96.404 + #endif
  96.405 + 
  96.406 + /* target supports implicit self modifying code */
    97.1 --- a/tools/ioemu/patches/xen-support-buffered-ioreqs	Wed Jan 10 08:00:50 2007 -0700
    97.2 +++ b/tools/ioemu/patches/xen-support-buffered-ioreqs	Wed Jan 10 08:40:47 2007 -0700
    97.3 @@ -1,7 +1,7 @@
    97.4  Index: ioemu/vl.c
    97.5  ===================================================================
    97.6 ---- ioemu.orig/vl.c	2006-12-08 02:02:37.000000000 +0000
    97.7 -+++ ioemu/vl.c	2006-12-08 02:02:37.000000000 +0000
    97.8 +--- ioemu.orig/vl.c	2006-12-20 15:21:54.000000000 +0000
    97.9 ++++ ioemu/vl.c	2006-12-20 15:21:54.000000000 +0000
   97.10  @@ -5838,6 +5838,7 @@
   97.11       unsigned long nr_pages, tmp_nr_pages, shared_page_nr;
   97.12       xen_pfn_t *page_array;
   97.13 @@ -10,7 +10,7 @@ Index: ioemu/vl.c
   97.14   
   97.15       char qemu_dm_logfilename[64];
   97.16   
   97.17 -@@ -6418,6 +6419,17 @@
   97.18 +@@ -6422,6 +6423,17 @@
   97.19       fprintf(logfile, "shared page at pfn:%lx, mfn: %"PRIx64"\n",
   97.20               shared_page_nr, (uint64_t)(page_array[shared_page_nr]));
   97.21   
   97.22 @@ -30,8 +30,8 @@ Index: ioemu/vl.c
   97.23   #elif defined(__ia64__)
   97.24  Index: ioemu/target-i386-dm/helper2.c
   97.25  ===================================================================
   97.26 ---- ioemu.orig/target-i386-dm/helper2.c	2006-12-08 02:02:35.000000000 +0000
   97.27 -+++ ioemu/target-i386-dm/helper2.c	2006-12-08 02:02:37.000000000 +0000
   97.28 +--- ioemu.orig/target-i386-dm/helper2.c	2006-12-20 15:21:47.000000000 +0000
   97.29 ++++ ioemu/target-i386-dm/helper2.c	2006-12-20 15:21:54.000000000 +0000
   97.30  @@ -76,6 +76,10 @@
   97.31   
   97.32   shared_iopage_t *shared_page = NULL;
    98.1 --- a/tools/ioemu/patches/xenstore-block-device-config	Wed Jan 10 08:00:50 2007 -0700
    98.2 +++ b/tools/ioemu/patches/xenstore-block-device-config	Wed Jan 10 08:40:47 2007 -0700
    98.3 @@ -1,7 +1,7 @@
    98.4  Index: ioemu/Makefile.target
    98.5  ===================================================================
    98.6 ---- ioemu.orig/Makefile.target	2006-12-08 02:02:36.000000000 +0000
    98.7 -+++ ioemu/Makefile.target	2006-12-08 02:02:37.000000000 +0000
    98.8 +--- ioemu.orig/Makefile.target	2006-12-20 15:21:51.000000000 +0000
    98.9 ++++ ioemu/Makefile.target	2006-12-20 15:21:53.000000000 +0000
   98.10  @@ -359,6 +359,7 @@
   98.11   VL_OBJS+= cirrus_vga.o mixeng.o parallel.o acpi.o piix_pci.o
   98.12   VL_OBJS+= usb-uhci.o
   98.13 @@ -13,7 +13,7 @@ Index: ioemu/Makefile.target
   98.14  Index: ioemu/xenstore.c
   98.15  ===================================================================
   98.16  --- /dev/null	1970-01-01 00:00:00.000000000 +0000
   98.17 -+++ ioemu/xenstore.c	2006-12-08 02:02:37.000000000 +0000
   98.18 ++++ ioemu/xenstore.c	2006-12-20 15:21:53.000000000 +0000
   98.19  @@ -0,0 +1,187 @@
   98.20  +/*
   98.21  + * This file is subject to the terms and conditions of the GNU General
   98.22 @@ -204,8 +204,8 @@ Index: ioemu/xenstore.c
   98.23  +}
   98.24  Index: ioemu/vl.c
   98.25  ===================================================================
   98.26 ---- ioemu.orig/vl.c	2006-12-08 02:02:37.000000000 +0000
   98.27 -+++ ioemu/vl.c	2006-12-08 02:02:37.000000000 +0000
   98.28 +--- ioemu.orig/vl.c	2006-12-20 15:21:52.000000000 +0000
   98.29 ++++ ioemu/vl.c	2006-12-20 15:21:53.000000000 +0000
   98.30  @@ -5256,9 +5256,11 @@
   98.31              "Standard options:\n"
   98.32              "-M machine      select emulated machine (-M ? for list)\n"
   98.33 @@ -359,7 +359,7 @@ Index: ioemu/vl.c
   98.34   
   98.35       setvbuf(stdout, NULL, _IOLBF, 0);
   98.36       
   98.37 -@@ -6441,6 +6472,7 @@
   98.38 +@@ -6433,6 +6464,7 @@
   98.39   
   98.40   #endif /* !CONFIG_DM */
   98.41   
   98.42 @@ -367,7 +367,7 @@ Index: ioemu/vl.c
   98.43       /* we always create the cdrom drive, even if no disk is there */
   98.44       bdrv_init();
   98.45       if (cdrom_index >= 0) {
   98.46 -@@ -6467,6 +6499,7 @@
   98.47 +@@ -6459,6 +6491,7 @@
   98.48               }
   98.49           }
   98.50       }
   98.51 @@ -375,7 +375,7 @@ Index: ioemu/vl.c
   98.52   
   98.53       /* we always create at least one floppy disk */
   98.54       fd_table[0] = bdrv_new("fda");
   98.55 -@@ -6545,6 +6578,8 @@
   98.56 +@@ -6537,6 +6570,8 @@
   98.57           }
   98.58       }
   98.59   
   98.60 @@ -386,8 +386,8 @@ Index: ioemu/vl.c
   98.61                     kernel_filename, kernel_cmdline, initrd_filename,
   98.62  Index: ioemu/monitor.c
   98.63  ===================================================================
   98.64 ---- ioemu.orig/monitor.c	2006-12-08 02:02:35.000000000 +0000
   98.65 -+++ ioemu/monitor.c	2006-12-08 02:02:37.000000000 +0000
   98.66 +--- ioemu.orig/monitor.c	2006-12-20 15:21:47.000000000 +0000
   98.67 ++++ ioemu/monitor.c	2006-12-20 15:21:53.000000000 +0000
   98.68  @@ -24,6 +24,7 @@
   98.69   #include "vl.h"
   98.70   #include "disas.h"
   98.71 @@ -416,8 +416,8 @@ Index: ioemu/monitor.c
   98.72       int i;
   98.73  Index: ioemu/block.c
   98.74  ===================================================================
   98.75 ---- ioemu.orig/block.c	2006-12-08 02:02:06.000000000 +0000
   98.76 -+++ ioemu/block.c	2006-12-08 02:02:37.000000000 +0000
   98.77 +--- ioemu.orig/block.c	2006-12-20 15:21:31.000000000 +0000
   98.78 ++++ ioemu/block.c	2006-12-20 15:21:53.000000000 +0000
   98.79  @@ -758,6 +758,7 @@
   98.80   static void raw_close(BlockDriverState *bs)
   98.81   {
   98.82 @@ -428,8 +428,8 @@ Index: ioemu/block.c
   98.83   
   98.84  Index: ioemu/vl.h
   98.85  ===================================================================
   98.86 ---- ioemu.orig/vl.h	2006-12-08 02:02:37.000000000 +0000
   98.87 -+++ ioemu/vl.h	2006-12-08 02:02:37.000000000 +0000
   98.88 +--- ioemu.orig/vl.h	2006-12-20 15:21:52.000000000 +0000
   98.89 ++++ ioemu/vl.h	2006-12-20 15:21:53.000000000 +0000
   98.90  @@ -1191,6 +1191,8 @@
   98.91   void term_print_help(void);
   98.92   void monitor_readline(const char *prompt, int is_password,
   98.93 @@ -455,8 +455,8 @@ Index: ioemu/vl.h
   98.94   extern char domain_name[];
   98.95  Index: ioemu/hw/ide.c
   98.96  ===================================================================
   98.97 ---- ioemu.orig/hw/ide.c	2006-12-08 02:02:35.000000000 +0000
   98.98 -+++ ioemu/hw/ide.c	2006-12-08 02:02:37.000000000 +0000
   98.99 +--- ioemu.orig/hw/ide.c	2006-12-20 15:21:49.000000000 +0000
  98.100 ++++ ioemu/hw/ide.c	2006-12-20 15:21:53.000000000 +0000
  98.101  @@ -1158,6 +1158,7 @@
  98.102           } else {
  98.103               ide_atapi_cmd_error(s, SENSE_NOT_READY, 
    99.1 --- a/tools/ioemu/patches/xenstore-write-vnc-port	Wed Jan 10 08:00:50 2007 -0700
    99.2 +++ b/tools/ioemu/patches/xenstore-write-vnc-port	Wed Jan 10 08:40:47 2007 -0700
    99.3 @@ -1,7 +1,7 @@
    99.4  Index: ioemu/xenstore.c
    99.5  ===================================================================
    99.6 ---- ioemu.orig/xenstore.c	2006-12-08 02:02:37.000000000 +0000
    99.7 -+++ ioemu/xenstore.c	2006-12-08 02:02:37.000000000 +0000
    99.8 +--- ioemu.orig/xenstore.c	2006-12-20 15:21:53.000000000 +0000
    99.9 ++++ ioemu/xenstore.c	2006-12-20 15:21:54.000000000 +0000
   99.10  @@ -185,3 +185,31 @@
   99.11       free(image);
   99.12       free(vec);
   99.13 @@ -36,9 +36,9 @@ Index: ioemu/xenstore.c
   99.14  +}
   99.15  Index: ioemu/vl.c
   99.16  ===================================================================
   99.17 ---- ioemu.orig/vl.c	2006-12-08 02:02:37.000000000 +0000
   99.18 -+++ ioemu/vl.c	2006-12-08 02:02:37.000000000 +0000
   99.19 -@@ -6535,6 +6535,7 @@
   99.20 +--- ioemu.orig/vl.c	2006-12-20 15:21:53.000000000 +0000
   99.21 ++++ ioemu/vl.c	2006-12-20 15:21:54.000000000 +0000
   99.22 +@@ -6527,6 +6527,7 @@
   99.23   	vnc_display = vnc_display_init(ds, vnc_display, vncunused, &vnclisten_addr);
   99.24   	if (vncviewer)
   99.25   	    vnc_start_viewer(vnc_display);
   99.26 @@ -48,8 +48,8 @@ Index: ioemu/vl.c
   99.27           sdl_display_init(ds, full_screen);
   99.28  Index: ioemu/vl.h
   99.29  ===================================================================
   99.30 ---- ioemu.orig/vl.h	2006-12-08 02:02:37.000000000 +0000
   99.31 -+++ ioemu/vl.h	2006-12-08 02:02:37.000000000 +0000
   99.32 +--- ioemu.orig/vl.h	2006-12-20 15:21:53.000000000 +0000
   99.33 ++++ ioemu/vl.h	2006-12-20 15:21:54.000000000 +0000
   99.34  @@ -1210,6 +1210,7 @@
   99.35   int xenstore_fd(void);
   99.36   void xenstore_process_event(void *opaque);
   100.1 --- a/tools/ioemu/target-i386-dm/exec-dm.c	Wed Jan 10 08:00:50 2007 -0700
   100.2 +++ b/tools/ioemu/target-i386-dm/exec-dm.c	Wed Jan 10 08:40:47 2007 -0700
   100.3 @@ -134,6 +134,7 @@ int loglevel;
   100.4  #endif
   100.5  
   100.6  #ifdef MAPCACHE
   100.7 +#include <pthread.h>
   100.8  static pthread_mutex_t mapcache_mutex;
   100.9  #define mapcache_lock() pthread_mutex_lock(&mapcache_mutex)
  100.10  #define mapcache_unlock() pthread_mutex_unlock(&mapcache_mutex)
   101.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Wed Jan 10 08:00:50 2007 -0700
   101.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Wed Jan 10 08:40:47 2007 -0700
   101.3 @@ -498,6 +498,8 @@ void handle_buffered_io(void *opaque)
   101.4  
   101.5  void cpu_handle_ioreq(void *opaque)
   101.6  {
   101.7 +    extern int vm_running;
   101.8 +    extern int shutdown_requested;
   101.9      CPUState *env = opaque;
  101.10      ioreq_t *req = cpu_get_ioreq();
  101.11  
  101.12 @@ -516,6 +518,25 @@ void cpu_handle_ioreq(void *opaque)
  101.13          }
  101.14  
  101.15          wmb(); /* Update ioreq contents /then/ update state. */
  101.16 +
  101.17 +	/*
  101.18 +         * We do this before we send the response so that the tools
  101.19 +         * have the opportunity to pick up on the reset before the
  101.20 +         * guest resumes and does a hlt with interrupts disabled which
  101.21 +         * causes Xen to powerdown the domain.
  101.22 +         */
  101.23 +        if (vm_running) {
  101.24 +            if (shutdown_requested) {
  101.25 +		fprintf(logfile, "shutdown requested in cpu_handle_ioreq\n");
  101.26 +		destroy_hvm_domain();
  101.27 +	    }
  101.28 +	    if (reset_requested) {
  101.29 +		fprintf(logfile, "reset requested in cpu_handle_ioreq.\n");
  101.30 +		qemu_system_reset();
  101.31 +		reset_requested = 0;
  101.32 +	    }
  101.33 +	}
  101.34 +
  101.35          req->state = STATE_IORESP_READY;
  101.36          xc_evtchn_notify(xce_handle, ioreq_local_port[send_vcpu]);
  101.37      }
   102.1 --- a/tools/ioemu/vl.c	Wed Jan 10 08:00:50 2007 -0700
   102.2 +++ b/tools/ioemu/vl.c	Wed Jan 10 08:40:47 2007 -0700
   102.3 @@ -6153,7 +6153,7 @@ int main(int argc, char **argv)
   102.4              case QEMU_OPTION_boot:
   102.5                  boot_device = strdup(optarg);
   102.6                  if (strspn(boot_device, "acd"
   102.7 -#ifdef TARGET_SPARC
   102.8 +#if defined(TARGET_SPARC) || defined(TARGET_I386)
   102.9                             "n"
  102.10  #endif
  102.11                          ) != strlen(boot_device)) {
   103.1 --- a/tools/ioemu/vnc.c	Wed Jan 10 08:00:50 2007 -0700
   103.2 +++ b/tools/ioemu/vnc.c	Wed Jan 10 08:40:47 2007 -0700
   103.3 @@ -54,12 +54,12 @@ typedef struct Buffer
   103.4  {
   103.5      size_t capacity;
   103.6      size_t offset;
   103.7 -    char *buffer;
   103.8 +    uint8_t *buffer;
   103.9  } Buffer;
  103.10  
  103.11  typedef struct VncState VncState;
  103.12  
  103.13 -typedef int VncReadEvent(VncState *vs, char *data, size_t len);
  103.14 +typedef int VncReadEvent(VncState *vs, uint8_t *data, size_t len);
  103.15  
  103.16  typedef void VncWritePixels(VncState *vs, void *data, int size);
  103.17  
  103.18 @@ -90,7 +90,7 @@ struct VncState
  103.19      uint64_t *update_row;	/* outstanding updates */
  103.20      int has_update;		/* there's outstanding updates in the
  103.21  				 * visible area */
  103.22 -    char *old_data;
  103.23 +    uint8_t *old_data;
  103.24      int depth; /* internal VNC frame buffer byte per pixel */
  103.25      int has_resize;
  103.26      int has_hextile;
  103.27 @@ -140,7 +140,7 @@ static void _vnc_update_client(void *opa
  103.28  static void vnc_update_client(void *opaque);
  103.29  static void vnc_client_read(void *opaque);
  103.30  static void framebuffer_set_updated(VncState *vs, int x, int y, int w, int h);
  103.31 -static int make_challenge(char *random, int size);
  103.32 +static int make_challenge(unsigned char *random, int size);
  103.33  static void set_seed(unsigned int *seedp);
  103.34  static void get_random(int len, unsigned char *buf);
  103.35  
  103.36 @@ -330,7 +330,7 @@ static void vnc_write_pixels_generic(Vnc
  103.37  static void send_framebuffer_update_raw(VncState *vs, int x, int y, int w, int h)
  103.38  {
  103.39      int i;
  103.40 -    char *row;
  103.41 +    uint8_t *row;
  103.42  
  103.43      vnc_framebuffer_update(vs, x, y, w, h, 0);
  103.44  
  103.45 @@ -394,9 +394,9 @@ static void send_framebuffer_update(VncS
  103.46  static void vnc_copy(DisplayState *ds, int src_x, int src_y, int dst_x, int dst_y, int w, int h)
  103.47  {
  103.48      int src, dst;
  103.49 -    char *src_row;
  103.50 -    char *dst_row;
  103.51 -    char *old_row;
  103.52 +    uint8_t *src_row;
  103.53 +    uint8_t *dst_row;
  103.54 +    uint8_t *old_row;
  103.55      int y = 0;
  103.56      int pitch = ds->linesize;
  103.57      VncState *vs = ds->opaque;
  103.58 @@ -465,8 +465,8 @@ static void _vnc_update_client(void *opa
  103.59      VncState *vs = opaque;
  103.60      int64_t now;
  103.61      int y;
  103.62 -    char *row;
  103.63 -    char *old_row;
  103.64 +    uint8_t *row;
  103.65 +    uint8_t *old_row;
  103.66      uint64_t width_mask;
  103.67      int n_rectangles;
  103.68      int saved_offset;
  103.69 @@ -491,7 +491,7 @@ static void _vnc_update_client(void *opa
  103.70      for (y = 0; y < vs->ds->height; y++) {
  103.71  	if (vs->dirty_row[y] & width_mask) {
  103.72  	    int x;
  103.73 -	    char *ptr, *old_ptr;
  103.74 +	    uint8_t *ptr, *old_ptr;
  103.75  
  103.76  	    ptr = row;
  103.77  	    old_ptr = old_row;
  103.78 @@ -654,7 +654,7 @@ static int buffer_empty(Buffer *buffer)
  103.79      return buffer->offset == 0;
  103.80  }
  103.81  
  103.82 -static char *buffer_end(Buffer *buffer)
  103.83 +static uint8_t *buffer_end(Buffer *buffer)
  103.84  {
  103.85      return buffer->buffer + buffer->offset;
  103.86  }
  103.87 @@ -778,7 +778,7 @@ static void vnc_write_u32(VncState *vs, 
  103.88  
  103.89  static void vnc_write_u16(VncState *vs, uint16_t value)
  103.90  {
  103.91 -    char buf[2];
  103.92 +    uint8_t buf[2];
  103.93  
  103.94      buf[0] = (value >> 8) & 0xFF;
  103.95      buf[1] = value & 0xFF;
  103.96 @@ -788,7 +788,7 @@ static void vnc_write_u16(VncState *vs, 
  103.97  
  103.98  static void vnc_write_u8(VncState *vs, uint8_t value)
  103.99  {
 103.100 -    vnc_write(vs, (char *)&value, 1);
 103.101 +    vnc_write(vs, &value, 1);
 103.102  }
 103.103  
 103.104  static void vnc_flush(VncState *vs)
 103.105 @@ -797,23 +797,23 @@ static void vnc_flush(VncState *vs)
 103.106  	vnc_client_write(vs);
 103.107  }
 103.108  
 103.109 -static uint8_t read_u8(char *data, size_t offset)
 103.110 +static uint8_t read_u8(uint8_t *data, size_t offset)
 103.111  {
 103.112      return data[offset];
 103.113  }
 103.114  
 103.115 -static uint16_t read_u16(char *data, size_t offset)
 103.116 +static uint16_t read_u16(uint8_t *data, size_t offset)
 103.117  {
 103.118      return ((data[offset] & 0xFF) << 8) | (data[offset + 1] & 0xFF);
 103.119  }
 103.120  
 103.121 -static int32_t read_s32(char *data, size_t offset)
 103.122 +static int32_t read_s32(uint8_t *data, size_t offset)
 103.123  {
 103.124      return (int32_t)((data[offset] << 24) | (data[offset + 1] << 16) |
 103.125  		     (data[offset + 2] << 8) | data[offset + 3]);
 103.126  }
 103.127  
 103.128 -static uint32_t read_u32(char *data, size_t offset)
 103.129 +static uint32_t read_u32(uint8_t *data, size_t offset)
 103.130  {
 103.131      return ((data[offset] << 24) | (data[offset + 1] << 16) |
 103.132  	    (data[offset + 2] << 8) | data[offset + 3]);
 103.133 @@ -1115,11 +1115,10 @@ static void set_pixel_format(VncState *v
 103.134      vga_hw_update();
 103.135  }
 103.136  
 103.137 -static int protocol_client_msg(VncState *vs, char *data, size_t len)
 103.138 +static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
 103.139  {
 103.140      int i;
 103.141      uint16_t limit;
 103.142 -    int64_t now;
 103.143  
 103.144      switch (data[0]) {
 103.145      case 0:
 103.146 @@ -1188,7 +1187,7 @@ static int protocol_client_msg(VncState 
 103.147  		return 8 + v;
 103.148  	}
 103.149  
 103.150 -	client_cut_text(vs, read_u32(data, 4), data + 8);
 103.151 +	client_cut_text(vs, read_u32(data, 4), (char *)(data + 8));
 103.152  	break;
 103.153      default:
 103.154  	printf("Msg: %d\n", data[0]);
 103.155 @@ -1200,7 +1199,7 @@ static int protocol_client_msg(VncState 
 103.156      return 0;
 103.157  }
 103.158  
 103.159 -static int protocol_client_init(VncState *vs, char *data, size_t len)
 103.160 +static int protocol_client_init(VncState *vs, uint8_t *data, size_t len)
 103.161  {
 103.162      size_t l;
 103.163      char pad[3] = { 0, 0, 0 };
 103.164 @@ -1261,7 +1260,7 @@ static int protocol_client_init(VncState
 103.165      return 0;
 103.166  }
 103.167  
 103.168 -static int protocol_response(VncState *vs, char *client_response, size_t len)
 103.169 +static int protocol_response(VncState *vs, uint8_t *client_response, size_t len)
 103.170  {
 103.171      extern char vncpasswd[64];
 103.172      extern unsigned char challenge[AUTHCHALLENGESIZE];
 103.173 @@ -1299,7 +1298,7 @@ static int protocol_response(VncState *v
 103.174      return 0;
 103.175  }
 103.176  
 103.177 -static int protocol_version(VncState *vs, char *version, size_t len)
 103.178 +static int protocol_version(VncState *vs, uint8_t *version, size_t len)
 103.179  {
 103.180      extern char vncpasswd[64];
 103.181      extern unsigned char challenge[AUTHCHALLENGESIZE];
 103.182 @@ -1318,7 +1317,7 @@ static int protocol_version(VncState *vs
 103.183  
 103.184  
 103.185      support = 0;
 103.186 -    if (maj = 3) {
 103.187 +    if (maj == 3) {
 103.188  	if (min == 3 || min ==4) {
 103.189  	    support = 1;
 103.190  	}
 103.191 @@ -1468,7 +1467,7 @@ int vnc_start_viewer(int port)
 103.192  
 103.193  unsigned int seed;
 103.194  
 103.195 -static int make_challenge(char *random, int size)
 103.196 +static int make_challenge(unsigned char *random, int size)
 103.197  {
 103.198   
 103.199      set_seed(&seed);
   104.1 --- a/tools/ioemu/vnchextile.h	Wed Jan 10 08:00:50 2007 -0700
   104.2 +++ b/tools/ioemu/vnchextile.h	Wed Jan 10 08:40:47 2007 -0700
   104.3 @@ -13,7 +13,7 @@ static void CONCAT(send_hextile_tile_, N
   104.4                                               uint32_t *last_fg32,
   104.5                                               int *has_bg, int *has_fg)
   104.6  {
   104.7 -    char *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth);
   104.8 +    uint8_t *row = (vs->ds->data + y * vs->ds->linesize + x * vs->depth);
   104.9      pixel_t *irow = (pixel_t *)row;
  104.10      int j, i;
  104.11      pixel_t *last_bg = (pixel_t *)last_bg32;
  104.12 @@ -119,7 +119,7 @@ static void CONCAT(send_hextile_tile_, N
  104.13  	for (j = 0; j < h; j++) {
  104.14  	    int has_color = 0;
  104.15  	    int min_x = -1;
  104.16 -	    pixel_t color;
  104.17 +	    pixel_t color = 0;
  104.18  
  104.19  	    for (i = 0; i < w; i++) {
  104.20  		if (!has_color) {
   105.1 --- a/tools/libxc/xc_hvm_build.c	Wed Jan 10 08:00:50 2007 -0700
   105.2 +++ b/tools/libxc/xc_hvm_build.c	Wed Jan 10 08:40:47 2007 -0700
   105.3 @@ -233,8 +233,7 @@ static int setup_guest(int xc_handle,
   105.4               SCRATCH_PFN)) == NULL) )
   105.5          goto error_out;
   105.6      memset(shared_info, 0, PAGE_SIZE);
   105.7 -    for ( i = 0; i < MAX_VIRT_CPUS; i++ )
   105.8 -        shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
   105.9 +    /* NB. evtchn_upcall_mask is unused: leave as zero. */
  105.10      memset(&shared_info->evtchn_mask[0], 0xff,
  105.11             sizeof(shared_info->evtchn_mask));
  105.12      munmap(shared_info, PAGE_SIZE);
   106.1 --- a/tools/libxc/xc_linux_build.c	Wed Jan 10 08:00:50 2007 -0700
   106.2 +++ b/tools/libxc/xc_linux_build.c	Wed Jan 10 08:40:47 2007 -0700
   106.3 @@ -595,6 +595,7 @@ static int compat_check(int xc_handle, s
   106.4          return 0;
   106.5      }
   106.6  
   106.7 +#ifndef __x86_64__//temp
   106.8      if (strstr(xen_caps, "xen-3.0-x86_32p")) {
   106.9          if (dsi->pae_kernel == PAEKERN_bimodal) {
  106.10              dsi->pae_kernel = PAEKERN_extended_cr3;
  106.11 @@ -612,6 +613,7 @@ static int compat_check(int xc_handle, s
  106.12              return 0;
  106.13          }
  106.14      }
  106.15 +#endif
  106.16  
  106.17      return 1;
  106.18  }
  106.19 @@ -1079,7 +1081,7 @@ static int setup_guest(int xc_handle,
  106.20  static int xc_linux_build_internal(int xc_handle,
  106.21                                     uint32_t domid,
  106.22                                     unsigned int mem_mb,
  106.23 -                                   char *image,
  106.24 +                                   const char *image,
  106.25                                     unsigned long image_size,
  106.26                                     struct initrd_info *initrd,
  106.27                                     const char *cmdline,
   107.1 --- a/tools/libxc/xc_linux_restore.c	Wed Jan 10 08:00:50 2007 -0700
   107.2 +++ b/tools/libxc/xc_linux_restore.c	Wed Jan 10 08:40:47 2007 -0700
   107.3 @@ -709,7 +709,7 @@ int xc_linux_restore(int xc_handle, int 
   107.4          goto out;
   107.5      }
   107.6  
   107.7 -    for (i = 0; i < ctxt.gdt_ents; i += 512) {
   107.8 +    for (i = 0; (512*i) < ctxt.gdt_ents; i++) {
   107.9          pfn = ctxt.gdt_frames[i];
  107.10          if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) {
  107.11              ERROR("GDT frame number is bad");
   108.1 --- a/tools/libxc/xc_linux_save.c	Wed Jan 10 08:00:50 2007 -0700
   108.2 +++ b/tools/libxc/xc_linux_save.c	Wed Jan 10 08:40:47 2007 -0700
   108.3 @@ -44,6 +44,7 @@ static xen_pfn_t *live_p2m = NULL;
   108.4  
   108.5  /* Live mapping of system MFN to PFN table. */
   108.6  static xen_pfn_t *live_m2p = NULL;
   108.7 +static unsigned long m2p_mfn0;
   108.8  
   108.9  /* grep fodder: machine_to_phys */
  108.10  
  108.11 @@ -80,7 +81,7 @@ static xen_pfn_t *live_m2p = NULL;
  108.12  #define BITMAP_SIZE   ((max_pfn + BITS_PER_LONG - 1) / 8)
  108.13  
  108.14  #define BITMAP_ENTRY(_nr,_bmap) \
  108.15 -   ((unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG]
  108.16 +   ((volatile unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG]
  108.17  
  108.18  #define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG)
  108.19  
  108.20 @@ -112,7 +113,7 @@ static inline unsigned int hweight32(uns
  108.21  static inline int count_bits ( int nr, volatile void *addr)
  108.22  {
  108.23      int i, count = 0;
  108.24 -    unsigned long *p = (unsigned long *)addr;
  108.25 +    volatile unsigned long *p = (volatile unsigned long *)addr;
  108.26      /* We know that the array is padded to unsigned long. */
  108.27      for( i = 0; i < (nr / (sizeof(unsigned long)*8)); i++, p++ )
  108.28          count += hweight32(*p);
  108.29 @@ -440,13 +441,23 @@ static int canonicalize_pagetable(unsign
  108.30      ** that this check will fail for other L2s.
  108.31      */
  108.32      if (pt_levels == 3 && type == XEN_DOMCTL_PFINFO_L2TAB) {
  108.33 +        int hstart;
  108.34 +        unsigned long he;
  108.35  
  108.36 -/* XXX index of the L2 entry in PAE mode which holds the guest LPT */
  108.37 -#define PAE_GLPT_L2ENTRY (495)
  108.38 -        pte = ((uint64_t*)spage)[PAE_GLPT_L2ENTRY];
  108.39 +        hstart = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
  108.40 +        he = ((const uint64_t *) spage)[hstart];
  108.41  
  108.42 -        if(((pte >> PAGE_SHIFT) & 0x0fffffff) == live_p2m[pfn])
  108.43 -            xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
  108.44 +        if ( ((he >> PAGE_SHIFT) & 0x0fffffff) == m2p_mfn0 ) {
  108.45 +            /* hvirt starts with xen stuff... */
  108.46 +            xen_start = hstart;
  108.47 +        } else if ( hvirt_start != 0xf5800000 ) {
  108.48 +            /* old L2s from before hole was shrunk... */
  108.49 +            hstart = (0xf5800000 >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff;
  108.50 +            he = ((const uint64_t *) spage)[hstart];
  108.51 +
  108.52 +            if( ((he >> PAGE_SHIFT) & 0x0fffffff) == m2p_mfn0 )
  108.53 +                xen_start = hstart;
  108.54 +        }
  108.55      }
  108.56  
  108.57      if (pt_levels == 4 && type == XEN_DOMCTL_PFINFO_L4TAB) {
  108.58 @@ -464,9 +475,9 @@ static int canonicalize_pagetable(unsign
  108.59          unsigned long pfn, mfn;
  108.60  
  108.61          if (pt_levels == 2)
  108.62 -            pte = ((uint32_t*)spage)[i];
  108.63 +            pte = ((const uint32_t*)spage)[i];
  108.64          else
  108.65 -            pte = ((uint64_t*)spage)[i];
  108.66 +            pte = ((const uint64_t*)spage)[i];
  108.67  
  108.68          if (i >= xen_start && i < xen_end)
  108.69              pte = 0;
  108.70 @@ -550,6 +561,8 @@ static xen_pfn_t *xc_map_m2p(int xc_hand
  108.71          return NULL;
  108.72      }
  108.73  
  108.74 +    m2p_mfn0 = entries[0].mfn;
  108.75 +
  108.76      free(extent_start);
  108.77      free(entries);
  108.78  
  108.79 @@ -915,14 +928,14 @@ int xc_linux_save(int xc_handle, int io_
  108.80  
  108.81                  if(!is_mapped(pfn_type[batch])) {
  108.82  
  108.83 -                    /* not currently in pusedo-physical map -- set bit
  108.84 -                       in to_fix that we must send this page in last_iter
  108.85 -                       unless its sent sooner anyhow */
  108.86 +                    /*
  108.87 +                    ** not currently in psuedo-physical map -- set bit
  108.88 +                    ** in to_fix since we must send this page in last_iter
  108.89 +                    ** unless its sent sooner anyhow, or it never enters
  108.90 +                    ** pseudo-physical map (e.g. for ballooned down domains)
  108.91 +                    */
  108.92  
  108.93                      set_bit(n, to_fix);
  108.94 -                    if( (iter > 1) && IS_REAL_PFN(n) )
  108.95 -                        DPRINTF("netbuf race: iter %d, pfn %x. mfn %lx\n",
  108.96 -                                iter, n, pfn_type[batch]);
  108.97                      continue;
  108.98                  }
  108.99  
 108.100 @@ -1052,7 +1065,7 @@ int xc_linux_save(int xc_handle, int io_
 108.101              DPRINTF("(of which %ld were fixups)\n", needed_to_fix  );
 108.102          }
 108.103  
 108.104 -        if (last_iter && debug){
 108.105 +        if (last_iter && debug) {
 108.106              int minusone = -1;
 108.107              memset(to_send, 0xff, BITMAP_SIZE);
 108.108              debug = 0;
 108.109 @@ -1068,17 +1081,14 @@ int xc_linux_save(int xc_handle, int io_
 108.110              continue;
 108.111          }
 108.112  
 108.113 -        if (last_iter) break;
 108.114 +        if (last_iter)
 108.115 +            break;
 108.116  
 108.117          if (live) {
 108.118 -
 108.119 -
 108.120 -            if(
 108.121 -                ((sent_this_iter > sent_last_iter) && RATE_IS_MAX()) ||
 108.122 +            if (((sent_this_iter > sent_last_iter) && RATE_IS_MAX()) ||
 108.123                  (iter >= max_iters) ||
 108.124                  (sent_this_iter+skip_this_iter < 50) ||
 108.125 -                (total_sent > max_pfn*max_factor) ) {
 108.126 -
 108.127 +                (total_sent > max_pfn*max_factor)) {
 108.128                  DPRINTF("Start last iteration\n");
 108.129                  last_iter = 1;
 108.130  
 108.131 @@ -1106,8 +1116,6 @@ int xc_linux_save(int xc_handle, int io_
 108.132              print_stats(xc_handle, dom, sent_this_iter, &stats, 1);
 108.133  
 108.134          }
 108.135 -
 108.136 -
 108.137      } /* end of while 1 */
 108.138  
 108.139      DPRINTF("All memory is saved\n");
 108.140 @@ -1159,7 +1167,7 @@ int xc_linux_save(int xc_handle, int io_
 108.141      }
 108.142  
 108.143      /* Canonicalise each GDT frame number. */
 108.144 -    for ( i = 0; i < ctxt.gdt_ents; i += 512 ) {
 108.145 +    for ( i = 0; (512*i) < ctxt.gdt_ents; i++ ) {
 108.146          if ( !translate_mfn_to_pfn(&ctxt.gdt_frames[i]) ) {
 108.147              ERROR("GDT frame is not in range of pseudophys map");
 108.148              goto out;
   109.1 --- a/tools/libxc/xc_load_bin.c	Wed Jan 10 08:00:50 2007 -0700
   109.2 +++ b/tools/libxc/xc_load_bin.c	Wed Jan 10 08:40:47 2007 -0700
   109.3 @@ -98,7 +98,7 @@ struct xen_bin_image_table
   109.4  #define FLAGS_MASK     ((~ 0) & (~ XEN_REACTOS_FLAG_ALIGN4K))
   109.5  #define FLAGS_REQUIRED XEN_REACTOS_FLAG_ADDRSVALID
   109.6  
   109.7 -static struct xen_bin_image_table *
   109.8 +static const struct xen_bin_image_table *
   109.9  findtable(const char *image, unsigned long image_size);
  109.10  static int
  109.11  parsebinimage(
  109.12 @@ -122,11 +122,11 @@ int probe_bin(const char *image,
  109.13      return 0;
  109.14  }
  109.15  
  109.16 -static struct xen_bin_image_table *
  109.17 +static const struct xen_bin_image_table *
  109.18  findtable(const char *image, unsigned long image_size)
  109.19  {
  109.20 -    struct xen_bin_image_table *table;
  109.21 -    unsigned long *probe_ptr;
  109.22 +    const struct xen_bin_image_table *table;
  109.23 +    const unsigned long *probe_ptr;
  109.24      unsigned probe_index;
  109.25      unsigned probe_count;
  109.26  
  109.27 @@ -142,13 +142,13 @@ findtable(const char *image, unsigned lo
  109.28                    sizeof(unsigned long);
  109.29  
  109.30      /* Search for the magic header */
  109.31 -    probe_ptr = (unsigned long *) image;
  109.32 +    probe_ptr = (const unsigned long *) image;
  109.33      table = NULL;
  109.34      for ( probe_index = 0; probe_index < probe_count; probe_index++ )
  109.35      {
  109.36          if ( XEN_REACTOS_MAGIC3 == *probe_ptr )
  109.37          {
  109.38 -            table = (struct xen_bin_image_table *) probe_ptr;
  109.39 +            table = (const struct xen_bin_image_table *) probe_ptr;
  109.40              /* Checksum correct? */
  109.41              if ( 0 == table->magic + table->flags + table->checksum )
  109.42              {
  109.43 @@ -165,7 +165,7 @@ static int parsebinimage(const char *ima
  109.44                           unsigned long image_size,
  109.45                           struct domain_setup_info *dsi)
  109.46  {
  109.47 -    struct xen_bin_image_table *image_info;
  109.48 +    const struct xen_bin_image_table *image_info;
  109.49      unsigned long start_addr;
  109.50      unsigned long end_addr;
  109.51  
  109.52 @@ -186,13 +186,13 @@ static int parsebinimage(const char *ima
  109.53  
  109.54      /* Sanity check on the addresses */
  109.55      if ( image_info->header_addr < image_info->load_addr ||
  109.56 -         ((char *) image_info - image) <
  109.57 +         ((const char *) image_info - image) <
  109.58           (image_info->header_addr - image_info->load_addr) )
  109.59      {
  109.60          ERROR("Invalid header_addr.");
  109.61          return -EINVAL;
  109.62      }
  109.63 -    start_addr = image_info->header_addr - ((char *) image_info - image);
  109.64 +    start_addr = image_info->header_addr - ((const char *) image_info - image);
  109.65      if ( 0 != image_info->load_end_addr &&
  109.66           ( image_info->load_end_addr < image_info->load_end_addr ||
  109.67             start_addr + image_size < image_info->load_end_addr ) )
  109.68 @@ -221,7 +221,7 @@ static int parsebinimage(const char *ima
  109.69      else
  109.70      {
  109.71          dsi->v_end = image_info->load_addr + image_size -
  109.72 -                     (((char *) image_info - image) -
  109.73 +                     (((const char *) image_info - image) -
  109.74                        (image_info->header_addr - image_info->load_addr));
  109.75      }
  109.76      dsi->v_kernstart = dsi->v_start;
  109.77 @@ -240,7 +240,7 @@ loadbinimage(
  109.78      unsigned long size;
  109.79      char         *va;
  109.80      unsigned long done, chunksz;
  109.81 -    struct xen_bin_image_table *image_info;
  109.82 +    const struct xen_bin_image_table *image_info;
  109.83  
  109.84      image_info = findtable(image, image_size);
  109.85      if ( NULL == image_info )
  109.86 @@ -252,7 +252,7 @@ loadbinimage(
  109.87      /* Determine image size */
  109.88      if ( 0 == image_info->load_end_addr )
  109.89      {
  109.90 -        size = image_size  - (((char *) image_info - image) -
  109.91 +        size = image_size  - (((const char *)image_info - image) -
  109.92                                (image_info->header_addr -
  109.93                                 image_info->load_addr));
  109.94      }
  109.95 @@ -262,7 +262,7 @@ loadbinimage(
  109.96      }
  109.97  
  109.98      /* It's possible that we need to skip the first part of the image */
  109.99 -    image += ((char *)image_info - image) -
 109.100 +    image += ((const char *)image_info - image) -
 109.101               (image_info->header_addr - image_info->load_addr);
 109.102  
 109.103      for ( done = 0; done < size; done += chunksz )
   110.1 --- a/tools/libxc/xc_load_elf.c	Wed Jan 10 08:00:50 2007 -0700
   110.2 +++ b/tools/libxc/xc_load_elf.c	Wed Jan 10 08:40:47 2007 -0700
   110.3 @@ -75,7 +75,7 @@ int probe_elf(const char *image,
   110.4                unsigned long image_size,
   110.5                struct load_funcs *load_funcs)
   110.6  {
   110.7 -    Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
   110.8 +    const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
   110.9  
  110.10      if ( !IS_ELF(*ehdr) )
  110.11          return -EINVAL;
  110.12 @@ -86,7 +86,7 @@ int probe_elf(const char *image,
  110.13      return 0;
  110.14  }
  110.15  
  110.16 -static inline int is_loadable_phdr(Elf_Phdr *phdr)
  110.17 +static inline int is_loadable_phdr(const Elf_Phdr *phdr)
  110.18  {
  110.19      return ((phdr->p_type == PT_LOAD) &&
  110.20              ((phdr->p_flags & (PF_W|PF_X)) != 0));
  110.21 @@ -96,12 +96,13 @@ static inline int is_loadable_phdr(Elf_P
  110.22   * Fallback for kernels containing only the legacy __xen_guest string
  110.23   * and no ELF notes.
  110.24   */
  110.25 -static int is_xen_guest_section(Elf_Shdr *shdr, const char *shstrtab)
  110.26 +static int is_xen_guest_section(const Elf_Shdr *shdr, const char *shstrtab)
  110.27  {
  110.28      return strcmp(&shstrtab[shdr->sh_name], "__xen_guest") == 0;
  110.29  }
  110.30  
  110.31 -static const char *xen_guest_lookup(struct domain_setup_info *dsi, int type)
  110.32 +static const char *xen_guest_lookup(
  110.33 +    const struct domain_setup_info *dsi, int type)
  110.34  {
  110.35      const char *xenguest_fallbacks[] = {
  110.36          [XEN_ELFNOTE_ENTRY] = "VIRT_ENTRY=",
  110.37 @@ -134,7 +135,8 @@ static const char *xen_guest_lookup(stru
  110.38      return p + strlen(fallback);
  110.39  }
  110.40  
  110.41 -static const char *xen_guest_string(struct domain_setup_info *dsi, int type)
  110.42 +static const char *xen_guest_string(
  110.43 +    const struct domain_setup_info *dsi, int type)
  110.44  {
  110.45      const char *p = xen_guest_lookup(dsi, type);
  110.46  
  110.47 @@ -148,8 +150,8 @@ static const char *xen_guest_string(stru
  110.48      return p;
  110.49  }
  110.50  
  110.51 -static unsigned long long xen_guest_numeric(struct domain_setup_info *dsi,
  110.52 -                                                   int type, int *defined)
  110.53 +static unsigned long long xen_guest_numeric(
  110.54 +    const struct domain_setup_info *dsi, int type, int *defined)
  110.55  {
  110.56      const char *p = xen_guest_lookup(dsi, type);
  110.57      unsigned long long value;
  110.58 @@ -175,19 +177,19 @@ static unsigned long long xen_guest_nume
  110.59  /*
  110.60   * Interface to the Xen ELF notes.
  110.61   */
  110.62 -#define ELFNOTE_NAME(_n_)   ((void*)(_n_) + sizeof(*(_n_)))
  110.63 +#define ELFNOTE_NAME(_n_)   ((const void*)(_n_) + sizeof(*(_n_)))
  110.64  #define ELFNOTE_DESC(_n_)   (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3))
  110.65  #define ELFNOTE_NEXT(_n_)   (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3))
  110.66  
  110.67 -static int is_xen_elfnote_section(const char *image, Elf_Shdr *shdr)
  110.68 +static int is_xen_elfnote_section(const char *image, const Elf_Shdr *shdr)
  110.69  {
  110.70 -    Elf_Note *note;
  110.71 +    const Elf_Note *note;
  110.72  
  110.73      if ( shdr->sh_type != SHT_NOTE )
  110.74          return 0;
  110.75  
  110.76 -    for ( note = (Elf_Note *)(image + shdr->sh_offset);
  110.77 -          note < (Elf_Note *)(image + shdr->sh_offset + shdr->sh_size);
  110.78 +    for ( note = (const Elf_Note *)(image + shdr->sh_offset);
  110.79 +          note < (const Elf_Note *)(image + shdr->sh_offset + shdr->sh_size);
  110.80            note = ELFNOTE_NEXT(note) )
  110.81      {
  110.82          if ( !strncmp(ELFNOTE_NAME(note), "Xen", 4) )
  110.83 @@ -197,15 +199,16 @@ static int is_xen_elfnote_section(const 
  110.84      return 0;
  110.85  }
  110.86  
  110.87 -static Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type)
  110.88 +static const Elf_Note *xen_elfnote_lookup(
  110.89 +    const struct domain_setup_info *dsi, int type)
  110.90  {
  110.91 -    Elf_Note *note;
  110.92 +    const Elf_Note *note;
  110.93  
  110.94      if ( !dsi->__elfnote_section )
  110.95          return NULL;
  110.96  
  110.97 -    for ( note = (Elf_Note *)dsi->__elfnote_section;
  110.98 -          note < (Elf_Note *)dsi->__elfnote_section_end;
  110.99 +    for ( note = (const Elf_Note *)dsi->__elfnote_section;
 110.100 +          note < (const Elf_Note *)dsi->__elfnote_section_end;
 110.101            note = ELFNOTE_NEXT(note) )
 110.102      {
 110.103          if ( strncmp(ELFNOTE_NAME(note), "Xen", 4) )
 110.104 @@ -218,9 +221,9 @@ static Elf_Note *xen_elfnote_lookup(stru
 110.105      return NULL;
 110.106  }
 110.107  
 110.108 -const char *xen_elfnote_string(struct domain_setup_info *dsi, int type)
 110.109 +const char *xen_elfnote_string(const struct domain_setup_info *dsi, int type)
 110.110  {
 110.111 -    Elf_Note *note;
 110.112 +    const Elf_Note *note;
 110.113  
 110.114      if ( !dsi->__elfnote_section )
 110.115          return xen_guest_string(dsi, type);
 110.116 @@ -232,10 +235,10 @@ const char *xen_elfnote_string(struct do
 110.117      return (const char *)ELFNOTE_DESC(note);
 110.118  }
 110.119  
 110.120 -unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
 110.121 +unsigned long long xen_elfnote_numeric(const struct domain_setup_info *dsi,
 110.122                                         int type, int *defined)
 110.123  {
 110.124 -    Elf_Note *note;
 110.125 +    const Elf_Note *note;
 110.126  
 110.127      *defined = 0;
 110.128  
 110.129 @@ -252,10 +255,10 @@ unsigned long long xen_elfnote_numeric(s
 110.130      {
 110.131      case 4:
 110.132          *defined = 1;
 110.133 -        return *(uint32_t*)ELFNOTE_DESC(note);
 110.134 +        return *(const uint32_t*)ELFNOTE_DESC(note);
 110.135      case 8:
 110.136          *defined = 1;
 110.137 -        return *(uint64_t*)ELFNOTE_DESC(note);
 110.138 +        return *(const uint64_t*)ELFNOTE_DESC(note);
 110.139      default:
 110.140          xc_set_error(XC_INVALID_KERNEL,
 110.141                       "elfnotes: unknown data size %#x for numeric type note %#x\n",
 110.142 @@ -268,9 +271,9 @@ static int parseelfimage(const char *ima
 110.143                           unsigned long image_len,
 110.144                           struct domain_setup_info *dsi)
 110.145  {
 110.146 -    Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
 110.147 -    Elf_Phdr *phdr;
 110.148 -    Elf_Shdr *shdr;
 110.149 +    const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
 110.150 +    const Elf_Phdr *phdr;
 110.151 +    const Elf_Shdr *shdr;
 110.152      Elf_Addr kernstart = ~0, kernend = 0, vaddr, virt_entry;
 110.153      const char *shstrtab, *p;
 110.154      int h, virt_base_defined, elf_pa_off_defined, virt_entry_defined;
 110.155 @@ -331,12 +334,13 @@ static int parseelfimage(const char *ima
 110.156      /* Look for .notes segment containing at least one Xen note */
 110.157      for ( h = 0; h < ehdr->e_shnum; h++ )
 110.158      {
 110.159 -        shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
 110.160 +        shdr = (const Elf_Shdr *)(
 110.161 +            image + ehdr->e_shoff + (h*ehdr->e_shentsize));
 110.162          if ( !is_xen_elfnote_section(image, shdr) )
 110.163              continue;
 110.164 -        dsi->__elfnote_section = (void *)image + shdr->sh_offset;
 110.165 +        dsi->__elfnote_section = (const void *)image + shdr->sh_offset;
 110.166          dsi->__elfnote_section_end =
 110.167 -            (void *)image + shdr->sh_offset + shdr->sh_size;
 110.168 +            (const void *)image + shdr->sh_offset + shdr->sh_size;
 110.169          break;
 110.170      }
 110.171  
 110.172 @@ -350,16 +354,18 @@ static int parseelfimage(const char *ima
 110.173                           "ELF image has no section-header strings table.");
 110.174              return -EINVAL;
 110.175          }
 110.176 -        shdr = (Elf_Shdr *)(image + ehdr->e_shoff +
 110.177 +        shdr = (const Elf_Shdr *)(image + ehdr->e_shoff +
 110.178                              (ehdr->e_shstrndx*ehdr->e_shentsize));
 110.179          shstrtab = image + shdr->sh_offset;
 110.180  
 110.181          for ( h = 0; h < ehdr->e_shnum; h++ )
 110.182          {
 110.183 -            shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize));
 110.184 +            shdr = (const Elf_Shdr *)(
 110.185 +                image + ehdr->e_shoff + (h*ehdr->e_shentsize));
 110.186              if ( is_xen_guest_section(shdr, shstrtab) )
 110.187              {
 110.188 -                dsi->__xen_guest_string = (char *)image + shdr->sh_offset;
 110.189 +                dsi->__xen_guest_string =
 110.190 +                    (const char *)image + shdr->sh_offset;
 110.191                  break;
 110.192              }
 110.193          }
 110.194 @@ -442,8 +448,8 @@ static int parseelfimage(const char *ima
 110.195       * If we are using the modern ELF notes interface then the default
 110.196       * is 0.
 110.197       */
 110.198 -    dsi->elf_paddr_offset =
 110.199 -        xen_elfnote_numeric(dsi, XEN_ELFNOTE_PADDR_OFFSET, &elf_pa_off_defined);
 110.200 +    dsi->elf_paddr_offset = xen_elfnote_numeric(dsi, XEN_ELFNOTE_PADDR_OFFSET,
 110.201 +                                                &elf_pa_off_defined);
 110.202      if ( !elf_pa_off_defined )
 110.203      {
 110.204          if ( dsi->__elfnote_section )
 110.205 @@ -462,7 +468,8 @@ static int parseelfimage(const char *ima
 110.206  
 110.207      for ( h = 0; h < ehdr->e_phnum; h++ )
 110.208      {
 110.209 -        phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
 110.210 +        phdr = (const Elf_Phdr *)(
 110.211 +            image + ehdr->e_phoff + (h*ehdr->e_phentsize));
 110.212          if ( !is_loadable_phdr(phdr) )
 110.213              continue;
 110.214          vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start;
 110.215 @@ -514,8 +521,8 @@ loadelfimage(
 110.216      const char *image, unsigned long elfsize, int xch, uint32_t dom,
 110.217      xen_pfn_t *parray, struct domain_setup_info *dsi)
 110.218  {
 110.219 -    Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
 110.220 -    Elf_Phdr *phdr;
 110.221 +    const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
 110.222 +    const Elf_Phdr *phdr;
 110.223      int h;
 110.224  
 110.225      char         *va;
 110.226 @@ -523,7 +530,8 @@ loadelfimage(
 110.227  
 110.228      for ( h = 0; h < ehdr->e_phnum; h++ )
 110.229      {
 110.230 -        phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize));
 110.231 +        phdr = (const Elf_Phdr *)(
 110.232 +            image + ehdr->e_phoff + (h*ehdr->e_phentsize));
 110.233          if ( !is_loadable_phdr(phdr) )
 110.234              continue;
 110.235  
 110.236 @@ -569,7 +577,8 @@ loadelfsymtab(
 110.237      const char *image, int xch, uint32_t dom, xen_pfn_t *parray,
 110.238      struct domain_setup_info *dsi)
 110.239  {
 110.240 -    Elf_Ehdr *ehdr = (Elf_Ehdr *)image, *sym_ehdr;
 110.241 +    const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image;
 110.242 +    Elf_Ehdr *sym_ehdr;
 110.243      Elf_Shdr *shdr;
 110.244      unsigned long maxva, symva;
 110.245      char *p;
   111.1 --- a/tools/libxc/xg_private.h	Wed Jan 10 08:00:50 2007 -0700
   111.2 +++ b/tools/libxc/xg_private.h	Wed Jan 10 08:40:47 2007 -0700
   111.3 @@ -146,7 +146,7 @@ struct domain_setup_info
   111.4       * You should use the xen_elfnote_* accessors below in order to
   111.5       * pickup the correct one and retain backwards compatibility.
   111.6       */
   111.7 -    void *__elfnote_section, *__elfnote_section_end;
   111.8 +    const void *__elfnote_section, *__elfnote_section_end;
   111.9      const char *__xen_guest_string;
  111.10  };
  111.11  
  111.12 @@ -162,14 +162,14 @@ typedef int (*loadimagefunc)(const char 
  111.13   * in the note is returned and *defined is set to non-zero. If no such
  111.14   * note is found then *defined is set to 0 and 0 is returned.
  111.15   */
  111.16 -extern unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi,
  111.17 +extern unsigned long long xen_elfnote_numeric(const struct domain_setup_info *dsi,
  111.18  					      int type, int *defined);
  111.19  
  111.20  /*
  111.21   * If an ELF note of the given type is found then the string contained
  111.22   * in the value is returned, otherwise NULL is returned.
  111.23   */
  111.24 -extern const char * xen_elfnote_string(struct domain_setup_info *dsi,
  111.25 +extern const char * xen_elfnote_string(const struct domain_setup_info *dsi,
  111.26  				       int type);
  111.27  
  111.28  struct load_funcs
   112.1 --- a/tools/libxc/xg_save_restore.h	Wed Jan 10 08:00:50 2007 -0700
   112.2 +++ b/tools/libxc/xg_save_restore.h	Wed Jan 10 08:40:47 2007 -0700
   112.3 @@ -53,8 +53,17 @@ static int get_platform_info(int xc_hand
   112.4  
   112.5      *hvirt_start = xen_params.virt_start;
   112.6  
   112.7 +    /*
   112.8 +     * XXX For now, 32bit dom0's can only save/restore 32bit domUs
   112.9 +     * on 64bit hypervisors, so no need to check which type of domain
  112.10 +     * we're dealing with.
  112.11 +     */
  112.12      if (strstr(xen_caps, "xen-3.0-x86_64"))
  112.13 +#if defined(__i386__)
  112.14 +        *pt_levels = 3;
  112.15 +#else
  112.16          *pt_levels = 4;
  112.17 +#endif
  112.18      else if (strstr(xen_caps, "xen-3.0-x86_32p"))
  112.19          *pt_levels = 3;
  112.20      else if (strstr(xen_caps, "xen-3.0-x86_32"))
  112.21 @@ -101,12 +110,6 @@ static int get_platform_info(int xc_hand
  112.22  /* Number of entries in the pfn_to_mfn_frame_list_list */
  112.23  #define P2M_FLL_ENTRIES (((max_pfn)+(fpp*fpp)-1)/(fpp*fpp))
  112.24  
  112.25 -/* Current guests allow 8MB 'slack' in their P2M */
  112.26 -#define NR_SLACK_ENTRIES   ((8 * 1024 * 1024) / PAGE_SIZE)
  112.27 -
  112.28 -/* Is the given PFN within the 'slack' region at the top of the P2M? */
  112.29 -#define IS_REAL_PFN(_pfn)  ((max_pfn - (_pfn)) > NR_SLACK_ENTRIES)
  112.30 -
  112.31  /* Returns TRUE if the PFN is currently mapped */
  112.32  #define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL))
  112.33  
   113.1 --- a/tools/libxen/include/xen_cpu_feature.h	Wed Jan 10 08:00:50 2007 -0700
   113.2 +++ b/tools/libxen/include/xen_cpu_feature.h	Wed Jan 10 08:40:47 2007 -0700
   113.3 @@ -198,12 +198,12 @@ enum xen_cpu_feature
   113.4      /**
   113.5       *  AMD 3DNow! extensions
   113.6       */
   113.7 -    XEN_CPU_FEATURE_3DNOWEXT,
   113.8 +    XEN_CPU_FEATURE_THREEDNOWEXT,
   113.9  
  113.10      /**
  113.11       *  3DNow!
  113.12       */
  113.13 -    XEN_CPU_FEATURE_3DNOW,
  113.14 +    XEN_CPU_FEATURE_THREEDNOW,
  113.15  
  113.16      /**
  113.17       *  CPU in recovery mode
   114.1 --- a/tools/libxen/src/xen_common.c	Wed Jan 10 08:00:50 2007 -0700
   114.2 +++ b/tools/libxen/src/xen_common.c	Wed Jan 10 08:40:47 2007 -0700
   114.3 @@ -373,11 +373,18 @@ static void server_error_2(xen_session *
   114.4  }
   114.5  
   114.6  
   114.7 +static bool is_node(xmlNode *n, char *type)
   114.8 +{
   114.9 +    return
  114.10 +        n->type == XML_ELEMENT_NODE &&
  114.11 +        0 == strcmp((char *)n->name, type);
  114.12 +}
  114.13 +
  114.14 +
  114.15  static bool is_container_node(xmlNode *n, char *type)
  114.16  {
  114.17      return
  114.18 -        n->type == XML_ELEMENT_NODE &&
  114.19 -        0 == strcmp((char *)n->name, type) &&
  114.20 +        is_node(n, type) &&
  114.21          n->children != NULL &&
  114.22          n->children == n->last &&
  114.23          n->children->type == XML_ELEMENT_NODE;
  114.24 @@ -390,13 +397,30 @@ static bool is_container_node(xmlNode *n
  114.25   */
  114.26  static xmlChar *string_from_value(xmlNode *n, char *type)
  114.27  {
  114.28 -    return
  114.29 -        is_container_node(n, "value") &&
  114.30 -        0 == strcmp((char *)n->children->name, type) ?
  114.31 -          (n->children->children == NULL ?
  114.32 -             xmlStrdup(BAD_CAST("")) :
  114.33 -             xmlNodeGetContent(n->children->children)) :
  114.34 -          NULL;
  114.35 +    /*
  114.36 +      <value><type>XYZ</type></value> is normal, but the XML-RPC spec also
  114.37 +      allows <value>XYZ</value> where XYZ is to be interpreted as a string.
  114.38 +    */
  114.39 +
  114.40 +    if (is_container_node(n, "value") &&
  114.41 +        0 == strcmp((char *)n->children->name, type))
  114.42 +    {
  114.43 +        return
  114.44 +            n->children->children == NULL ?
  114.45 +                xmlStrdup(BAD_CAST("")) :
  114.46 +                xmlNodeGetContent(n->children->children);
  114.47 +    }
  114.48 +    else if (0 == strcmp(type, "string") && is_node(n, "value"))
  114.49 +    {
  114.50 +        return
  114.51 +            n->children == NULL ?
  114.52 +                xmlStrdup(BAD_CAST("")) :
  114.53 +                xmlNodeGetContent(n->children);
  114.54 +    }
  114.55 +    else
  114.56 +    {
  114.57 +        return NULL;
  114.58 +    }
  114.59  }
  114.60  
  114.61  
  114.62 @@ -557,8 +581,14 @@ static void parse_into(xen_session *s, x
  114.63          xmlChar *string = string_from_value(value_node, "double");
  114.64          if (string == NULL)
  114.65          {
  114.66 +#if PERMISSIVE
  114.67 +            fprintf(stderr,
  114.68 +                    "Expected a Float from the server, but didn't get one\n");
  114.69 +            ((double *)value)[slot] = 0.0;
  114.70 +#else
  114.71              server_error(
  114.72                  s, "Expected a Float from the server, but didn't get one");
  114.73 +#endif
  114.74          }
  114.75          else
  114.76          {
   115.1 --- a/tools/libxen/src/xen_cpu_feature.c	Wed Jan 10 08:00:50 2007 -0700
   115.2 +++ b/tools/libxen/src/xen_cpu_feature.c	Wed Jan 10 08:40:47 2007 -0700
   115.3 @@ -62,8 +62,8 @@ static const char *lookup_table[] =
   115.4      "NX",
   115.5      "MMXEXT",
   115.6      "LM",
   115.7 -    "3DNOWEXT",
   115.8 -    "3DNOW",
   115.9 +    "THREEDNOWEXT",
  115.10 +    "THREEDNOW",
  115.11      "RECOVERY",
  115.12      "LONGRUN",
  115.13      "LRTI",
   116.1 --- a/tools/pygrub/src/pygrub	Wed Jan 10 08:00:50 2007 -0700
   116.2 +++ b/tools/pygrub/src/pygrub	Wed Jan 10 08:40:47 2007 -0700
   116.3 @@ -13,7 +13,7 @@
   116.4  # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   116.5  #
   116.6  
   116.7 -import os, sys, string, struct, tempfile
   116.8 +import os, sys, string, struct, tempfile, re
   116.9  import copy
  116.10  import logging
  116.11  
  116.12 @@ -66,6 +66,15 @@ def get_active_offset(file):
  116.13      P1 = 446
  116.14      return struct.unpack("<L", buf[P1+8:P1+12])[0] * SECTOR_SIZE
  116.15  
  116.16 +def open_fs(file):
  116.17 +    offset = 0
  116.18 +    if is_disk_image(file):
  116.19 +        offset = get_active_offset(file)
  116.20 +        if offset == -1:
  116.21 +            raise RuntimeError, "Unable to find active partition on disk"
  116.22 +
  116.23 +    return fsimage.open(file, offset)
  116.24 +
  116.25  class GrubLineEditor(curses.textpad.Textbox):
  116.26      def __init__(self, screen, startx, starty, line = ""):
  116.27          screen.addstr(startx, starty, "> ")
  116.28 @@ -143,12 +152,12 @@ class GrubLineEditor(curses.textpad.Text
  116.29          
  116.30  
  116.31  class Grub:
  116.32 -    def __init__(self, file, isconfig = False):
  116.33 +    def __init__(self, file, fs = None):
  116.34          self.screen = None
  116.35          self.entry_win = None
  116.36          self.text_win = None
  116.37          if file:
  116.38 -            self.read_config(file, isconfig)
  116.39 +            self.read_config(file, fs)
  116.40  
  116.41      def draw_main_windows(self):
  116.42          if self.screen is None: #only init stuff once
  116.43 @@ -295,8 +304,8 @@ class Grub:
  116.44              # else, we cancelled and should just go back
  116.45              break
  116.46  
  116.47 -    def read_config(self, fn, isConfig = False):
  116.48 -        """Read the given file to parse the config.  If isconfig, then
  116.49 +    def read_config(self, fn, fs = None):
  116.50 +        """Read the given file to parse the config.  If fs = None, then
  116.51          we're being given a raw config file rather than a disk image."""
  116.52          
  116.53          if not os.access(fn, os.R_OK):
  116.54 @@ -304,38 +313,25 @@ class Grub:
  116.55  
  116.56          self.cf = grub.GrubConf.GrubConfigFile()
  116.57  
  116.58 -        if isConfig:
  116.59 +        if not fs:
  116.60              # set the config file and parse it
  116.61              self.cf.filename = fn
  116.62              self.cf.parse()
  116.63              return
  116.64  
  116.65 -        offset = 0
  116.66 -        if is_disk_image(fn):
  116.67 -            offset = get_active_offset(fn)
  116.68 -            if offset == -1:
  116.69 -                raise RuntimeError, "Unable to find active partition on disk"
  116.70 -
  116.71 -        # open the image and read the grub config
  116.72 -        fs = fsimage.open(fn, offset)
  116.73 -
  116.74 -        if fs is not None:
  116.75 -            grubfile = None
  116.76 -            for f in ("/boot/grub/menu.lst", "/boot/grub/grub.conf",
  116.77 -                      "/grub/menu.lst", "/grub/grub.conf"):
  116.78 -                if fs.file_exists(f):
  116.79 -                    grubfile = f
  116.80 -                    break
  116.81 -            if grubfile is None:
  116.82 -                raise RuntimeError, "we couldn't find grub config file in the image provided."
  116.83 -            f = fs.open_file(grubfile)
  116.84 -            buf = f.read()
  116.85 -            del f
  116.86 -            del fs
  116.87 -            # then parse the grub config
  116.88 -            self.cf.parse(buf)
  116.89 -        else:
  116.90 -            raise RuntimeError, "Unable to read filesystem" 
  116.91 +        grubfile = None
  116.92 +        for f in ("/boot/grub/menu.lst", "/boot/grub/grub.conf",
  116.93 +                  "/grub/menu.lst", "/grub/grub.conf"):
  116.94 +            if fs.file_exists(f):
  116.95 +                grubfile = f
  116.96 +                break
  116.97 +        if grubfile is None:
  116.98 +            raise RuntimeError, "we couldn't find grub config file in the image provided."
  116.99 +        f = fs.open_file(grubfile)
 116.100 +        buf = f.read()
 116.101 +        del f
 116.102 +        # then parse the grub config
 116.103 +        self.cf.parse(buf)
 116.104  
 116.105      def run(self):
 116.106          timeout = int(self.cf.timeout)
 116.107 @@ -431,19 +427,93 @@ def get_entry_idx(cf, entry):
 116.108  
 116.109      return None
 116.110  
 116.111 +def run_grub(file, entry, fs):
 116.112 +    global g
 116.113 +    global sel
 116.114 +
 116.115 +    def run_main(scr, *args):
 116.116 +        global sel
 116.117 +        global g
 116.118 +        sel = g.run()
 116.119 +
 116.120 +    g = Grub(file, fs)
 116.121 +    if interactive:
 116.122 +        curses.wrapper(run_main)
 116.123 +    else:
 116.124 +        sel = g.cf.default
 116.125 +
 116.126 +    # set the entry to boot as requested
 116.127 +    if entry is not None:
 116.128 +        idx = get_entry_idx(g.cf, entry)
 116.129 +        if idx is not None and idx > 0 and idx < len(g.cf.images):
 116.130 +           sel = idx
 116.131 +
 116.132 +    if sel == -1:
 116.133 +        print "No kernel image selected!"
 116.134 +        sys.exit(1)
 116.135 +
 116.136 +    img = g.cf.images[sel]
 116.137 +
 116.138 +    grubcfg = { "kernel": None, "ramdisk": None, "args": None }
 116.139 +
 116.140 +    grubcfg["kernel"] = img.kernel[1]
 116.141 +    if img.initrd:
 116.142 +        grubcfg["ramdisk"] = img.initrd[1]
 116.143 +    if img.args:
 116.144 +        grubcfg["args"] = img.args
 116.145 +
 116.146 +    return grubcfg
 116.147 +
 116.148 +# If nothing has been specified, look for a Solaris domU. If found, perform the
 116.149 +# necessary tweaks.
 116.150 +def sniff_solaris(fs, cfg):
 116.151 +    if not fs.file_exists("/platform/i86xen/kernel/unix"):
 116.152 +        return cfg
 116.153 +    
 116.154 +    # darned python
 116.155 +    longmode = (sys.maxint != 2147483647L)
 116.156 +    if not longmode:
 116.157 +        longmode = os.uname()[4] == "x86_64"
 116.158 +    if not longmode:
 116.159 +        if (os.access("/usr/bin/isainfo", os.R_OK) and
 116.160 +            os.popen("/usr/bin/isainfo -b").read() == "64\n"):
 116.161 +            longmode = True
 116.162 +
 116.163 +    if not cfg["kernel"]:
 116.164 +        cfg["kernel"] = "/platform/i86xen/kernel/unix"
 116.165 +        cfg["ramdisk"] = "/platform/i86pc/boot_archive"
 116.166 +        if longmode:
 116.167 +            cfg["kernel"] = "/platform/i86xen/kernel/amd64/unix"
 116.168 +            cfg["ramdisk"] = "/platform/i86pc/amd64/boot_archive"
 116.169 +
 116.170 +    # Unpleasant. Typically we'll have 'root=foo -k' or 'root=foo /kernel -k',
 116.171 +    # and we need to maintain Xen properties (root= and ip=) and the kernel
 116.172 +    # before any user args.
 116.173 +    
 116.174 +    xenargs = ""
 116.175 +    userargs = ""
 116.176 +    
 116.177 +    if not cfg["args"]:
 116.178 +        cfg["args"] = cfg["kernel"]
 116.179 +    else:
 116.180 +        for arg in cfg["args"].split():
 116.181 +            if re.match("^root=", arg) or re.match("^ip=", arg):
 116.182 +                xenargs += arg + " "
 116.183 +            elif arg != cfg["kernel"]:
 116.184 +                userargs += arg + " "
 116.185 +        cfg["args"] = xenargs + " " + cfg["kernel"] + " " + userargs
 116.186 +
 116.187 +    return cfg
 116.188 + 
 116.189  if __name__ == "__main__":
 116.190      sel = None
 116.191      
 116.192 -    def run_main(scr, *args):
 116.193 -        global sel
 116.194 -        sel = g.run()
 116.195 -
 116.196      def usage():
 116.197 -        print >> sys.stderr, "Usage: %s [-q|--quiet] [--output=] [--entry=] <image>" %(sys.argv[0],)
 116.198 +        print >> sys.stderr, "Usage: %s [-q|--quiet] [--output=] [--kernel=] [--ramdisk=] [--args=] [--entry=] <image>" %(sys.argv[0],)
 116.199  
 116.200      try:
 116.201          opts, args = getopt.gnu_getopt(sys.argv[1:], 'qh::',
 116.202 -                                   ["quiet", "help", "output=", "entry=",
 116.203 +                                   ["quiet", "help", "output=", "entry=", "kernel=", "ramdisk=", "args=",
 116.204                                      "isconfig"])
 116.205      except getopt.GetoptError:
 116.206          usage()
 116.207 @@ -458,6 +528,14 @@ if __name__ == "__main__":
 116.208      entry = None
 116.209      interactive = True
 116.210      isconfig = False
 116.211 +
 116.212 +    # what was passed in
 116.213 +    incfg = { "kernel": None, "ramdisk": None, "args": None }
 116.214 +    # what grub or sniffing chose
 116.215 +    chosencfg = { "kernel": None, "ramdisk": None, "args": None }
 116.216 +    # what to boot
 116.217 +    bootcfg = { "kernel": None, "ramdisk": None, "args": None }
 116.218 +
 116.219      for o, a in opts:
 116.220          if o in ("-q", "--quiet"):
 116.221              interactive = False
 116.222 @@ -466,6 +544,12 @@ if __name__ == "__main__":
 116.223              sys.exit()
 116.224          elif o in ("--output",):
 116.225              output = a
 116.226 +        elif o in ("--kernel",):
 116.227 +            incfg["kernel"] = a
 116.228 +        elif o in ("--ramdisk",):
 116.229 +            incfg["ramdisk"] = a
 116.230 +        elif o in ("--args",):
 116.231 +            incfg["args"] = a
 116.232          elif o in ("--entry",):
 116.233              entry = a
 116.234              # specifying the entry to boot implies non-interactive
 116.235 @@ -478,58 +562,42 @@ if __name__ == "__main__":
 116.236      else:
 116.237          fd = os.open(output, os.O_WRONLY)
 116.238  
 116.239 -    g = Grub(file, isconfig)
 116.240 -    if interactive:
 116.241 -        curses.wrapper(run_main)
 116.242 -    else:
 116.243 -        sel = g.cf.default
 116.244 -
 116.245 -    # set the entry to boot as requested
 116.246 -    if entry is not None:
 116.247 -        idx = get_entry_idx(g.cf, entry)
 116.248 -        if idx is not None and idx > 0 and idx < len(g.cf.images):
 116.249 -            sel = idx
 116.250 -
 116.251 -    if sel == -1:
 116.252 -        print "No kernel image selected!"
 116.253 -        sys.exit(1)
 116.254 -
 116.255 -    img = g.cf.images[sel]
 116.256 -    print "Going to boot %s" %(img.title)
 116.257 -    print "  kernel: %s" %(img.kernel[1],)
 116.258 -    if img.initrd:
 116.259 -        print "  initrd: %s" %(img.initrd[1],)
 116.260 -
 116.261 +    # debug
 116.262      if isconfig:
 116.263 -        print "  args: %s" %(img.args,)
 116.264 +        chosencfg = run_grub(file, entry)
 116.265 +        print "  kernel: %s" % chosencfg["kernel"]
 116.266 +        if img.initrd:
 116.267 +            print "  initrd: %s" % chosencfg["ramdisk"]
 116.268 +        print "  args: %s" % chosencfg["args"]
 116.269          sys.exit(0)
 116.270 -        
 116.271 -    offset = 0
 116.272 -    if is_disk_image(file):
 116.273 -        offset = get_active_offset(file)
 116.274 -        if offset == -1:
 116.275 -            raise RuntimeError, "Unable to find active partition on disk"
 116.276 +
 116.277 +    fs = open_fs(file)
 116.278  
 116.279 -    # read the kernel and initrd onto the hostfs
 116.280 -    fs = fsimage.open(file, offset)
 116.281 +    chosencfg = sniff_solaris(fs, incfg)
 116.282 +
 116.283 +    if not chosencfg["kernel"]:
 116.284 +        chosencfg = run_grub(file, entry, fs)
 116.285  
 116.286 -    kernel = fs.open_file(img.kernel[1],).read()
 116.287 -    (tfd, fn) = tempfile.mkstemp(prefix="boot_kernel.",
 116.288 +    data = fs.open_file(chosencfg["kernel"]).read()
 116.289 +    (tfd, bootcfg["kernel"]) = tempfile.mkstemp(prefix="boot_kernel.",
 116.290          dir="/var/run/xend/boot")
 116.291 -    os.write(tfd, kernel)
 116.292 +    os.write(tfd, data)
 116.293      os.close(tfd)
 116.294 -    sxp = "linux (kernel %s)" %(fn,)
 116.295  
 116.296 -    if img.initrd:
 116.297 -        initrd = fs.open_file(img.initrd[1],).read()
 116.298 -        (tfd, fn) = tempfile.mkstemp(prefix="boot_ramdisk.",
 116.299 +    if chosencfg["ramdisk"]:
 116.300 +        data = fs.open_file(chosencfg["ramdisk"],).read()
 116.301 +        (tfd, bootcfg["ramdisk"]) = tempfile.mkstemp(prefix="boot_ramdisk.",
 116.302              dir="/var/run/xend/boot")
 116.303 -        os.write(tfd, initrd)
 116.304 +        os.write(tfd, data)
 116.305          os.close(tfd)
 116.306 -        sxp += "(ramdisk %s)" %(fn,)
 116.307      else:
 116.308          initrd = None
 116.309 -    sxp += "(args '%s')" %(img.args,)
 116.310 +
 116.311 +    sxp = "linux (kernel %s)" % bootcfg["kernel"]
 116.312 +    if bootcfg["ramdisk"]:
 116.313 +        sxp += "(ramdisk %s)" % bootcfg["ramdisk"]
 116.314 +    if chosencfg["args"]:
 116.315 +        sxp += "(args \"%s\")" % chosencfg["args"]
 116.316  
 116.317      sys.stdout.flush()
 116.318      os.write(fd, sxp)
   117.1 --- a/tools/python/Makefile	Wed Jan 10 08:00:50 2007 -0700
   117.2 +++ b/tools/python/Makefile	Wed Jan 10 08:40:47 2007 -0700
   117.3 @@ -7,16 +7,30 @@ all: build
   117.4  .PHONY: build
   117.5  build:
   117.6  	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py build
   117.7 +	if which $(MSGFMT) >/dev/null ; then \
   117.8 +          for file in `cd xen/xm; find messages -name xen-xm.po`; do \
   117.9 +            dest=`echo "build/$$file" | \
  117.10 +                  sed -e 's#xen-xm.po#LC_MESSAGES/xen-xm.mo#'`; \
  117.11 +            mkdir -p `dirname "$$dest"`; \
  117.12 +            $(MSGFMT) -c -o "$$dest" "xen/xm/$$file"; \
  117.13 +          done; \
  117.14 +        fi
  117.15  
  117.16  .PHONY: install
  117.17  ifndef XEN_PYTHON_NATIVE_INSTALL
  117.18 -install: all
  117.19 +install: install-messages
  117.20  	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --home="$(DESTDIR)/usr" --prefix="" --force
  117.21  else
  117.22 -install: all
  117.23 +install: install-messages
  117.24  	CC="$(CC)" CFLAGS="$(CFLAGS)" python setup.py install --root="$(DESTDIR)" --force
  117.25  endif
  117.26  
  117.27 +install-messages: all
  117.28 +	if which $(MSGFMT) >/dev/null ; then \
  117.29 +	  mkdir -p "$(DESTDIR)/usr/share/locale"; \
  117.30 +	  cp -R build/messages/* "$(DESTDIR)/usr/share/locale/"; \
  117.31 +	fi
  117.32 +
  117.33  .PHONY: test
  117.34  test:
  117.35  	export LD_LIBRARY_PATH=$$(readlink -f ../libxc):$$(readlink -f ../xenstore); python test.py -b -u
   118.1 --- a/tools/python/scripts/xapi.py	Wed Jan 10 08:00:50 2007 -0700
   118.2 +++ b/tools/python/scripts/xapi.py	Wed Jan 10 08:40:47 2007 -0700
   118.3 @@ -41,6 +41,7 @@ VBD_LIST_FORMAT = '%(name_label)-18s %(u
   118.4  COMMANDS = {
   118.5      'host-info': ('', 'Get Xen Host Info'),
   118.6      'host-set-name': ('', 'Set host name'),
   118.7 +    'pif-list': ('', 'List all PIFs'),
   118.8      'sr-list':   ('', 'List all SRs'),
   118.9      'vbd-list':  ('', 'List all VBDs'),
  118.10      'vbd-create': ('<domname> <pycfg> [opts]',
  118.11 @@ -63,6 +64,15 @@ COMMANDS = {
  118.12  }
  118.13  
  118.14  OPTIONS = {
  118.15 +    'sr-list': [(('-l', '--long'),
  118.16 +                 {'action':'store_true',
  118.17 +                  'help':'List all properties of SR'})
  118.18 +               ],
  118.19 +
  118.20 +    'vdi-list': [(('-l', '--long'),
  118.21 +                  {'action':'store_true',
  118.22 +                   'help':'List all properties of VDI'})
  118.23 +               ],        
  118.24      'vm-list': [(('-l', '--long'),
  118.25                   {'action':'store_true',
  118.26                    'help':'List all properties of VMs'})
  118.27 @@ -145,7 +155,7 @@ def execute(fn, *args):
  118.28  def _connect(*args):
  118.29      global _server, _session, _initialised
  118.30      if not _initialised:
  118.31 -        _server = ServerProxy('httpu:///var/run/xend/xmlrpc.sock')
  118.32 +        _server = ServerProxy('httpu:///var/run/xend/xen-api.sock')
  118.33          login = raw_input("Login: ")
  118.34          password = getpass()
  118.35          creds = (login, password)
  118.36 @@ -361,29 +371,53 @@ def xapi_vbd_list(*args):
  118.37          print VBD_LIST_FORMAT % vbd_struct
  118.38  
  118.39  def xapi_vdi_list(*args):
  118.40 +    opts, args = parse_args('vdi-list', args, set_defaults = True)
  118.41 +    is_long = opts and opts.long
  118.42 +
  118.43      server, session = _connect()
  118.44      vdis = execute(server.VDI.get_all, session)
  118.45  
  118.46 -    print VDI_LIST_FORMAT % {'name_label': 'VDI Label',
  118.47 -                             'uuid' : 'UUID',
  118.48 -                             'virtual_size': 'Sectors',
  118.49 -                             'sector_size': 'Sector Size'}
  118.50 -    
  118.51 -    for vdi in vdis:
  118.52 -        vdi_struct = execute(server.VDI.get_record, session, vdi)
  118.53 -        print VDI_LIST_FORMAT % vdi_struct
  118.54 +    if not is_long:
  118.55 +        print VDI_LIST_FORMAT % {'name_label': 'VDI Label',
  118.56 +                                 'uuid' : 'UUID',
  118.57 +                                 'virtual_size': 'Sectors',
  118.58 +                                 'sector_size': 'Sector Size'}
  118.59 +        
  118.60 +        for vdi in vdis:
  118.61 +            vdi_struct = execute(server.VDI.get_record, session, vdi)
  118.62 +            print VDI_LIST_FORMAT % vdi_struct
  118.63 +
  118.64 +    else:
  118.65 +
  118.66 +        for vdi in vdis:
  118.67 +            vdi_struct = execute(server.VDI.get_record, session, vdi)
  118.68 +            pprint(vdi_struct)
  118.69  
  118.70  def xapi_sr_list(*args):
  118.71 +    opts, args = parse_args('sr-list', args, set_defaults = True)
  118.72 +    is_long = opts and opts.long
  118.73 +    
  118.74      server, session = _connect()
  118.75      srs = execute(server.SR.get_all, session)
  118.76 -    print SR_LIST_FORMAT % {'name_label': 'SR Label',
  118.77 -                            'uuid' : 'UUID',
  118.78 -                            'physical_size': 'Size',
  118.79 -                            'type': 'Type'}
  118.80 -    for sr in srs:
  118.81 -        sr_struct = execute(server.SR.get_record, session, sr)
  118.82 -        sr_struct['physical_size'] = int(sr_struct['physical_size'])/MB
  118.83 -        print SR_LIST_FORMAT % sr_struct
  118.84 +    if not is_long:
  118.85 +        print SR_LIST_FORMAT % {'name_label': 'SR Label',
  118.86 +                                'uuid' : 'UUID',
  118.87 +                                'physical_size': 'Size (MB)',
  118.88 +                                'type': 'Type'}
  118.89 +        
  118.90 +        for sr in srs:
  118.91 +            sr_struct = execute(server.SR.get_record, session, sr)
  118.92 +            sr_struct['physical_size'] = int(sr_struct['physical_size'])/MB
  118.93 +            print SR_LIST_FORMAT % sr_struct
  118.94 +    else:
  118.95 +        for sr in srs:
  118.96 +            sr_struct = execute(server.SR.get_record, session, sr)        
  118.97 +            pprint(sr_struct)
  118.98 +
  118.99 +def xapi_sr_rename(*args):
 118.100 +    server, session = _connect()
 118.101 +    sr = execute(server.SR.get_by_name_label, session, args[0])
 118.102 +    execute(server.SR.set_name_label, session, sr[0], args[1])
 118.103  
 118.104  def xapi_vdi_create(*args):
 118.105      opts, args = parse_args('vdi-create', args)
 118.106 @@ -421,10 +455,11 @@ def xapi_vdi_rename(*args):
 118.107      if len(args) < 2:
 118.108          raise OptionError('Not enough arguments')
 118.109  
 118.110 -    vdi_uuid = args[0]
 118.111 +    vdi_uuid = execute(server.VDI.get_by_name_label, session, args[0])
 118.112      vdi_name = args[1]
 118.113 -    print 'Renaming VDI %s to %s' % (vdi_uuid, vdi_name)
 118.114 -    result = execute(server.VDI.set_name_label, session, vdi_uuid, vdi_name)
 118.115 +    
 118.116 +    print 'Renaming VDI %s to %s' % (vdi_uuid[0], vdi_name)
 118.117 +    result = execute(server.VDI.set_name_label, session, vdi_uuid[0], vdi_name)
 118.118      print 'Done.'
 118.119  
 118.120  
 118.121 @@ -448,6 +483,14 @@ def xapi_vtpm_create(*args):
 118.122      print "Has vtpm record '%s'" % vtpm_rec
 118.123  
 118.124  
 118.125 +def xapi_pif_list(*args):
 118.126 +    server, session = _connect()
 118.127 +    pif_uuids = execute(server.PIF.get_all, session)
 118.128 +    for pif_uuid in pif_uuids:
 118.129 +        pif = execute(server.PIF.get_record, session, pif_uuid)
 118.130 +        print pif
 118.131 +    
 118.132 +
 118.133  #
 118.134  # Command Line Utils
 118.135  #
 118.136 @@ -517,10 +560,12 @@ def usage(command = None, print_usage = 
 118.137              print
 118.138              print 'Subcommands:'
 118.139              print
 118.140 -        sorted_commands = sorted(COMMANDS.keys())
 118.141 -        for command  in sorted_commands:
 118.142 -            args, description = COMMANDS[command]
 118.143 -            print '%-16s  %-40s' % (command, description)
 118.144 +
 118.145 +        for func in sorted(globals().keys()):
 118.146 +            if func.startswith('xapi_'):
 118.147 +                command = func[5:].replace('_', '-')
 118.148 +                args, description = COMMANDS.get(command, ('', ''))
 118.149 +                print '%-16s  %-40s' % (command, description)
 118.150          print
 118.151      else:
 118.152          parse_args(command, ['-h'])
 118.153 @@ -549,7 +594,7 @@ def main(args):
 118.154      try:
 118.155          subcmd_func(*args[1:])
 118.156      except XenAPIError, e:
 118.157 -        print 'Error: %s' % str(e.args[1])
 118.158 +        print 'Error: %s' % str(e.args[0])
 118.159          sys.exit(2)
 118.160      except OptionError, e:
 118.161          print 'Error: %s' % e
   119.1 --- a/tools/python/xen/lowlevel/acm/acm.c	Wed Jan 10 08:00:50 2007 -0700
   119.2 +++ b/tools/python/xen/lowlevel/acm/acm.c	Wed Jan 10 08:40:47 2007 -0700
   119.3 @@ -35,6 +35,8 @@
   119.4  fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a ,    \
   119.5      errno, strerror(errno))
   119.6  
   119.7 +static PyObject *acm_error_obj;
   119.8 +
   119.9  /* generic shared function */
  119.10  void * __getssid(int domid, uint32_t *buflen)
  119.11  {
  119.12 @@ -80,28 +82,26 @@ static PyObject *policy(PyObject * self,
  119.13  {
  119.14      /* out */
  119.15      char *policyreference;
  119.16 -    PyObject *ret = NULL;
  119.17 +    PyObject *ret;
  119.18      void *ssid_buffer;
  119.19      uint32_t buf_len;
  119.20  
  119.21      if (!PyArg_ParseTuple(args, "", NULL)) {
  119.22 -    goto out1;
  119.23 +        return NULL;
  119.24      }
  119.25      ssid_buffer =  __getssid(0, &buf_len);
  119.26 -    if (ssid_buffer == NULL) {
  119.27 -        goto out1;
  119.28 -    } else if (buf_len < sizeof(struct acm_ssid_buffer)) {
  119.29 -        goto out2;
  119.30 -    } else {
  119.31 +    if (ssid_buffer == NULL || buf_len < sizeof(struct acm_ssid_buffer)) {
  119.32 +        free(ssid_buffer);
  119.33 +        return PyErr_SetFromErrno(acm_error_obj);
  119.34 +    }
  119.35 +    else {
  119.36          struct acm_ssid_buffer *ssid = (struct acm_ssid_buffer *)ssid_buffer;
  119.37          policyreference = (char *)(ssid_buffer + ssid->policy_reference_offset
  119.38                         + sizeof (struct acm_policy_reference_buffer));
  119.39 +        ret = Py_BuildValue("s", policyreference);
  119.40 +        free(ssid_buffer);
  119.41 +        return ret;
  119.42      }
  119.43 -    ret = Py_BuildValue("s", policyreference);
  119.44 - out2:
  119.45 -    free(ssid_buffer);
  119.46 - out1:
  119.47 -    return ret;
  119.48  }
  119.49  
  119.50  
  119.51 @@ -213,5 +213,8 @@ static PyMethodDef acmMethods[] = {
  119.52  /* inits */
  119.53  PyMODINIT_FUNC initacm(void)
  119.54  {
  119.55 -    Py_InitModule("acm", acmMethods);
  119.56 +    PyObject *m = Py_InitModule("acm", acmMethods);
  119.57 +    acm_error_obj = PyErr_NewException("acm.Error", PyExc_RuntimeError, NULL);
  119.58 +    Py_INCREF(acm_error_obj);
  119.59 +    PyModule_AddObject(m, "Error", acm_error_obj);
  119.60  }
   120.1 --- a/tools/python/xen/util/Brctl.py	Wed Jan 10 08:00:50 2007 -0700
   120.2 +++ b/tools/python/xen/util/Brctl.py	Wed Jan 10 08:40:47 2007 -0700
   120.3 @@ -28,6 +28,31 @@ def cmd(p, s):
   120.4      if not opts.dryrun:
   120.5          os.system(c)
   120.6  
   120.7 +bridgeRE = re.compile(r'([^\t]*)\t*[^\t]*\t*[^\t]*\t*([^\t]*)')
   120.8 +def get_state():
   120.9 +    fin = os.popen(CMD_BRCTL + ' show', 'r')
  120.10 +    try:
  120.11 +        bridges = {}
  120.12 +        brlist = None
  120.13 +        brname = None
  120.14 +        first = True
  120.15 +        for line in fin:
  120.16 +            if first:
  120.17 +                first = False
  120.18 +            elif line[0] == '\t':
  120.19 +                brlist.append(line.strip())
  120.20 +            else:
  120.21 +                if brname:
  120.22 +                    bridges[brname] = brlist
  120.23 +                m = bridgeRE.match(line)
  120.24 +                brname = m.group(1)
  120.25 +                brlist = [m.group(2).strip()]
  120.26 +        if brname:
  120.27 +            bridges[brname] = brlist
  120.28 +        return bridges
  120.29 +    finally:
  120.30 +        fin.close()
  120.31 +
  120.32  def vif_bridge_add(params):
  120.33      """Add the network interface for vif on dom to a bridge.
  120.34      """
   121.1 --- a/tools/python/xen/util/security.py	Wed Jan 10 08:00:50 2007 -0700
   121.2 +++ b/tools/python/xen/util/security.py	Wed Jan 10 08:40:47 2007 -0700
   121.3 @@ -115,7 +115,7 @@ def get_security_info(info, field):
   121.4      if isinstance(info, dict):
   121.5          security = info['security']
   121.6      elif isinstance(info, list):
   121.7 -        security = sxp.child_value(info, 'security', )
   121.8 +        security = sxp.child_value(info, 'security')
   121.9      if not security:
  121.10          if field == 'ssidref':
  121.11              #return default ssid
  121.12 @@ -357,7 +357,7 @@ def refresh_ssidref(config):
  121.13      if isinstance(config, dict):
  121.14          security = config['security']
  121.15      elif isinstance(config, list):
  121.16 -        security = sxp.child_value(config, 'security',)
  121.17 +        security = sxp.child_value(config, 'security')
  121.18      else:
  121.19          err("Instance type of config parameter not supported.")
  121.20      if not security:
  121.21 @@ -637,11 +637,11 @@ def res_security_check(resource, domain_
  121.22      """
  121.23      rtnval = 1
  121.24  
  121.25 -    #build canonical resource name
  121.26 -    resource = unify_resname(resource)
  121.27 -
  121.28      # if security is on, ask the hypervisor for a decision
  121.29      if on():
  121.30 +        #build canonical resource name
  121.31 +        resource = unify_resname(resource)
  121.32 +
  121.33          (label, ssidref, policy) = get_res_security_details(resource)
  121.34          domac = ['access_control']
  121.35          domac.append(['policy', active_policy])
  121.36 @@ -660,6 +660,8 @@ def res_security_check(resource, domain_
  121.37  
  121.38      # security is off, make sure resource isn't labeled
  121.39      else:
  121.40 +        # Note, we can't canonicalise the resource here, because people using
  121.41 +        # xm without ACM are free to use relative paths.
  121.42          (label, policy) = get_res_label(resource)
  121.43          if policy != 'NULL':
  121.44              raise ACMError("Security is off, but '"+resource+"' is labeled")
   122.1 --- a/tools/python/xen/util/xmlrpclib2.py	Wed Jan 10 08:00:50 2007 -0700
   122.2 +++ b/tools/python/xen/util/xmlrpclib2.py	Wed Jan 10 08:40:47 2007 -0700
   122.3 @@ -20,6 +20,7 @@
   122.4  An enhanced XML-RPC client/server interface for Python.
   122.5  """
   122.6  
   122.7 +import re
   122.8  import string
   122.9  import fcntl
  122.10  from types import *
  122.11 @@ -49,13 +50,15 @@ except ImportError:
  122.12  
  122.13  
  122.14  def stringify(value):
  122.15 -    if isinstance(value, IntType) and not isinstance(value, BooleanType):
  122.16 +    if isinstance(value, float) or \
  122.17 +       isinstance(value, long) or \
  122.18 +       (isinstance(value, int) and not isinstance(value, bool)):
  122.19          return str(value)
  122.20 -    elif isinstance(value, DictType):
  122.21 +    elif isinstance(value, dict):
  122.22          for k, v in value.items():
  122.23              value[k] = stringify(v)
  122.24          return value
  122.25 -    elif isinstance(value, (TupleType, ListType)):
  122.26 +    elif isinstance(value, (tuple, list)):
  122.27          return [stringify(v) for v in value]
  122.28      else:
  122.29          return value
  122.30 @@ -163,8 +166,10 @@ class ServerProxy(xmlrpclib.ServerProxy)
  122.31  class TCPXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer):
  122.32      allow_reuse_address = True
  122.33  
  122.34 -    def __init__(self, addr, allowed, requestHandler=None,
  122.35 +    def __init__(self, addr, allowed, xenapi, requestHandler=None,
  122.36                   logRequests = 1):
  122.37 +        self.xenapi = xenapi
  122.38 +        
  122.39          if requestHandler is None:
  122.40              requestHandler = XMLRPCRequestHandler
  122.41          SimpleXMLRPCServer.__init__(self, addr,
  122.42 @@ -182,7 +187,7 @@ class TCPXMLRPCServer(SocketServer.Threa
  122.43          flags |= fcntl.FD_CLOEXEC
  122.44          fcntl.fcntl(client.fileno(), fcntl.F_SETFD, flags)
  122.45          return (client, addr)
  122.46 -                                                                                
  122.47 +
  122.48      def _marshaled_dispatch(self, data, dispatch_method = None):
  122.49          params, method = xmlrpclib.loads(data)
  122.50          if False:
  122.51 @@ -214,12 +219,29 @@ class TCPXMLRPCServer(SocketServer.Threa
  122.52          except xmlrpclib.Fault, fault:
  122.53              response = xmlrpclib.dumps(fault)
  122.54          except Exception, exn:
  122.55 -            import xen.xend.XendClient
  122.56 -            log.exception(exn)
  122.57 -            response = xmlrpclib.dumps(
  122.58 -                xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn)))
  122.59 +            if self.xenapi:
  122.60 +                if _is_not_supported(exn):
  122.61 +                    errdesc = ['MESSAGE_METHOD_UNKNOWN', method]
  122.62 +                else:
  122.63 +                    log.exception('Internal error handling %s', method)
  122.64 +                    errdesc = ['INTERNAL_ERROR', str(exn)]
  122.65 +                response = xmlrpclib.dumps(
  122.66 +                    ({ "Status": "Failure",
  122.67 +                       "ErrorDescription": errdesc },),
  122.68 +                    methodresponse = 1)
  122.69 +            else:
  122.70 +                log.exception('Internal error handling %s', method)
  122.71 +                import xen.xend.XendClient
  122.72 +                response = xmlrpclib.dumps(
  122.73 +                    xmlrpclib.Fault(xen.xend.XendClient.ERROR_INTERNAL, str(exn)))
  122.74 +        return response
  122.75  
  122.76 -        return response
  122.77 +
  122.78 +notSupportedRE = re.compile(r'method "(.*)" is not supported')
  122.79 +def _is_not_supported(exn):
  122.80 +    m = notSupportedRE.search(exn[0])
  122.81 +    return m is not None
  122.82 +
  122.83  
  122.84  # This is a XML-RPC server that sits on a Unix domain socket.
  122.85  # It implements proper support for allow_reuse_address by
  122.86 @@ -235,10 +257,10 @@ class UnixXMLRPCRequestHandler(XMLRPCReq
  122.87  class UnixXMLRPCServer(TCPXMLRPCServer):
  122.88      address_family = socket.AF_UNIX
  122.89  
  122.90 -    def __init__(self, addr, allowed, logRequests = 1):
  122.91 +    def __init__(self, addr, allowed, xenapi, logRequests = 1):
  122.92          mkdir.parents(os.path.dirname(addr), stat.S_IRWXU, True)
  122.93          if self.allow_reuse_address and os.path.exists(addr):
  122.94              os.unlink(addr)
  122.95  
  122.96 -        TCPXMLRPCServer.__init__(self, addr, allowed,
  122.97 +        TCPXMLRPCServer.__init__(self, addr, allowed, xenapi,
  122.98                                   UnixXMLRPCRequestHandler, logRequests)
   123.1 --- a/tools/python/xen/xend/XendAPI.py	Wed Jan 10 08:00:50 2007 -0700
   123.2 +++ b/tools/python/xen/xend/XendAPI.py	Wed Jan 10 08:40:47 2007 -0700
   123.3 @@ -15,11 +15,16 @@
   123.4  # Copyright (C) 2006 XenSource Ltd.
   123.5  #============================================================================
   123.6  
   123.7 +import inspect
   123.8 +import os
   123.9 +import string
  123.10 +import sys
  123.11 +import traceback
  123.12 +
  123.13  from xen.xend import XendDomain, XendDomainInfo, XendNode
  123.14  from xen.xend import XendLogging
  123.15  
  123.16  from xen.xend.XendAuthSessions import instance as auth_manager
  123.17 -from xen.xend.XendAuthSessions import session_required
  123.18  from xen.xend.XendError import *
  123.19  from xen.xend.XendClient import ERROR_INVALID_DOMAIN
  123.20  from xen.xend.XendLogging import log
  123.21 @@ -30,13 +35,19 @@ from xen.util.xmlrpclib2 import stringif
  123.22  AUTH_NONE = 'none'
  123.23  AUTH_PAM = 'pam'
  123.24  
  123.25 +argcounts = {}
  123.26 +
  123.27  # ------------------------------------------
  123.28  # Utility Methods for Xen API Implementation
  123.29  # ------------------------------------------
  123.30  
  123.31  def xen_api_success(value):
  123.32      """Wraps a return value in XenAPI format."""
  123.33 -    return {"Status": "Success", "Value": stringify(value)}
  123.34 +    if value is None:
  123.35 +        s = ''
  123.36 +    else:
  123.37 +        s = stringify(value)
  123.38 +    return {"Status": "Success", "Value": s}
  123.39  
  123.40  def xen_api_success_void():
  123.41      """Return success, but caller expects no return value."""
  123.42 @@ -44,7 +55,16 @@ def xen_api_success_void():
  123.43  
  123.44  def xen_api_error(error):
  123.45      """Wraps an error value in XenAPI format."""
  123.46 -    return {"Status": "Error", "ErrorDescription": error}
  123.47 +    if type(error) == tuple:
  123.48 +        error = list(error)
  123.49 +    if type(error) != list:
  123.50 +        error = [error]
  123.51 +    if len(error) == 0:
  123.52 +        error = ['INTERNAL_ERROR', 'Empty list given to xen_api_error']
  123.53 +
  123.54 +    return { "Status": "Failure",
  123.55 +             "ErrorDescription": [str(x) for x in error] }
  123.56 +
  123.57  
  123.58  def xen_api_todo():
  123.59      """Temporary method to make sure we track down all the TODOs"""
  123.60 @@ -68,186 +88,164 @@ def trace(func, api_name = ''):
  123.61      trace_func.api = api_name
  123.62      return trace_func
  123.63  
  123.64 -def valid_host(func):
  123.65 -    """Decorator to verify if host_ref is valid before calling
  123.66 -    method.
  123.67  
  123.68 -    @param func: function with params: (self, session, host_ref)
  123.69 +def catch_typeerror(func):
  123.70 +    """Decorator to catch any TypeErrors and translate them into Xen-API
  123.71 +    errors.
  123.72 +
  123.73 +    @param func: function with params: (self, ...)
  123.74      @rtype: callable object
  123.75 -    """    
  123.76 -    def check_host_ref(self, session, host_ref, *args, **kwargs):
  123.77 -        xennode = XendNode.instance()
  123.78 -        if type(host_ref) == type(str()) and xennode.is_valid_host(host_ref):
  123.79 -            return func(self, session, host_ref, *args, **kwargs)
  123.80 -        else:
  123.81 -            return {'Status': 'Failure',
  123.82 -                    'ErrorDescription': XEND_ERROR_HOST_INVALID}
  123.83 +    """
  123.84 +    def f(self, *args, **kwargs):
  123.85 +        try:
  123.86 +            return func(self, *args, **kwargs)
  123.87 +        except TypeError, exn:
  123.88 +            #log.exception('catch_typeerror')
  123.89 +            if hasattr(func, 'api') and func.api in argcounts:
  123.90 +                # Assume that if the exception was thrown inside this
  123.91 +                # file, then it is due to an invalid call from the client,
  123.92 +                # but if it was thrown elsewhere, then it's an internal
  123.93 +                # error (which will be handled further up).
  123.94 +                tb = sys.exc_info()[2]
  123.95 +                try:
  123.96 +                    sourcefile = traceback.extract_tb(tb)[-1][0]
  123.97 +                    if sourcefile == inspect.getsourcefile(XendAPI):
  123.98 +                        return xen_api_error(
  123.99 +                            ['MESSAGE_PARAMETER_COUNT_MISMATCH',
 123.100 +                             func.api, argcounts[func.api],
 123.101 +                             len(args) + len(kwargs)])
 123.102 +                finally:
 123.103 +                    del tb
 123.104 +            raise
 123.105  
 123.106 -    # make sure we keep the 'api' attribute
 123.107 -    if hasattr(func, 'api'):
 123.108 -        check_host_ref.api = func.api
 123.109 -        
 123.110 -    return check_host_ref
 123.111 +    return f
 123.112 +
 123.113  
 123.114 -def valid_host_cpu(func):
 123.115 -    """Decorator to verify if host_cpu_ref is valid before calling
 123.116 -    method.
 123.117 +def session_required(func):
 123.118 +    """Decorator to verify if session is valid before calling method.
 123.119  
 123.120 -    @param func: function with params: (self, session, host_cpu_ref)
 123.121 +    @param func: function with params: (self, session, ...)
 123.122      @rtype: callable object
 123.123      """    
 123.124 -    def check_host_cpu_ref(self, session, host_cpu_ref, *args, **kwargs):
 123.125 -        xennode = XendNode.instance()
 123.126 -        if type(host_cpu_ref) == type(str()) and \
 123.127 -               xennode.is_valid_cpu(host_cpu_ref):
 123.128 -            return func(self, session, host_cpu_ref, *args, **kwargs)
 123.129 -        else:
 123.130 -            return {'Status': 'Failure',
 123.131 -                    'ErrorDescription': XEND_ERROR_HOST_CPU_INVALID}
 123.132 -        
 123.133 -    # make sure we keep the 'api' attribute
 123.134 -    if hasattr(func, 'api'):
 123.135 -        check_host_cpu_ref.api = func.api
 123.136 -        
 123.137 -    return check_host_cpu_ref
 123.138 -
 123.139 -def valid_vm(func):
 123.140 -    """Decorator to verify if vm_ref is valid before calling
 123.141 -    method.
 123.142 -
 123.143 -    @param func: function with params: (self, session, vm_ref)
 123.144 -    @rtype: callable object
 123.145 -    """    
 123.146 -    def check_vm_ref(self, session, *args, **kwargs):
 123.147 -        if len(args) == 0:
 123.148 -            return {'Status': 'Failure',
 123.149 -                    'ErrorDescription': XEND_ERROR_VM_INVALID}
 123.150 -
 123.151 -        vm_ref = args[0]
 123.152 -        xendom = XendDomain.instance()
 123.153 -        if type(vm_ref) == type(str()) and \
 123.154 -               xendom.is_valid_vm(vm_ref):
 123.155 +    def check_session(self, session, *args, **kwargs):
 123.156 +        if auth_manager().is_session_valid(session):
 123.157              return func(self, session, *args, **kwargs)
 123.158          else:
 123.159 -            return {'Status': 'Failure',
 123.160 -                    'ErrorDescription': XEND_ERROR_VM_INVALID}
 123.161 +            return xen_api_error(['SESSION_INVALID', session])
 123.162 +
 123.163 +    return check_session
 123.164 +
 123.165 +
 123.166 +def _is_valid_ref(ref, validator):
 123.167 +    return type(ref) == str and validator(ref)
 123.168 +
 123.169 +def _check_ref(validator, errcode, func, api, session, ref, *args, **kwargs):
 123.170 +    if _is_valid_ref(ref, validator):
 123.171 +        return func(api, session, ref, *args, **kwargs)
 123.172 +    else:
 123.173 +        return xen_api_error([errcode, ref])
 123.174 +
 123.175  
 123.176 -    # make sure we keep the 'api' attribute
 123.177 -    if hasattr(func, 'api'):
 123.178 -        check_vm_ref.api = func.api
 123.179 -        
 123.180 -    return check_vm_ref
 123.181 +def valid_host(func):
 123.182 +    """Decorator to verify if host_ref is valid before calling method.
 123.183  
 123.184 -def valid_vbd(func):
 123.185 -    """Decorator to verify if vbd_ref is valid before calling
 123.186 -    method.
 123.187 +    @param func: function with params: (self, session, host_ref, ...)
 123.188 +    @rtype: callable object
 123.189 +    """
 123.190 +    return lambda *args, **kwargs: \
 123.191 +           _check_ref(XendNode.instance().is_valid_host,
 123.192 +                      'HOST_HANDLE_INVALID', func, *args, **kwargs)
 123.193  
 123.194 -    @param func: function with params: (self, session, vbd_ref)
 123.195 +def valid_host_cpu(func):
 123.196 +    """Decorator to verify if host_cpu_ref is valid before calling method.
 123.197 +
 123.198 +    @param func: function with params: (self, session, host_cpu_ref, ...)
 123.199      @rtype: callable object
 123.200      """    
 123.201 -    def check_vbd_ref(self, session, vbd_ref, *args, **kwargs):
 123.202 -        xendom = XendDomain.instance()
 123.203 -        if type(vbd_ref) == type(str()) and \
 123.204 -               xendom.is_valid_dev('vbd', vbd_ref):
 123.205 -            return func(self, session, vbd_ref, *args, **kwargs)
 123.206 -        else:
 123.207 -            return {'Status': 'Failure',
 123.208 -                    'ErrorDescription': XEND_ERROR_VBD_INVALID}
 123.209 +    return lambda *args, **kwargs: \
 123.210 +           _check_ref(XendNode.instance().is_valid_cpu,
 123.211 +                      'HOST_CPU_HANDLE_INVALID', func, *args, **kwargs)
 123.212 +
 123.213 +def valid_vm(func):
 123.214 +    """Decorator to verify if vm_ref is valid before calling method.
 123.215 +
 123.216 +    @param func: function with params: (self, session, vm_ref, ...)
 123.217 +    @rtype: callable object
 123.218 +    """    
 123.219 +    return lambda *args, **kwargs: \
 123.220 +           _check_ref(XendDomain.instance().is_valid_vm,
 123.221 +                      'VM_HANDLE_INVALID', func, *args, **kwargs)
 123.222 +
 123.223 +def valid_network(func):
 123.224 +    """Decorator to verify if network_ref is valid before calling method.
 123.225  
 123.226 -    # make sure we keep the 'api' attribute
 123.227 -    if hasattr(func, 'api'):
 123.228 -        check_vbd_ref.api = func.api
 123.229 -        
 123.230 -    return check_vbd_ref
 123.231 +    @param func: function with params: (self, session, network_ref, ...)
 123.232 +    @rtype: callable object
 123.233 +    """    
 123.234 +    return lambda *args, **kwargs: \
 123.235 +           _check_ref(XendNode.instance().is_valid_network,
 123.236 +                      'NETWORK_HANDLE_INVALID', func, *args, **kwargs)
 123.237 +
 123.238 +def valid_vbd(func):
 123.239 +    """Decorator to verify if vbd_ref is valid before calling method.
 123.240 +
 123.241 +    @param func: function with params: (self, session, vbd_ref, ...)
 123.242 +    @rtype: callable object
 123.243 +    """    
 123.244 +    return lambda *args, **kwargs: \
 123.245 +           _check_ref(lambda r: XendDomain.instance().is_valid_dev('vbd', r),
 123.246 +                      'VBD_HANDLE_INVALID', func, *args, **kwargs)
 123.247  
 123.248  def valid_vif(func):
 123.249 -    """Decorator to verify if vif_ref is valid before calling
 123.250 -    method.
 123.251 +    """Decorator to verify if vif_ref is valid before calling method.
 123.252  
 123.253 -    @param func: function with params: (self, session, vif_ref)
 123.254 +    @param func: function with params: (self, session, vif_ref, ...)
 123.255      @rtype: callable object
 123.256      """
 123.257 -    def check_vif_ref(self, session, vif_ref, *args, **kwargs):
 123.258 -        xendom = XendDomain.instance()
 123.259 -        if type(vif_ref) == type(str()) and \
 123.260 -               xendom.is_valid_dev('vif', vif_ref):
 123.261 -            return func(self, session, vif_ref, *args, **kwargs)
 123.262 -        else:
 123.263 -            return {'Status': 'Failure',
 123.264 -                    'ErrorDescription': XEND_ERROR_VIF_INVALID}
 123.265 -
 123.266 -    # make sure we keep the 'api' attribute
 123.267 -    if hasattr(func, 'api'):
 123.268 -        check_vif_ref.api = func.api
 123.269 -        
 123.270 -    return check_vif_ref
 123.271 -
 123.272 +    return lambda *args, **kwargs: \
 123.273 +           _check_ref(lambda r: XendDomain.instance().is_valid_dev('vif', r),
 123.274 +                      'VIF_HANDLE_INVALID', func, *args, **kwargs)
 123.275  
 123.276  def valid_vdi(func):
 123.277 -    """Decorator to verify if vdi_ref is valid before calling
 123.278 -    method.
 123.279 +    """Decorator to verify if vdi_ref is valid before calling method.
 123.280  
 123.281 -    @param func: function with params: (self, session, vdi_ref)
 123.282 +    @param func: function with params: (self, session, vdi_ref, ...)
 123.283      @rtype: callable object
 123.284      """
 123.285 -    def check_vdi_ref(self, session, vdi_ref, *args, **kwargs):
 123.286 -        xennode = XendNode.instance()
 123.287 -        if type(vdi_ref) == type(str()) and \
 123.288 -               xennode.get_sr().is_valid_vdi(vdi_ref):
 123.289 -            return func(self, session, vdi_ref, *args, **kwargs)
 123.290 -        else:
 123.291 -            return {'Status': 'Failure',
 123.292 -                    'ErrorDescription': XEND_ERROR_VDI_INVALID}
 123.293 -
 123.294 -    # make sure we keep the 'api' attribute
 123.295 -    if hasattr(func, 'api'):
 123.296 -        check_vdi_ref.api = func.api
 123.297 -        
 123.298 -    return check_vdi_ref
 123.299 +    return lambda *args, **kwargs: \
 123.300 +           _check_ref(XendNode.instance().get_sr().is_valid_vdi,
 123.301 +                      'VDI_HANDLE_INVALID', func, *args, **kwargs)
 123.302  
 123.303  def valid_vtpm(func):
 123.304 -    """Decorator to verify if vtpm_ref is valid before calling
 123.305 -    method.
 123.306 +    """Decorator to verify if vtpm_ref is valid before calling method.
 123.307  
 123.308 -    @param func: function with params: (self, session, vtpm_ref)
 123.309 +    @param func: function with params: (self, session, vtpm_ref, ...)
 123.310      @rtype: callable object
 123.311      """
 123.312 -    def check_vtpm_ref(self, session, vtpm_ref, *args, **kwargs):
 123.313 -        xendom = XendDomain.instance()
 123.314 -        if type(vtpm_ref) == type(str()) and \
 123.315 -               xendom.is_valid_dev('vtpm', vtpm_ref):
 123.316 -            return func(self, session, vtpm_ref, *args, **kwargs)
 123.317 -        else:
 123.318 -            return {'Status': 'Failure',
 123.319 -                    'ErrorDescription': XEND_ERROR_VTPM_INVALID}
 123.320 -
 123.321 -    # make sure we keep the 'api' attribute
 123.322 -    if hasattr(func, 'api'):
 123.323 -        check_vtpm_ref.api = func.api
 123.324 -
 123.325 -    return check_vtpm_ref
 123.326 +    return lambda *args, **kwargs: \
 123.327 +           _check_ref(lambda r: XendDomain.instance().is_valid_dev('vtpm', r),
 123.328 +                      'VTPM_HANDLE_INVALID', func, *args, **kwargs)
 123.329  
 123.330  def valid_sr(func):
 123.331 +    """Decorator to verify if sr_ref is valid before calling method.
 123.332 +
 123.333 +    @param func: function with params: (self, session, sr_ref, ...)
 123.334 +    @rtype: callable object
 123.335 +    """
 123.336 +    return lambda *args, **kwargs: \
 123.337 +           _check_ref(lambda r: XendNode.instance().get_sr().uuid == r,
 123.338 +                      'SR_HANDLE_INVALID', func, *args, **kwargs)
 123.339 +
 123.340 +def valid_pif(func):
 123.341      """Decorator to verify if sr_ref is valid before calling
 123.342      method.
 123.343  
 123.344      @param func: function with params: (self, session, sr_ref)
 123.345      @rtype: callable object
 123.346      """
 123.347 -    def check_sr_ref(self, session, sr_ref, *args, **kwargs):
 123.348 -        xennode = XendNode.instance()
 123.349 -        if type(sr_ref) == type(str()) and \
 123.350 -               xennode.get_sr().uuid == sr_ref:
 123.351 -            return func(self, session, sr_ref, *args, **kwargs)
 123.352 -        else:
 123.353 -            return {'Status': 'Failure',
 123.354 -                    'ErrorDescription': XEND_ERROR_SR_INVALID}
 123.355 -
 123.356 -    # make sure we keep the 'api' attribute
 123.357 -    if hasattr(func, 'api'):
 123.358 -        check_sr_ref.api = func.api
 123.359 -        
 123.360 -    return check_sr_ref
 123.361 +    return lambda *args, **kwargs: \
 123.362 +           _check_ref(lambda r: r in XendNode.instance().pifs,
 123.363 +                      'PIF_HANDLE_INVALID', func, *args, **kwargs)
 123.364  
 123.365  # -----------------------------
 123.366  # Bridge to Legacy XM API calls
 123.367 @@ -263,10 +261,14 @@ def do_vm_func(fn_name, vm_ref, *args, *
 123.368      @param *args: more arguments
 123.369      @type *args: tuple
 123.370      """
 123.371 -    xendom = XendDomain.instance()
 123.372 -    fn = getattr(xendom, fn_name)
 123.373 -    xendom.do_legacy_api_with_uuid(fn, vm_ref, *args, **kwargs)
 123.374 -    return xen_api_success_void()
 123.375 +    try:
 123.376 +        xendom = XendDomain.instance()
 123.377 +        fn = getattr(xendom, fn_name)
 123.378 +        xendom.do_legacy_api_with_uuid(fn, vm_ref, *args, **kwargs)
 123.379 +        return xen_api_success_void()
 123.380 +    except VMBadState, exn:
 123.381 +        return xen_api_error(['VM_BAD_POWER_STATE', vm_ref, exn.expected,
 123.382 +                              exn.actual])
 123.383  
 123.384  
 123.385  class XendAPI:
 123.386 @@ -274,7 +276,7 @@ class XendAPI:
 123.387      used via XMLRPCServer.
 123.388  
 123.389      All methods that need a valid session are marked with
 123.390 -    a L{XendAuthManager.session_required} decorator that will
 123.391 +    a L{session_required} decorator that will
 123.392      transparently perform the required session authentication.
 123.393  
 123.394      We need to support Python <2.4, so we use the old decorator syntax.
 123.395 @@ -284,109 +286,13 @@ class XendAPI:
 123.396      """
 123.397  
 123.398      def __init__(self, auth):
 123.399 -        """Initialised Xen API wrapper by making sure all functions
 123.400 -        have the correct validation decorators such as L{valid_host}
 123.401 -        and L{session_required}.
 123.402 -        """
 123.403          self.auth = auth
 123.404  
 123.405 -        classes = {
 123.406 -            'session': (session_required,),
 123.407 -            'host': (valid_host, session_required),
 123.408 -            'host_cpu': (valid_host_cpu, session_required),
 123.409 -            'VM': (valid_vm, session_required),
 123.410 -            'VBD': (valid_vbd, session_required),
 123.411 -            'VIF': (valid_vif, session_required),
 123.412 -            'VDI': (valid_vdi, session_required),
 123.413 -            'VTPM':(valid_vtpm, session_required),
 123.414 -            'SR':  (valid_sr, session_required)}
 123.415 -        
 123.416 -        # Cheat methods
 123.417 -        # -------------
 123.418 -        # Methods that have a trivial implementation for all classes.
 123.419 -        # 1. get_by_uuid == getting by ref, so just return uuid for
 123.420 -        #    all get_by_uuid() methods.
 123.421 -        
 123.422 -        for cls in classes.keys():
 123.423 -            get_by_uuid = '%s_get_by_uuid' % cls
 123.424 -            get_uuid = '%s_get_uuid' % cls
 123.425 -            setattr(XendAPI, get_by_uuid,
 123.426 -                    lambda s, sess, obj_ref: xen_api_success(obj_ref))
 123.427 -            setattr(XendAPI, get_uuid,
 123.428 -                    lambda s, sess, obj_ref: xen_api_success(obj_ref))
 123.429 -
 123.430 -        # 2. get_record is just getting all the attributes, so provide
 123.431 -        #    a fake template implementation.
 123.432 -        # 
 123.433 -        # TODO: ...
 123.434 -
 123.435 -
 123.436 -        # Wrapping validators around XMLRPC calls
 123.437 -        # ---------------------------------------
 123.438 -        
 123.439 -        for cls, validators in classes.items():
 123.440 -            ro_attrs = getattr(self, '%s_attr_ro' % cls, [])
 123.441 -            rw_attrs = getattr(self, '%s_attr_rw' % cls, [])
 123.442 -            methods  = getattr(self, '%s_methods' % cls, [])
 123.443 -            funcs    = getattr(self, '%s_funcs' % cls, [])
 123.444 -
 123.445 -            # wrap validators around readable class attributes
 123.446 -            for attr_name in ro_attrs + rw_attrs + self.Base_attr_ro:
 123.447 -                getter_name = '%s_get_%s' % (cls, attr_name)
 123.448 -                try:
 123.449 -                    getter = getattr(XendAPI, getter_name)
 123.450 -                    for validator in validators:
 123.451 -                        getter = validator(getter)
 123.452 -                    getter.api = '%s.get_%s' % (cls, attr_name)
 123.453 -                    setattr(XendAPI, getter_name, getter)
 123.454 -                except AttributeError:
 123.455 -                    pass
 123.456 -                    #log.warn("API call: %s not found" % getter_name)
 123.457 -
 123.458 -            # wrap validators around writable class attrributes
 123.459 -            for attr_name in rw_attrs + self.Base_attr_rw:
 123.460 -                setter_name = '%s_set_%s' % (cls, attr_name)
 123.461 -                try:
 123.462 -                    setter = getattr(XendAPI, setter_name)
 123.463 -                    for validator in validators:
 123.464 -                        setter = validator(setter)
 123.465 -                    setter.api = '%s.set_%s' % (cls, attr_name)
 123.466 -                    setattr(XendAPI, setter_name, setter)
 123.467 -                except AttributeError:
 123.468 -                    pass
 123.469 -                    #log.warn("API call: %s not found" % setter_name)
 123.470 -
 123.471 -            # wrap validators around methods
 123.472 -            for method_name in methods + self.Base_methods:
 123.473 -                method_full_name = '%s_%s' % (cls, method_name)
 123.474 -
 123.475 -                try:
 123.476 -                    method = getattr(XendAPI, method_full_name)
 123.477 -                    for validator in validators:
 123.478 -                        method = validator(method)
 123.479 -                    method.api = '%s.%s' % (cls, method_name)
 123.480 -                    setattr(XendAPI, method_full_name, method)
 123.481 -                except AttributeError:
 123.482 -                    pass
 123.483 -                    #log.warn('API call: %s not found' % method_full_name)
 123.484 -
 123.485 -            # wrap validators around class functions
 123.486 -            for func_name in funcs + self.Base_funcs:
 123.487 -                func_full_name = '%s_%s' % (cls, func_name)
 123.488 -                try:
 123.489 -                    method = getattr(XendAPI, func_full_name)
 123.490 -                    method = session_required(method)
 123.491 -                    method.api = '%s.%s' % (cls, func_name)
 123.492 -                    setattr(XendAPI, func_full_name, method)
 123.493 -                except AttributeError:
 123.494 -                    pass
 123.495 -                    #log.warn('API call: %s not found' % func_full_name)
 123.496 -
 123.497  
 123.498      Base_attr_ro = ['uuid']
 123.499      Base_attr_rw = []
 123.500 -    Base_methods = ['destroy', 'get_record']
 123.501 -    Base_funcs   = ['create', 'get_by_uuid', 'get_all']
 123.502 +    Base_methods = ['destroy', 'get_by_uuid', 'get_record']
 123.503 +    Base_funcs   = ['create', 'get_all']
 123.504  
 123.505      # Xen API: Class Session
 123.506      # ----------------------------------------------------------------
 123.507 @@ -396,14 +302,20 @@ class XendAPI:
 123.508      session_methods = ['logout']
 123.509      # session_funcs = ['login_with_password']    
 123.510  
 123.511 -    def session_login_with_password(self, username, password):
 123.512 +    def session_login_with_password(self, *args):
 123.513 +        if len(args) != 2:
 123.514 +            return xen_api_error(
 123.515 +                ['MESSAGE_PARAMETER_COUNT_MISMATCH',
 123.516 +                 'session.login_with_password', 2, len(args)])
 123.517 +        username = args[0]
 123.518 +        password = args[1]
 123.519          try:
 123.520              session = (self.auth == AUTH_NONE and
 123.521                         auth_manager().login_unconditionally(username) or
 123.522                         auth_manager().login_with_password(username, password))
 123.523              return xen_api_success(session)
 123.524          except XendError, e:
 123.525 -            return xen_api_error(XEND_ERROR_AUTHENTICATION_FAILED)
 123.526 +            return xen_api_error(['SESSION_AUTHENTICATION_FAILED'])
 123.527      session_login_with_password.api = 'session.login_with_password'
 123.528  
 123.529  
 123.530 @@ -425,7 +337,7 @@ class XendAPI:
 123.531          user = auth_manager().get_user(session)
 123.532          if user:
 123.533              return xen_api_success(user)
 123.534 -        return xen_api_error(XEND_ERROR_SESSION_INVALID)
 123.535 +        return xen_api_error(['SESSION_INVALID', session])
 123.536  
 123.537  
 123.538      # Xen API: Class User
 123.539 @@ -548,18 +460,156 @@ class XendAPI:
 123.540          return xen_api_error(XEND_ERROR_UNSUPPORTED)
 123.541  
 123.542  
 123.543 -    # Xen API: Class Network
 123.544 +    # Xen API: Class network
 123.545      # ----------------------------------------------------------------
 123.546 -    # TODO: NOT IMPLEMENTED
 123.547  
 123.548 -    Network_attr_ro = ['VIFs']
 123.549 -    Network_attr_rw = ['name_label',
 123.550 +    network_attr_ro = ['VIFs', 'PIFs']
 123.551 +    network_attr_rw = ['name_label',
 123.552                         'name_description',
 123.553 -                       'NIC',
 123.554 -                       'VLAN',
 123.555                         'default_gateway',
 123.556                         'default_netmask']
 123.557  
 123.558 +    def network_create(self, _, name_label, name_description,
 123.559 +                       default_gateway, default_netmask):
 123.560 +        return xen_api_success(
 123.561 +            XendNode.instance().network_create(name_label, name_description,
 123.562 +                                               default_gateway,
 123.563 +                                               default_netmask))
 123.564 +
 123.565 +    def network_destroy(self, _, ref):
 123.566 +        return xen_api_success(XendNode.instance().network_destroy(ref))
 123.567 +
 123.568 +    def _get_network(self, ref):
 123.569 +        return XendNode.instance().get_network(ref)
 123.570 +
 123.571 +    def network_get_all(self, _):
 123.572 +        return xen_api_success(XendNode.instance().get_network_refs())
 123.573 +
 123.574 +    def network_get_record(self, _, ref):
 123.575 +        return xen_api_success(
 123.576 +            XendNode.instance().get_network(ref).get_record())
 123.577 +
 123.578 +    def network_get_name_label(self, _, ref):
 123.579 +        return xen_api_success(self._get_network(ref).name_label)
 123.580 +
 123.581 +    def network_get_name_description(self, _, ref):
 123.582 +        return xen_api_success(self._get_network(ref).name_description)
 123.583 +
 123.584 +    def network_get_default_gateway(self, _, ref):
 123.585 +        return xen_api_success(self._get_network(ref).default_gateway)
 123.586 +
 123.587 +    def network_get_default_netmask(self, _, ref):
 123.588 +        return xen_api_success(self._get_network(ref).default_netmask)
 123.589 +
 123.590 +    def network_get_VIFs(self, _, ref):
 123.591 +        return xen_api_success(self._get_network(ref).get_VIF_UUIDs())
 123.592 +
 123.593 +    def network_get_PIFs(self, session, ref):
 123.594 +        return xen_api_success(self._get_network(ref).get_PIF_UUIDs())
 123.595 +
 123.596 +    def network_set_name_label(self, _, ref, val):
 123.597 +        return xen_api_success(self._get_network(ref).set_name_label(val))
 123.598 +
 123.599 +    def network_set_name_description(self, _, ref, val):
 123.600 +        return xen_api_success(self._get_network(ref).set_name_description(val))
 123.601 +
 123.602 +    def network_set_default_gateway(self, _, ref, val):
 123.603 +        return xen_api_success(self._get_network(ref).set_default_gateway(val))
 123.604 +
 123.605 +    def network_set_default_netmask(self, _, ref, val):
 123.606 +        return xen_api_success(self._get_network(ref).set_default_netmask(val))
 123.607 +
 123.608 +
 123.609 +    # Xen API: Class PIF
 123.610 +    # ----------------------------------------------------------------
 123.611 +
 123.612 +    PIF_attr_ro = ['io_read_kbs',
 123.613 +                   'io_write_kbs']
 123.614 +    PIF_attr_rw = ['name',
 123.615 +                   'network',
 123.616 +                   'host',
 123.617 +                   'MAC',
 123.618 +                   'MTU',
 123.619 +                   'VLAN']
 123.620 +
 123.621 +    PIF_attr_inst = PIF_attr_rw
 123.622 +
 123.623 +    PIF_methods = ['create_VLAN']
 123.624 +
 123.625 +    def _get_PIF(self, ref):
 123.626 +        return XendNode.instance().pifs[ref]
 123.627 +
 123.628 +    def PIF_create(self, _, name, network_uuid, host_uuid, mac, mtu, vlan):
 123.629 +        try:
 123.630 +            node = XendNode.instance()
 123.631 +            if host_uuid != node.uuid:
 123.632 +                return xen_api_error(['HOST_HANDLE_INVALID', host_uuid])
 123.633 +
 123.634 +            elif _is_valid_ref(network_uuid, node.is_valid_network):
 123.635 +                network = node.get_network(network_uuid)
 123.636 +                return xen_api_success(node.PIF_create(name, mtu, vlan, mac,
 123.637 +                                                       network))
 123.638 +            else:
 123.639 +                return xen_api_error(['NETWORK_HANDLE_INVALID', network_uuid])
 123.640 +        except NetworkAlreadyConnected, exn:
 123.641 +            return xen_api_error(['NETWORK_ALREADY_CONNECTED',
 123.642 +                                  network_uuid, exn.pif_uuid])
 123.643 +
 123.644 +    def PIF_destroy(self, _, ref):
 123.645 +        return xen_api_success(XendNode.instance().PIF_destroy(ref))
 123.646 +
 123.647 +    # object methods
 123.648 +    def PIF_get_record(self, _, ref):
 123.649 +        return xen_api_success(self._get_PIF(ref).get_record())
 123.650 +
 123.651 +    def PIF_get_all(self, _):
 123.652 +        return xen_api_success(XendNode.instance().pifs.keys())
 123.653 +
 123.654 +    def PIF_get_name(self, _, ref):
 123.655 +        return xen_api_success(self._get_PIF(ref).name)
 123.656 +
 123.657 +    def PIF_get_network(self, _, ref):
 123.658 +        return xen_api_success(self._get_PIF(ref).network.uuid)
 123.659 +
 123.660 +    def PIF_get_host(self, _, ref):
 123.661 +        return xen_api_success(self._get_PIF(ref).host.uuid)
 123.662 +
 123.663 +    def PIF_get_MAC(self, _, ref):
 123.664 +        return xen_api_success(self._get_PIF(ref).mac)
 123.665 +
 123.666 +    def PIF_get_MTU(self, _, ref):
 123.667 +        return xen_api_success(self._get_PIF(ref).mtu)
 123.668 +
 123.669 +    def PIF_get_VLAN(self, _, ref):
 123.670 +        return xen_api_success(self._get_PIF(ref).vlan)
 123.671 +
 123.672 +    def PIF_get_io_read_kbs(self, _, ref):
 123.673 +        return xen_api_success(self._get_PIF(ref).get_io_read_kbs())
 123.674 +
 123.675 +    def PIF_get_io_write_kbs(self, _, ref):
 123.676 +        return xen_api_success(self._get_PIF(ref).get_io_write_kbs())
 123.677 +    
 123.678 +    def PIF_set_name(self, _, ref, name):
 123.679 +        return xen_api_success(self._get_PIF(ref).set_name(name))
 123.680 +
 123.681 +    def PIF_set_MAC(self, _, ref, mac):
 123.682 +        return xen_api_success(self._get_PIF(ref).set_mac(mac))
 123.683 +
 123.684 +    def PIF_set_MTU(self, _, ref, mtu):
 123.685 +        return xen_api_success(self._get_PIF(ref).set_mtu(mtu))
 123.686 +
 123.687 +    def PIF_create_VLAN(self, _, ref, network, vlan):
 123.688 +        try:
 123.689 +            if _is_valid_ref(network, XendNode.instance().is_valid_network):
 123.690 +                return xen_api_success(XendNode.instance().PIF_create_VLAN(
 123.691 +                    ref, network, vlan))
 123.692 +            else:
 123.693 +                return xen_api_error(['NETWORK_HANDLE_INVALID', network])
 123.694 +        except NetworkAlreadyConnected, exn:
 123.695 +            return xen_api_error(['NETWORK_ALREADY_CONNECTED',
 123.696 +                                  network, exn.pif_uuid])
 123.697 +
 123.698 +
 123.699      # Xen API: Class VM
 123.700      # ----------------------------------------------------------------        
 123.701  
 123.702 @@ -833,55 +883,55 @@ class XendAPI:
 123.703          dom.setName(label)
 123.704          return xen_api_success_void()
 123.705      
 123.706 -    def VM_set_name_description(self, session, vm_ref):
 123.707 +    def VM_set_name_description(self, session, vm_ref, desc):
 123.708          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.709 -        return xen_api_success_void()
 123.710 +        return xen_api_todo()
 123.711      
 123.712 -    def VM_set_user_version(self, session, vm_ref):
 123.713 +    def VM_set_user_version(self, session, vm_ref, ver):
 123.714          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.715 -        return xen_api_success_void()
 123.716 +        return xen_api_todo()
 123.717      
 123.718 -    def VM_set_is_a_template(self, session, vm_ref):
 123.719 +    def VM_set_is_a_template(self, session, vm_ref, is_template):
 123.720          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.721 -        return xen_api_success_void()
 123.722 +        return xen_api_todo()
 123.723      
 123.724 -    def VM_set_memory_dynamic_max(self, session, vm_ref):
 123.725 +    def VM_set_memory_dynamic_max(self, session, vm_ref, mem):
 123.726          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.727 -        return xen_api_success_void()
 123.728 +        return xen_api_todo()
 123.729      
 123.730 -    def VM_set_memory_dynamic_min(self, session, vm_ref):
 123.731 +    def VM_set_memory_dynamic_min(self, session, vm_ref, mem):
 123.732          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.733 -        return xen_api_success_void()
 123.734 +        return xen_api_todo()
 123.735      
 123.736 -    def VM_set_VCPUs_policy(self, session, vm_ref):
 123.737 +    def VM_set_VCPUs_policy(self, session, vm_ref, policy):
 123.738          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.739 -        return xen_api_success_void()
 123.740 +        return xen_api_todo()
 123.741      
 123.742 -    def VM_set_VCPUs_params(self, session, vm_ref):
 123.743 +    def VM_set_VCPUs_params(self, session, vm_ref, params):
 123.744          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.745 -        return xen_api_success_void()
 123.746 +        return xen_api_todo()
 123.747      
 123.748 -    def VM_set_VCPUs_features_force_on(self, session, vm_ref):
 123.749 +    def VM_set_VCPUs_features_force_on(self, session, vm_ref, features):
 123.750          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.751 -        return xen_api_success_void()
 123.752 +        return xen_api_todo()
 123.753      
 123.754 -    def VM_set_VCPUs_features_force_off(self, session, vm_ref):
 123.755 +    def VM_set_VCPUs_features_force_off(self, session, vm_ref, features):
 123.756          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.757 -        return xen_api_success_void()
 123.758 +        return xen_api_todo()
 123.759      
 123.760 -    def VM_set_actions_after_shutdown(self, session, vm_ref):
 123.761 +    def VM_set_actions_after_shutdown(self, session, vm_ref, action):
 123.762          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.763 -        return xen_api_success_void()
 123.764 +        return xen_api_todo()
 123.765      
 123.766 -    def VM_set_actions_after_reboot(self, session, vm_ref):
 123.767 +    def VM_set_actions_after_reboot(self, session, vm_ref, action):
 123.768          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.769 -        return xen_api_success_void()
 123.770 +        return xen_api_todo()
 123.771      
 123.772 -    def VM_set_actions_after_suspend(self, session, vm_ref):
 123.773 +    def VM_set_actions_after_suspend(self, session, vm_ref, action):
 123.774          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.775 -        return xen_api_success_void()
 123.776 +        return xen_api_todo()
 123.777      
 123.778 -    def VM_set_actions_after_crash(self, session, vm_ref):
 123.779 +    def VM_set_actions_after_crash(self, session, vm_ref, action):
 123.780          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.781          return xen_api_success_void()
 123.782  
 123.783 @@ -905,27 +955,27 @@ class XendAPI:
 123.784  
 123.785      def VM_set_platform_std_VGA(self, session, vm_ref):
 123.786          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.787 -        return xen_api_success_void()
 123.788 +        return xen_api_todo()
 123.789      
 123.790 -    def VM_set_platform_serial(self, session, vm_ref):
 123.791 +    def VM_set_platform_serial(self, session, vm_ref, serial):
 123.792          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.793 -        return xen_api_success_void()
 123.794 +        return xen_api_todo()
 123.795      
 123.796 -    def VM_set_platform_localtime(self, session, vm_ref):
 123.797 +    def VM_set_platform_localtime(self, session, vm_ref, localtime):
 123.798          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.799 -        return xen_api_success_void()
 123.800 +        return xen_api_todo()
 123.801      
 123.802 -    def VM_set_platform_clock_offset(self, session, vm_ref):
 123.803 +    def VM_set_platform_clock_offset(self, session, vm_ref, clock_offset):
 123.804          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.805 -        return xen_api_success_void()
 123.806 +        return xen_api_todo()
 123.807      
 123.808 -    def VM_set_platform_enable_audio(self, session, vm_ref):
 123.809 +    def VM_set_platform_enable_audio(self, session, vm_ref, enable_audio):
 123.810          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.811 -        return xen_api_success_void()
 123.812 +        return xen_api_todo()
 123.813      
 123.814      def VM_set_otherConfig(self, session, vm_ref):
 123.815          dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
 123.816 -        return xen_api_success_void()
 123.817 +        return xen_api_todo()
 123.818      
 123.819      # class methods
 123.820      def VM_get_all(self, session):
 123.821 @@ -937,7 +987,7 @@ class XendAPI:
 123.822          dom = xendom.domain_lookup_nr(label)
 123.823          if dom:
 123.824              return xen_api_success([dom.get_uuid()])
 123.825 -        return xen_api_error(XEND_ERROR_VM_INVALID)
 123.826 +        return xen_api_success([])
 123.827      
 123.828      def VM_create(self, session, vm_struct):
 123.829          xendom = XendDomain.instance()
 123.830 @@ -949,7 +999,7 @@ class XendAPI:
 123.831          xendom = XendDomain.instance()
 123.832          xeninfo = xendom.get_vm_by_uuid(vm_ref)
 123.833          if not xeninfo:
 123.834 -            return xen_api_error(XEND_ERROR_VM_INVALID)
 123.835 +            return xen_api_error(['VM_HANDLE_INVALID', vm_ref])
 123.836          
 123.837          record = {
 123.838              'uuid': xeninfo.get_uuid(),
 123.839 @@ -1051,10 +1101,10 @@ class XendAPI:
 123.840          xendom = XendDomain.instance()
 123.841          vm = xendom.get_vm_with_dev_uuid('vbd', vbd_ref)
 123.842          if not vm:
 123.843 -            return xen_api_error(XEND_ERROR_VBD_INVALID)
 123.844 +            return xen_api_error(['VBD_HANDLE_INVALID', vbd_ref])
 123.845          cfg = vm.get_dev_xenapi_config('vbd', vbd_ref)
 123.846          if not cfg:
 123.847 -            return xen_api_error(XEND_ERROR_VBD_INVALID)
 123.848 +            return xen_api_error(['VBD_HANDLE_INVALID', vbd_ref])
 123.849  
 123.850          valid_vbd_keys = self.VBD_attr_ro + self.VBD_attr_rw + \
 123.851                           self.Base_attr_ro + self.Base_attr_rw
 123.852 @@ -1073,7 +1123,7 @@ class XendAPI:
 123.853      def VBD_create(self, session, vbd_struct):
 123.854          xendom = XendDomain.instance()
 123.855          if not xendom.is_valid_vm(vbd_struct['VM']):
 123.856 -            return xen_api_error(XEND_ERROR_DOMAIN_INVALID)
 123.857 +            return xen_api_error(['VM_HANDLE_INVALID', vbd_struct['VM']])
 123.858          
 123.859          dom = xendom.get_vm_by_uuid(vbd_struct['VM'])
 123.860          vbd_ref = ''
 123.861 @@ -1087,7 +1137,7 @@ class XendAPI:
 123.862                  sr = XendNode.instance().get_sr()
 123.863                  vdi_image = sr.xen_api_get_by_uuid(vdi_ref)
 123.864                  if not vdi_image:
 123.865 -                    return xen_api_error(XEND_ERROR_VDI_INVALID)
 123.866 +                    return xen_api_error(['VDI_HANDLE_INVALID', vdi_ref])
 123.867                  vdi_image = vdi_image.qcow_path
 123.868                  vbd_ref = dom.create_vbd_with_vdi(vbd_struct, vdi_image)
 123.869          except XendError:
 123.870 @@ -1137,10 +1187,10 @@ class XendAPI:
 123.871          xendom = XendDomain.instance()
 123.872          vm = xendom.get_vm_with_dev_uuid('vif', vif_ref)
 123.873          if not vm:
 123.874 -            return xen_api_error(XEND_ERROR_VIF_INVALID)
 123.875 +            return xen_api_error(['VIF_HANDLE_INVALID', vif_ref])
 123.876          cfg = vm.get_dev_xenapi_config('vif', vif_ref)
 123.877          if not cfg:
 123.878 -            return xen_api_error(XEND_ERROR_VIF_INVALID)
 123.879 +            return xen_api_error(['VIF_HANDLE_INVALID', vif_ref])
 123.880          
 123.881          valid_vif_keys = self.VIF_attr_ro + self.VIF_attr_rw + \
 123.882                           self.Base_attr_ro + self.Base_attr_rw
 123.883 @@ -1164,7 +1214,7 @@ class XendAPI:
 123.884              except XendError:
 123.885                  return xen_api_error(XEND_ERROR_TODO)
 123.886          else:
 123.887 -            return xen_api_error(XEND_ERROR_DOMAIN_INVALID)
 123.888 +            return xen_api_error(['VM_HANDLE_INVALID', vif_struct['VM']])
 123.889  
 123.890  
 123.891      # Xen API: Class VDI
 123.892 @@ -1185,74 +1235,54 @@ class XendAPI:
 123.893  
 123.894      VDI_methods = ['snapshot']
 123.895      VDI_funcs = ['get_by_name_label']
 123.896 +
 123.897 +    def _get_VDI(self, ref):
 123.898 +        return XendNode.instance().get_sr().xen_api_get_by_uuid(ref)
 123.899      
 123.900      def VDI_get_VBDs(self, session, vdi_ref):
 123.901          return xen_api_todo()
 123.902      
 123.903      def VDI_get_physical_utilisation(self, session, vdi_ref):
 123.904 -        sr = XendNode.instance().get_sr()
 123.905 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.906 -        return xen_api_success(image.get_physical_utilisation())        
 123.907 +        return xen_api_success(self._get_VDI(vdi_ref).
 123.908 +                               get_physical_utilisation())        
 123.909      
 123.910      def VDI_get_sector_size(self, session, vdi_ref):
 123.911 -        sr = XendNode.instance().get_sr()
 123.912 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.913 -        return xen_api_success(image.sector_size)        
 123.914 +        return xen_api_success(self._get_VDI(vdi_ref).sector_size)        
 123.915      
 123.916      def VDI_get_type(self, session, vdi_ref):
 123.917 -        sr = XendNode.instance().get_sr()
 123.918 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.919 -        return xen_api_success(image.type)
 123.920 +        return xen_api_success(self._get_VDI(vdi_ref).type)
 123.921      
 123.922      def VDI_get_parent(self, session, vdi_ref):
 123.923 -        sr = XendNode.instance().get_sr()
 123.924 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.925 -        return xen_api_success(image.parent)        
 123.926 +        return xen_api_success(self._get_VDI(vdi_ref).parent)        
 123.927      
 123.928      def VDI_get_children(self, session, vdi_ref):
 123.929 -        sr = XendNode.instance().get_sr()
 123.930 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.931 -        return xen_api_success(image.children)        
 123.932 +        return xen_api_success(self._get_VDI(vdi_ref).children)        
 123.933      
 123.934      def VDI_get_name_label(self, session, vdi_ref):
 123.935 -        sr = XendNode.instance().get_sr()
 123.936 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.937 -        return xen_api_success(image.name_label)
 123.938 +        return xen_api_success(self._get_VDI(vdi_ref).name_label)
 123.939  
 123.940      def VDI_get_name_description(self, session, vdi_ref):
 123.941 -        sr = XendNode.instance().get_sr()
 123.942 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.943 -        return xen_api_success(image.name_description)
 123.944 +        return xen_api_success(self._get_VDI(vdi_ref).name_description)
 123.945  
 123.946      def VDI_get_SR(self, session, vdi_ref):
 123.947          sr = XendNode.instance().get_sr()
 123.948          return xen_api_success(sr.uuid)
 123.949  
 123.950      def VDI_get_virtual_size(self, session, vdi_ref):
 123.951 -        sr = XendNode.instance().get_sr()
 123.952 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.953 -        return xen_api_success(image.virtual_size)
 123.954 +        return xen_api_success(self._get_VDI(vdi_ref).virtual_size)
 123.955  
 123.956      def VDI_get_sharable(self, session, vdi_ref):
 123.957 -        sr = XendNode.instance().get_sr()
 123.958 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.959 -        return xen_api_success(image.sharable)
 123.960 +        return xen_api_success(self._get_VDI(vdi_ref).sharable)
 123.961  
 123.962      def VDI_get_read_only(self, session, vdi_ref):
 123.963 -        sr = XendNode.instance().get_sr()
 123.964 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.965 -        return xen_api_success(image.sharable)        
 123.966 +        return xen_api_success(self._get_VDI(vdi_ref).read_only)        
 123.967  
 123.968      def VDI_set_name_label(self, session, vdi_ref, value):
 123.969 -        sr = XendNode.instance().get_sr()
 123.970 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.971 -        image.name_label = value
 123.972 +        self._get_VDI(vdi_ref).name_label = value
 123.973          return xen_api_success_void()
 123.974  
 123.975      def VDI_set_name_description(self, session, vdi_ref, value):
 123.976 -        sr = XendNode.instance().get_sr()
 123.977 -        image = sr.xen_api_get_by_uuid(vdi_ref)
 123.978 -        image.name_description = value
 123.979 +        self._get_VDI(vdi_ref).name_description = value
 123.980          return xen_api_success_void()
 123.981  
 123.982      def VDI_set_SR(self, session, vdi_ref, value):
 123.983 @@ -1262,9 +1292,12 @@ class XendAPI:
 123.984          return xen_api_error(XEND_ERROR_UNSUPPORTED)
 123.985  
 123.986      def VDI_set_sharable(self, session, vdi_ref, value):
 123.987 -        return xen_api_todo()
 123.988 +        self._get_VDI(vdi_ref).sharable = bool(value)
 123.989 +        return xen_api_success_void()
 123.990 +    
 123.991      def VDI_set_read_only(self, session, vdi_ref, value):
 123.992 -        return xen_api_todo()
 123.993 +        self._get_VDI(vdi_ref).read_only = bool(value)
 123.994 +        return xen_api_success_void()
 123.995  
 123.996      # Object Methods
 123.997      def VDI_snapshot(self, session, vdi_ref):
 123.998 @@ -1278,31 +1311,28 @@ class XendAPI:
 123.999      def VDI_get_record(self, session, vdi_ref):
123.1000          sr = XendNode.instance().get_sr()
123.1001          image = sr.xen_api_get_by_uuid(vdi_ref)
123.1002 -        if image:
123.1003 -            return xen_api_success({
123.1004 -                'uuid': vdi_ref,
123.1005 -                'name_label': image.name_label,
123.1006 -                'name_description': image.name_description,
123.1007 -                'SR': sr.uuid,
123.1008 -                'VBDs': [], # TODO
123.1009 -                'virtual_size': image.virtual_size,
123.1010 -                'physical_utilisation': image.physical_utilisation,
123.1011 -                'sector_size': image.sector_size,
123.1012 -                'type': image.type,
123.1013 -                'parent': image.parent,
123.1014 -                'children': image.children,
123.1015 -                'sharable': image.sharable,
123.1016 -                'read_only': image.read_only,
123.1017 -                })
123.1018 -
123.1019 -        return xen_api_error(XEND_ERROR_VDI_INVALID)
123.1020 +        return xen_api_success({
123.1021 +            'uuid': vdi_ref,
123.1022 +            'name_label': image.name_label,
123.1023 +            'name_description': image.name_description,
123.1024 +            'SR': sr.uuid,
123.1025 +            'VBDs': [], # TODO
123.1026 +            'virtual_size': image.virtual_size,
123.1027 +            'physical_utilisation': image.physical_utilisation,
123.1028 +            'sector_size': image.sector_size,
123.1029 +            'type': image.type,
123.1030 +            'parent': image.parent,
123.1031 +            'children': image.children,
123.1032 +            'sharable': image.sharable,
123.1033 +            'read_only': image.read_only,
123.1034 +            })
123.1035  
123.1036      # Class Functions    
123.1037      def VDI_create(self, session, vdi_struct):
123.1038          sr = XendNode.instance().get_sr()
123.1039          sr_ref = vdi_struct['SR']
123.1040          if sr.uuid != sr_ref:
123.1041 -            return xen_api_error(XEND_ERROR_SR_INVALID)
123.1042 +            return xen_api_error(['SR_HANDLE_INVALID', vdi_struct['SR']])
123.1043  
123.1044          vdi_uuid = sr.create_image(vdi_struct)
123.1045          return xen_api_success(vdi_uuid)
123.1046 @@ -1315,9 +1345,8 @@ class XendAPI:
123.1047          sr = XendNode.instance().get_sr()
123.1048          image_uuid = sr.xen_api_get_by_name_label(name)
123.1049          if image_uuid:
123.1050 -            return xen_api_success(image_uuid)
123.1051 -        
123.1052 -        return xen_api_error(XEND_ERROR_VDI_INVALID)
123.1053 +            return xen_api_success([image_uuid])
123.1054 +        return xen_api_success([])
123.1055  
123.1056  
123.1057      # Xen API: Class VTPM
123.1058 @@ -1336,10 +1365,10 @@ class XendAPI:
123.1059          xendom = XendDomain.instance()
123.1060          vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
123.1061          if not vm:
123.1062 -            return xen_api_error(XEND_ERROR_VTPM_INVALID)
123.1063 +            return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
123.1064          cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref)
123.1065          if not cfg:
123.1066 -            return xen_api_error(XEND_ERROR_VTPM_INVALID)
123.1067 +            return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
123.1068          valid_vtpm_keys = self.VTPM_attr_ro + self.VTPM_attr_rw + \
123.1069                            self.Base_attr_ro + self.Base_attr_rw
123.1070          for k in cfg.keys():
123.1071 @@ -1353,10 +1382,10 @@ class XendAPI:
123.1072          xendom = XendDomain.instance()
123.1073          vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
123.1074          if not vm:
123.1075 -            return xen_api_error(XEND_ERROR_VTPM_INVALID)
123.1076 +            return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
123.1077          cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref)
123.1078          if not cfg:
123.1079 -            return xen_api_error(XEND_ERROR_VTPM_INVALID)
123.1080 +            return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
123.1081          if cfg.has_key('instance'):
123.1082              instance = cfg['instance']
123.1083          else:
123.1084 @@ -1367,10 +1396,10 @@ class XendAPI:
123.1085          xendom = XendDomain.instance()
123.1086          vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
123.1087          if not vm:
123.1088 -            return xen_api_error(XEND_ERROR_VTPM_INVALID)
123.1089 +            return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
123.1090          cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref)
123.1091          if not cfg:
123.1092 -            return xen_api_error(XEND_ERROR_VTPM_INVALID)
123.1093 +            return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
123.1094          if cfg.has_key('type'):
123.1095              driver = cfg['type']
123.1096          else:
123.1097 @@ -1381,10 +1410,10 @@ class XendAPI:
123.1098          xendom = XendDomain.instance()
123.1099          vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
123.1100          if not vm:
123.1101 -            return xen_api_error(XEND_ERROR_VTPM_INVALID)
123.1102 +            return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
123.1103          cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref)
123.1104          if not cfg:
123.1105 -            return xen_api_error(XEND_ERROR_VTPM_INVALID)
123.1106 +            return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
123.1107          if cfg.has_key('backend'):
123.1108              backend = cfg['backend']
123.1109          else:
123.1110 @@ -1407,7 +1436,7 @@ class XendAPI:
123.1111              except XendError:
123.1112                  return xen_api_error(XEND_ERROR_TODO)
123.1113          else:
123.1114 -            return xen_api_error(XEND_ERROR_DOMAIN_INVALID)
123.1115 +            return xen_api_error(['VM_HANDLE_INVALID', vtpm_struct['VM']])
123.1116  
123.1117  
123.1118      # Xen API: Class SR
123.1119 @@ -1439,7 +1468,7 @@ class XendAPI:
123.1120      def SR_get_by_name_label(self, session, label):
123.1121          sr = XendNode.instance().get_sr()
123.1122          if sr.name_label != label:
123.1123 -            return xen_api_error(XEND_ERROR_SR_INVALID)
123.1124 +            return xen_api_success([])
123.1125          return xen_api_success([sr.uuid])
123.1126  
123.1127      def SR_create(self, session):
123.1128 @@ -1457,61 +1486,143 @@ class XendAPI:
123.1129      
123.1130      def SR_get_record(self, session, sr_ref):
123.1131          sr = XendNode.instance().get_sr()
123.1132 -        return xen_api_success({
123.1133 -            'uuid': sr.uuid,
123.1134 -            'name_label': sr.name_label,
123.1135 -            'name_description': sr.name_description,
123.1136 -            'VDIs': sr.list_images(),
123.1137 -            'virtual_allocation': sr.used_space_bytes(),
123.1138 -            'physical_utilisation': sr.used_space_bytes(),
123.1139 -            'physical_size': sr.total_space_bytes(),
123.1140 -            'type': sr.type,
123.1141 -            'location': sr.location
123.1142 -            })
123.1143 +        return xen_api_success(sr.get_record())
123.1144  
123.1145      # Attribute acceess
123.1146 -    def SR_get_VDIs(self, session, sr_ref):
123.1147 -        sr = XendNode.instance().get_sr()
123.1148 -        return xen_api_success(sr.list_images())
123.1149  
123.1150 -    def SR_get_virtual_allocation(self, session, sr_ref):
123.1151 -        sr = XendNode.instance().get_sr()        
123.1152 -        return sr.used_space_bytes()
123.1153 +    def _get_SR_func(self, _, func):
123.1154 +        return xen_api_success(getattr(XendNode.instance().get_sr(), func)())
123.1155 +
123.1156 +    def _get_SR_attr(self, _, attr):
123.1157 +        return xen_api_success(getattr(XendNode.instance().get_sr(), attr))
123.1158  
123.1159 -    def SR_get_physical_utilisation(self, session, sr_ref):
123.1160 -        sr = XendNode.instance().get_sr()        
123.1161 -        return sr.used_space_bytes()
123.1162 +    def SR_get_VDIs(self, _, ref):
123.1163 +        return self._get_SR_func(ref, 'list_images')
123.1164 +
123.1165 +    def SR_get_virtual_allocation(self, _, ref):
123.1166 +        return self._get_SR_func(ref, 'virtual_allocation')
123.1167  
123.1168 -    def SR_get_physical_size(self, session, sr_ref):
123.1169 -        sr = XendNode.instance().get_sr()        
123.1170 -        return sr.total_space_bytes()
123.1171 +    def SR_get_physical_utilisation(self, _, ref):
123.1172 +        return self._get_SR_func(ref, 'used_space_bytes')
123.1173 +
123.1174 +    def SR_get_physical_size(self, _, ref):
123.1175 +        return self._get_SR_func(ref, 'total_space_bytes')
123.1176      
123.1177 -    def SR_get_type(self, session, sr_ref):
123.1178 -        sr = XendNode.instance().get_sr()
123.1179 -        return xen_api_success(sr.type)
123.1180 +    def SR_get_type(self, _, ref):
123.1181 +        return self._get_SR_attr(ref, 'type')
123.1182  
123.1183 -    def SR_get_location(self, session, sr_ref):
123.1184 -        sr = XendNode.instance().get_sr()
123.1185 -        return xen_api_success(sr.location)
123.1186 +    def SR_get_location(self, _, ref):
123.1187 +        return self._get_SR_attr(ref, 'location')
123.1188  
123.1189 -    def SR_get_name_label(self, session, sr_ref):
123.1190 -        sr = XendNode.instance().get_sr()
123.1191 -        return xen_api_success(sr.name_label)      
123.1192 +    def SR_get_name_label(self, _, ref):
123.1193 +        return self._get_SR_attr(ref, 'name_label')
123.1194      
123.1195 -    def SR_get_name_description(self, session, sr_ref):
123.1196 -        sr = XendNode.instance().get_sr()
123.1197 -        return xen_api_success(sr.name_description)        
123.1198 +    def SR_get_name_description(self, _, ref):
123.1199 +        return self._get_SR_attr(ref, 'name_description')
123.1200  
123.1201      def SR_set_name_label(self, session, sr_ref, value):
123.1202          sr = XendNode.instance().get_sr()
123.1203          sr.name_label = value
123.1204 +        XendNode.instance().save()
123.1205          return xen_api_success_void()
123.1206      
123.1207      def SR_set_name_description(self, session, sr_ref, value):
123.1208          sr = XendNode.instance().get_sr()
123.1209          sr.name_description = value
123.1210 +        XendNode.instance().save()        
123.1211          return xen_api_success_void()
123.1212  
123.1213 +
123.1214 +def _decorate():
123.1215 +    """Initialise Xen API wrapper by making sure all functions
123.1216 +    have the correct validation decorators such as L{valid_host}
123.1217 +    and L{session_required}.
123.1218 +    """
123.1219 +
123.1220 +    global_validators = [session_required, catch_typeerror]
123.1221 +    classes = {
123.1222 +        'session' : None,
123.1223 +        'host'    : valid_host,
123.1224 +        'host_cpu': valid_host_cpu,
123.1225 +        'network' : valid_network,
123.1226 +        'VM'      : valid_vm,
123.1227 +        'VBD'     : valid_vbd,
123.1228 +        'VIF'     : valid_vif,
123.1229 +        'VDI'     : valid_vdi,
123.1230 +        'VTPM'    : valid_vtpm,
123.1231 +        'SR'      : valid_sr,
123.1232 +        'PIF'     : valid_pif
123.1233 +        }
123.1234 +
123.1235 +    # Cheat methods
123.1236 +    # -------------
123.1237 +    # Methods that have a trivial implementation for all classes.
123.1238 +    # 1. get_by_uuid == getting by ref, so just return uuid for
123.1239 +    #    all get_by_uuid() methods.
123.1240 +
123.1241 +    for cls in classes.keys():
123.1242 +        get_by_uuid = '%s_get_by_uuid' % cls
123.1243 +        get_uuid = '%s_get_uuid' % cls
123.1244 +        def _get_by_uuid(_1, _2, ref):
123.1245 +            return xen_api_success(ref)
123.1246 +
123.1247 +        def _get_uuid(_1, _2, ref):
123.1248 +            return xen_api_success(ref)
123.1249 +
123.1250 +        setattr(XendAPI, get_by_uuid, _get_by_uuid)
123.1251 +        setattr(XendAPI, get_uuid,    _get_uuid)
123.1252 +
123.1253 +    # 2. get_record is just getting all the attributes, so provide
123.1254 +    #    a fake template implementation.
123.1255 +    # 
123.1256 +    # TODO: ...
123.1257 +
123.1258 +
123.1259 +    # Wrapping validators around XMLRPC calls
123.1260 +    # ---------------------------------------
123.1261 +
123.1262 +    for cls, validator in classes.items():
123.1263 +        def doit(n, takes_instance):
123.1264 +            n_ = n.replace('.', '_')
123.1265 +            try:
123.1266 +                f = getattr(XendAPI, n_)
123.1267 +                argcounts[n] = f.func_code.co_argcount - 1
123.1268 +
123.1269 +                validators = takes_instance and validator and [validator] \
123.1270 +                             or []
123.1271 +                validators += global_validators
123.1272 +                for v in validators:
123.1273 +                    f = v(f)
123.1274 +                    f.api = n
123.1275 +                setattr(XendAPI, n_, f)
123.1276 +            except AttributeError:
123.1277 +                log.warn("API call: %s not found" % n)
123.1278 +
123.1279 +
123.1280 +        ro_attrs = getattr(XendAPI, '%s_attr_ro' % cls, [])
123.1281 +        rw_attrs = getattr(XendAPI, '%s_attr_rw' % cls, [])
123.1282 +        methods  = getattr(XendAPI, '%s_methods' % cls, [])
123.1283 +        funcs    = getattr(XendAPI, '%s_funcs'   % cls, [])
123.1284 +
123.1285 +        # wrap validators around readable class attributes
123.1286 +        for attr_name in ro_attrs + rw_attrs + XendAPI.Base_attr_ro:
123.1287 +            doit('%s.get_%s' % (cls, attr_name), True)
123.1288 +
123.1289 +        # wrap validators around writable class attrributes
123.1290 +        for attr_name in rw_attrs + XendAPI.Base_attr_rw:
123.1291 +            doit('%s.set_%s' % (cls, attr_name), True)
123.1292 +
123.1293 +        # wrap validators around methods
123.1294 +        for method_name in methods + XendAPI.Base_methods:
123.1295 +            doit('%s.%s' % (cls, method_name), True)
123.1296 +
123.1297 +        # wrap validators around class functions
123.1298 +        for func_name in funcs + XendAPI.Base_funcs:
123.1299 +            doit('%s.%s' % (cls, func_name), False)
123.1300 +
123.1301 +_decorate()
123.1302 +
123.1303 +
123.1304  #   
123.1305  # Auto generate some stubs based on XendAPI introspection
123.1306  #
   124.1 --- a/tools/python/xen/xend/XendAPIConstants.py	Wed Jan 10 08:00:50 2007 -0700
   124.2 +++ b/tools/python/xen/xend/XendAPIConstants.py	Wed Jan 10 08:40:47 2007 -0700
   124.3 @@ -41,7 +41,7 @@ XEN_API_CPU_FEATURE = [
   124.4      'CMOV', 'PAT', 'PSE36', 'PN', 'CLFLSH', 'DTES',
   124.5      'ACPI', 'MMX', 'FXCR', 'XMM', 'XMM2', 'SELFSNOOP',
   124.6      'HT', 'ACC', 'IA64', 'SYSCALL', 'MP', 'NX', 'MMXEXT',
   124.7 -    'LM', '3DNOWEXT', '3DNOW', 'RECOVERY', 'LONGRUN',
   124.8 +    'LM', 'THREEDNOWEXT', 'THREEDNOW', 'RECOVERY', 'LONGRUN',
   124.9      'LRTI', 'CXMMX', 'K6_MTRR', 'CYRIX_ARR', 'CENTAUR_MCR',
  124.10      'K8', 'K7', 'P3', 'P4', 'CONSTANT_TSC', 'FXSAVE_LEAK',
  124.11      'XMM3', 'MWAIT', 'DSCPL', 'EST', 'TM2', 'CID', 'CX16',
  124.12 @@ -73,3 +73,4 @@ XEN_API_BOOT_TYPE = [
  124.13  XEN_API_VBD_MODE = ['RO', 'RW']
  124.14  XEN_API_VDI_TYPE = ['system', 'user', 'ephemeral']
  124.15  XEN_API_DRIVER_TYPE = ['ioemu', 'paravirtualised']
  124.16 +XEN_API_VBD_TYPE = ['CD', 'Disk']
   125.1 --- a/tools/python/xen/xend/XendAuthSessions.py	Wed Jan 10 08:00:50 2007 -0700
   125.2 +++ b/tools/python/xen/xend/XendAuthSessions.py	Wed Jan 10 08:40:47 2007 -0700
   125.3 @@ -130,16 +130,3 @@ def instance():
   125.4          inst = XendAuthSessions()
   125.5          inst.init()
   125.6      return inst
   125.7 -
   125.8 -# Handy Authentication Decorators
   125.9 -# -------------------------------
  125.10 -def session_required(func):
  125.11 -    def check_session(self, session, *args, **kwargs):
  125.12 -        if instance().is_session_valid(session):
  125.13 -            return func(self, session, *args, **kwargs)
  125.14 -        else:
  125.15 -            return {'Status': 'Failure',
  125.16 -                    'ErrorDescription': XEND_ERROR_SESSION_INVALID}
  125.17 -    return check_session
  125.18 -
  125.19 -
   126.1 --- a/tools/python/xen/xend/XendBootloader.py	Wed Jan 10 08:00:50 2007 -0700
   126.2 +++ b/tools/python/xen/xend/XendBootloader.py	Wed Jan 10 08:40:47 2007 -0700
   126.3 @@ -53,6 +53,12 @@ def bootloader(blexec, disk, quiet = Fal
   126.4      child = os.fork()
   126.5      if (not child):
   126.6          args = [ blexec ]
   126.7 +        if kernel:
   126.8 +            args.append("--kernel=%s" % kernel)
   126.9 +        if ramdisk:
  126.10 +            args.append("--ramdisk=%s" % ramdisk)
  126.11 +        if kernel_args:
  126.12 +            args.append("--args=%s" % kernel_args)
  126.13          if quiet:
  126.14              args.append("-q")
  126.15          args.append("--output=%s" % fifo)
   127.1 --- a/tools/python/xen/xend/XendConfig.py	Wed Jan 10 08:00:50 2007 -0700
   127.2 +++ b/tools/python/xen/xend/XendConfig.py	Wed Jan 10 08:40:47 2007 -0700
   127.3 @@ -93,6 +93,8 @@ XENAPI_CFG_TO_LEGACY_CFG = {
   127.4      'actions_after_reboot': 'on_reboot',
   127.5      'actions_after_crash': 'on_crash', 
   127.6      'platform_localtime': 'localtime',
   127.7 +    'PV_bootloader': 'bootloader',
   127.8 +    'PV_bootloader_args': 'bootloader_args',
   127.9  }
  127.10  
  127.11  LEGACY_CFG_TO_XENAPI_CFG = reverse_dict(XENAPI_CFG_TO_LEGACY_CFG)
  127.12 @@ -139,7 +141,7 @@ XENAPI_CFG_TYPES = {
  127.13      'tpm_backend': int,    
  127.14      'PV_bootloader': str,
  127.15      'PV_kernel': str,
  127.16 -    'PV_initrd': str,
  127.17 +    'PV_ramdisk': str,
  127.18      'PV_args': str,
  127.19      'PV_bootloader_args': str,
  127.20      'HVM_boot': str,
  127.21 @@ -297,7 +299,7 @@ class XendConfig(dict):
  127.22              self._sxp_to_xapi_unsupported(sxp_obj)
  127.23          elif xapi:
  127.24              self.update_with_xenapi_config(xapi)
  127.25 -            self._add_xapi_unsupported()
  127.26 +            self._add_xapi_unsupported(xapi)
  127.27          elif dominfo:
  127.28              # output from xc.domain_getinfo
  127.29              self._dominfo_to_xapi(dominfo)
  127.30 @@ -506,8 +508,12 @@ class XendConfig(dict):
  127.31                  pci_devs = []
  127.32                  for pci_dev in sxp.children(config, 'dev'):
  127.33                      pci_dev_info = {}
  127.34 -                    for opt, val in pci_dev[1:]:
  127.35 -                        pci_dev_info[opt] = val
  127.36 +                    for opt_val in pci_dev[1:]:
  127.37 +                        try:
  127.38 +                            opt, val = opt_val
  127.39 +                            pci_dev_info[opt] = val
  127.40 +                        except TypeError:
  127.41 +                            pass
  127.42                      pci_devs.append(pci_dev_info)
  127.43                  
  127.44                  cfg['devices'][pci_devs_uuid] = (dev_type,
  127.45 @@ -570,7 +576,6 @@ class XendConfig(dict):
  127.46          if 'security' in cfg and isinstance(cfg['security'], str):
  127.47              cfg['security'] = sxp.from_string(cfg['security'])
  127.48  
  127.49 -        # TODO: get states
  127.50          old_state = sxp.child_value(sxp_cfg, 'state')
  127.51          if old_state:
  127.52              for i in range(len(CONFIG_OLD_DOM_STATES)):
  127.53 @@ -715,6 +720,8 @@ class XendConfig(dict):
  127.54          _set_cfg_if_exists('on_xend_start')
  127.55          _set_cfg_if_exists('vcpu_avail')
  127.56          _set_cfg_if_exists('max_vcpu_id') # needed for vcpuDomDetails
  127.57 +        _set_cfg_if_exists('cpu_weight')
  127.58 +        _set_cfg_if_exists('cpu_cap')
  127.59          
  127.60          # Parse and store runtime configuration 
  127.61          _set_cfg_if_exists('start_time')
  127.62 @@ -724,19 +731,22 @@ class XendConfig(dict):
  127.63          _set_cfg_if_exists('up_time')
  127.64          _set_cfg_if_exists('status') # TODO, deprecated  
  127.65  
  127.66 -    def _add_xapi_unsupported(self):
  127.67 +    def _add_xapi_unsupported(self, xapi_dict):
  127.68          """Updates the configuration object with entries that are not
  127.69          officially supported by the Xen API but is required for
  127.70          the rest of Xend to function.
  127.71          """
  127.72  
  127.73          # populate image
  127.74 -        hvm = self['HVM_boot'] != ''
  127.75 -        self['image']['type'] = hvm and 'hvm' or 'linux'
  127.76 -        if hvm:
  127.77 -            self['image']['hvm'] = {}
  127.78 -            for xapi, cfgapi in XENAPI_HVM_CFG.items():
  127.79 -                self['image']['hvm'][cfgapi] = self[xapi]
  127.80 +        if 'image' in xapi_dict:
  127.81 +            self['image'].update(xapi_dict['image'])
  127.82 +        else:
  127.83 +            hvm = self['HVM_boot'] != ''
  127.84 +            self['image']['type'] = hvm and 'hvm' or 'linux'
  127.85 +            if hvm:
  127.86 +                self['image']['hvm'] = {}
  127.87 +                for xapi, cfgapi in XENAPI_HVM_CFG.items():
  127.88 +                    self['image']['hvm'][cfgapi] = self[xapi]
  127.89              
  127.90  
  127.91      def _get_old_state_string(self):
  127.92 @@ -848,14 +858,15 @@ class XendConfig(dict):
  127.93              for cls in XendDevices.valid_devices():
  127.94                  found = False
  127.95                  
  127.96 -                # figure if there is a device that is running
  127.97 -                if domain:
  127.98 +                # figure if there is a dev controller is valid and running
  127.99 +                if domain and domain.getDomid() != None:
 127.100                      try:
 127.101                          controller = domain.getDeviceController(cls)
 127.102                          configs = controller.configurations()
 127.103                          for config in configs:
 127.104                              sxpr.append(['device', config])
 127.105 -                            found = True
 127.106 +
 127.107 +                        found = True
 127.108                      except:
 127.109                          log.exception("dumping sxp from device controllers")
 127.110                          pass
 127.111 @@ -916,11 +927,12 @@ class XendConfig(dict):
 127.112              dev_type = sxp.name(config)
 127.113              dev_info = {}
 127.114  
 127.115 -            try:
 127.116 -                for opt, val in config[1:]:
 127.117 +            for opt_val in config[1:]:
 127.118 +                try:
 127.119 +                    opt, val = opt_val
 127.120                      dev_info[opt] = val
 127.121 -            except ValueError:
 127.122 -                pass # SXP has no options for this device
 127.123 +                except (TypeError, ValueError): # unpack error