ia64/xen-unstable

changeset 11026:54550e85f25a

merge with xen-unstable.hg
author awilliam@xenbuild.aw
date Wed Aug 09 08:34:06 2006 -0600 (2006-08-09)
parents bfc69471550e b16252dbcb1f
children d735526b02ec
files buildconfigs/linux-defconfig_xen0_ia64 buildconfigs/linux-defconfig_xen_ia64 linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c tools/ioemu/pc-bios/proll.patch xen/arch/ia64/xen/hypercall.c xen/arch/ia64/xen/xensetup.c xen/include/xen/reboot.h
line diff
     1.1 --- a/buildconfigs/linux-defconfig_xen0_ia64	Wed Aug 09 08:01:52 2006 -0600
     1.2 +++ b/buildconfigs/linux-defconfig_xen0_ia64	Wed Aug 09 08:34:06 2006 -0600
     1.3 @@ -1532,8 +1532,9 @@ CONFIG_XEN_BLKDEV_BACKEND=y
     1.4  # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
     1.5  CONFIG_XEN_NETDEV_LOOPBACK=y
     1.6  CONFIG_XEN_PCIDEV_BACKEND=y
     1.7 -CONFIG_XEN_PCIDEV_BACKEND_VPCI=y
     1.8 +# CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
     1.9  # CONFIG_XEN_PCIDEV_BACKEND_PASS is not set
    1.10 +CONFIG_XEN_PCIDEV_BACKEND_SLOT=y
    1.11  # CONFIG_XEN_PCIDEV_BE_DEBUG is not set
    1.12  # CONFIG_XEN_TPMDEV_BACKEND is not set
    1.13  CONFIG_XEN_BLKDEV_FRONTEND=y
     2.1 --- a/buildconfigs/linux-defconfig_xen0_x86_32	Wed Aug 09 08:01:52 2006 -0600
     2.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_32	Wed Aug 09 08:34:06 2006 -0600
     2.3 @@ -1320,6 +1320,7 @@ CONFIG_XEN_BACKEND=y
     2.4  CONFIG_XEN_PCIDEV_BACKEND=y
     2.5  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
     2.6  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
     2.7 +# CONFIG_XEN_PCIDEV_BACKEND_SLOT is not set
     2.8  # CONFIG_XEN_PCIDEV_BE_DEBUG is not set
     2.9  CONFIG_XEN_BLKDEV_BACKEND=y
    2.10  CONFIG_XEN_BLKDEV_TAP=y
     3.1 --- a/buildconfigs/linux-defconfig_xen0_x86_64	Wed Aug 09 08:01:52 2006 -0600
     3.2 +++ b/buildconfigs/linux-defconfig_xen0_x86_64	Wed Aug 09 08:34:06 2006 -0600
     3.3 @@ -1261,6 +1261,7 @@ CONFIG_XEN_BACKEND=y
     3.4  CONFIG_XEN_PCIDEV_BACKEND=y
     3.5  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
     3.6  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
     3.7 +# CONFIG_XEN_PCIDEV_BACKEND_SLOT is not set
     3.8  # CONFIG_XEN_PCIDEV_BE_DEBUG is not set
     3.9  CONFIG_XEN_BLKDEV_BACKEND=y
    3.10  CONFIG_XEN_BLKDEV_TAP=y
     4.1 --- a/buildconfigs/linux-defconfig_xen_ia64	Wed Aug 09 08:01:52 2006 -0600
     4.2 +++ b/buildconfigs/linux-defconfig_xen_ia64	Wed Aug 09 08:34:06 2006 -0600
     4.3 @@ -1538,8 +1538,9 @@ CONFIG_XEN_BLKDEV_BACKEND=y
     4.4  # CONFIG_XEN_NETDEV_PIPELINED_TRANSMITTER is not set
     4.5  CONFIG_XEN_NETDEV_LOOPBACK=y
     4.6  CONFIG_XEN_PCIDEV_BACKEND=y
     4.7 -CONFIG_XEN_PCIDEV_BACKEND_VPCI=y
     4.8 +# CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
     4.9  # CONFIG_XEN_PCIDEV_BACKEND_PASS is not set
    4.10 +CONFIG_XEN_PCIDEV_BACKEND_SLOT=y
    4.11  # CONFIG_XEN_PCIDEV_BE_DEBUG is not set
    4.12  # CONFIG_XEN_TPMDEV_BACKEND is not set
    4.13  CONFIG_XEN_BLKDEV_FRONTEND=y
     5.1 --- a/buildconfigs/linux-defconfig_xen_x86_32	Wed Aug 09 08:01:52 2006 -0600
     5.2 +++ b/buildconfigs/linux-defconfig_xen_x86_32	Wed Aug 09 08:34:06 2006 -0600
     5.3 @@ -3021,6 +3021,7 @@ CONFIG_XEN_BACKEND=y
     5.4  CONFIG_XEN_PCIDEV_BACKEND=m
     5.5  CONFIG_XEN_PCIDEV_BACKEND_VPCI=y
     5.6  # CONFIG_XEN_PCIDEV_BACKEND_PASS is not set
     5.7 +# CONFIG_XEN_PCIDEV_BACKEND_SLOT is not set
     5.8  # CONFIG_XEN_PCIDEV_BE_DEBUG is not set
     5.9  CONFIG_XEN_BLKDEV_BACKEND=y
    5.10  CONFIG_XEN_BLKDEV_TAP=y
     6.1 --- a/buildconfigs/linux-defconfig_xen_x86_64	Wed Aug 09 08:01:52 2006 -0600
     6.2 +++ b/buildconfigs/linux-defconfig_xen_x86_64	Wed Aug 09 08:34:06 2006 -0600
     6.3 @@ -2853,6 +2853,7 @@ CONFIG_XEN_BACKEND=y
     6.4  CONFIG_XEN_PCIDEV_BACKEND=m
     6.5  # CONFIG_XEN_PCIDEV_BACKEND_VPCI is not set
     6.6  CONFIG_XEN_PCIDEV_BACKEND_PASS=y
     6.7 +# CONFIG_XEN_PCIDEV_BACKEND_SLOT is not set
     6.8  # CONFIG_XEN_PCIDEV_BE_DEBUG is not set
     6.9  CONFIG_XEN_BLKDEV_BACKEND=y
    6.10  CONFIG_XEN_BLKDEV_TAP=y
     7.1 --- a/docs/src/user.tex	Wed Aug 09 08:01:52 2006 -0600
     7.2 +++ b/docs/src/user.tex	Wed Aug 09 08:34:06 2006 -0600
     7.3 @@ -3170,7 +3170,7 @@ editing \path{grub.conf}.
     7.4  \item [ tbuf\_size=xxx ] Set the size of the per-cpu trace buffers, in
     7.5    pages (default 0).  
     7.6  \item [ sched=xxx ] Select the CPU scheduler Xen should use.  The
     7.7 -  current possibilities are `sedf' (default), `credit', and `bvt'.
     7.8 +  current possibilities are `credit' (default), `sedf', and `bvt'.
     7.9  \item [ apic\_verbosity=debug,verbose ] Print more detailed
    7.10    information about local APIC and IOAPIC configuration.
    7.11  \item [ lapic ] Force use of local APIC even when left disabled by
     8.1 --- a/linux-2.6-xen-sparse/drivers/xen/Kconfig	Wed Aug 09 08:01:52 2006 -0600
     8.2 +++ b/linux-2.6-xen-sparse/drivers/xen/Kconfig	Wed Aug 09 08:34:06 2006 -0600
     8.3 @@ -117,7 +117,7 @@ config XEN_PCIDEV_BACKEND_VPCI
     8.4  	  This PCI Backend hides the true PCI topology and makes the frontend
     8.5  	  think there is a single PCI bus with only the exported devices on it.
     8.6  	  For example, a device at 03:05.0 will be re-assigned to 00:00.0. A
     8.7 -	  second device at 02:1a.0 will be re-assigned to 00:01.0.
     8.8 +	  second device at 02:1a.1 will be re-assigned to 00:01.1.
     8.9  
    8.10  config XEN_PCIDEV_BACKEND_PASS
    8.11  	bool "Passthrough"
    8.12 @@ -129,6 +129,15 @@ config XEN_PCIDEV_BACKEND_PASS
    8.13  	  which depend on finding their hardward in certain bus/slot
    8.14  	  locations.
    8.15  
    8.16 +config XEN_PCIDEV_BACKEND_SLOT
    8.17 +	bool "Slot"
    8.18 +	---help---
    8.19 +	  This PCI Backend hides the true PCI topology and makes the frontend
    8.20 +	  think there is a single PCI bus with only the exported devices on it.
    8.21 +	  Contrary to the virtual PCI backend, a function becomes a new slot.
    8.22 +	  For example, a device at 03:05.2 will be re-assigned to 00:00.0. A
    8.23 +	  second device at 02:1a.1 will be re-assigned to 00:01.0.
    8.24 +
    8.25  endchoice
    8.26  
    8.27  config XEN_PCIDEV_BE_DEBUG
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Aug 09 08:01:52 2006 -0600
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Wed Aug 09 08:34:06 2006 -0600
     9.3 @@ -563,10 +563,14 @@ struct page *balloon_alloc_empty_page_ra
     9.4  		set_xen_guest_handle(reservation.extent_start, &gmfn);
     9.5  		ret = HYPERVISOR_memory_op(XENMEM_decrease_reservation,
     9.6  					   &reservation);
     9.7 +		if (ret == -ENOSYS)
     9.8 +			goto err;
     9.9  		BUG_ON(ret != 1);
    9.10  	} else {
    9.11  		ret = apply_to_page_range(&init_mm, vstart, PAGE_SIZE << order,
    9.12  					  dealloc_pte_fn, NULL);
    9.13 +		if (ret == -ENOSYS)
    9.14 +			goto err;
    9.15  		BUG_ON(ret);
    9.16  	}
    9.17  	current_pages -= 1UL << order;
    9.18 @@ -583,6 +587,11 @@ struct page *balloon_alloc_empty_page_ra
    9.19  		set_page_count(page + i, 1);
    9.20  
    9.21  	return page;
    9.22 +
    9.23 + err:
    9.24 +	free_pages(vstart, order);
    9.25 +	balloon_unlock(flags);
    9.26 +	return NULL;
    9.27  }
    9.28  
    9.29  void balloon_dealloc_empty_page_range(
    10.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Wed Aug 09 08:01:52 2006 -0600
    10.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/blkback.c	Wed Aug 09 08:34:06 2006 -0600
    10.3 @@ -513,6 +513,12 @@ static int __init blkif_init(void)
    10.4  		return -ENODEV;
    10.5  
    10.6  	mmap_pages            = blkif_reqs * BLKIF_MAX_SEGMENTS_PER_REQUEST;
    10.7 +
    10.8 +	page = balloon_alloc_empty_page_range(mmap_pages);
    10.9 +	if (page == NULL)
   10.10 +		return -ENOMEM;
   10.11 +	mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
   10.12 +
   10.13  	pending_reqs          = kmalloc(sizeof(pending_reqs[0]) *
   10.14  					blkif_reqs, GFP_KERNEL);
   10.15  	pending_grant_handles = kmalloc(sizeof(pending_grant_handles[0]) *
   10.16 @@ -529,9 +535,6 @@ static int __init blkif_init(void)
   10.17  
   10.18  	blkif_interface_init();
   10.19  	
   10.20 -	page = balloon_alloc_empty_page_range(mmap_pages);
   10.21 -	BUG_ON(page == NULL);
   10.22 -	mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
   10.23  	printk("%s: reqs=%d, pages=%d, mmap_vstart=0x%lx\n",
   10.24  	       __FUNCTION__, blkif_reqs, mmap_pages, mmap_vstart);
   10.25  	BUG_ON(mmap_vstart == 0);
    11.1 --- a/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Wed Aug 09 08:01:52 2006 -0600
    11.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blktap/blktap.c	Wed Aug 09 08:34:06 2006 -0600
    11.3 @@ -709,30 +709,19 @@ static void make_response(blkif_t *blkif
    11.4  /******************************************************************
    11.5   * misc small helpers
    11.6   */
    11.7 -/* FIXME: Return ENOMEM properly on failure to allocate additional reqs. */
    11.8 -static void req_increase(void)
    11.9 +static int req_increase(void)
   11.10  {
   11.11  	int i, j;
   11.12  	struct page *page;
   11.13  	unsigned long flags;
   11.14 +	int ret;
   11.15  
   11.16  	spin_lock_irqsave(&pending_free_lock, flags);
   11.17  
   11.18 +	ret = -EINVAL;
   11.19  	if (mmap_alloc >= MAX_PENDING_REQS || mmap_lock) 
   11.20  		goto done;
   11.21  
   11.22 -	pending_reqs[mmap_alloc]  = kzalloc(sizeof(pending_req_t) *
   11.23 -					blkif_reqs, GFP_KERNEL);
   11.24 -	pending_addrs[mmap_alloc] = kzalloc(sizeof(unsigned long) *
   11.25 -					mmap_pages, GFP_KERNEL);
   11.26 -
   11.27 -	if (!pending_reqs[mmap_alloc] || !pending_addrs[mmap_alloc]) {
   11.28 -		kfree(pending_reqs[mmap_alloc]);
   11.29 -		kfree(pending_addrs[mmap_alloc]);
   11.30 -		WPRINTK("%s: out of memory\n", __FUNCTION__); 
   11.31 -		goto done;
   11.32 -	}
   11.33 -
   11.34  #ifdef __ia64__
   11.35  	extern unsigned long alloc_empty_foreign_map_page_range(
   11.36  		unsigned long pages);
   11.37 @@ -740,7 +729,11 @@ static void req_increase(void)
   11.38  		alloc_empty_foreign_map_page_range(mmap_pages);
   11.39  #else /* ! ia64 */
   11.40  	page = balloon_alloc_empty_page_range(mmap_pages);
   11.41 -	BUG_ON(page == NULL);
   11.42 +	ret = -ENOMEM;
   11.43 +	if (page == NULL) {
   11.44 +		printk("%s balloon_alloc_empty_page_range gave NULL\n", __FUNCTION__);
   11.45 +		goto done;
   11.46 +	}
   11.47  
   11.48  	/* Pin all of the pages. */
   11.49  	for (i=0; i<mmap_pages; i++)
   11.50 @@ -751,6 +744,23 @@ static void req_increase(void)
   11.51  	mmap_start[mmap_alloc].mpage = page;
   11.52  
   11.53  #endif
   11.54 +
   11.55 +	pending_reqs[mmap_alloc]  = kzalloc(sizeof(pending_req_t) *
   11.56 +					blkif_reqs, GFP_KERNEL);
   11.57 +	pending_addrs[mmap_alloc] = kzalloc(sizeof(unsigned long) *
   11.58 +					mmap_pages, GFP_KERNEL);
   11.59 +
   11.60 +	ret = -ENOMEM;
   11.61 +	if (!pending_reqs[mmap_alloc] || !pending_addrs[mmap_alloc]) {
   11.62 +		kfree(pending_reqs[mmap_alloc]);
   11.63 +		kfree(pending_addrs[mmap_alloc]);
   11.64 +		WPRINTK("%s: out of memory\n", __FUNCTION__); 
   11.65 +		ret = -ENOMEM;
   11.66 +		goto done;
   11.67 +	}
   11.68 +
   11.69 +	ret = 0;
   11.70 +
   11.71  	DPRINTK("%s: reqs=%d, pages=%d, mmap_vstart=0x%lx\n",
   11.72  	        __FUNCTION__, blkif_reqs, mmap_pages, 
   11.73  	       mmap_start[mmap_alloc].start);
   11.74 @@ -774,7 +784,7 @@ static void req_increase(void)
   11.75  	DPRINTK("# MMAPs increased to %d\n",mmap_alloc);
   11.76   done:
   11.77  	spin_unlock_irqrestore(&pending_free_lock, flags);
   11.78 -
   11.79 +	return ret;
   11.80  }
   11.81  
   11.82  static void mmap_req_del(int mmap)
   11.83 @@ -1389,7 +1399,13 @@ static int __init blkif_init(void)
   11.84  		return -ENODEV;
   11.85  
   11.86  	INIT_LIST_HEAD(&pending_free);
   11.87 -        for(i = 0; i < 2; i++) req_increase();
   11.88 +        for(i = 0; i < 2; i++) {
   11.89 +		ret = req_increase();
   11.90 +		if (ret)
   11.91 +			break;
   11.92 +	}
   11.93 +	if (i == 0)
   11.94 +		return ret;
   11.95  
   11.96  	tap_blkif_interface_init();
   11.97  
    12.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Wed Aug 09 08:01:52 2006 -0600
    12.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Wed Aug 09 08:34:06 2006 -0600
    12.3 @@ -1306,7 +1306,9 @@ static int __init netback_init(void)
    12.4  	net_timer.function = net_alarm;
    12.5      
    12.6  	page = balloon_alloc_empty_page_range(MAX_PENDING_REQS);
    12.7 -	BUG_ON(page == NULL);
    12.8 +	if (page == NULL)
    12.9 +		return -ENOMEM;
   12.10 +
   12.11  	mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
   12.12  
   12.13  	for (i = 0; i < MAX_PENDING_REQS; i++) {
    13.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Aug 09 08:01:52 2006 -0600
    13.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Aug 09 08:34:06 2006 -0600
    13.3 @@ -497,6 +497,9 @@ static int network_open(struct net_devic
    13.4  	network_alloc_rx_buffers(dev);
    13.5  	np->rx.sring->rsp_event = np->rx.rsp_cons + 1;
    13.6  
    13.7 +	if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
    13.8 +		netif_rx_schedule(dev);
    13.9 +
   13.10  	netif_start_queue(dev);
   13.11  
   13.12  	return 0;
    14.1 --- a/linux-2.6-xen-sparse/drivers/xen/pciback/Makefile	Wed Aug 09 08:01:52 2006 -0600
    14.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/Makefile	Wed Aug 09 08:34:06 2006 -0600
    14.3 @@ -7,6 +7,7 @@ pciback-y += conf_space.o conf_space_hea
    14.4  	     conf_space_capability_pm.o \
    14.5               conf_space_quirks.o
    14.6  pciback-$(CONFIG_XEN_PCIDEV_BACKEND_VPCI) += vpci.o
    14.7 +pciback-$(CONFIG_XEN_PCIDEV_BACKEND_SLOT) += slot.o
    14.8  pciback-$(CONFIG_XEN_PCIDEV_BACKEND_PASS) += passthrough.o
    14.9  
   14.10  ifeq ($(CONFIG_XEN_PCIDEV_BE_DEBUG),y)
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/linux-2.6-xen-sparse/drivers/xen/pciback/slot.c	Wed Aug 09 08:34:06 2006 -0600
    15.3 @@ -0,0 +1,151 @@
    15.4 +/*
    15.5 + * PCI Backend - Provides a Virtual PCI bus (with real devices)
    15.6 + *               to the frontend
    15.7 + *
    15.8 + *   Author: Ryan Wilson <hap9@epoch.ncsc.mil> (vpci.c)
    15.9 + *   Author: Tristan Gingold <tristan.gingold@bull.net>, from vpci.c
   15.10 + */
   15.11 +
   15.12 +#include <linux/list.h>
   15.13 +#include <linux/slab.h>
   15.14 +#include <linux/pci.h>
   15.15 +#include <linux/spinlock.h>
   15.16 +#include "pciback.h"
   15.17 +
   15.18 +/* There are at most 32 slots in a pci bus.  */
   15.19 +#define PCI_SLOT_MAX 32
   15.20 +
   15.21 +#define PCI_BUS_NBR 2
   15.22 +
   15.23 +struct slot_dev_data {
   15.24 +	/* Access to dev_list must be protected by lock */
   15.25 +	struct pci_dev *slots[PCI_BUS_NBR][PCI_SLOT_MAX];
   15.26 +	spinlock_t lock;
   15.27 +};
   15.28 +
   15.29 +struct pci_dev *pciback_get_pci_dev(struct pciback_device *pdev,
   15.30 +				    unsigned int domain, unsigned int bus,
   15.31 +				    unsigned int devfn)
   15.32 +{
   15.33 +	struct pci_dev *dev = NULL;
   15.34 +	struct slot_dev_data *slot_dev = pdev->pci_dev_data;
   15.35 +	unsigned long flags;
   15.36 +
   15.37 +	if (domain != 0 || PCI_FUNC(devfn) != 0)
   15.38 +		return NULL;
   15.39 +
   15.40 +	if (PCI_SLOT(devfn) >= PCI_SLOT_MAX || bus >= PCI_BUS_NBR)
   15.41 +		return NULL;
   15.42 +
   15.43 +	spin_lock_irqsave(&slot_dev->lock, flags);
   15.44 +	dev = slot_dev->slots[bus][PCI_SLOT(devfn)];
   15.45 +	spin_unlock_irqrestore(&slot_dev->lock, flags);
   15.46 +
   15.47 +	return dev;
   15.48 +}
   15.49 +
   15.50 +int pciback_add_pci_dev(struct pciback_device *pdev, struct pci_dev *dev)
   15.51 +{
   15.52 +	int err = 0, slot, bus;
   15.53 +	struct slot_dev_data *slot_dev = pdev->pci_dev_data;
   15.54 +	unsigned long flags;
   15.55 +
   15.56 +	if ((dev->class >> 24) == PCI_BASE_CLASS_BRIDGE) {
   15.57 +		err = -EFAULT;
   15.58 +		xenbus_dev_fatal(pdev->xdev, err,
   15.59 +				 "Can't export bridges on the virtual PCI bus");
   15.60 +		goto out;
   15.61 +	}
   15.62 +
   15.63 +	spin_lock_irqsave(&slot_dev->lock, flags);
   15.64 +
   15.65 +	/* Assign to a new slot on the virtual PCI bus */
   15.66 +	for (bus = 0; bus < PCI_BUS_NBR; bus++)
   15.67 +		for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
   15.68 +			if (slot_dev->slots[bus][slot] == NULL) {
   15.69 +				printk(KERN_INFO
   15.70 +				       "pciback: slot: %s: assign to virtual slot %d, bus %d\n",
   15.71 +				       pci_name(dev), slot, bus);
   15.72 +				slot_dev->slots[bus][slot] = dev;
   15.73 +				goto unlock;
   15.74 +			}
   15.75 +		}
   15.76 +
   15.77 +	err = -ENOMEM;
   15.78 +	xenbus_dev_fatal(pdev->xdev, err,
   15.79 +			 "No more space on root virtual PCI bus");
   15.80 +
   15.81 +      unlock:
   15.82 +	spin_unlock_irqrestore(&slot_dev->lock, flags);
   15.83 +      out:
   15.84 +	return err;
   15.85 +}
   15.86 +
   15.87 +void pciback_release_pci_dev(struct pciback_device *pdev, struct pci_dev *dev)
   15.88 +{
   15.89 +	int slot, bus;
   15.90 +	struct slot_dev_data *slot_dev = pdev->pci_dev_data;
   15.91 +	struct pci_dev *found_dev = NULL;
   15.92 +	unsigned long flags;
   15.93 +
   15.94 +	spin_lock_irqsave(&slot_dev->lock, flags);
   15.95 +
   15.96 +	for (bus = 0; bus < PCI_BUS_NBR; bus++)
   15.97 +		for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
   15.98 +			if (slot_dev->slots[bus][slot] == dev) {
   15.99 +				slot_dev->slots[bus][slot] = NULL;
  15.100 +				found_dev = dev;
  15.101 +				goto out;
  15.102 +			}
  15.103 +		}
  15.104 +
  15.105 +      out:
  15.106 +	spin_unlock_irqrestore(&slot_dev->lock, flags);
  15.107 +
  15.108 +	if (found_dev)
  15.109 +		pcistub_put_pci_dev(found_dev);
  15.110 +}
  15.111 +
  15.112 +int pciback_init_devices(struct pciback_device *pdev)
  15.113 +{
  15.114 +	int slot, bus;
  15.115 +	struct slot_dev_data *slot_dev;
  15.116 +
  15.117 +	slot_dev = kmalloc(sizeof(*slot_dev), GFP_KERNEL);
  15.118 +	if (!slot_dev)
  15.119 +		return -ENOMEM;
  15.120 +
  15.121 +	spin_lock_init(&slot_dev->lock);
  15.122 +
  15.123 +	for (bus = 0; bus < PCI_BUS_NBR; bus++)
  15.124 +		for (slot = 0; slot < PCI_SLOT_MAX; slot++)
  15.125 +			slot_dev->slots[bus][slot] = NULL;
  15.126 +
  15.127 +	pdev->pci_dev_data = slot_dev;
  15.128 +
  15.129 +	return 0;
  15.130 +}
  15.131 +
  15.132 +int pciback_publish_pci_roots(struct pciback_device *pdev,
  15.133 +			      publish_pci_root_cb publish_cb)
  15.134 +{
  15.135 +	/* The Virtual PCI bus has only one root */
  15.136 +	return publish_cb(pdev, 0, 0);
  15.137 +}
  15.138 +
  15.139 +void pciback_release_devices(struct pciback_device *pdev)
  15.140 +{
  15.141 +	int slot, bus;
  15.142 +	struct slot_dev_data *slot_dev = pdev->pci_dev_data;
  15.143 +	struct pci_dev *dev;
  15.144 +
  15.145 +	for (bus = 0; bus < PCI_BUS_NBR; bus++)
  15.146 +		for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
  15.147 +			dev = slot_dev->slots[bus][slot];
  15.148 +			if (dev != NULL)
  15.149 +				pcistub_put_pci_dev(dev);
  15.150 +		}
  15.151 +
  15.152 +	kfree(slot_dev);
  15.153 +	pdev->pci_dev_data = NULL;
  15.154 +}
    16.1 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Wed Aug 09 08:01:52 2006 -0600
    16.2 +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	Wed Aug 09 08:34:06 2006 -0600
    16.3 @@ -270,6 +270,7 @@ static int __init privcmd_init(void)
    16.4  	set_bit(__HYPERVISOR_sched_op_compat,  hypercall_permission_map);
    16.5  	set_bit(__HYPERVISOR_event_channel_op_compat,
    16.6  		hypercall_permission_map);
    16.7 +	set_bit(__HYPERVISOR_hvm_op,           hypercall_permission_map);
    16.8  
    16.9  	privcmd_intf = create_xen_proc_entry("privcmd", 0400);
   16.10  	if (privcmd_intf != NULL)
    17.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/mmu_context.h	Wed Aug 09 08:01:52 2006 -0600
    17.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/mmu_context.h	Wed Aug 09 08:34:06 2006 -0600
    17.3 @@ -51,7 +51,8 @@ static inline void switch_mm(struct mm_s
    17.4  	struct mmuext_op _op[2], *op = _op;
    17.5  
    17.6  	if (likely(prev != next)) {
    17.7 -		BUG_ON(!test_bit(PG_pinned, &virt_to_page(next->pgd)->flags));
    17.8 +		BUG_ON(!xen_feature(XENFEAT_writable_page_tables) &&
    17.9 +		       !test_bit(PG_pinned, &virt_to_page(next->pgd)->flags));
   17.10  
   17.11  		/* stop flush ipis for the previous mm */
   17.12  		cpu_clear(cpu, prev->cpu_vm_mask);
    18.1 --- a/linux-2.6-xen-sparse/include/asm-i386/spinlock.h	Wed Aug 09 08:01:52 2006 -0600
    18.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/spinlock.h	Wed Aug 09 08:34:06 2006 -0600
    18.3 @@ -23,7 +23,7 @@
    18.4  		(*(volatile signed char *)(&(x)->slock) <= 0)
    18.5  
    18.6  #define __raw_spin_lock_string \
    18.7 -	"\n1:\n" \
    18.8 +	"\n1:\t" \
    18.9  	LOCK \
   18.10  	"decb %0\n\t" \
   18.11  	"jns 3f\n" \
   18.12 @@ -35,7 +35,7 @@
   18.13  	"3:\n\t"
   18.14  
   18.15  #define __raw_spin_lock_string_flags \
   18.16 -	"\n1:\n" \
   18.17 +	"\n1:\t" \
   18.18  	LOCK \
   18.19  	"decb %0\n\t" \
   18.20  	"jns 4f\n\t" \
    19.1 --- a/tools/Makefile	Wed Aug 09 08:01:52 2006 -0600
    19.2 +++ b/tools/Makefile	Wed Aug 09 08:34:06 2006 -0600
    19.3 @@ -8,7 +8,7 @@ SUBDIRS-y += misc
    19.4  SUBDIRS-y += examples
    19.5  SUBDIRS-y += xentrace
    19.6  SUBDIRS-$(CONFIG_XCUTILS) += xcutils
    19.7 -SUBDIRS-y += firmware
    19.8 +SUBDIRS-$(CONFIG_X86) += firmware
    19.9  SUBDIRS-y += security
   19.10  SUBDIRS-y += console
   19.11  SUBDIRS-y += xenmon
    20.1 --- a/tools/blktap/drivers/Makefile	Wed Aug 09 08:01:52 2006 -0600
    20.2 +++ b/tools/blktap/drivers/Makefile	Wed Aug 09 08:34:06 2006 -0600
    20.3 @@ -33,9 +33,7 @@ LIBS      += -lcrypto
    20.4  LIBS      += -lz
    20.5  LIBS      += -L$(XEN_XENSTORE) -lxenstore
    20.6  
    20.7 -AIOLIBS   := -L $(LIBAIO_DIR)
    20.8 -AIOLIBS   += -laio
    20.9 -AIOLIBS   += -static
   20.10 +AIOLIBS   := $(LIBAIO_DIR)/libaio.a
   20.11  
   20.12  BLK-OBJS  := block-aio.o 
   20.13  BLK-OBJS  += block-sync.o 
   20.14 @@ -49,21 +47,18 @@ all: $(IBIN) qcow-util
   20.15  LINUX_ROOT := $(wildcard $(XEN_ROOT)/linux-2.6.*-xen-sparse)
   20.16  
   20.17  
   20.18 -blktapctrl: 
   20.19 +blktapctrl: blktapctrl.c
   20.20  	$(CC) $(CFLAGS) -o blktapctrl $(LIBS) blktapctrl.c
   20.21  
   20.22 -tapdisk: $(BLK-OBJS)
   20.23 +tapdisk: $(BLK-OBJS) tapdisk.c
   20.24  	$(CC) $(CFLAGS) -o tapdisk $(BLK-OBJS) tapdisk.c \
   20.25  		$(AIOLIBS) $(LIBS)
   20.26  
   20.27 +.PHONY: qcow-util
   20.28 +qcow-util: img2qcow qcow2raw qcow-create
   20.29  
   20.30 -qcow-util: $(BLK-OBJS)
   20.31 -	$(CC) $(CFLAGS) -o img2qcow $(BLK-OBJS) img2qcow.c \
   20.32 -		$(AIOLIBS)  $(LIBS)
   20.33 -	$(CC) $(CFLAGS) -o qcow2raw $(BLK-OBJS) qcow2raw.c  \
   20.34 -		$(AIOLIBS)  $(LIBS)
   20.35 -	$(CC) $(CFLAGS) -o qcow-create $(BLK-OBJS) qcow-create.c  \
   20.36 -		$(AIOLIBS)  $(LIBS)
   20.37 +img2qcow qcow2raw qcow-create: %: $(BLK-OBJS)
   20.38 +	$(CC) $(CFLAGS) -o $* $(BLK-OBJS) $*.c $(AIOLIBS)  $(LIBS)
   20.39  
   20.40  install: all
   20.41  	$(INSTALL_PROG) $(IBIN) $(QCOW_UTIL) $(DESTDIR)$(INSTALL_DIR)
    21.1 --- a/tools/blktap/lib/Makefile	Wed Aug 09 08:01:52 2006 -0600
    21.2 +++ b/tools/blktap/lib/Makefile	Wed Aug 09 08:34:06 2006 -0600
    21.3 @@ -35,10 +35,14 @@ IBINS   :=
    21.4  
    21.5  LIB      = libblktap.a libblktap.so.$(MAJOR).$(MINOR)
    21.6  
    21.7 +.PHONY: all
    21.8  all: build
    21.9  
   21.10 -build:
   21.11 -	$(MAKE) libblktap
   21.12 +.PHONY: build
   21.13 +build: libblktap.a
   21.14 +
   21.15 +.PHONY: libblktap
   21.16 +libblktap: libblktap.a
   21.17  
   21.18  install: all
   21.19  	$(INSTALL_DIR) -p $(DESTDIR)/usr/$(LIBDIR)
   21.20 @@ -51,13 +55,13 @@ install: all
   21.21  clean:
   21.22  	rm -rf *.a *.so* *.o *.rpm $(LIB) *~ $(DEPS) xen TAGS
   21.23  
   21.24 -libblktap: $(OBJS) 
   21.25 +libblktap.a: $(OBJS) 
   21.26  	$(CC) $(CFLAGS) -Wl,-soname -Wl,$(SONAME) -shared         \
   21.27  	      -L$(XEN_XENSTORE) -l xenstore                       \
   21.28  	      -o libblktap.so.$(MAJOR).$(MINOR) $^ $(LIBS)
   21.29  	ln -sf libblktap.so.$(MAJOR).$(MINOR) libblktap.so.$(MAJOR)
   21.30 -	ln -sf libblktap.so.$(MAJOR) $@.so
   21.31 -	ar rc libblktap.a $@.so
   21.32 +	ln -sf libblktap.so.$(MAJOR) libblktap.so
   21.33 +	ar rc $@ libblktap.so
   21.34  
   21.35  .PHONY: TAGS all build clean install libblktap
   21.36  
    22.1 --- a/tools/examples/block	Wed Aug 09 08:01:52 2006 -0600
    22.2 +++ b/tools/examples/block	Wed Aug 09 08:34:06 2006 -0600
    22.3 @@ -239,8 +239,11 @@ case "$command" in
    22.4        exit 0
    22.5      fi
    22.6  
    22.7 -    p=$(xenstore_read "$XENBUS_PATH/params")
    22.8 -    mode=$(xenstore_read "$XENBUS_PATH/mode")
    22.9 +    if [ -n "$t" ]
   22.10 +    then
   22.11 +      p=$(xenstore_read "$XENBUS_PATH/params")
   22.12 +      mode=$(xenstore_read "$XENBUS_PATH/mode")
   22.13 +    fi
   22.14  
   22.15      case $t in 
   22.16        phy)
   22.17 @@ -370,6 +373,13 @@ mount it read-write in a guest domain."
   22.18          release_lock "block"
   22.19          exit 0
   22.20  	;;
   22.21 +
   22.22 +      "")
   22.23 +        claim_lock "block"
   22.24 +        success
   22.25 +        echo happy gun \"$t\" >>/tmp/block.$$
   22.26 +        release_lock "block"
   22.27 +	;;
   22.28      esac
   22.29      ;;
   22.30  
   22.31 @@ -384,6 +394,10 @@ mount it read-write in a guest domain."
   22.32  	losetup -d "$node"
   22.33  	exit 0
   22.34  	;;
   22.35 +
   22.36 +      "")
   22.37 +        exit 0
   22.38 +	;;
   22.39      esac
   22.40      ;;
   22.41  
    23.1 --- a/tools/examples/xend-config.sxp	Wed Aug 09 08:01:52 2006 -0600
    23.2 +++ b/tools/examples/xend-config.sxp	Wed Aug 09 08:34:06 2006 -0600
    23.3 @@ -54,7 +54,7 @@
    23.4  #  (xend-relocation-hosts-allow '^localhost$ ^.*\.example\.org$')
    23.5  #
    23.6  #(xend-relocation-hosts-allow '')
    23.7 -(xend-relocation-hosts-allow '^localhost$')
    23.8 +(xend-relocation-hosts-allow '^localhost$ ^localhost\.localdomain$')
    23.9  
   23.10  # The limit (in kilobytes) on the size of the console buffer
   23.11  #(console-limit 1024)
    24.1 --- a/tools/examples/xmexample.hvm	Wed Aug 09 08:01:52 2006 -0600
    24.2 +++ b/tools/examples/xmexample.hvm	Wed Aug 09 08:34:06 2006 -0600
    24.3 @@ -66,7 +66,7 @@ vif = [ 'type=ioemu, bridge=xenbr0' ]
    24.4  # and MODE is r for read-only, w for read-write.
    24.5  
    24.6  #disk = [ 'phy:hda1,hda1,r' ]
    24.7 -disk = [ 'file:/var/images/min-el3-i386.img,ioemu:hda,w' ]
    24.8 +disk = [ 'file:/var/images/min-el3-i386.img,hda,w', ',hdc:cdrom,r' ]
    24.9  
   24.10  #----------------------------------------------------------------------------
   24.11  # Configure the behaviour when a domain exits.  There are three 'reasons'
   24.12 @@ -111,10 +111,6 @@ disk = [ 'file:/var/images/min-el3-i386.
   24.13  device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
   24.14  
   24.15  #-----------------------------------------------------------------------------
   24.16 -# Disk image for 
   24.17 -#cdrom=
   24.18 -
   24.19 -#-----------------------------------------------------------------------------
   24.20  # boot on floppy (a), hard disk (c) or CD-ROM (d) 
   24.21  #boot=[a|c|d]
   24.22  #-----------------------------------------------------------------------------
   24.23 @@ -153,8 +149,8 @@ serial='pty'
   24.24  
   24.25  
   24.26  #-----------------------------------------------------------------------------
   24.27 -#   enable audio support
   24.28 -#audio=1
   24.29 +#   enable sound card support, [sb16|es1370|all|..,..], default none
   24.30 +#soundhw='sb16'
   24.31  
   24.32  
   24.33  #-----------------------------------------------------------------------------
    25.1 --- a/tools/firmware/acpi/acpi_dsdt.asl	Wed Aug 09 08:01:52 2006 -0600
    25.2 +++ b/tools/firmware/acpi/acpi_dsdt.asl	Wed Aug 09 08:34:06 2006 -0600
    25.3 @@ -16,7 +16,7 @@
    25.4  //* Place - Suite 330, Boston, MA 02111-1307 USA.
    25.5  
    25.6  //**
    25.7 -//** 		DSDT for Xen with Qemu device model
    25.8 +//**  DSDT for Xen with Qemu device model
    25.9  //**
   25.10  //**
   25.11  
   25.12 @@ -50,21 +50,36 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
   25.13      })
   25.14  
   25.15  
   25.16 -      	Name(PICD, 0)	
   25.17 +    Name(PICD, 0)
   25.18  
   25.19 -	Method(_PIC, 1) { 
   25.20 +    Method(_PIC, 1) { 
   25.21   
   25.22 -		Store(Arg0, PICD) 
   25.23 -	}
   25.24 +    Store(Arg0, PICD) 
   25.25 +    }
   25.26      Scope (\_SB)
   25.27      {
   25.28 -        Device (PCI0)
   25.29 +       /* Fix HCT test for 0x400 pci memory - need to report low 640 MB mem as motherboard resource            */
   25.30 +
   25.31 +       Device(MEM0) {
   25.32 +           Name(_HID, EISAID("PNP0C02"))
   25.33 +           Name(_CRS, ResourceTemplate() {
   25.34 +           QWordMemory (ResourceConsumer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
   25.35 +                    0x00000000,
   25.36 +                    0x00000000,
   25.37 +                    0x0009ffff,
   25.38 +                    0x00000000,
   25.39 +                    0x000a0000)
   25.40 +           }
   25.41 +           )
   25.42 +       }
   25.43 +
   25.44 +       Device (PCI0)
   25.45          {
   25.46 -            Name (_HID, EisaId ("PNP0A03"))
   25.47 -            Name (_UID, 0x00)
   25.48 -            Name (_ADR, 0x00)
   25.49 -            Name (_BBN, 0x00)
   25.50 -            OperationRegion (PIRP, PCI_Config, 0x3c, 0x10)
   25.51 +           Name (_HID, EisaId ("PNP0A03"))
   25.52 +           Name (_UID, 0x00)
   25.53 +           Name (_ADR, 0x00)
   25.54 +           Name (_BBN, 0x00)
   25.55 +           OperationRegion (PIRP, PCI_Config, 0x3c, 0x10)
   25.56             Field(PIRP, ByteAcc, NoLock, Preserve){        
   25.57            IRQ3,3,
   25.58            IRQ5,5,
   25.59 @@ -79,7 +94,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
   25.60            
   25.61                 Name (PRT0, ResourceTemplate ()
   25.62                  {
   25.63 -					/* bus number is from 0 - 255*/
   25.64 +         /* bus number is from 0 - 255*/
   25.65                      WordBusNumber (ResourceConsumer, MinFixed, MaxFixed, SubDecode,
   25.66                          0x0000,
   25.67                          0x0000,
   25.68 @@ -122,7 +137,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
   25.69                          0x00000000,
   25.70                          0x00030000)
   25.71  
   25.72 -                 /* reserve what device model consumed for PCI VGA device        */
   25.73 +                /* reserve what device model consumed for PCI VGA device        */
   25.74  
   25.75                      DWordMemory (ResourceConsumer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
   25.76                          0x00000000,
   25.77 @@ -146,9 +161,9 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
   25.78                  })
   25.79                  Return (PRT0)
   25.80              }
   25.81 -	Name(BUFA, ResourceTemplate() {
   25.82 +       Name(BUFA, ResourceTemplate() {
   25.83                  IRQ(Level, ActiveLow, Shared) {
   25.84 -                        3,4,5,6,7,10,11,12,14,15}		 
   25.85 +                        3,4,5,6,7,10,11,12,14,15} 
   25.86                  }) 
   25.87  
   25.88                  Name(BUFB, Buffer(){
   25.89 @@ -156,7 +171,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
   25.90                  0x79, 0})
   25.91  
   25.92                  CreateWordField(BUFB, 0x01, IRQV)
   25.93 -		
   25.94 +
   25.95                  Name(BUFC, Buffer(){
   25.96                  5, 7, 10, 11
   25.97                   })
   25.98 @@ -165,17 +180,17 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
   25.99                  CreateByteField(BUFC, 0x01, PIQB)
  25.100                  CreateByteField(BUFC, 0x01, PIQC)
  25.101                  CreateByteField(BUFC, 0x01, PIQD)
  25.102 -                		
  25.103 -		Device(LNKA)	{
  25.104 -                Name(_HID, EISAID("PNP0C0F")) 	// PCI interrupt link
  25.105 +                
  25.106 +                Device(LNKA)    {
  25.107 +                Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link
  25.108                  Name(_UID, 1)
  25.109                  Method(_STA, 0) {
  25.110                                 And(PIRA, 0x80, Local0)
  25.111                          If(LEqual(Local0, 0x80)) {
  25.112 -                                Return(0x09)	
  25.113 +                                Return(0x09)   
  25.114                                  }
  25.115                          Else {
  25.116 -                                Return(0x0B)  	
  25.117 +                                Return(0x0B) 
  25.118                                  }
  25.119                          }
  25.120  
  25.121 @@ -189,34 +204,34 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
  25.122                  }
  25.123  
  25.124                  Method(_CRS) {
  25.125 -                        And(PIRB, 0x0f, Local0)		 
  25.126 -                        ShiftLeft(0x1, Local0, IRQV)	 
  25.127 -                        Return(BUFB)			 
  25.128 +                        And(PIRB, 0x0f, Local0) 
  25.129 +                        ShiftLeft(0x1, Local0, IRQV) 
  25.130 +                        Return(BUFB) 
  25.131                  } 
  25.132  
  25.133                  Method(_SRS, 1) {
  25.134 -                                CreateWordField(ARG0, 0x01, IRQ1)	 
  25.135 -                        FindSetRightBit(IRQ1, Local0)		 
  25.136 -                        Decrement(Local0)			 
  25.137 -                        Store(Local0, PIRA)			 
  25.138 +                                CreateWordField(ARG0, 0x01, IRQ1) 
  25.139 +                        FindSetRightBit(IRQ1, Local0) 
  25.140 +                        Decrement(Local0) 
  25.141 +                        Store(Local0, PIRA)
  25.142                   } // Method(_SRS)
  25.143          }
  25.144  
  25.145 -        Device(LNKB)	{
  25.146 -                Name(_HID, EISAID("PNP0C0F")) 	 
  25.147 +        Device(LNKB){
  25.148 +                Name(_HID, EISAID("PNP0C0F"))  
  25.149                  Name(_UID, 2)
  25.150                  Method(_STA, 0) {
  25.151                                 And(PIRB, 0x80, Local0)
  25.152                          If(LEqual(Local0, 0x80)) {
  25.153 -                                Return(0x09)	 
  25.154 +                                Return(0x09) 
  25.155                                  }
  25.156                          Else {
  25.157 -                                Return(0x0B)  	 
  25.158 +                                Return(0x0B) 
  25.159                                  }
  25.160                          }
  25.161  
  25.162                  Method(_PRS) {
  25.163 -                                Return(BUFA)			 
  25.164 +                                Return(BUFA) 
  25.165                  } // Method(_PRS)
  25.166  
  25.167                  Method(_DIS) {
  25.168 @@ -225,35 +240,35 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
  25.169                  }
  25.170  
  25.171                  Method(_CRS) {
  25.172 -                        And(PIRB, 0x0f, Local0)		 
  25.173 -                        ShiftLeft(0x1, Local0, IRQV)	 
  25.174 -                        Return(BUFB)			 
  25.175 +                        And(PIRB, 0x0f, Local0) 
  25.176 +                        ShiftLeft(0x1, Local0, IRQV) 
  25.177 +                        Return(BUFB) 
  25.178                  } // Method(_CRS)
  25.179  
  25.180                  Method(_SRS, 1) {
  25.181 -                                CreateWordField(ARG0, 0x01, IRQ1)	 
  25.182 -                        FindSetRightBit(IRQ1, Local0)		 
  25.183 -                        Decrement(Local0)			 
  25.184 -                        Store(Local0, PIRB)			 
  25.185 +                        CreateWordField(ARG0, 0x01, IRQ1) 
  25.186 +                        FindSetRightBit(IRQ1, Local0) 
  25.187 +                        Decrement(Local0)
  25.188 +                        Store(Local0, PIRB) 
  25.189                   } // Method(_SRS)
  25.190          }
  25.191  
  25.192 -        Device(LNKC)	{
  25.193 -                Name(_HID, EISAID("PNP0C0F")) 	// PCI interrupt link
  25.194 +        Device(LNKC){
  25.195 +                Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link
  25.196                  Name(_UID, 3)
  25.197                  Method(_STA, 0) {
  25.198 -                               And(PIRC, 0x80, Local0)
  25.199 +                        And(PIRC, 0x80, Local0)
  25.200                          If(LEqual(Local0, 0x80)) {
  25.201 -                                Return(0x09)	 
  25.202 +                                Return(0x09) 
  25.203                          }
  25.204                          Else {
  25.205 -                                Return(0x0B)  	 
  25.206 +                                Return(0x0B)
  25.207                          }
  25.208                  }
  25.209  
  25.210 -                Method(_PRS) {				 
  25.211 -                        Return(BUFA)			 
  25.212 -                } // Method(_PRS)			 
  25.213 +                Method(_PRS) { 
  25.214 +                        Return(BUFA)
  25.215 +                } // Method(_PRS)
  25.216  
  25.217                  Method(_DIS) {
  25.218  
  25.219 @@ -261,91 +276,89 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
  25.220                  }
  25.221  
  25.222                  Method(_CRS) {
  25.223 -                        And(PIRC, 0x0f, Local0)		 
  25.224 -                        ShiftLeft(0x1, Local0, IRQV)	 
  25.225 -                        Return(BUFB)			 
  25.226 +                        And(PIRC, 0x0f, Local0) 
  25.227 +                        ShiftLeft(0x1, Local0, IRQV) 
  25.228 +                        Return(BUFB) 
  25.229                  } // Method(_CRS)
  25.230  
  25.231                  Method(_SRS, 1) {
  25.232 -                                CreateWordField(ARG0, 0x01, IRQ1)	 
  25.233 -                        FindSetRightBit(IRQ1, Local0)		 
  25.234 -                        Decrement(Local0)			 
  25.235 -                        Store(Local0, PIRC)			 
  25.236 +                                CreateWordField(ARG0, 0x01, IRQ1) 
  25.237 +                        FindSetRightBit(IRQ1, Local0) 
  25.238 +                        Decrement(Local0) 
  25.239 +                        Store(Local0, PIRC)
  25.240                   } // Method(_SRS)
  25.241          }
  25.242  
  25.243 -        Device(LNKD)	{
  25.244 -                Name(_HID, EISAID("PNP0C0F")) 	 
  25.245 +        Device(LNKD) {
  25.246 +                Name(_HID, EISAID("PNP0C0F"))  
  25.247                  Name(_UID, 4)
  25.248                  Method(_STA, 0) {
  25.249                                 And(PIRD, 0x80, Local0)
  25.250                          If(LEqual(Local0, 0x80)) {
  25.251 -                                Return(0x09)	 
  25.252 +                                Return(0x09) 
  25.253                          }
  25.254                          Else {
  25.255 -                                Return(0x0B)  	 
  25.256 +                                Return(0x0B) 
  25.257                          }
  25.258                  }
  25.259  
  25.260 -                Method(_PRS) {				 
  25.261 -                        Return(BUFA)			 
  25.262 -                } // Method(_PRS)			 
  25.263 +                Method(_PRS) { 
  25.264 +                        Return(BUFA) 
  25.265 +                } // Method(_PRS)
  25.266  
  25.267                  Method(_DIS) {
  25.268                                 Or(PIRD, 0x80, PIRD)
  25.269                  }
  25.270  
  25.271                  Method(_CRS) {
  25.272 -                        And(PIRD, 0x0f, Local0)		 
  25.273 -                        ShiftLeft(0x1, Local0, IRQV)	 
  25.274 -                        Return(BUFB)			 
  25.275 +                        And(PIRD, 0x0f, Local0) 
  25.276 +                        ShiftLeft(0x1, Local0, IRQV) 
  25.277 +                        Return(BUFB) 
  25.278                  } // Method(_CRS)
  25.279  
  25.280                  Method(_SRS, 1) {
  25.281 -                                CreateWordField(ARG0, 0x01, IRQ1)	 
  25.282 -                        FindSetRightBit(IRQ1, Local0)		 
  25.283 -                        Decrement(Local0)			 
  25.284 -                        Store(Local0, PIRD)			 
  25.285 +                                CreateWordField(ARG0, 0x01, IRQ1) 
  25.286 +                        FindSetRightBit(IRQ1, Local0) 
  25.287 +                        Decrement(Local0) 
  25.288 +                        Store(Local0, PIRD) 
  25.289                   } // Method(_SRS)
  25.290          }
  25.291          Method(_PRT,0) {
  25.292 -			If(PICD) {Return(PRTA)}  
  25.293 -			Return (PRTP)  
  25.294 -		} // end _PRT
  25.295 -		
  25.296 -		
  25.297 -        Name(PRTP, Package(){
  25.298 -                        Package(){0x0000ffff, 0, \_SB.PCI0.LNKA, 0}, 	// Slot 1, INTA
  25.299 -                        Package(){0x0000ffff, 1, \_SB.PCI0.LNKB, 0}, 	// Slot 1, INTB
  25.300 -                        Package(){0x0000ffff, 2, \_SB.PCI0.LNKC, 0}, 	// Slot 1, INTC
  25.301 -                        Package(){0x0000ffff, 3, \_SB.PCI0.LNKD, 0}, 	// Slot 1, INTD
  25.302 +               If(PICD) {Return(PRTA)}  
  25.303 +               Return (PRTP)  
  25.304 +               } // end _PRT
  25.305  
  25.306 -                        Package(){0x0001ffff, 0, \_SB.PCI0.LNKB, 0}, 	// Slot 2, INTB
  25.307 -                        Package(){0x0001ffff, 1, \_SB.PCI0.LNKC, 0}, 	// Slot 2, INTC
  25.308 -                        Package(){0x0001ffff, 2, \_SB.PCI0.LNKD, 0}, 	// Slot 2, INTD
  25.309 -                        Package(){0x0001ffff, 3, \_SB.PCI0.LNKA, 0}, 	// Slot 2, INTA
  25.310 +        Name(PRTP, Package(){
  25.311 +                        Package(){0x0000ffff, 0, \_SB.PCI0.LNKA, 0}, // Slot 1, INTA
  25.312 +                        Package(){0x0000ffff, 1, \_SB.PCI0.LNKB, 0}, // Slot 1, INTB
  25.313 +                        Package(){0x0000ffff, 2, \_SB.PCI0.LNKC, 0}, // Slot 1, INTC
  25.314 +                        Package(){0x0000ffff, 3, \_SB.PCI0.LNKD, 0}, // Slot 1, INTD
  25.315 +
  25.316 +                        Package(){0x0001ffff, 0, \_SB.PCI0.LNKB, 0}, // Slot 2, INTB
  25.317 +                        Package(){0x0001ffff, 1, \_SB.PCI0.LNKC, 0}, // Slot 2, INTC
  25.318 +                        Package(){0x0001ffff, 2, \_SB.PCI0.LNKD, 0}, // Slot 2, INTD
  25.319 +                        Package(){0x0001ffff, 3, \_SB.PCI0.LNKA, 0}, // Slot 2, INTA
  25.320                          
  25.321 -                        Package(){0x0002ffff, 0, \_SB.PCI0.LNKC, 0}, 	// Slot 3, INTC
  25.322 -                        Package(){0x0002ffff, 1, \_SB.PCI0.LNKD, 0}, 	// Slot 3, INTD
  25.323 -                        Package(){0x0002ffff, 2, \_SB.PCI0.LNKA, 0}, 	// Slot 3, INTA
  25.324 -                        Package(){0x0002ffff, 3, \_SB.PCI0.LNKB, 0}, 	// Slot 3, INTB
  25.325 +                        Package(){0x0002ffff, 0, \_SB.PCI0.LNKC, 0}, // Slot 3, INTC
  25.326 +                        Package(){0x0002ffff, 1, \_SB.PCI0.LNKD, 0}, // Slot 3, INTD
  25.327 +                        Package(){0x0002ffff, 2, \_SB.PCI0.LNKA, 0}, // Slot 3, INTA
  25.328 +                        Package(){0x0002ffff, 3, \_SB.PCI0.LNKB, 0}, // Slot 3, INTB
  25.329                          
  25.330 -                        Package(){0x0003ffff, 0, \_SB.PCI0.LNKD, 0}, 	// Slot 2, INTD
  25.331 -                        Package(){0x0003ffff, 1, \_SB.PCI0.LNKA, 0}, 	// Slot 2, INTA
  25.332 -                        Package(){0x0003ffff, 2, \_SB.PCI0.LNKB, 0}, 	// Slot 2, INTB
  25.333 -                        Package(){0x0003ffff, 3, \_SB.PCI0.LNKC, 0}, 	// Slot 2, INTC
  25.334 +                        Package(){0x0003ffff, 0, \_SB.PCI0.LNKD, 0}, // Slot 2, INTD
  25.335 +                        Package(){0x0003ffff, 1, \_SB.PCI0.LNKA, 0}, // Slot 2, INTA
  25.336 +                        Package(){0x0003ffff, 2, \_SB.PCI0.LNKB, 0}, // Slot 2, INTB
  25.337 +                        Package(){0x0003ffff, 3, \_SB.PCI0.LNKC, 0}, // Slot 2, INTC
  25.338                          
  25.339                          }
  25.340              )
  25.341 -	Name(PRTA, Package(){
  25.342 -                        Package(){0x0001ffff, 0, 0, 5}, 	// Device 1, INTA
  25.343 +        Name(PRTA, Package(){
  25.344 +                        Package(){0x0001ffff, 0, 0, 5}, // Device 1, INTA
  25.345  
  25.346 -                        Package(){0x0002ffff, 0, 0, 7}, 	// Device 2, INTA
  25.347 +                        Package(){0x0002ffff, 0, 0, 7},  // Device 2, INTA
  25.348                         
  25.349 -                        Package(){0x0003ffff, 0, 0, 10}, 	// Device 3, INTA
  25.350 +                        Package(){0x0003ffff, 0, 0, 10}, // Device 3, INTA
  25.351  
  25.352 -                        Package(){0x0003ffff, 0, 0, 11}, 	// Device 4, INTA
  25.353 -                                   
  25.354 +                        Package(){0x0004ffff, 0, 0, 11},  // Device 4, INTA                                
  25.355                          
  25.356                          }
  25.357              )
  25.358 @@ -354,22 +367,22 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
  25.359              {
  25.360                  Name (_ADR, 0x00000000) /* device id, PCI bus num, ... */
  25.361   
  25.362 -		OperationRegion(PIRQ, PCI_Config, 0x60, 0x4)
  25.363 +            OperationRegion(PIRQ, PCI_Config, 0x60, 0x4)
  25.364                          Scope(\) {
  25.365 -                                Field (\_SB.PCI0.ISA.PIRQ, ByteAcc, NoLock, Preserve) {
  25.366 +                                 Field (\_SB.PCI0.ISA.PIRQ, ByteAcc, NoLock, Preserve) {
  25.367                                          PIRA, 8,
  25.368                                          PIRB, 8,
  25.369                                          PIRC, 8,
  25.370                                          PIRD, 8
  25.371                                          }
  25.372 -                                }
  25.373 +                                 }
  25.374                  Device (SYSR)
  25.375                  {
  25.376                      Name (_HID, EisaId ("PNP0C02"))
  25.377                      Name (_UID, 0x01)
  25.378                      Name (CRS, ResourceTemplate ()
  25.379                      {
  25.380 -						/* TODO: list hidden resources */
  25.381 +               /* TODO: list hidden resources */
  25.382                          IO (Decode16, 0x0010, 0x0010, 0x00, 0x10)
  25.383                          IO (Decode16, 0x0022, 0x0022, 0x00, 0x0C)
  25.384                          IO (Decode16, 0x0030, 0x0030, 0x00, 0x10)
  25.385 @@ -417,7 +430,7 @@ DefinitionBlock ("DSDT.aml", "DSDT", 1, 
  25.386                          IO (Decode16, 0x0089, 0x0089, 0x00, 0x03)
  25.387                          IO (Decode16, 0x008F, 0x008F, 0x00, 0x01)
  25.388                          IO (Decode16, 0x00C0, 0x00C0, 0x00, 0x20)
  25.389 -						IO (Decode16, 0x0480, 0x0480, 0x00, 0x10)
  25.390 +                        IO (Decode16, 0x0480, 0x0480, 0x00, 0x10)
  25.391                      })
  25.392                  }
  25.393  
    26.1 --- a/tools/firmware/acpi/acpi_dsdt.c	Wed Aug 09 08:01:52 2006 -0600
    26.2 +++ b/tools/firmware/acpi/acpi_dsdt.c	Wed Aug 09 08:34:06 2006 -0600
    26.3 @@ -5,15 +5,15 @@
    26.4   * Copyright (C) 2000 - 2005 Intel Corporation
    26.5   * Supports ACPI Specification Revision 3.0
    26.6   * 
    26.7 - * Compilation of "acpi_dsdt.asl" - Mon Jun 12 22:33:41 2006
    26.8 + * Compilation of "acpi_dsdt.asl" - Thu Aug  3 11:05:15 2006
    26.9   * 
   26.10   * C source code output
   26.11   *
   26.12   */
   26.13  unsigned char AmlCode[] = 
   26.14  {
   26.15 -    0x44,0x53,0x44,0x54,0xC3,0x08,0x00,0x00,  /* 00000000    "DSDT...." */
   26.16 -    0x01,0x0C,0x49,0x4E,0x54,0x45,0x4C,0x00,  /* 00000008    "..INTEL." */
   26.17 +    0x44,0x53,0x44,0x54,0x0E,0x09,0x00,0x00,  /* 00000000    "DSDT...." */
   26.18 +    0x01,0x03,0x49,0x4E,0x54,0x45,0x4C,0x00,  /* 00000008    "..INTEL." */
   26.19      0x69,0x6E,0x74,0x2D,0x78,0x65,0x6E,0x00,  /* 00000010    "int-xen." */
   26.20      0xD6,0x07,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
   26.21      0x13,0x05,0x05,0x20,0x08,0x50,0x4D,0x42,  /* 00000020    "... .PMB" */
   26.22 @@ -34,264 +34,273 @@ unsigned char AmlCode[] =
   26.23      0x12,0x08,0x04,0x0A,0x07,0x0A,0x07,0x00,  /* 00000098    "........" */
   26.24      0x00,0x08,0x50,0x49,0x43,0x44,0x00,0x14,  /* 000000A0    "..PICD.." */
   26.25      0x0C,0x5F,0x50,0x49,0x43,0x01,0x70,0x68,  /* 000000A8    "._PIC.ph" */
   26.26 -    0x50,0x49,0x43,0x44,0x10,0x4E,0x80,0x5F,  /* 000000B0    "PICD.N._" */
   26.27 -    0x53,0x42,0x5F,0x5B,0x82,0x46,0x80,0x50,  /* 000000B8    "SB_[.F.P" */
   26.28 -    0x43,0x49,0x30,0x08,0x5F,0x48,0x49,0x44,  /* 000000C0    "CI0._HID" */
   26.29 -    0x0C,0x41,0xD0,0x0A,0x03,0x08,0x5F,0x55,  /* 000000C8    ".A...._U" */
   26.30 -    0x49,0x44,0x00,0x08,0x5F,0x41,0x44,0x52,  /* 000000D0    "ID.._ADR" */
   26.31 -    0x00,0x08,0x5F,0x42,0x42,0x4E,0x00,0x5B,  /* 000000D8    ".._BBN.[" */
   26.32 -    0x80,0x50,0x49,0x52,0x50,0x02,0x0A,0x3C,  /* 000000E0    ".PIRP..<" */
   26.33 -    0x0A,0x10,0x5B,0x81,0x24,0x50,0x49,0x52,  /* 000000E8    "..[.$PIR" */
   26.34 -    0x50,0x01,0x49,0x52,0x51,0x33,0x03,0x49,  /* 000000F0    "P.IRQ3.I" */
   26.35 -    0x52,0x51,0x35,0x05,0x49,0x52,0x51,0x37,  /* 000000F8    "RQ5.IRQ7" */
   26.36 -    0x07,0x49,0x52,0x51,0x39,0x09,0x49,0x52,  /* 00000100    ".IRQ9.IR" */
   26.37 -    0x51,0x41,0x0A,0x49,0x52,0x51,0x42,0x0B,  /* 00000108    "QA.IRQB." */
   26.38 -    0x14,0x48,0x0D,0x5F,0x43,0x52,0x53,0x00,  /* 00000110    ".H._CRS." */
   26.39 -    0x08,0x50,0x52,0x54,0x30,0x11,0x46,0x0C,  /* 00000118    ".PRT0.F." */
   26.40 -    0x0A,0xC2,0x88,0x0D,0x00,0x02,0x0F,0x00,  /* 00000120    "........" */
   26.41 -    0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,  /* 00000128    "........" */
   26.42 -    0x00,0x01,0x47,0x01,0xF8,0x0C,0xF8,0x0C,  /* 00000130    "..G....." */
   26.43 -    0x01,0x08,0x88,0x0D,0x00,0x01,0x0C,0x03,  /* 00000138    "........" */
   26.44 -    0x00,0x00,0x00,0x00,0xF7,0x0C,0x00,0x00,  /* 00000140    "........" */
   26.45 -    0xF8,0x0C,0x88,0x0D,0x00,0x01,0x0C,0x03,  /* 00000148    "........" */
   26.46 -    0x00,0x00,0x00,0x0D,0xFF,0x0F,0x00,0x00,  /* 00000150    "........" */
   26.47 -    0x00,0x03,0x88,0x0D,0x00,0x01,0x0D,0x03,  /* 00000158    "........" */
   26.48 -    0x00,0x00,0x00,0xC0,0x1F,0xC0,0x00,0x00,  /* 00000160    "........" */
   26.49 -    0x20,0x00,0x88,0x0D,0x00,0x01,0x0D,0x03,  /* 00000168    " ......." */
   26.50 -    0x00,0x00,0x20,0xC0,0x3F,0xC0,0x00,0x00,  /* 00000170    ".. .?..." */
   26.51 -    0x10,0x00,0x87,0x17,0x00,0x00,0x0C,0x02,  /* 00000178    "........" */
   26.52 -    0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,  /* 00000180    "........" */
   26.53 -    0xFF,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,  /* 00000188    "........" */
   26.54 -    0x00,0x00,0x03,0x00,0x87,0x17,0x00,0x00,  /* 00000190    "........" */
   26.55 -    0x0D,0x03,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000198    "........" */
   26.56 -    0x00,0xF0,0xFF,0xFF,0xFF,0xF1,0x00,0x00,  /* 000001A0    "........" */
   26.57 -    0x00,0x00,0x00,0x00,0x00,0x02,0x87,0x17,  /* 000001A8    "........" */
   26.58 -    0x00,0x00,0x0D,0x03,0x00,0x00,0x00,0x00,  /* 000001B0    "........" */
   26.59 -    0x00,0x00,0x00,0xF2,0xFF,0x0F,0x00,0xF2,  /* 000001B8    "........" */
   26.60 -    0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,  /* 000001C0    "........" */
   26.61 -    0x87,0x17,0x00,0x00,0x0D,0x03,0x00,0x00,  /* 000001C8    "........" */
   26.62 -    0x00,0x00,0x00,0x10,0x00,0xF2,0x1F,0x10,  /* 000001D0    "........" */
   26.63 -    0x00,0xF2,0x00,0x00,0x00,0x00,0x20,0x00,  /* 000001D8    "...... ." */
   26.64 -    0x00,0x00,0x79,0x00,0xA4,0x50,0x52,0x54,  /* 000001E0    "..y..PRT" */
   26.65 -    0x30,0x08,0x42,0x55,0x46,0x41,0x11,0x09,  /* 000001E8    "0.BUFA.." */
   26.66 -    0x0A,0x06,0x23,0xF8,0xDC,0x18,0x79,0x00,  /* 000001F0    "..#...y." */
   26.67 -    0x08,0x42,0x55,0x46,0x42,0x11,0x09,0x0A,  /* 000001F8    ".BUFB..." */
   26.68 -    0x06,0x23,0x00,0x00,0x18,0x79,0x00,0x8B,  /* 00000200    ".#...y.." */
   26.69 -    0x42,0x55,0x46,0x42,0x01,0x49,0x52,0x51,  /* 00000208    "BUFB.IRQ" */
   26.70 -    0x56,0x08,0x42,0x55,0x46,0x43,0x11,0x07,  /* 00000210    "V.BUFC.." */
   26.71 -    0x0A,0x04,0x05,0x07,0x0A,0x0B,0x8C,0x42,  /* 00000218    ".......B" */
   26.72 -    0x55,0x46,0x43,0x01,0x50,0x49,0x51,0x41,  /* 00000220    "UFC.PIQA" */
   26.73 -    0x8C,0x42,0x55,0x46,0x43,0x01,0x50,0x49,  /* 00000228    ".BUFC.PI" */
   26.74 -    0x51,0x42,0x8C,0x42,0x55,0x46,0x43,0x01,  /* 00000230    "QB.BUFC." */
   26.75 -    0x50,0x49,0x51,0x43,0x8C,0x42,0x55,0x46,  /* 00000238    "PIQC.BUF" */
   26.76 -    0x43,0x01,0x50,0x49,0x51,0x44,0x5B,0x82,  /* 00000240    "C.PIQD[." */
   26.77 -    0x48,0x08,0x4C,0x4E,0x4B,0x41,0x08,0x5F,  /* 00000248    "H.LNKA._" */
   26.78 -    0x48,0x49,0x44,0x0C,0x41,0xD0,0x0C,0x0F,  /* 00000250    "HID.A..." */
   26.79 -    0x08,0x5F,0x55,0x49,0x44,0x01,0x14,0x1C,  /* 00000258    "._UID..." */
   26.80 -    0x5F,0x53,0x54,0x41,0x00,0x7B,0x50,0x49,  /* 00000260    "_STA.{PI" */
   26.81 -    0x52,0x41,0x0A,0x80,0x60,0xA0,0x08,0x93,  /* 00000268    "RA..`..." */
   26.82 -    0x60,0x0A,0x80,0xA4,0x0A,0x09,0xA1,0x04,  /* 00000270    "`......." */
   26.83 -    0xA4,0x0A,0x0B,0x14,0x0B,0x5F,0x50,0x52,  /* 00000278    "....._PR" */
   26.84 -    0x53,0x00,0xA4,0x42,0x55,0x46,0x41,0x14,  /* 00000280    "S..BUFA." */
   26.85 -    0x11,0x5F,0x44,0x49,0x53,0x00,0x7D,0x50,  /* 00000288    "._DIS.}P" */
   26.86 -    0x49,0x52,0x41,0x0A,0x80,0x50,0x49,0x52,  /* 00000290    "IRA..PIR" */
   26.87 -    0x41,0x14,0x1A,0x5F,0x43,0x52,0x53,0x00,  /* 00000298    "A.._CRS." */
   26.88 -    0x7B,0x50,0x49,0x52,0x42,0x0A,0x0F,0x60,  /* 000002A0    "{PIRB..`" */
   26.89 -    0x79,0x01,0x60,0x49,0x52,0x51,0x56,0xA4,  /* 000002A8    "y.`IRQV." */
   26.90 -    0x42,0x55,0x46,0x42,0x14,0x1B,0x5F,0x53,  /* 000002B0    "BUFB.._S" */
   26.91 -    0x52,0x53,0x01,0x8B,0x68,0x01,0x49,0x52,  /* 000002B8    "RS..h.IR" */
   26.92 -    0x51,0x31,0x82,0x49,0x52,0x51,0x31,0x60,  /* 000002C0    "Q1.IRQ1`" */
   26.93 -    0x76,0x60,0x70,0x60,0x50,0x49,0x52,0x41,  /* 000002C8    "v`p`PIRA" */
   26.94 -    0x5B,0x82,0x49,0x08,0x4C,0x4E,0x4B,0x42,  /* 000002D0    "[.I.LNKB" */
   26.95 -    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 000002D8    "._HID.A." */
   26.96 -    0x0C,0x0F,0x08,0x5F,0x55,0x49,0x44,0x0A,  /* 000002E0    "..._UID." */
   26.97 -    0x02,0x14,0x1C,0x5F,0x53,0x54,0x41,0x00,  /* 000002E8    "..._STA." */
   26.98 -    0x7B,0x50,0x49,0x52,0x42,0x0A,0x80,0x60,  /* 000002F0    "{PIRB..`" */
   26.99 -    0xA0,0x08,0x93,0x60,0x0A,0x80,0xA4,0x0A,  /* 000002F8    "...`...." */
  26.100 -    0x09,0xA1,0x04,0xA4,0x0A,0x0B,0x14,0x0B,  /* 00000300    "........" */
  26.101 -    0x5F,0x50,0x52,0x53,0x00,0xA4,0x42,0x55,  /* 00000308    "_PRS..BU" */
  26.102 -    0x46,0x41,0x14,0x11,0x5F,0x44,0x49,0x53,  /* 00000310    "FA.._DIS" */
  26.103 -    0x00,0x7D,0x50,0x49,0x52,0x42,0x0A,0x80,  /* 00000318    ".}PIRB.." */
  26.104 -    0x50,0x49,0x52,0x42,0x14,0x1A,0x5F,0x43,  /* 00000320    "PIRB.._C" */
  26.105 -    0x52,0x53,0x00,0x7B,0x50,0x49,0x52,0x42,  /* 00000328    "RS.{PIRB" */
  26.106 -    0x0A,0x0F,0x60,0x79,0x01,0x60,0x49,0x52,  /* 00000330    "..`y.`IR" */
  26.107 -    0x51,0x56,0xA4,0x42,0x55,0x46,0x42,0x14,  /* 00000338    "QV.BUFB." */
  26.108 -    0x1B,0x5F,0x53,0x52,0x53,0x01,0x8B,0x68,  /* 00000340    "._SRS..h" */
  26.109 -    0x01,0x49,0x52,0x51,0x31,0x82,0x49,0x52,  /* 00000348    ".IRQ1.IR" */
  26.110 -    0x51,0x31,0x60,0x76,0x60,0x70,0x60,0x50,  /* 00000350    "Q1`v`p`P" */
  26.111 -    0x49,0x52,0x42,0x5B,0x82,0x49,0x08,0x4C,  /* 00000358    "IRB[.I.L" */
  26.112 -    0x4E,0x4B,0x43,0x08,0x5F,0x48,0x49,0x44,  /* 00000360    "NKC._HID" */
  26.113 -    0x0C,0x41,0xD0,0x0C,0x0F,0x08,0x5F,0x55,  /* 00000368    ".A...._U" */
  26.114 -    0x49,0x44,0x0A,0x03,0x14,0x1C,0x5F,0x53,  /* 00000370    "ID...._S" */
  26.115 -    0x54,0x41,0x00,0x7B,0x50,0x49,0x52,0x43,  /* 00000378    "TA.{PIRC" */
  26.116 -    0x0A,0x80,0x60,0xA0,0x08,0x93,0x60,0x0A,  /* 00000380    "..`...`." */
  26.117 -    0x80,0xA4,0x0A,0x09,0xA1,0x04,0xA4,0x0A,  /* 00000388    "........" */
  26.118 -    0x0B,0x14,0x0B,0x5F,0x50,0x52,0x53,0x00,  /* 00000390    "..._PRS." */
  26.119 -    0xA4,0x42,0x55,0x46,0x41,0x14,0x11,0x5F,  /* 00000398    ".BUFA.._" */
  26.120 -    0x44,0x49,0x53,0x00,0x7D,0x50,0x49,0x52,  /* 000003A0    "DIS.}PIR" */
  26.121 -    0x43,0x0A,0x80,0x50,0x49,0x52,0x43,0x14,  /* 000003A8    "C..PIRC." */
  26.122 -    0x1A,0x5F,0x43,0x52,0x53,0x00,0x7B,0x50,  /* 000003B0    "._CRS.{P" */
  26.123 -    0x49,0x52,0x43,0x0A,0x0F,0x60,0x79,0x01,  /* 000003B8    "IRC..`y." */
  26.124 -    0x60,0x49,0x52,0x51,0x56,0xA4,0x42,0x55,  /* 000003C0    "`IRQV.BU" */
  26.125 -    0x46,0x42,0x14,0x1B,0x5F,0x53,0x52,0x53,  /* 000003C8    "FB.._SRS" */
  26.126 -    0x01,0x8B,0x68,0x01,0x49,0x52,0x51,0x31,  /* 000003D0    "..h.IRQ1" */
  26.127 -    0x82,0x49,0x52,0x51,0x31,0x60,0x76,0x60,  /* 000003D8    ".IRQ1`v`" */
  26.128 -    0x70,0x60,0x50,0x49,0x52,0x43,0x5B,0x82,  /* 000003E0    "p`PIRC[." */
  26.129 -    0x49,0x08,0x4C,0x4E,0x4B,0x44,0x08,0x5F,  /* 000003E8    "I.LNKD._" */
  26.130 -    0x48,0x49,0x44,0x0C,0x41,0xD0,0x0C,0x0F,  /* 000003F0    "HID.A..." */
  26.131 -    0x08,0x5F,0x55,0x49,0x44,0x0A,0x04,0x14,  /* 000003F8    "._UID..." */
  26.132 -    0x1C,0x5F,0x53,0x54,0x41,0x00,0x7B,0x50,  /* 00000400    "._STA.{P" */
  26.133 -    0x49,0x52,0x44,0x0A,0x80,0x60,0xA0,0x08,  /* 00000408    "IRD..`.." */
  26.134 -    0x93,0x60,0x0A,0x80,0xA4,0x0A,0x09,0xA1,  /* 00000410    ".`......" */
  26.135 -    0x04,0xA4,0x0A,0x0B,0x14,0x0B,0x5F,0x50,  /* 00000418    "......_P" */
  26.136 -    0x52,0x53,0x00,0xA4,0x42,0x55,0x46,0x41,  /* 00000420    "RS..BUFA" */
  26.137 -    0x14,0x11,0x5F,0x44,0x49,0x53,0x00,0x7D,  /* 00000428    ".._DIS.}" */
  26.138 -    0x50,0x49,0x52,0x44,0x0A,0x80,0x50,0x49,  /* 00000430    "PIRD..PI" */
  26.139 -    0x52,0x44,0x14,0x1A,0x5F,0x43,0x52,0x53,  /* 00000438    "RD.._CRS" */
  26.140 -    0x00,0x7B,0x50,0x49,0x52,0x44,0x0A,0x0F,  /* 00000440    ".{PIRD.." */
  26.141 -    0x60,0x79,0x01,0x60,0x49,0x52,0x51,0x56,  /* 00000448    "`y.`IRQV" */
  26.142 -    0xA4,0x42,0x55,0x46,0x42,0x14,0x1B,0x5F,  /* 00000450    ".BUFB.._" */
  26.143 -    0x53,0x52,0x53,0x01,0x8B,0x68,0x01,0x49,  /* 00000458    "SRS..h.I" */
  26.144 -    0x52,0x51,0x31,0x82,0x49,0x52,0x51,0x31,  /* 00000460    "RQ1.IRQ1" */
  26.145 -    0x60,0x76,0x60,0x70,0x60,0x50,0x49,0x52,  /* 00000468    "`v`p`PIR" */
  26.146 -    0x44,0x14,0x16,0x5F,0x50,0x52,0x54,0x00,  /* 00000470    "D.._PRT." */
  26.147 -    0xA0,0x0A,0x50,0x49,0x43,0x44,0xA4,0x50,  /* 00000478    "..PICD.P" */
  26.148 -    0x52,0x54,0x41,0xA4,0x50,0x52,0x54,0x50,  /* 00000480    "RTA.PRTP" */
  26.149 -    0x08,0x50,0x52,0x54,0x50,0x12,0x43,0x0E,  /* 00000488    ".PRTP.C." */
  26.150 -    0x10,0x12,0x0B,0x04,0x0B,0xFF,0xFF,0x00,  /* 00000490    "........" */
  26.151 -    0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0B,0x04,  /* 00000498    "LNKA...." */
  26.152 -    0x0B,0xFF,0xFF,0x01,0x4C,0x4E,0x4B,0x42,  /* 000004A0    "....LNKB" */
  26.153 -    0x00,0x12,0x0C,0x04,0x0B,0xFF,0xFF,0x0A,  /* 000004A8    "........" */
  26.154 -    0x02,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0C,  /* 000004B0    ".LNKC..." */
  26.155 -    0x04,0x0B,0xFF,0xFF,0x0A,0x03,0x4C,0x4E,  /* 000004B8    "......LN" */
  26.156 -    0x4B,0x44,0x00,0x12,0x0D,0x04,0x0C,0xFF,  /* 000004C0    "KD......" */
  26.157 -    0xFF,0x01,0x00,0x00,0x4C,0x4E,0x4B,0x42,  /* 000004C8    "....LNKB" */
  26.158 -    0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x01,  /* 000004D0    "........" */
  26.159 -    0x00,0x01,0x4C,0x4E,0x4B,0x43,0x00,0x12,  /* 000004D8    "..LNKC.." */
  26.160 -    0x0E,0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,  /* 000004E0    "........" */
  26.161 -    0x02,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0E,  /* 000004E8    ".LNKD..." */
  26.162 -    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,0x03,  /* 000004F0    "........" */
  26.163 -    0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0D,0x04,  /* 000004F8    "LNKA...." */
  26.164 -    0x0C,0xFF,0xFF,0x02,0x00,0x00,0x4C,0x4E,  /* 00000500    "......LN" */
  26.165 -    0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,0xFF,  /* 00000508    "KC......" */
  26.166 -    0xFF,0x02,0x00,0x01,0x4C,0x4E,0x4B,0x44,  /* 00000510    "....LNKD" */
  26.167 -    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x02,  /* 00000518    "........" */
  26.168 -    0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000520    "...LNKA." */
  26.169 -    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 00000528    "........" */
  26.170 -    0x0A,0x03,0x4C,0x4E,0x4B,0x42,0x00,0x12,  /* 00000530    "..LNKB.." */
  26.171 -    0x0D,0x04,0x0C,0xFF,0xFF,0x03,0x00,0x00,  /* 00000538    "........" */
  26.172 -    0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,0x04,  /* 00000540    "LNKD...." */
  26.173 -    0x0C,0xFF,0xFF,0x03,0x00,0x01,0x4C,0x4E,  /* 00000548    "......LN" */
  26.174 -    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000550    "KA......" */
  26.175 -    0xFF,0x03,0x00,0x0A,0x02,0x4C,0x4E,0x4B,  /* 00000558    ".....LNK" */
  26.176 -    0x42,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000560    "B......." */
  26.177 -    0x03,0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x43,  /* 00000568    "....LNKC" */
  26.178 -    0x00,0x08,0x50,0x52,0x54,0x41,0x12,0x32,  /* 00000570    "..PRTA.2" */
  26.179 -    0x04,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x01,  /* 00000578    "........" */
  26.180 -    0x00,0x00,0x00,0x0A,0x05,0x12,0x0B,0x04,  /* 00000580    "........" */
  26.181 -    0x0C,0xFF,0xFF,0x02,0x00,0x00,0x00,0x0A,  /* 00000588    "........" */
  26.182 -    0x07,0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x03,  /* 00000590    "........" */
  26.183 -    0x00,0x00,0x00,0x0A,0x0A,0x12,0x0B,0x04,  /* 00000598    "........" */
  26.184 -    0x0C,0xFF,0xFF,0x03,0x00,0x00,0x00,0x0A,  /* 000005A0    "........" */
  26.185 -    0x0B,0x5B,0x82,0x48,0x31,0x49,0x53,0x41,  /* 000005A8    ".[.H1ISA" */
  26.186 -    0x5F,0x08,0x5F,0x41,0x44,0x52,0x00,0x5B,  /* 000005B0    "_._ADR.[" */
  26.187 -    0x80,0x50,0x49,0x52,0x51,0x02,0x0A,0x60,  /* 000005B8    ".PIRQ..`" */
  26.188 -    0x0A,0x04,0x10,0x2E,0x5C,0x00,0x5B,0x81,  /* 000005C0    "....\.[." */
  26.189 -    0x29,0x5C,0x2F,0x04,0x5F,0x53,0x42,0x5F,  /* 000005C8    ")\/._SB_" */
  26.190 -    0x50,0x43,0x49,0x30,0x49,0x53,0x41,0x5F,  /* 000005D0    "PCI0ISA_" */
  26.191 -    0x50,0x49,0x52,0x51,0x01,0x50,0x49,0x52,  /* 000005D8    "PIRQ.PIR" */
  26.192 -    0x41,0x08,0x50,0x49,0x52,0x42,0x08,0x50,  /* 000005E0    "A.PIRB.P" */
  26.193 -    0x49,0x52,0x43,0x08,0x50,0x49,0x52,0x44,  /* 000005E8    "IRC.PIRD" */
  26.194 -    0x08,0x5B,0x82,0x46,0x0B,0x53,0x59,0x53,  /* 000005F0    ".[.F.SYS" */
  26.195 -    0x52,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 000005F8    "R._HID.A" */
  26.196 -    0xD0,0x0C,0x02,0x08,0x5F,0x55,0x49,0x44,  /* 00000600    "...._UID" */
  26.197 -    0x01,0x08,0x43,0x52,0x53,0x5F,0x11,0x4E,  /* 00000608    "..CRS_.N" */
  26.198 -    0x08,0x0A,0x8A,0x47,0x01,0x10,0x00,0x10,  /* 00000610    "...G...." */
  26.199 -    0x00,0x00,0x10,0x47,0x01,0x22,0x00,0x22,  /* 00000618    "...G."."" */
  26.200 -    0x00,0x00,0x0C,0x47,0x01,0x30,0x00,0x30,  /* 00000620    "...G.0.0" */
  26.201 -    0x00,0x00,0x10,0x47,0x01,0x44,0x00,0x44,  /* 00000628    "...G.D.D" */
  26.202 -    0x00,0x00,0x1C,0x47,0x01,0x62,0x00,0x62,  /* 00000630    "...G.b.b" */
  26.203 -    0x00,0x00,0x02,0x47,0x01,0x65,0x00,0x65,  /* 00000638    "...G.e.e" */
  26.204 -    0x00,0x00,0x0B,0x47,0x01,0x72,0x00,0x72,  /* 00000640    "...G.r.r" */
  26.205 -    0x00,0x00,0x0E,0x47,0x01,0x80,0x00,0x80,  /* 00000648    "...G...." */
  26.206 -    0x00,0x00,0x01,0x47,0x01,0x84,0x00,0x84,  /* 00000650    "...G...." */
  26.207 -    0x00,0x00,0x03,0x47,0x01,0x88,0x00,0x88,  /* 00000658    "...G...." */
  26.208 -    0x00,0x00,0x01,0x47,0x01,0x8C,0x00,0x8C,  /* 00000660    "...G...." */
  26.209 -    0x00,0x00,0x03,0x47,0x01,0x90,0x00,0x90,  /* 00000668    "...G...." */
  26.210 -    0x00,0x00,0x10,0x47,0x01,0xA2,0x00,0xA2,  /* 00000670    "...G...." */
  26.211 -    0x00,0x00,0x1C,0x47,0x01,0xE0,0x00,0xE0,  /* 00000678    "...G...." */
  26.212 -    0x00,0x00,0x10,0x47,0x01,0xA0,0x08,0xA0,  /* 00000680    "...G...." */
  26.213 -    0x08,0x00,0x04,0x47,0x01,0xC0,0x0C,0xC0,  /* 00000688    "...G...." */
  26.214 -    0x0C,0x00,0x10,0x47,0x01,0xD0,0x04,0xD0,  /* 00000690    "...G...." */
  26.215 -    0x04,0x00,0x02,0x79,0x00,0x14,0x0B,0x5F,  /* 00000698    "...y..._" */
  26.216 -    0x43,0x52,0x53,0x00,0xA4,0x43,0x52,0x53,  /* 000006A0    "CRS..CRS" */
  26.217 -    0x5F,0x5B,0x82,0x2B,0x50,0x49,0x43,0x5F,  /* 000006A8    "_[.+PIC_" */
  26.218 -    0x08,0x5F,0x48,0x49,0x44,0x0B,0x41,0xD0,  /* 000006B0    "._HID.A." */
  26.219 -    0x08,0x5F,0x43,0x52,0x53,0x11,0x18,0x0A,  /* 000006B8    "._CRS..." */
  26.220 -    0x15,0x47,0x01,0x20,0x00,0x20,0x00,0x01,  /* 000006C0    ".G. . .." */
  26.221 -    0x02,0x47,0x01,0xA0,0x00,0xA0,0x00,0x01,  /* 000006C8    ".G......" */
  26.222 -    0x02,0x22,0x04,0x00,0x79,0x00,0x5B,0x82,  /* 000006D0    "."..y.[." */
  26.223 -    0x47,0x05,0x44,0x4D,0x41,0x30,0x08,0x5F,  /* 000006D8    "G.DMA0._" */
  26.224 -    0x48,0x49,0x44,0x0C,0x41,0xD0,0x02,0x00,  /* 000006E0    "HID.A..." */
  26.225 -    0x08,0x5F,0x43,0x52,0x53,0x11,0x41,0x04,  /* 000006E8    "._CRS.A." */
  26.226 -    0x0A,0x3D,0x2A,0x10,0x04,0x47,0x01,0x00,  /* 000006F0    ".=*..G.." */
  26.227 -    0x00,0x00,0x00,0x00,0x10,0x47,0x01,0x81,  /* 000006F8    ".....G.." */
  26.228 -    0x00,0x81,0x00,0x00,0x03,0x47,0x01,0x87,  /* 00000700    ".....G.." */
  26.229 -    0x00,0x87,0x00,0x00,0x01,0x47,0x01,0x89,  /* 00000708    ".....G.." */
  26.230 -    0x00,0x89,0x00,0x00,0x03,0x47,0x01,0x8F,  /* 00000710    ".....G.." */
  26.231 -    0x00,0x8F,0x00,0x00,0x01,0x47,0x01,0xC0,  /* 00000718    ".....G.." */
  26.232 -    0x00,0xC0,0x00,0x00,0x20,0x47,0x01,0x80,  /* 00000720    ".... G.." */
  26.233 -    0x04,0x80,0x04,0x00,0x10,0x79,0x00,0x5B,  /* 00000728    ".....y.[" */
  26.234 -    0x82,0x25,0x54,0x4D,0x52,0x5F,0x08,0x5F,  /* 00000730    ".%TMR_._" */
  26.235 -    0x48,0x49,0x44,0x0C,0x41,0xD0,0x01,0x00,  /* 00000738    "HID.A..." */
  26.236 -    0x08,0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,  /* 00000740    "._CRS..." */
  26.237 -    0x0D,0x47,0x01,0x40,0x00,0x40,0x00,0x00,  /* 00000748    ".G.@.@.." */
  26.238 -    0x04,0x22,0x01,0x00,0x79,0x00,0x5B,0x82,  /* 00000750    "."..y.[." */
  26.239 -    0x25,0x52,0x54,0x43,0x5F,0x08,0x5F,0x48,  /* 00000758    "%RTC_._H" */
  26.240 -    0x49,0x44,0x0C,0x41,0xD0,0x0B,0x00,0x08,  /* 00000760    "ID.A...." */
  26.241 -    0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,0x0D,  /* 00000768    "_CRS...." */
  26.242 -    0x47,0x01,0x70,0x00,0x70,0x00,0x00,0x02,  /* 00000770    "G.p.p..." */
  26.243 -    0x22,0x00,0x01,0x79,0x00,0x5B,0x82,0x22,  /* 00000778    ""..y.[."" */
  26.244 -    0x53,0x50,0x4B,0x52,0x08,0x5F,0x48,0x49,  /* 00000780    "SPKR._HI" */
  26.245 -    0x44,0x0C,0x41,0xD0,0x08,0x00,0x08,0x5F,  /* 00000788    "D.A...._" */
  26.246 -    0x43,0x52,0x53,0x11,0x0D,0x0A,0x0A,0x47,  /* 00000790    "CRS....G" */
  26.247 -    0x01,0x61,0x00,0x61,0x00,0x00,0x01,0x79,  /* 00000798    ".a.a...y" */
  26.248 -    0x00,0x5B,0x82,0x31,0x50,0x53,0x32,0x4D,  /* 000007A0    ".[.1PS2M" */
  26.249 +    0x50,0x49,0x43,0x44,0x10,0x49,0x85,0x5F,  /* 000000B0    "PICD.I._" */
  26.250 +    0x53,0x42,0x5F,0x5B,0x82,0x49,0x04,0x4D,  /* 000000B8    "SB_[.I.M" */
  26.251 +    0x45,0x4D,0x30,0x08,0x5F,0x48,0x49,0x44,  /* 000000C0    "EM0._HID" */
  26.252 +    0x0C,0x41,0xD0,0x0C,0x02,0x08,0x5F,0x43,  /* 000000C8    ".A...._C" */
  26.253 +    0x52,0x53,0x11,0x33,0x0A,0x30,0x8A,0x2B,  /* 000000D0    "RS.3.0.+" */
  26.254 +    0x00,0x00,0x0D,0x03,0x00,0x00,0x00,0x00,  /* 000000D8    "........" */
  26.255 +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000E0    "........" */
  26.256 +    0x00,0x00,0x00,0x00,0xFF,0xFF,0x09,0x00,  /* 000000E8    "........" */
  26.257 +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000000F0    "........" */
  26.258 +    0x00,0x00,0x00,0x00,0x00,0x00,0x0A,0x00,  /* 000000F8    "........" */
  26.259 +    0x00,0x00,0x00,0x00,0x79,0x00,0x5B,0x82,  /* 00000100    "....y.[." */
  26.260 +    0x46,0x80,0x50,0x43,0x49,0x30,0x08,0x5F,  /* 00000108    "F.PCI0._" */
  26.261 +    0x48,0x49,0x44,0x0C,0x41,0xD0,0x0A,0x03,  /* 00000110    "HID.A..." */
  26.262 +    0x08,0x5F,0x55,0x49,0x44,0x00,0x08,0x5F,  /* 00000118    "._UID.._" */
  26.263 +    0x41,0x44,0x52,0x00,0x08,0x5F,0x42,0x42,  /* 00000120    "ADR.._BB" */
  26.264 +    0x4E,0x00,0x5B,0x80,0x50,0x49,0x52,0x50,  /* 00000128    "N.[.PIRP" */
  26.265 +    0x02,0x0A,0x3C,0x0A,0x10,0x5B,0x81,0x24,  /* 00000130    "..<..[.$" */
  26.266 +    0x50,0x49,0x52,0x50,0x01,0x49,0x52,0x51,  /* 00000138    "PIRP.IRQ" */
  26.267 +    0x33,0x03,0x49,0x52,0x51,0x35,0x05,0x49,  /* 00000140    "3.IRQ5.I" */
  26.268 +    0x52,0x51,0x37,0x07,0x49,0x52,0x51,0x39,  /* 00000148    "RQ7.IRQ9" */
  26.269 +    0x09,0x49,0x52,0x51,0x41,0x0A,0x49,0x52,  /* 00000150    ".IRQA.IR" */
  26.270 +    0x51,0x42,0x0B,0x14,0x48,0x0D,0x5F,0x43,  /* 00000158    "QB..H._C" */
  26.271 +    0x52,0x53,0x00,0x08,0x50,0x52,0x54,0x30,  /* 00000160    "RS..PRT0" */
  26.272 +    0x11,0x46,0x0C,0x0A,0xC2,0x88,0x0D,0x00,  /* 00000168    ".F......" */
  26.273 +    0x02,0x0F,0x00,0x00,0x00,0x00,0x00,0xFF,  /* 00000170    "........" */
  26.274 +    0x00,0x00,0x00,0x00,0x01,0x47,0x01,0xF8,  /* 00000178    ".....G.." */
  26.275 +    0x0C,0xF8,0x0C,0x01,0x08,0x88,0x0D,0x00,  /* 00000180    "........" */
  26.276 +    0x01,0x0C,0x03,0x00,0x00,0x00,0x00,0xF7,  /* 00000188    "........" */
  26.277 +    0x0C,0x00,0x00,0xF8,0x0C,0x88,0x0D,0x00,  /* 00000190    "........" */
  26.278 +    0x01,0x0C,0x03,0x00,0x00,0x00,0x0D,0xFF,  /* 00000198    "........" */
  26.279 +    0x0F,0x00,0x00,0x00,0x03,0x88,0x0D,0x00,  /* 000001A0    "........" */
  26.280 +    0x01,0x0D,0x03,0x00,0x00,0x00,0xC0,0x1F,  /* 000001A8    "........" */
  26.281 +    0xC0,0x00,0x00,0x20,0x00,0x88,0x0D,0x00,  /* 000001B0    "... ...." */
  26.282 +    0x01,0x0D,0x03,0x00,0x00,0x20,0xC0,0x3F,  /* 000001B8    "..... .?" */
  26.283 +    0xC0,0x00,0x00,0x10,0x00,0x87,0x17,0x00,  /* 000001C0    "........" */
  26.284 +    0x00,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,  /* 000001C8    "........" */
  26.285 +    0x00,0x0C,0x00,0xFF,0xFF,0x0F,0x00,0x00,  /* 000001D0    "........" */
  26.286 +    0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x87,  /* 000001D8    "........" */
  26.287 +    0x17,0x00,0x00,0x0D,0x03,0x00,0x00,0x00,  /* 000001E0    "........" */
  26.288 +    0x00,0x00,0x00,0x00,0xF0,0xFF,0xFF,0xFF,  /* 000001E8    "........" */
  26.289 +    0xF1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 000001F0    "........" */
  26.290 +    0x02,0x87,0x17,0x00,0x00,0x0D,0x03,0x00,  /* 000001F8    "........" */
  26.291 +    0x00,0x00,0x00,0x00,0x00,0x00,0xF2,0xFF,  /* 00000200    "........" */
  26.292 +    0x0F,0x00,0xF2,0x00,0x00,0x00,0x00,0x00,  /* 00000208    "........" */
  26.293 +    0x10,0x00,0x00,0x87,0x17,0x00,0x00,0x0D,  /* 00000210    "........" */
  26.294 +    0x03,0x00,0x00,0x00,0x00,0x00,0x10,0x00,  /* 00000218    "........" */
  26.295 +    0xF2,0x1F,0x10,0x00,0xF2,0x00,0x00,0x00,  /* 00000220    "........" */
  26.296 +    0x00,0x20,0x00,0x00,0x00,0x79,0x00,0xA4,  /* 00000228    ". ...y.." */
  26.297 +    0x50,0x52,0x54,0x30,0x08,0x42,0x55,0x46,  /* 00000230    "PRT0.BUF" */
  26.298 +    0x41,0x11,0x09,0x0A,0x06,0x23,0xF8,0xDC,  /* 00000238    "A....#.." */
  26.299 +    0x18,0x79,0x00,0x08,0x42,0x55,0x46,0x42,  /* 00000240    ".y..BUFB" */
  26.300 +    0x11,0x09,0x0A,0x06,0x23,0x00,0x00,0x18,  /* 00000248    "....#..." */
  26.301 +    0x79,0x00,0x8B,0x42,0x55,0x46,0x42,0x01,  /* 00000250    "y..BUFB." */
  26.302 +    0x49,0x52,0x51,0x56,0x08,0x42,0x55,0x46,  /* 00000258    "IRQV.BUF" */
  26.303 +    0x43,0x11,0x07,0x0A,0x04,0x05,0x07,0x0A,  /* 00000260    "C......." */
  26.304 +    0x0B,0x8C,0x42,0x55,0x46,0x43,0x01,0x50,  /* 00000268    "..BUFC.P" */
  26.305 +    0x49,0x51,0x41,0x8C,0x42,0x55,0x46,0x43,  /* 00000270    "IQA.BUFC" */
  26.306 +    0x01,0x50,0x49,0x51,0x42,0x8C,0x42,0x55,  /* 00000278    ".PIQB.BU" */
  26.307 +    0x46,0x43,0x01,0x50,0x49,0x51,0x43,0x8C,  /* 00000280    "FC.PIQC." */
  26.308 +    0x42,0x55,0x46,0x43,0x01,0x50,0x49,0x51,  /* 00000288    "BUFC.PIQ" */
  26.309 +    0x44,0x5B,0x82,0x48,0x08,0x4C,0x4E,0x4B,  /* 00000290    "D[.H.LNK" */
  26.310 +    0x41,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000298    "A._HID.A" */
  26.311 +    0xD0,0x0C,0x0F,0x08,0x5F,0x55,0x49,0x44,  /* 000002A0    "...._UID" */
  26.312 +    0x01,0x14,0x1C,0x5F,0x53,0x54,0x41,0x00,  /* 000002A8    "..._STA." */
  26.313 +    0x7B,0x50,0x49,0x52,0x41,0x0A,0x80,0x60,  /* 000002B0    "{PIRA..`" */
  26.314 +    0xA0,0x08,0x93,0x60,0x0A,0x80,0xA4,0x0A,  /* 000002B8    "...`...." */
  26.315 +    0x09,0xA1,0x04,0xA4,0x0A,0x0B,0x14,0x0B,  /* 000002C0    "........" */
  26.316 +    0x5F,0x50,0x52,0x53,0x00,0xA4,0x42,0x55,  /* 000002C8    "_PRS..BU" */
  26.317 +    0x46,0x41,0x14,0x11,0x5F,0x44,0x49,0x53,  /* 000002D0    "FA.._DIS" */
  26.318 +    0x00,0x7D,0x50,0x49,0x52,0x41,0x0A,0x80,  /* 000002D8    ".}PIRA.." */
  26.319 +    0x50,0x49,0x52,0x41,0x14,0x1A,0x5F,0x43,  /* 000002E0    "PIRA.._C" */
  26.320 +    0x52,0x53,0x00,0x7B,0x50,0x49,0x52,0x42,  /* 000002E8    "RS.{PIRB" */
  26.321 +    0x0A,0x0F,0x60,0x79,0x01,0x60,0x49,0x52,  /* 000002F0    "..`y.`IR" */
  26.322 +    0x51,0x56,0xA4,0x42,0x55,0x46,0x42,0x14,  /* 000002F8    "QV.BUFB." */
  26.323 +    0x1B,0x5F,0x53,0x52,0x53,0x01,0x8B,0x68,  /* 00000300    "._SRS..h" */
  26.324 +    0x01,0x49,0x52,0x51,0x31,0x82,0x49,0x52,  /* 00000308    ".IRQ1.IR" */
  26.325 +    0x51,0x31,0x60,0x76,0x60,0x70,0x60,0x50,  /* 00000310    "Q1`v`p`P" */
  26.326 +    0x49,0x52,0x41,0x5B,0x82,0x49,0x08,0x4C,  /* 00000318    "IRA[.I.L" */
  26.327 +    0x4E,0x4B,0x42,0x08,0x5F,0x48,0x49,0x44,  /* 00000320    "NKB._HID" */
  26.328 +    0x0C,0x41,0xD0,0x0C,0x0F,0x08,0x5F,0x55,  /* 00000328    ".A...._U" */
  26.329 +    0x49,0x44,0x0A,0x02,0x14,0x1C,0x5F,0x53,  /* 00000330    "ID...._S" */
  26.330 +    0x54,0x41,0x00,0x7B,0x50,0x49,0x52,0x42,  /* 00000338    "TA.{PIRB" */
  26.331 +    0x0A,0x80,0x60,0xA0,0x08,0x93,0x60,0x0A,  /* 00000340    "..`...`." */
  26.332 +    0x80,0xA4,0x0A,0x09,0xA1,0x04,0xA4,0x0A,  /* 00000348    "........" */
  26.333 +    0x0B,0x14,0x0B,0x5F,0x50,0x52,0x53,0x00,  /* 00000350    "..._PRS." */
  26.334 +    0xA4,0x42,0x55,0x46,0x41,0x14,0x11,0x5F,  /* 00000358    ".BUFA.._" */
  26.335 +    0x44,0x49,0x53,0x00,0x7D,0x50,0x49,0x52,  /* 00000360    "DIS.}PIR" */
  26.336 +    0x42,0x0A,0x80,0x50,0x49,0x52,0x42,0x14,  /* 00000368    "B..PIRB." */
  26.337 +    0x1A,0x5F,0x43,0x52,0x53,0x00,0x7B,0x50,  /* 00000370    "._CRS.{P" */
  26.338 +    0x49,0x52,0x42,0x0A,0x0F,0x60,0x79,0x01,  /* 00000378    "IRB..`y." */
  26.339 +    0x60,0x49,0x52,0x51,0x56,0xA4,0x42,0x55,  /* 00000380    "`IRQV.BU" */
  26.340 +    0x46,0x42,0x14,0x1B,0x5F,0x53,0x52,0x53,  /* 00000388    "FB.._SRS" */
  26.341 +    0x01,0x8B,0x68,0x01,0x49,0x52,0x51,0x31,  /* 00000390    "..h.IRQ1" */
  26.342 +    0x82,0x49,0x52,0x51,0x31,0x60,0x76,0x60,  /* 00000398    ".IRQ1`v`" */
  26.343 +    0x70,0x60,0x50,0x49,0x52,0x42,0x5B,0x82,  /* 000003A0    "p`PIRB[." */
  26.344 +    0x49,0x08,0x4C,0x4E,0x4B,0x43,0x08,0x5F,  /* 000003A8    "I.LNKC._" */
  26.345 +    0x48,0x49,0x44,0x0C,0x41,0xD0,0x0C,0x0F,  /* 000003B0    "HID.A..." */
  26.346 +    0x08,0x5F,0x55,0x49,0x44,0x0A,0x03,0x14,  /* 000003B8    "._UID..." */
  26.347 +    0x1C,0x5F,0x53,0x54,0x41,0x00,0x7B,0x50,  /* 000003C0    "._STA.{P" */
  26.348 +    0x49,0x52,0x43,0x0A,0x80,0x60,0xA0,0x08,  /* 000003C8    "IRC..`.." */
  26.349 +    0x93,0x60,0x0A,0x80,0xA4,0x0A,0x09,0xA1,  /* 000003D0    ".`......" */
  26.350 +    0x04,0xA4,0x0A,0x0B,0x14,0x0B,0x5F,0x50,  /* 000003D8    "......_P" */
  26.351 +    0x52,0x53,0x00,0xA4,0x42,0x55,0x46,0x41,  /* 000003E0    "RS..BUFA" */
  26.352 +    0x14,0x11,0x5F,0x44,0x49,0x53,0x00,0x7D,  /* 000003E8    ".._DIS.}" */
  26.353 +    0x50,0x49,0x52,0x43,0x0A,0x80,0x50,0x49,  /* 000003F0    "PIRC..PI" */
  26.354 +    0x52,0x43,0x14,0x1A,0x5F,0x43,0x52,0x53,  /* 000003F8    "RC.._CRS" */
  26.355 +    0x00,0x7B,0x50,0x49,0x52,0x43,0x0A,0x0F,  /* 00000400    ".{PIRC.." */
  26.356 +    0x60,0x79,0x01,0x60,0x49,0x52,0x51,0x56,  /* 00000408    "`y.`IRQV" */
  26.357 +    0xA4,0x42,0x55,0x46,0x42,0x14,0x1B,0x5F,  /* 00000410    ".BUFB.._" */
  26.358 +    0x53,0x52,0x53,0x01,0x8B,0x68,0x01,0x49,  /* 00000418    "SRS..h.I" */
  26.359 +    0x52,0x51,0x31,0x82,0x49,0x52,0x51,0x31,  /* 00000420    "RQ1.IRQ1" */
  26.360 +    0x60,0x76,0x60,0x70,0x60,0x50,0x49,0x52,  /* 00000428    "`v`p`PIR" */
  26.361 +    0x43,0x5B,0x82,0x49,0x08,0x4C,0x4E,0x4B,  /* 00000430    "C[.I.LNK" */
  26.362 +    0x44,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000438    "D._HID.A" */
  26.363 +    0xD0,0x0C,0x0F,0x08,0x5F,0x55,0x49,0x44,  /* 00000440    "...._UID" */
  26.364 +    0x0A,0x04,0x14,0x1C,0x5F,0x53,0x54,0x41,  /* 00000448    "...._STA" */
  26.365 +    0x00,0x7B,0x50,0x49,0x52,0x44,0x0A,0x80,  /* 00000450    ".{PIRD.." */
  26.366 +    0x60,0xA0,0x08,0x93,0x60,0x0A,0x80,0xA4,  /* 00000458    "`...`..." */
  26.367 +    0x0A,0x09,0xA1,0x04,0xA4,0x0A,0x0B,0x14,  /* 00000460    "........" */
  26.368 +    0x0B,0x5F,0x50,0x52,0x53,0x00,0xA4,0x42,  /* 00000468    "._PRS..B" */
  26.369 +    0x55,0x46,0x41,0x14,0x11,0x5F,0x44,0x49,  /* 00000470    "UFA.._DI" */
  26.370 +    0x53,0x00,0x7D,0x50,0x49,0x52,0x44,0x0A,  /* 00000478    "S.}PIRD." */
  26.371 +    0x80,0x50,0x49,0x52,0x44,0x14,0x1A,0x5F,  /* 00000480    ".PIRD.._" */
  26.372 +    0x43,0x52,0x53,0x00,0x7B,0x50,0x49,0x52,  /* 00000488    "CRS.{PIR" */
  26.373 +    0x44,0x0A,0x0F,0x60,0x79,0x01,0x60,0x49,  /* 00000490    "D..`y.`I" */
  26.374 +    0x52,0x51,0x56,0xA4,0x42,0x55,0x46,0x42,  /* 00000498    "RQV.BUFB" */
  26.375 +    0x14,0x1B,0x5F,0x53,0x52,0x53,0x01,0x8B,  /* 000004A0    ".._SRS.." */
  26.376 +    0x68,0x01,0x49,0x52,0x51,0x31,0x82,0x49,  /* 000004A8    "h.IRQ1.I" */
  26.377 +    0x52,0x51,0x31,0x60,0x76,0x60,0x70,0x60,  /* 000004B0    "RQ1`v`p`" */
  26.378 +    0x50,0x49,0x52,0x44,0x14,0x16,0x5F,0x50,  /* 000004B8    "PIRD.._P" */
  26.379 +    0x52,0x54,0x00,0xA0,0x0A,0x50,0x49,0x43,  /* 000004C0    "RT...PIC" */
  26.380 +    0x44,0xA4,0x50,0x52,0x54,0x41,0xA4,0x50,  /* 000004C8    "D.PRTA.P" */
  26.381 +    0x52,0x54,0x50,0x08,0x50,0x52,0x54,0x50,  /* 000004D0    "RTP.PRTP" */
  26.382 +    0x12,0x43,0x0E,0x10,0x12,0x0B,0x04,0x0B,  /* 000004D8    ".C......" */
  26.383 +    0xFF,0xFF,0x00,0x4C,0x4E,0x4B,0x41,0x00,  /* 000004E0    "...LNKA." */
  26.384 +    0x12,0x0B,0x04,0x0B,0xFF,0xFF,0x01,0x4C,  /* 000004E8    ".......L" */
  26.385 +    0x4E,0x4B,0x42,0x00,0x12,0x0C,0x04,0x0B,  /* 000004F0    "NKB....." */
  26.386 +    0xFF,0xFF,0x0A,0x02,0x4C,0x4E,0x4B,0x43,  /* 000004F8    "....LNKC" */
  26.387 +    0x00,0x12,0x0C,0x04,0x0B,0xFF,0xFF,0x0A,  /* 00000500    "........" */
  26.388 +    0x03,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000508    ".LNKD..." */
  26.389 +    0x04,0x0C,0xFF,0xFF,0x01,0x00,0x00,0x4C,  /* 00000510    ".......L" */
  26.390 +    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000518    "NKB....." */
  26.391 +    0xFF,0xFF,0x01,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000520    ".....LNK" */
  26.392 +    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000528    "C......." */
  26.393 +    0x01,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000530    "....LNKD" */
  26.394 +    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x01,  /* 00000538    "........" */
  26.395 +    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000540    "...LNKA." */
  26.396 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 00000548    "........" */
  26.397 +    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 00000550    ".LNKC..." */
  26.398 +    0x04,0x0C,0xFF,0xFF,0x02,0x00,0x01,0x4C,  /* 00000558    ".......L" */
  26.399 +    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 00000560    "NKD....." */
  26.400 +    0xFF,0xFF,0x02,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000568    "......LN" */
  26.401 +    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000570    "KA......" */
  26.402 +    0xFF,0x02,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000578    ".....LNK" */
  26.403 +    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000580    "B......." */
  26.404 +    0x03,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000588    "...LNKD." */
  26.405 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x03,0x00,  /* 00000590    "........" */
  26.406 +    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 00000598    ".LNKA..." */
  26.407 +    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x02,  /* 000005A0    "........" */
  26.408 +    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000005A8    "LNKB...." */
  26.409 +    0x0C,0xFF,0xFF,0x03,0x00,0x0A,0x03,0x4C,  /* 000005B0    ".......L" */
  26.410 +    0x4E,0x4B,0x43,0x00,0x08,0x50,0x52,0x54,  /* 000005B8    "NKC..PRT" */
  26.411 +    0x41,0x12,0x32,0x04,0x12,0x0B,0x04,0x0C,  /* 000005C0    "A.2....." */
  26.412 +    0xFF,0xFF,0x01,0x00,0x00,0x00,0x0A,0x05,  /* 000005C8    "........" */
  26.413 +    0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x02,0x00,  /* 000005D0    "........" */
  26.414 +    0x00,0x00,0x0A,0x07,0x12,0x0B,0x04,0x0C,  /* 000005D8    "........" */
  26.415 +    0xFF,0xFF,0x03,0x00,0x00,0x00,0x0A,0x0A,  /* 000005E0    "........" */
  26.416 +    0x12,0x0B,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 000005E8    "........" */
  26.417 +    0x00,0x00,0x0A,0x0B,0x5B,0x82,0x48,0x31,  /* 000005F0    "....[.H1" */
  26.418 +    0x49,0x53,0x41,0x5F,0x08,0x5F,0x41,0x44,  /* 000005F8    "ISA_._AD" */
  26.419 +    0x52,0x00,0x5B,0x80,0x50,0x49,0x52,0x51,  /* 00000600    "R.[.PIRQ" */
  26.420 +    0x02,0x0A,0x60,0x0A,0x04,0x10,0x2E,0x5C,  /* 00000608    "..`....\" */
  26.421 +    0x00,0x5B,0x81,0x29,0x5C,0x2F,0x04,0x5F,  /* 00000610    ".[.)\/._" */
  26.422 +    0x53,0x42,0x5F,0x50,0x43,0x49,0x30,0x49,  /* 00000618    "SB_PCI0I" */
  26.423 +    0x53,0x41,0x5F,0x50,0x49,0x52,0x51,0x01,  /* 00000620    "SA_PIRQ." */
  26.424 +    0x50,0x49,0x52,0x41,0x08,0x50,0x49,0x52,  /* 00000628    "PIRA.PIR" */
  26.425 +    0x42,0x08,0x50,0x49,0x52,0x43,0x08,0x50,  /* 00000630    "B.PIRC.P" */
  26.426 +    0x49,0x52,0x44,0x08,0x5B,0x82,0x46,0x0B,  /* 00000638    "IRD.[.F." */
  26.427 +    0x53,0x59,0x53,0x52,0x08,0x5F,0x48,0x49,  /* 00000640    "SYSR._HI" */
  26.428 +    0x44,0x0C,0x41,0xD0,0x0C,0x02,0x08,0x5F,  /* 00000648    "D.A...._" */
  26.429 +    0x55,0x49,0x44,0x01,0x08,0x43,0x52,0x53,  /* 00000650    "UID..CRS" */
  26.430 +    0x5F,0x11,0x4E,0x08,0x0A,0x8A,0x47,0x01,  /* 00000658    "_.N...G." */
  26.431 +    0x10,0x00,0x10,0x00,0x00,0x10,0x47,0x01,  /* 00000660    "......G." */
  26.432 +    0x22,0x00,0x22,0x00,0x00,0x0C,0x47,0x01,  /* 00000668    ""."...G." */
  26.433 +    0x30,0x00,0x30,0x00,0x00,0x10,0x47,0x01,  /* 00000670    "0.0...G." */
  26.434 +    0x44,0x00,0x44,0x00,0x00,0x1C,0x47,0x01,  /* 00000678    "D.D...G." */
  26.435 +    0x62,0x00,0x62,0x00,0x00,0x02,0x47,0x01,  /* 00000680    "b.b...G." */
  26.436 +    0x65,0x00,0x65,0x00,0x00,0x0B,0x47,0x01,  /* 00000688    "e.e...G." */
  26.437 +    0x72,0x00,0x72,0x00,0x00,0x0E,0x47,0x01,  /* 00000690    "r.r...G." */
  26.438 +    0x80,0x00,0x80,0x00,0x00,0x01,0x47,0x01,  /* 00000698    "......G." */
  26.439 +    0x84,0x00,0x84,0x00,0x00,0x03,0x47,0x01,  /* 000006A0    "......G." */
  26.440 +    0x88,0x00,0x88,0x00,0x00,0x01,0x47,0x01,  /* 000006A8    "......G." */
  26.441 +    0x8C,0x00,0x8C,0x00,0x00,0x03,0x47,0x01,  /* 000006B0    "......G." */
  26.442 +    0x90,0x00,0x90,0x00,0x00,0x10,0x47,0x01,  /* 000006B8    "......G." */
  26.443 +    0xA2,0x00,0xA2,0x00,0x00,0x1C,0x47,0x01,  /* 000006C0    "......G." */
  26.444 +    0xE0,0x00,0xE0,0x00,0x00,0x10,0x47,0x01,  /* 000006C8    "......G." */
  26.445 +    0xA0,0x08,0xA0,0x08,0x00,0x04,0x47,0x01,  /* 000006D0    "......G." */
  26.446 +    0xC0,0x0C,0xC0,0x0C,0x00,0x10,0x47,0x01,  /* 000006D8    "......G." */
  26.447 +    0xD0,0x04,0xD0,0x04,0x00,0x02,0x79,0x00,  /* 000006E0    "......y." */
  26.448 +    0x14,0x0B,0x5F,0x43,0x52,0x53,0x00,0xA4,  /* 000006E8    ".._CRS.." */
  26.449 +    0x43,0x52,0x53,0x5F,0x5B,0x82,0x2B,0x50,  /* 000006F0    "CRS_[.+P" */
  26.450 +    0x49,0x43,0x5F,0x08,0x5F,0x48,0x49,0x44,  /* 000006F8    "IC_._HID" */
  26.451 +    0x0B,0x41,0xD0,0x08,0x5F,0x43,0x52,0x53,  /* 00000700    ".A.._CRS" */
  26.452 +    0x11,0x18,0x0A,0x15,0x47,0x01,0x20,0x00,  /* 00000708    "....G. ." */
  26.453 +    0x20,0x00,0x01,0x02,0x47,0x01,0xA0,0x00,  /* 00000710    " ...G..." */
  26.454 +    0xA0,0x00,0x01,0x02,0x22,0x04,0x00,0x79,  /* 00000718    "...."..y" */
  26.455 +    0x00,0x5B,0x82,0x47,0x05,0x44,0x4D,0x41,  /* 00000720    ".[.G.DMA" */
  26.456 +    0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000728    "0._HID.A" */
  26.457 +    0xD0,0x02,0x00,0x08,0x5F,0x43,0x52,0x53,  /* 00000730    "...._CRS" */
  26.458 +    0x11,0x41,0x04,0x0A,0x3D,0x2A,0x10,0x04,  /* 00000738    ".A..=*.." */
  26.459 +    0x47,0x01,0x00,0x00,0x00,0x00,0x00,0x10,  /* 00000740    "G......." */
  26.460 +    0x47,0x01,0x81,0x00,0x81,0x00,0x00,0x03,  /* 00000748    "G......." */
  26.461 +    0x47,0x01,0x87,0x00,0x87,0x00,0x00,0x01,  /* 00000750    "G......." */
  26.462 +    0x47,0x01,0x89,0x00,0x89,0x00,0x00,0x03,  /* 00000758    "G......." */
  26.463 +    0x47,0x01,0x8F,0x00,0x8F,0x00,0x00,0x01,  /* 00000760    "G......." */
  26.464 +    0x47,0x01,0xC0,0x00,0xC0,0x00,0x00,0x20,  /* 00000768    "G...... " */
  26.465 +    0x47,0x01,0x80,0x04,0x80,0x04,0x00,0x10,  /* 00000770    "G......." */
  26.466 +    0x79,0x00,0x5B,0x82,0x25,0x54,0x4D,0x52,  /* 00000778    "y.[.%TMR" */
  26.467 +    0x5F,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000780    "_._HID.A" */
  26.468 +    0xD0,0x01,0x00,0x08,0x5F,0x43,0x52,0x53,  /* 00000788    "...._CRS" */
  26.469 +    0x11,0x10,0x0A,0x0D,0x47,0x01,0x40,0x00,  /* 00000790    "....G.@." */
  26.470 +    0x40,0x00,0x00,0x04,0x22,0x01,0x00,0x79,  /* 00000798    "@..."..y" */
  26.471 +    0x00,0x5B,0x82,0x25,0x52,0x54,0x43,0x5F,  /* 000007A0    ".[.%RTC_" */
  26.472      0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 000007A8    "._HID.A." */
  26.473 -    0x0F,0x13,0x08,0x5F,0x43,0x49,0x44,0x0C,  /* 000007B0    "..._CID." */
  26.474 -    0x41,0xD0,0x0F,0x13,0x14,0x09,0x5F,0x53,  /* 000007B8    "A....._S" */
  26.475 -    0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,  /* 000007C0    "TA....._" */
  26.476 -    0x43,0x52,0x53,0x11,0x08,0x0A,0x05,0x22,  /* 000007C8    "CRS...."" */
  26.477 -    0x00,0x10,0x79,0x00,0x5B,0x82,0x42,0x04,  /* 000007D0    "..y.[.B." */
  26.478 -    0x50,0x53,0x32,0x4B,0x08,0x5F,0x48,0x49,  /* 000007D8    "PS2K._HI" */
  26.479 -    0x44,0x0C,0x41,0xD0,0x03,0x03,0x08,0x5F,  /* 000007E0    "D.A...._" */
  26.480 -    0x43,0x49,0x44,0x0C,0x41,0xD0,0x03,0x0B,  /* 000007E8    "CID.A..." */
  26.481 -    0x14,0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,  /* 000007F0    ".._STA.." */
  26.482 -    0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 000007F8    "..._CRS." */
  26.483 -    0x18,0x0A,0x15,0x47,0x01,0x60,0x00,0x60,  /* 00000800    "...G.`.`" */
  26.484 -    0x00,0x00,0x01,0x47,0x01,0x64,0x00,0x64,  /* 00000808    "...G.d.d" */
  26.485 -    0x00,0x00,0x01,0x22,0x02,0x00,0x79,0x00,  /* 00000810    "..."..y." */
  26.486 -    0x5B,0x82,0x3A,0x46,0x44,0x43,0x30,0x08,  /* 00000818    "[.:FDC0." */
  26.487 -    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x07,  /* 00000820    "_HID.A.." */
  26.488 -    0x00,0x14,0x09,0x5F,0x53,0x54,0x41,0x00,  /* 00000828    "..._STA." */
  26.489 -    0xA4,0x0A,0x0F,0x08,0x5F,0x43,0x52,0x53,  /* 00000830    "...._CRS" */
  26.490 -    0x11,0x1B,0x0A,0x18,0x47,0x01,0xF0,0x03,  /* 00000838    "....G..." */
  26.491 -    0xF0,0x03,0x01,0x06,0x47,0x01,0xF7,0x03,  /* 00000840    "....G..." */
  26.492 -    0xF7,0x03,0x01,0x01,0x22,0x40,0x00,0x2A,  /* 00000848    "...."@.*" */
  26.493 -    0x04,0x00,0x79,0x00,0x5B,0x82,0x35,0x55,  /* 00000850    "..y.[.5U" */
  26.494 -    0x41,0x52,0x31,0x08,0x5F,0x48,0x49,0x44,  /* 00000858    "AR1._HID" */
  26.495 -    0x0C,0x41,0xD0,0x05,0x01,0x08,0x5F,0x55,  /* 00000860    ".A...._U" */
  26.496 -    0x49,0x44,0x01,0x14,0x09,0x5F,0x53,0x54,  /* 00000868    "ID..._ST" */
  26.497 -    0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,  /* 00000870    "A....._C" */
  26.498 -    0x52,0x53,0x11,0x10,0x0A,0x0D,0x47,0x01,  /* 00000878    "RS....G." */
  26.499 -    0xF8,0x03,0xF8,0x03,0x01,0x08,0x22,0x10,  /* 00000880    "......"." */
  26.500 -    0x00,0x79,0x00,0x5B,0x82,0x36,0x55,0x41,  /* 00000888    ".y.[.6UA" */
  26.501 -    0x52,0x32,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000890    "R2._HID." */
  26.502 -    0x41,0xD0,0x05,0x01,0x08,0x5F,0x55,0x49,  /* 00000898    "A...._UI" */
  26.503 -    0x44,0x0A,0x02,0x14,0x09,0x5F,0x53,0x54,  /* 000008A0    "D...._ST" */
  26.504 -    0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,  /* 000008A8    "A....._C" */
  26.505 -    0x52,0x53,0x11,0x10,0x0A,0x0D,0x47,0x01,  /* 000008B0    "RS....G." */
  26.506 -    0xF8,0x02,0xF8,0x02,0x01,0x08,0x22,0x08,  /* 000008B8    "......"." */
  26.507 -    0x00,0x79,0x00,
  26.508 +    0x0B,0x00,0x08,0x5F,0x43,0x52,0x53,0x11,  /* 000007B0    "..._CRS." */
  26.509 +    0x10,0x0A,0x0D,0x47,0x01,0x70,0x00,0x70,  /* 000007B8    "...G.p.p" */
  26.510 +    0x00,0x00,0x02,0x22,0x00,0x01,0x79,0x00,  /* 000007C0    "..."..y." */
  26.511 +    0x5B,0x82,0x22,0x53,0x50,0x4B,0x52,0x08,  /* 000007C8    "[."SPKR." */
  26.512 +    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x08,  /* 000007D0    "_HID.A.." */
  26.513 +    0x00,0x08,0x5F,0x43,0x52,0x53,0x11,0x0D,  /* 000007D8    ".._CRS.." */
  26.514 +    0x0A,0x0A,0x47,0x01,0x61,0x00,0x61,0x00,  /* 000007E0    "..G.a.a." */
  26.515 +    0x00,0x01,0x79,0x00,0x5B,0x82,0x31,0x50,  /* 000007E8    "..y.[.1P" */
  26.516 +    0x53,0x32,0x4D,0x08,0x5F,0x48,0x49,0x44,  /* 000007F0    "S2M._HID" */
  26.517 +    0x0C,0x41,0xD0,0x0F,0x13,0x08,0x5F,0x43,  /* 000007F8    ".A...._C" */
  26.518 +    0x49,0x44,0x0C,0x41,0xD0,0x0F,0x13,0x14,  /* 00000800    "ID.A...." */
  26.519 +    0x09,0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,  /* 00000808    "._STA..." */
  26.520 +    0x0F,0x08,0x5F,0x43,0x52,0x53,0x11,0x08,  /* 00000810    ".._CRS.." */
  26.521 +    0x0A,0x05,0x22,0x00,0x10,0x79,0x00,0x5B,  /* 00000818    ".."..y.[" */
  26.522 +    0x82,0x42,0x04,0x50,0x53,0x32,0x4B,0x08,  /* 00000820    ".B.PS2K." */
  26.523 +    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x03,  /* 00000828    "_HID.A.." */
  26.524 +    0x03,0x08,0x5F,0x43,0x49,0x44,0x0C,0x41,  /* 00000830    ".._CID.A" */
  26.525 +    0xD0,0x03,0x0B,0x14,0x09,0x5F,0x53,0x54,  /* 00000838    "....._ST" */
  26.526 +    0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,0x43,  /* 00000840    "A....._C" */
  26.527 +    0x52,0x53,0x11,0x18,0x0A,0x15,0x47,0x01,  /* 00000848    "RS....G." */
  26.528 +    0x60,0x00,0x60,0x00,0x00,0x01,0x47,0x01,  /* 00000850    "`.`...G." */
  26.529 +    0x64,0x00,0x64,0x00,0x00,0x01,0x22,0x02,  /* 00000858    "d.d..."." */
  26.530 +    0x00,0x79,0x00,0x5B,0x82,0x3A,0x46,0x44,  /* 00000860    ".y.[.:FD" */
  26.531 +    0x43,0x30,0x08,0x5F,0x48,0x49,0x44,0x0C,  /* 00000868    "C0._HID." */
  26.532 +    0x41,0xD0,0x07,0x00,0x14,0x09,0x5F,0x53,  /* 00000870    "A....._S" */
  26.533 +    0x54,0x41,0x00,0xA4,0x0A,0x0F,0x08,0x5F,  /* 00000878    "TA....._" */
  26.534 +    0x43,0x52,0x53,0x11,0x1B,0x0A,0x18,0x47,  /* 00000880    "CRS....G" */
  26.535 +    0x01,0xF0,0x03,0xF0,0x03,0x01,0x06,0x47,  /* 00000888    ".......G" */
  26.536 +    0x01,0xF7,0x03,0xF7,0x03,0x01,0x01,0x22,  /* 00000890    "......."" */
  26.537 +    0x40,0x00,0x2A,0x04,0x00,0x79,0x00,0x5B,  /* 00000898    "@.*..y.[" */
  26.538 +    0x82,0x35,0x55,0x41,0x52,0x31,0x08,0x5F,  /* 000008A0    ".5UAR1._" */
  26.539 +    0x48,0x49,0x44,0x0C,0x41,0xD0,0x05,0x01,  /* 000008A8    "HID.A..." */
  26.540 +    0x08,0x5F,0x55,0x49,0x44,0x01,0x14,0x09,  /* 000008B0    "._UID..." */
  26.541 +    0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,  /* 000008B8    "_STA...." */
  26.542 +    0x08,0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,  /* 000008C0    "._CRS..." */
  26.543 +    0x0D,0x47,0x01,0xF8,0x03,0xF8,0x03,0x01,  /* 000008C8    ".G......" */
  26.544 +    0x08,0x22,0x10,0x00,0x79,0x00,0x5B,0x82,  /* 000008D0    "."..y.[." */
  26.545 +    0x36,0x55,0x41,0x52,0x32,0x08,0x5F,0x48,  /* 000008D8    "6UAR2._H" */
  26.546 +    0x49,0x44,0x0C,0x41,0xD0,0x05,0x01,0x08,  /* 000008E0    "ID.A...." */
  26.547 +    0x5F,0x55,0x49,0x44,0x0A,0x02,0x14,0x09,  /* 000008E8    "_UID...." */
  26.548 +    0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,  /* 000008F0    "_STA...." */
  26.549 +    0x08,0x5F,0x43,0x52,0x53,0x11,0x10,0x0A,  /* 000008F8    "._CRS..." */
  26.550 +    0x0D,0x47,0x01,0xF8,0x02,0xF8,0x02,0x01,  /* 00000900    ".G......" */
  26.551 +    0x08,0x22,0x08,0x00,0x79,0x00,
  26.552  };
  26.553  int DsdtLen=sizeof(AmlCode);
    27.1 --- a/tools/firmware/hvmloader/Makefile	Wed Aug 09 08:01:52 2006 -0600
    27.2 +++ b/tools/firmware/hvmloader/Makefile	Wed Aug 09 08:34:06 2006 -0600
    27.3 @@ -42,12 +42,15 @@ OBJCOPY  = objcopy
    27.4  CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
    27.5  LDFLAGS  = -m32 -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR)
    27.6  
    27.7 +SRCS = hvmloader.c acpi_madt.c mp_tables.c util.c
    27.8 +OBJS = $(patsubst %.c,%.o,$(SRCS))
    27.9 +
   27.10  .PHONY: all
   27.11  all: hvmloader
   27.12  
   27.13 -hvmloader: roms.h hvmloader.c acpi_madt.c mp_tables.c
   27.14 -	$(CC) $(CFLAGS) -c hvmloader.c acpi_madt.c mp_tables.c
   27.15 -	$(CC) $(LDFLAGS) -o hvmloader.tmp hvmloader.o acpi_madt.o mp_tables.o
   27.16 +hvmloader: roms.h $(SRCS)
   27.17 +	$(CC) $(CFLAGS) -c $(SRCS)
   27.18 +	$(CC) $(LDFLAGS) -o hvmloader.tmp $(OBJS)
   27.19  	$(OBJCOPY) hvmloader.tmp hvmloader
   27.20  	rm -f hvmloader.tmp
   27.21  
    28.1 --- a/tools/firmware/hvmloader/acpi_madt.c	Wed Aug 09 08:01:52 2006 -0600
    28.2 +++ b/tools/firmware/hvmloader/acpi_madt.c	Wed Aug 09 08:34:06 2006 -0600
    28.3 @@ -20,13 +20,11 @@
    28.4  
    28.5  #include "../acpi/acpi2_0.h"
    28.6  #include "../acpi/acpi_madt.h"
    28.7 -
    28.8 +#include "util.h"
    28.9  #include <xen/hvm/hvm_info_table.h>
   28.10  
   28.11  #define NULL ((void*)0)
   28.12  
   28.13 -extern int puts(const char *s);
   28.14 -
   28.15  static struct hvm_info_table *table = NULL;
   28.16  
   28.17  static int validate_hvm_info(struct hvm_info_table *t)
    29.1 --- a/tools/firmware/hvmloader/hvmloader.c	Wed Aug 09 08:01:52 2006 -0600
    29.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Wed Aug 09 08:34:06 2006 -0600
    29.3 @@ -23,9 +23,13 @@
    29.4   */
    29.5  #include "roms.h"
    29.6  #include "../acpi/acpi2_0.h"  /* for ACPI_PHYSICAL_ADDRESS */
    29.7 +#include "hypercall.h"
    29.8 +#include "util.h"
    29.9 +#include <xen/version.h>
   29.10  #include <xen/hvm/hvm_info_table.h>
   29.11  
   29.12  /* memory map */
   29.13 +#define HYPERCALL_PHYSICAL_ADDRESS	0x00080000
   29.14  #define VGABIOS_PHYSICAL_ADDRESS	0x000C0000
   29.15  #define	VMXASSIST_PHYSICAL_ADDRESS	0x000D0000
   29.16  #define	ROMBIOS_PHYSICAL_ADDRESS	0x000F0000
   29.17 @@ -75,65 +79,14 @@ extern int acpi_madt_update(unsigned cha
   29.18  extern void create_mp_tables(void);
   29.19  struct hvm_info_table *get_hvm_info_table(void);
   29.20  
   29.21 -static inline void
   29.22 -outw(unsigned short addr, unsigned short val)
   29.23 -{
   29.24 -        __asm__ __volatile__ ("outw %%ax, %%dx" :: "d"(addr), "a"(val));
   29.25 -}
   29.26 -
   29.27 -static inline void
   29.28 -outb(unsigned short addr, unsigned char val)
   29.29 -{
   29.30 -        __asm__ __volatile__ ("outb %%al, %%dx" :: "d"(addr), "a"(val));
   29.31 -}
   29.32 -
   29.33 -static inline unsigned char
   29.34 -inb(unsigned short addr)
   29.35 -{
   29.36 -        unsigned char val;
   29.37 -
   29.38 -        __asm__ __volatile__ ("inb %w1,%0" : "=a" (val) : "Nd" (addr));
   29.39 -        return val;
   29.40 -}
   29.41 -
   29.42 -void *
   29.43 -memcpy(void *dest, const void *src, unsigned n)
   29.44 -{
   29.45 -	int t0, t1, t2;
   29.46 -
   29.47 -	__asm__ __volatile__(
   29.48 -		"cld\n"
   29.49 -		"rep; movsl\n"
   29.50 -		"testb $2,%b4\n"
   29.51 -		"je 1f\n"
   29.52 -		"movsw\n"
   29.53 -		"1: testb $1,%b4\n"
   29.54 -		"je 2f\n"
   29.55 -		"movsb\n"
   29.56 -		"2:"
   29.57 -		: "=&c" (t0), "=&D" (t1), "=&S" (t2)
   29.58 -		: "0" (n/4), "q" (n), "1" ((long) dest), "2" ((long) src)
   29.59 -		: "memory"
   29.60 -	);
   29.61 -	return dest;
   29.62 -}
   29.63 -
   29.64 -int
   29.65 -puts(const char *s)
   29.66 -{
   29.67 -	while (*s)
   29.68 -		outb(0xE9, *s++);
   29.69 -	return 0;
   29.70 -}
   29.71 -
   29.72 -int
   29.73 +static int
   29.74  cirrus_check(void)
   29.75  {
   29.76  	outw(0x3C4, 0x9206);
   29.77  	return inb(0x3C5) == 0x12;
   29.78  }
   29.79  
   29.80 -int
   29.81 +static int
   29.82  vmmcall(int function, int edi, int esi, int edx, int ecx, int ebx)
   29.83  {
   29.84          int eax;
   29.85 @@ -147,7 +100,7 @@ vmmcall(int function, int edi, int esi, 
   29.86          return eax;
   29.87  }
   29.88  
   29.89 -int
   29.90 +static int
   29.91  check_amd(void)
   29.92  {
   29.93  	char id[12];
   29.94 @@ -162,6 +115,60 @@ check_amd(void)
   29.95  	return __builtin_memcmp(id, "AuthenticAMD", 12) == 0;
   29.96  }
   29.97  
   29.98 +static void
   29.99 +cpuid(uint32_t idx, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
  29.100 +{
  29.101 +	__asm__ __volatile__(
  29.102 +		"cpuid"
  29.103 +		: "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
  29.104 +		: "0" (idx) );
  29.105 +}
  29.106 +
  29.107 +static void
  29.108 +wrmsr(uint32_t idx, uint64_t v)
  29.109 +{
  29.110 +	__asm__ __volatile__(
  29.111 +		"wrmsr"
  29.112 +		: : "c" (idx), "a" ((uint32_t)v), "d" ((uint32_t)(v>>32)) );
  29.113 +}
  29.114 +
  29.115 +static void
  29.116 +init_hypercalls(void)
  29.117 +{
  29.118 +	uint32_t eax, ebx, ecx, edx;
  29.119 +	unsigned long i;
  29.120 +	char signature[13], number[13];
  29.121 +	xen_extraversion_t extraversion;
  29.122 +
  29.123 +	cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
  29.124 +
  29.125 +	*(uint32_t *)(signature + 0) = ebx;
  29.126 +	*(uint32_t *)(signature + 4) = ecx;
  29.127 +	*(uint32_t *)(signature + 8) = edx;
  29.128 +	signature[12] = '\0';
  29.129 +
  29.130 +	if (strcmp("XenVMMXenVMM", signature) || (eax < 0x40000002)) {
  29.131 +		puts("FATAL: Xen hypervisor not detected\n");
  29.132 +		__asm__ __volatile__( "ud2" );
  29.133 +	}
  29.134 +
  29.135 +	cpuid(0x40000001, &eax, &ebx, &ecx, &edx);
  29.136 +
  29.137 +	puts("Detected Xen v");
  29.138 +	puts(itoa(number, eax >> 16));
  29.139 +	puts(".");
  29.140 +	puts(itoa(number, eax & 0xffff));
  29.141 +
  29.142 +	cpuid(0x40000002, &eax, &ebx, &ecx, &edx);
  29.143 +
  29.144 +	for (i = 0; i < eax; i++)
  29.145 +		wrmsr(ebx, HYPERCALL_PHYSICAL_ADDRESS + (i << 12) + i);
  29.146 +
  29.147 +	hypercall_xen_version(XENVER_extraversion, extraversion);
  29.148 +	puts(extraversion);
  29.149 +	puts("\n");
  29.150 +}
  29.151 +
  29.152  int
  29.153  main(void)
  29.154  {
  29.155 @@ -169,6 +176,8 @@ main(void)
  29.156  
  29.157  	puts("HVM Loader\n");
  29.158  
  29.159 +	init_hypercalls();
  29.160 +
  29.161  	puts("Loading ROMBIOS ...\n");
  29.162  	memcpy((void *)ROMBIOS_PHYSICAL_ADDRESS, rombios, sizeof(rombios));
  29.163  	if (t->apic_enabled)
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/tools/firmware/hvmloader/hypercall.h	Wed Aug 09 08:34:06 2006 -0600
    30.3 @@ -0,0 +1,180 @@
    30.4 +/******************************************************************************
    30.5 + * hypercall.h
    30.6 + * 
    30.7 + * Copyright (c) 2002-2006, K A Fraser
    30.8 + * 
    30.9 + * This program is free software; you can redistribute it and/or
   30.10 + * modify it under the terms of the GNU General Public License version 2
   30.11 + * as published by the Free Software Foundation; or, when distributed
   30.12 + * separately from the Linux kernel or incorporated into other
   30.13 + * software packages, subject to the following license:
   30.14 + * 
   30.15 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   30.16 + * of this source file (the "Software"), to deal in the Software without
   30.17 + * restriction, including without limitation the rights to use, copy, modify,
   30.18 + * merge, publish, distribute, sublicense, and/or sell copies of the Software,
   30.19 + * and to permit persons to whom the Software is furnished to do so, subject to
   30.20 + * the following conditions:
   30.21 + * 
   30.22 + * The above copyright notice and this permission notice shall be included in
   30.23 + * all copies or substantial portions of the Software.
   30.24 + * 
   30.25 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   30.26 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   30.27 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   30.28 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   30.29 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   30.30 + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
   30.31 + * IN THE SOFTWARE.
   30.32 + */
   30.33 +
   30.34 +#ifndef __HVMLOADER_HYPERCALL_H__
   30.35 +#define __HVMLOADER_HYPERCALL_H__
   30.36 +
   30.37 +/*
   30.38 + * NB. Hypercall address needs to be relative to a linkage symbol for
   30.39 + * some version of ld to relocate the relative calls properly.
   30.40 + * Keep this in sync with HYPERCALL_PHYSICAL_ADDRESS in hvmloader.c!
   30.41 + */
   30.42 +#define hypercall_pa "_start - 0x80000"
   30.43 +
   30.44 +#define __STR(x) #x
   30.45 +#define STR(x) __STR(x)
   30.46 +
   30.47 +#define _hypercall0(type, name)						\
   30.48 +({									\
   30.49 +	long __res;							\
   30.50 +	asm volatile (							\
   30.51 +		"call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32)	\
   30.52 +		: "=a" (__res)						\
   30.53 +		:							\
   30.54 +		: "memory" );						\
   30.55 +	(type)__res;							\
   30.56 +})
   30.57 +
   30.58 +#define _hypercall1(type, name, a1)					\
   30.59 +({									\
   30.60 +	long __res, __ign1;						\
   30.61 +	asm volatile (							\
   30.62 +		"call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32)	\
   30.63 +		: "=a" (__res), "=b" (__ign1)				\
   30.64 +		: "1" ((long)(a1))					\
   30.65 +		: "memory" );						\
   30.66 +	(type)__res;							\
   30.67 +})
   30.68 +
   30.69 +#define _hypercall2(type, name, a1, a2)					\
   30.70 +({									\
   30.71 +	long __res, __ign1, __ign2;					\
   30.72 +	asm volatile (							\
   30.73 +		"call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32)	\
   30.74 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2)		\
   30.75 +		: "1" ((long)(a1)), "2" ((long)(a2))			\
   30.76 +		: "memory" );						\
   30.77 +	(type)__res;							\
   30.78 +})
   30.79 +
   30.80 +#define _hypercall3(type, name, a1, a2, a3)				\
   30.81 +({									\
   30.82 +	long __res, __ign1, __ign2, __ign3;				\
   30.83 +	asm volatile (							\
   30.84 +		"call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32)	\
   30.85 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),		\
   30.86 +		"=d" (__ign3)						\
   30.87 +		: "1" ((long)(a1)), "2" ((long)(a2)),			\
   30.88 +		"3" ((long)(a3))					\
   30.89 +		: "memory" );						\
   30.90 +	(type)__res;							\
   30.91 +})
   30.92 +
   30.93 +#define _hypercall4(type, name, a1, a2, a3, a4)				\
   30.94 +({									\
   30.95 +	long __res, __ign1, __ign2, __ign3, __ign4;			\
   30.96 +	asm volatile (							\
   30.97 +		"call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32)	\
   30.98 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),		\
   30.99 +		"=d" (__ign3), "=S" (__ign4)				\
  30.100 +		: "1" ((long)(a1)), "2" ((long)(a2)),			\
  30.101 +		"3" ((long)(a3)), "4" ((long)(a4))			\
  30.102 +		: "memory" );						\
  30.103 +	(type)__res;							\
  30.104 +})
  30.105 +
  30.106 +#define _hypercall5(type, name, a1, a2, a3, a4, a5)			\
  30.107 +({									\
  30.108 +	long __res, __ign1, __ign2, __ign3, __ign4, __ign5;		\
  30.109 +	asm volatile (							\
  30.110 +		"call "hypercall_pa" + " STR(__HYPERVISOR_##name * 32)	\
  30.111 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2),		\
  30.112 +		"=d" (__ign3), "=S" (__ign4), "=D" (__ign5)		\
  30.113 +		: "1" ((long)(a1)), "2" ((long)(a2)),			\
  30.114 +		"3" ((long)(a3)), "4" ((long)(a4)),			\
  30.115 +		"5" ((long)(a5))					\
  30.116 +		: "memory" );						\
  30.117 +	(type)__res;							\
  30.118 +})
  30.119 +
  30.120 +static inline int
  30.121 +hypercall_sched_op(
  30.122 +	int cmd, void *arg)
  30.123 +{
  30.124 +	return _hypercall2(int, sched_op, cmd, arg);
  30.125 +}
  30.126 +
  30.127 +static inline int
  30.128 +hypercall_memory_op(
  30.129 +	unsigned int cmd, void *arg)
  30.130 +{
  30.131 +	return _hypercall2(int, memory_op, cmd, arg);
  30.132 +}
  30.133 +
  30.134 +static inline int
  30.135 +hypercall_multicall(
  30.136 +	void *call_list, int nr_calls)
  30.137 +{
  30.138 +	return _hypercall2(int, multicall, call_list, nr_calls);
  30.139 +}
  30.140 +
  30.141 +static inline int
  30.142 +hypercall_event_channel_op(
  30.143 +	int cmd, void *arg)
  30.144 +{
  30.145 +	return _hypercall2(int, event_channel_op, cmd, arg);
  30.146 +}
  30.147 +
  30.148 +static inline int
  30.149 +hypercall_xen_version(
  30.150 +	int cmd, void *arg)
  30.151 +{
  30.152 +	return _hypercall2(int, xen_version, cmd, arg);
  30.153 +}
  30.154 +
  30.155 +static inline int
  30.156 +hypercall_console_io(
  30.157 +	int cmd, int count, char *str)
  30.158 +{
  30.159 +	return _hypercall3(int, console_io, cmd, count, str);
  30.160 +}
  30.161 +
  30.162 +static inline int
  30.163 +hypercall_vm_assist(
  30.164 +	unsigned int cmd, unsigned int type)
  30.165 +{
  30.166 +	return _hypercall2(int, vm_assist, cmd, type);
  30.167 +}
  30.168 +
  30.169 +static inline int
  30.170 +hypercall_vcpu_op(
  30.171 +	int cmd, int vcpuid, void *extra_args)
  30.172 +{
  30.173 +	return _hypercall3(int, vcpu_op, cmd, vcpuid, extra_args);
  30.174 +}
  30.175 +
  30.176 +static inline int
  30.177 +hypercall_hvm_op(
  30.178 +	int cmd, void *arg)
  30.179 +{
  30.180 +	return _hypercall2(int, hvm_op, cmd, arg);
  30.181 +}
  30.182 +
  30.183 +#endif /* __HVMLOADER_HYPERCALL_H__ */
    31.1 --- a/tools/firmware/hvmloader/mp_tables.c	Wed Aug 09 08:01:52 2006 -0600
    31.2 +++ b/tools/firmware/hvmloader/mp_tables.c	Wed Aug 09 08:34:06 2006 -0600
    31.3 @@ -93,7 +93,8 @@ typedef   signed long int64_t;
    31.4  
    31.5  #define INTR_MAX_NR            16
    31.6  
    31.7 -extern int puts(const char *); /* for printing */
    31.8 +#include "util.h"
    31.9 +
   31.10  extern int get_vcpu_nr(void);  /* for the guest's VCPU count */
   31.11  
   31.12  /*
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/tools/firmware/hvmloader/util.c	Wed Aug 09 08:34:06 2006 -0600
    32.3 @@ -0,0 +1,96 @@
    32.4 +/*
    32.5 + * util.c: Helper library functions for HVMLoader.
    32.6 + *
    32.7 + * Leendert van Doorn, leendert@watson.ibm.com
    32.8 + * Copyright (c) 2005, International Business Machines Corporation.
    32.9 + *
   32.10 + * This program is free software; you can redistribute it and/or modify it
   32.11 + * under the terms and conditions of the GNU General Public License,
   32.12 + * version 2, as published by the Free Software Foundation.
   32.13 + *
   32.14 + * This program is distributed in the hope it will be useful, but WITHOUT
   32.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   32.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   32.17 + * more details.
   32.18 + *
   32.19 + * You should have received a copy of the GNU General Public License along with
   32.20 + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
   32.21 + * Place - Suite 330, Boston, MA 02111-1307 USA.
   32.22 + */
   32.23 +
   32.24 +#include "../acpi/acpi2_0.h"  /* for ACPI_PHYSICAL_ADDRESS */
   32.25 +#include "util.h"
   32.26 +
   32.27 +void outw(uint16_t addr, uint16_t val)
   32.28 +{
   32.29 +	__asm__ __volatile__ ("outw %%ax, %%dx" :: "d"(addr), "a"(val));
   32.30 +}
   32.31 +
   32.32 +void outb(uint16_t addr, uint8_t val)
   32.33 +{
   32.34 +	__asm__ __volatile__ ("outb %%al, %%dx" :: "d"(addr), "a"(val));
   32.35 +}
   32.36 +
   32.37 +uint8_t inb(uint16_t addr)
   32.38 +{
   32.39 +	uint8_t val;
   32.40 +	__asm__ __volatile__ ("inb %w1,%0" : "=a" (val) : "Nd" (addr));
   32.41 +	return val;
   32.42 +}
   32.43 +
   32.44 +char *itoa(char *a, unsigned int i)
   32.45 +{
   32.46 +	unsigned int _i = i, x = 0;
   32.47 +
   32.48 +	do {
   32.49 +		x++;
   32.50 +		_i /= 10;
   32.51 +	} while (_i != 0);
   32.52 +
   32.53 +	a += x;
   32.54 +	*a-- = '\0';
   32.55 +
   32.56 +	do {
   32.57 +		*a-- = (i % 10) + '0';
   32.58 +		i /= 10;
   32.59 +	} while (i != 0);
   32.60 +
   32.61 +	return a + 1;
   32.62 +}
   32.63 +
   32.64 +int strcmp(const char *cs, const char *ct)
   32.65 +{
   32.66 +	signed char res;
   32.67 +
   32.68 +	while (((res = *cs - *ct++) == 0) && (*cs++ != '\0'))
   32.69 +		continue;
   32.70 +
   32.71 +	return res;
   32.72 +}
   32.73 +
   32.74 +void *memcpy(void *dest, const void *src, unsigned n)
   32.75 +{
   32.76 +	int t0, t1, t2;
   32.77 +
   32.78 +	__asm__ __volatile__(
   32.79 +		"cld\n"
   32.80 +		"rep; movsl\n"
   32.81 +		"testb $2,%b4\n"
   32.82 +		"je 1f\n"
   32.83 +		"movsw\n"
   32.84 +		"1: testb $1,%b4\n"
   32.85 +		"je 2f\n"
   32.86 +		"movsb\n"
   32.87 +		"2:"
   32.88 +		: "=&c" (t0), "=&D" (t1), "=&S" (t2)
   32.89 +		: "0" (n/4), "q" (n), "1" ((long) dest), "2" ((long) src)
   32.90 +		: "memory"
   32.91 +	);
   32.92 +	return dest;
   32.93 +}
   32.94 +
   32.95 +void puts(const char *s)
   32.96 +{
   32.97 +	while (*s)
   32.98 +		outb(0xE9, *s++);
   32.99 +}
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/tools/firmware/hvmloader/util.h	Wed Aug 09 08:34:06 2006 -0600
    33.3 @@ -0,0 +1,19 @@
    33.4 +#ifndef __HVMLOADER_UTIL_H__
    33.5 +#define __HVMLOADER_UTIL_H__
    33.6 +
    33.7 +/* I/O output */
    33.8 +void outw(uint16_t addr, uint16_t val);
    33.9 +void outb(uint16_t addr, uint8_t val);
   33.10 +
   33.11 +/* I/O input */
   33.12 +uint8_t inb(uint16_t addr);
   33.13 +
   33.14 +/* String and memory functions */
   33.15 +int strcmp(const char *cs, const char *ct);
   33.16 +void *memcpy(void *dest, const void *src, unsigned n);
   33.17 +char *itoa(char *a, unsigned int i);
   33.18 +
   33.19 +/* Debug output */
   33.20 +void puts(const char *s);
   33.21 +
   33.22 +#endif /* __HVMLOADER_UTIL_H__ */
    34.1 --- a/tools/ioemu/.CVS/Entries	Wed Aug 09 08:01:52 2006 -0600
    34.2 +++ b/tools/ioemu/.CVS/Entries	Wed Aug 09 08:34:06 2006 -0600
    34.3 @@ -11,99 +11,99 @@ D/tests////
    34.4  D/fpu////
    34.5  D/keymaps////
    34.6  D/target-mips////
    34.7 -/.cvsignore/1.13/Thu May 25 18:22:25 2006//Trelease_0_8_1
    34.8 -/COPYING/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
    34.9 -/COPYING.LIB/1.2/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.10 -/Changelog/1.116/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.11 -/LICENSE/1.2/Sat Feb 12 14:45:23 2005//Trelease_0_8_1
   34.12 -/Makefile/1.99/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.13 -/Makefile.target/1.107/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.14 -/README/1.12/Wed May 24 10:40:08 2006//Trelease_0_8_1
   34.15 -/README.distrib/1.2/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.16 -/TODO/1.38/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.17 -/VERSION/1.28/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.18 -/a.out.h/1.2/Wed May 24 10:40:08 2006//Trelease_0_8_1
   34.19 -/aes.c/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.20 -/aes.h/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.21 -/alpha-dis.c/1.3/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.22 -/alpha.ld/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.23 -/arm-dis.c/1.3/Wed May 24 10:40:08 2006//Trelease_0_8_1
   34.24 -/arm.ld/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.25 -/block-bochs.c/1.1/Tue Apr 26 21:34:00 2005//Trelease_0_8_1
   34.26 -/block-cloop.c/1.3/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.27 -/block-cow.c/1.5/Thu May 25 12:38:49 2006//Trelease_0_8_1
   34.28 -/block-dmg.c/1.4/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.29 -/block-qcow.c/1.6/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.30 -/block-vmdk.c/1.7/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.31 -/block-vpc.c/1.2/Thu May 25 12:38:49 2006//Trelease_0_8_1
   34.32 -/block-vvfat.c/1.5/Thu May 25 18:22:25 2006//Trelease_0_8_1
   34.33 -/block.c/1.26/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.34 -/block_int.h/1.4/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.35 -/bswap.h/1.5/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.36 -/cocoa.m/1.8/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.37 -/configure/1.100/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.38 -/console.c/1.5/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.39 -/cpu-all.h/1.54/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.40 -/cpu-defs.h/1.15/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.41 -/cpu-exec.c/1.78/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.42 -/dis-asm.h/1.11/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.43 -/disas.c/1.30/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.44 -/disas.h/1.7/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.45 -/dyngen-exec.h/1.27/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.46 -/dyngen-op.h/1.1/Mon Jan  3 23:40:55 2005//Trelease_0_8_1
   34.47 -/dyngen.c/1.42/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.48 -/dyngen.h/1.10/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.49 -/elf.h/1.6/Thu May 25 12:38:50 2006//Trelease_0_8_1
   34.50 -/elf_ops.h/1.3/Tue May  2 20:54:12 2006//Trelease_0_8_1
   34.51 -/exec-all.h/1.47/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.52 -/exec.c/1.79/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.53 -/gdbstub.c/1.36/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.54 -/gdbstub.h/1.2/Tue Apr 26 20:42:36 2005//Trelease_0_8_1
   34.55 -/i386-dis.c/1.5/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.56 -/i386-vl.ld/1.3/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.57 -/i386.ld/1.2/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.58 -/ia64.ld/1.1/Thu Apr  7 22:20:28 2005//Trelease_0_8_1
   34.59 -/keymaps.c/1.2/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.60 -/kqemu.c/1.10/Thu May 25 18:22:26 2006//Trelease_0_8_1
   34.61 -/kqemu.h/1.1/Wed Feb  8 22:39:17 2006//Trelease_0_8_1
   34.62 -/linux-2.6.9-qemu-fast.patch/1.1/Wed Dec  8 23:48:11 2004//Trelease_0_8_1
   34.63 -/loader.c/1.2/Wed Apr 26 22:05:26 2006//Trelease_0_8_1
   34.64 -/m68k-dis.c/1.1/Sun Nov  6 16:52:11 2005//Trelease_0_8_1
   34.65 -/m68k.ld/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.66 -/mips-dis.c/1.3/Thu May 25 18:22:28 2006//Trelease_0_8_1
   34.67 -/monitor.c/1.48/Thu May 25 18:22:28 2006//Trelease_0_8_1
   34.68 -/osdep.c/1.10/Wed May 24 10:40:10 2006//Trelease_0_8_1
   34.69 -/osdep.h/1.5/Wed May 24 10:40:10 2006//Trelease_0_8_1
   34.70 -/ppc-dis.c/1.7/Thu May 25 12:38:51 2006//Trelease_0_8_1
   34.71 -/ppc.ld/1.2/Thu May 25 12:38:51 2006//Trelease_0_8_1
   34.72 -/qemu-binfmt-conf.sh/1.4/Thu May 25 18:22:28 2006//Trelease_0_8_1
   34.73 -/qemu-doc.texi/1.87/Thu May 25 18:22:29 2006//Trelease_0_8_1
   34.74 -/qemu-img.c/1.8/Thu May 25 12:38:51 2006//Trelease_0_8_1
   34.75 -/qemu-img.texi/1.2/Thu May 25 12:38:51 2006//Trelease_0_8_1
   34.76 -/qemu-tech.texi/1.9/Thu May 25 18:22:29 2006//Trelease_0_8_1
   34.77 -/qemu_socket.h/1.1/Sun Apr 30 22:53:25 2006//Trelease_0_8_1
   34.78 -/readline.c/1.1/Tue May 23 19:16:56 2006//Trelease_0_8_1
   34.79 -/s390.ld/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.80 -/sdl.c/1.26/Thu May 25 18:22:29 2006//Trelease_0_8_1
   34.81 -/sdl_keysym.h/1.3/Tue Mar  1 21:43:41 2005//Trelease_0_8_1
   34.82 -/sh4-dis.c/1.1/Thu Apr 27 21:05:14 2006//Trelease_0_8_1
   34.83 -/softmmu_exec.h/1.1/Sun Oct 30 18:16:26 2005//Trelease_0_8_1
   34.84 -/softmmu_header.h/1.13/Thu May 25 18:22:29 2006//Trelease_0_8_1
   34.85 -/softmmu_template.h/1.16/Thu May 25 18:22:29 2006//Trelease_0_8_1
   34.86 -/sparc-dis.c/1.2/Thu May 25 18:22:29 2006//Trelease_0_8_1
   34.87 -/sparc.ld/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
   34.88 -/tap-win32.c/1.2/Sun Feb 19 12:40:00 2006//Trelease_0_8_1
   34.89 -/texi2pod.pl/1.1/Wed May 17 14:47:02 2006//Trelease_0_8_1
   34.90 -/thunk.c/1.6/Wed May 24 10:40:10 2006//Trelease_0_8_1
   34.91 -/thunk.h/1.13/Wed May 17 14:47:02 2006//Trelease_0_8_1
   34.92 -/translate-all.c/1.14/Thu May 25 18:22:29 2006//Trelease_0_8_1
   34.93 -/translate-op.c/1.1/Sun Mar 13 16:53:06 2005//Trelease_0_8_1
   34.94 -/usb-linux.c/1.4/Sat Mar 11 18:03:38 2006//Trelease_0_8_1
   34.95 -/vgafont.h/1.1/Wed May 17 14:47:02 2006//Trelease_0_8_1
   34.96 -/vl.c/1.184/Thu May 25 18:22:30 2006//Trelease_0_8_1
   34.97 -/vl.h/1.116/Thu May 25 18:22:30 2006//Trelease_0_8_1
   34.98 -/vnc.c/1.4/Mon May  1 21:44:22 2006//Trelease_0_8_1
   34.99 -/vnc_keysym.h/1.1/Sun Apr 30 21:28:36 2006//Trelease_0_8_1
  34.100 -/vnchextile.h/1.1/Sun Apr 30 21:28:36 2006//Trelease_0_8_1
  34.101 -/x86_64.ld/1.1/Thu Jan  6 20:50:00 2005//Trelease_0_8_1
  34.102  D/target-sh4////
  34.103 +/.cvsignore/1.14/Sun Aug  6 01:03:44 2006//Trelease_0_8_2
  34.104 +/COPYING/1.1/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
  34.105 +/COPYING.LIB/1.2/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
  34.106 +/Changelog/1.121/Sun Aug  6 01:03:44 2006//Trelease_0_8_2
  34.107 +/LICENSE/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.108 +/Makefile/1.104/Sun Aug  6 01:03:44 2006//Trelease_0_8_2
  34.109 +/Makefile.target/1.121/Sun Aug  6 01:03:44 2006//Trelease_0_8_2
  34.110 +/README/1.12/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.111 +/README.distrib/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.112 +/TODO/1.39/Sun Aug  6 01:03:44 2006//Trelease_0_8_2
  34.113 +/VERSION/1.29/Sun Aug  6 01:03:44 2006//Trelease_0_8_2
  34.114 +/a.out.h/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.115 +/aes.c/1.1/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
  34.116 +/aes.h/1.1/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
  34.117 +/alpha-dis.c/1.3/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.118 +/alpha.ld/1.1/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.119 +/arm-dis.c/1.3/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.120 +/arm.ld/1.1/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.121 +/block-bochs.c/1.1/Sun Aug  6 00:55:02 2006//Trelease_0_8_2
  34.122 +/block-cloop.c/1.3/Sun Aug  6 00:55:02 2006//Trelease_0_8_2
  34.123 +/block-cow.c/1.6/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.124 +/block-dmg.c/1.4/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.125 +/block-qcow.c/1.7/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.126 +/block-vmdk.c/1.8/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.127 +/block-vpc.c/1.3/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.128 +/block-vvfat.c/1.6/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.129 +/block.c/1.28/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.130 +/block_int.h/1.5/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.131 +/bswap.h/1.5/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
  34.132 +/cocoa.m/1.10/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.133 +/configure/1.110/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.134 +/console.c/1.8/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.135 +/cpu-all.h/1.57/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.136 +/cpu-defs.h/1.16/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.137 +/cpu-exec.c/1.83/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.138 +/dis-asm.h/1.11/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.139 +/disas.c/1.31/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.140 +/disas.h/1.7/Sun Aug  6 00:55:03 2006//Trelease_0_8_2
  34.141 +/dyngen-exec.h/1.29/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.142 +/dyngen-op.h/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.143 +/dyngen.c/1.45/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.144 +/dyngen.h/1.11/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.145 +/elf.h/1.7/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.146 +/elf_ops.h/1.3/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.147 +/exec-all.h/1.48/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.148 +/exec.c/1.82/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.149 +/gdbstub.c/1.40/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.150 +/gdbstub.h/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.151 +/i386-dis.c/1.5/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.152 +/i386-vl.ld/1.3/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.153 +/i386.ld/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.154 +/ia64.ld/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.155 +/keymaps.c/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.156 +/kqemu.c/1.12/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.157 +/kqemu.h/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  34.158 +/linux-2.6.9-qemu-fast.patch/1.1/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.159 +/loader.c/1.3/Sun Aug  6 01:03:45 2006//Trelease_0_8_2
  34.160 +/m68k-dis.c/1.1/Sun Aug  6 01:03:46 2006//Trelease_0_8_2
  34.161 +/m68k.ld/1.1/Sun Aug  6 01:03:46 2006//Trelease_0_8_2
  34.162 +/mips-dis.c/1.4/Sun Aug  6 01:03:47 2006//Trelease_0_8_2
  34.163 +/monitor.c/1.54/Sun Aug  6 01:03:47 2006//Trelease_0_8_2
  34.164 +/osdep.c/1.11/Sun Aug  6 01:03:47 2006//Trelease_0_8_2
  34.165 +/osdep.h/1.6/Sun Aug  6 01:03:47 2006//Trelease_0_8_2
  34.166 +/ppc-dis.c/1.7/Sun Aug  6 01:03:48 2006//Trelease_0_8_2
  34.167 +/ppc.ld/1.2/Sun Aug  6 01:03:48 2006//Trelease_0_8_2
  34.168 +/qemu-binfmt-conf.sh/1.4/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.169 +/qemu-doc.texi/1.100/Sun Aug  6 01:03:48 2006//Trelease_0_8_2
  34.170 +/qemu-img.c/1.10/Sun Aug  6 01:03:48 2006//Trelease_0_8_2
  34.171 +/qemu-img.texi/1.2/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.172 +/qemu-tech.texi/1.9/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.173 +/qemu_socket.h/1.1/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.174 +/readline.c/1.1/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.175 +/s390.ld/1.1/Sun Aug  6 01:03:48 2006//Trelease_0_8_2
  34.176 +/sdl.c/1.29/Sun Aug  6 01:03:48 2006//Trelease_0_8_2
  34.177 +/sdl_keysym.h/1.3/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.178 +/sh4-dis.c/1.1/Sun Aug  6 01:03:48 2006//Trelease_0_8_2
  34.179 +/softmmu_exec.h/1.1/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.180 +/softmmu_header.h/1.13/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.181 +/softmmu_template.h/1.16/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.182 +/sparc-dis.c/1.3/Sun Aug  6 01:03:49 2006//Trelease_0_8_2
  34.183 +/sparc.ld/1.1/Sun Aug  6 01:03:49 2006//Trelease_0_8_2
  34.184 +/tap-win32.c/1.3/Sun Aug  6 01:03:49 2006//Trelease_0_8_2
  34.185 +/texi2pod.pl/1.1/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.186 +/thunk.c/1.6/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.187 +/thunk.h/1.13/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
  34.188 +/translate-all.c/1.14/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.189 +/translate-op.c/1.1/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.190 +/usb-linux.c/1.8/Sun Aug  6 01:03:49 2006//Trelease_0_8_2
  34.191 +/vgafont.h/1.1/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
  34.192 +/vl.c/1.202/Sun Aug  6 01:03:49 2006//Trelease_0_8_2
  34.193 +/vl.h/1.136/Sun Aug  6 01:03:49 2006//Trelease_0_8_2
  34.194 +/vnc.c/1.7/Sun Aug  6 01:03:49 2006//Trelease_0_8_2
  34.195 +/vnc_keysym.h/1.1/Fri Jul 14 12:43:46 2006//Trelease_0_8_2
  34.196 +/vnchextile.h/1.2/Sun Aug  6 01:03:49 2006//Trelease_0_8_2
  34.197 +/x86_64.ld/1.1/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/tools/ioemu/.CVS/Entries.Log	Wed Aug 09 08:34:06 2006 -0600
    35.3 @@ -0,0 +1,7 @@
    35.4 +A D/linux-user////
    35.5 +A D/slirp////
    35.6 +A D/target-arm////
    35.7 +A D/target-mips////
    35.8 +A D/target-ppc////
    35.9 +A D/target-sh4////
   35.10 +A D/target-sparc////
    36.1 --- a/tools/ioemu/.CVS/Tag	Wed Aug 09 08:01:52 2006 -0600
    36.2 +++ b/tools/ioemu/.CVS/Tag	Wed Aug 09 08:34:06 2006 -0600
    36.3 @@ -1,1 +1,1 @@
    36.4 -Nrelease_0_8_1
    36.5 +Nrelease_0_8_2
    37.1 --- a/tools/ioemu/.cvsignore	Wed Aug 09 08:01:52 2006 -0600
    37.2 +++ b/tools/ioemu/.cvsignore	Wed Aug 09 08:34:06 2006 -0600
    37.3 @@ -11,6 +11,8 @@ ppc64-softmmu
    37.4  ppc-user
    37.5  qemu-doc.html
    37.6  qemu-tech.html
    37.7 +qemu-doc.info
    37.8 +qemu-tech.info
    37.9  qemu.1
   37.10  qemu.pod
   37.11  qemu-img.1
   37.12 @@ -25,5 +27,16 @@ mips-softmmu
   37.13  mipsel-softmmu
   37.14  mips-user
   37.15  mipsel-user
   37.16 +.gdbinit
   37.17  sh4-user
   37.18  sh4-softmmu
   37.19 +*.aux
   37.20 +*.cp
   37.21 +*.dvi
   37.22 +*.fn
   37.23 +*.ky
   37.24 +*.log
   37.25 +*.pg
   37.26 +*.toc
   37.27 +*.tp
   37.28 +*.vr
    38.1 --- a/tools/ioemu/Changelog	Wed Aug 09 08:01:52 2006 -0600
    38.2 +++ b/tools/ioemu/Changelog	Wed Aug 09 08:34:06 2006 -0600
    38.3 @@ -1,3 +1,22 @@
    38.4 +version 0.8.2:
    38.5 +
    38.6 +  - ACPI support
    38.7 +  - PC VGA BIOS fixes
    38.8 +  - switch to OpenBios for SPARC targets (Blue Swirl)
    38.9 +  - VNC server fixes
   38.10 +  - MIPS FPU support (Marius Groeger)
   38.11 +  - Solaris/SPARC host support (Ben Taylor)
   38.12 +  - PPC breakpoints and single stepping (Jason Wessel)
   38.13 +  - USB updates (Paul Brook)
   38.14 +  - UDP/TCP/telnet character devices (Jason Wessel)
   38.15 +  - Windows sparse file support (Frediano Ziglio)
   38.16 +  - RTL8139 NIC TCP segmentation offloading (Igor Kovalenko)
   38.17 +  - PCNET NIC support (Antony T Curtis)
   38.18 +  - Support for variable frequency host CPUs
   38.19 +  - Workaround for win32 SMP hosts
   38.20 +  - Support for AMD Flash memories (Jocelyn Mayer)
   38.21 +  - Audio capture to WAV files support (malc)
   38.22 +
   38.23  version 0.8.1:
   38.24  
   38.25    - USB tablet support (Brad Campbell, Anthony Liguori)
    39.1 --- a/tools/ioemu/Makefile	Wed Aug 09 08:01:52 2006 -0600
    39.2 +++ b/tools/ioemu/Makefile	Wed Aug 09 08:34:06 2006 -0600
    39.3 @@ -1,12 +1,20 @@
    39.4 +# Makefile for QEMU.
    39.5 +
    39.6  XEN_ROOT=../..
    39.7  include $(XEN_ROOT)/tools/Rules.mk
    39.8  
    39.9  -include config-host.mak
   39.10  
   39.11 +.PHONY: all clean distclean dvi info install install-doc tar tarbin \
   39.12 +	speed test test2 html dvi info
   39.13 +
   39.14  CFLAGS+=-Wall -O2 -g -fno-strict-aliasing -I.
   39.15  ifdef CONFIG_DARWIN
   39.16  CFLAGS+= -mdynamic-no-pic
   39.17  endif
   39.18 +ifeq ($(ARCH),sparc)
   39.19 +CFLAGS+=-mcpu=ultrasparc
   39.20 +endif
   39.21  LDFLAGS=-g
   39.22  LIBS=
   39.23  DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
   39.24 @@ -20,11 +28,15 @@ else
   39.25  DOCS=
   39.26  endif
   39.27  
   39.28 -all: $(DOCS)
   39.29 -	for d in $(TARGET_DIRS); do \
   39.30 -	$(MAKE) -C $$d $@ || exit 1 ; \
   39.31 -        done
   39.32 +TOOLS=
   39.33  
   39.34 +all: $(TOOLS) $(DOCS) recurse-all
   39.35 +
   39.36 +subdir-%:
   39.37 +	$(MAKE) -C $(subst subdir-,,$@) all
   39.38 +
   39.39 +recurse-all: $(patsubst %,subdir-%, $(TARGET_DIRS))
   39.40 +        
   39.41  qemu-img$(EXESUF): qemu-img.c block.c block-cow.c block-qcow.c aes.c block-vmdk.c block-cloop.c block-dmg.c block-bochs.c block-vpc.c block-vvfat.c
   39.42  	$(CC) -DQEMU_TOOL $(CFLAGS) $(LDFLAGS) $(DEFINES) -o $@ $^ -lz $(LIBS)
   39.43  
   39.44 @@ -42,6 +54,7 @@ clean:
   39.45  
   39.46  distclean: clean
   39.47  	rm -f config-host.mak config-host.h $(DOCS)
   39.48 +	rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
   39.49  	for d in $(TARGET_DIRS); do \
   39.50  	rm -rf $$d || exit 1 ; \
   39.51          done
   39.52 @@ -63,7 +76,7 @@ install: all $(if $(BUILD_DOCS),install-
   39.53  #	$(INSTALL) -m 755 -s $(TOOLS) "$(DESTDIR)$(bindir)"
   39.54  #	mkdir -p "$(DESTDIR)$(datadir)"
   39.55  #	for x in bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \
   39.56 -#			video.x proll.elf linux_boot.bin; do \
   39.57 +#			video.x openbios-sparc32 linux_boot.bin; do \
   39.58  #		$(INSTALL) -m 644 $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(datadir)"; \
   39.59  #	done
   39.60  ifndef CONFIG_WIN32
   39.61 @@ -106,6 +119,12 @@ qemu-img.1: qemu-img.texi
   39.62  	perl -w $(SRC_PATH)/texi2pod.pl $< qemu-img.pod
   39.63  	pod2man --section=1 --center=" " --release=" " qemu-img.pod > $@
   39.64  
   39.65 +info: qemu-doc.info qemu-tech.info
   39.66 +
   39.67 +dvi: qemu-doc.dvi qemu-tech.dvi
   39.68 +
   39.69 +html: qemu-doc.html qemu-tech.html
   39.70 +
   39.71  FILE=qemu-$(shell cat VERSION)
   39.72  
   39.73  # tar release (use 'make -k tar' on a checkouted tree)
   39.74 @@ -138,7 +157,7 @@ tarbin:
   39.75  	$(datadir)/vgabios-cirrus.bin \
   39.76  	$(datadir)/ppc_rom.bin \
   39.77  	$(datadir)/video.x \
   39.78 -	$(datadir)/proll.elf \
   39.79 +	$(datadir)/openbios-sparc32 \
   39.80  	$(datadir)/linux_boot.bin \
   39.81  	$(docdir)/qemu-doc.html \
   39.82  	$(docdir)/qemu-tech.html \
    40.1 --- a/tools/ioemu/Makefile.target	Wed Aug 09 08:01:52 2006 -0600
    40.2 +++ b/tools/ioemu/Makefile.target	Wed Aug 09 08:34:06 2006 -0600
    40.3 @@ -40,6 +40,11 @@ ifeq ($(TARGET_ARCH),arm)
    40.4      TARGET_ARCH2=armeb
    40.5    endif
    40.6  endif
    40.7 +ifeq ($(TARGET_ARCH),sh4)
    40.8 +  ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
    40.9 +    TARGET_ARCH2=sh4eb
   40.10 +  endif
   40.11 +endif
   40.12  ifeq ($(TARGET_ARCH),mips)
   40.13    ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
   40.14      TARGET_ARCH2=mipsel
   40.15 @@ -114,17 +119,24 @@ LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
   40.16  endif
   40.17  
   40.18  ifeq ($(ARCH),sparc)
   40.19 -CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
   40.20 +ifeq ($(CONFIG_SOLARIS),yes)
   40.21 +CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g2 -ffixed-g3
   40.22 +LDFLAGS+=-m32
   40.23 +OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -fno-omit-frame-pointer -ffixed-i0
   40.24 +else
   40.25 +CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
   40.26  LDFLAGS+=-m32
   40.27  OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
   40.28  HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
   40.29  # -static is used to avoid g1/g3 usage by the dynamic linker
   40.30  LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
   40.31  endif
   40.32 +endif
   40.33  
   40.34  ifeq ($(ARCH),sparc64)
   40.35 -CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
   40.36 +CFLAGS+=-mcpu=ultrasparc -m64 -ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
   40.37  LDFLAGS+=-m64
   40.38 +LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld
   40.39  OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
   40.40  endif
   40.41  
   40.42 @@ -186,7 +198,12 @@ LDFLAGS+=-p
   40.43  main.o: CFLAGS+=-p
   40.44  endif
   40.45  
   40.46 -OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o 
   40.47 +OBJS= main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o \
   40.48 +      elfload.o linuxload.o
   40.49 +ifdef TARGET_HAS_BFLT
   40.50 +OBJS+= flatload.o
   40.51 +endif
   40.52 +
   40.53  ifeq ($(TARGET_ARCH), i386)
   40.54  OBJS+= vm86.o
   40.55  endif
   40.56 @@ -323,25 +340,32 @@ endif
   40.57  ifdef CONFIG_ADLIB
   40.58  SOUND_HW += fmopl.o adlib.o
   40.59  endif
   40.60 +AUDIODRV+= wavcapture.o
   40.61 +
   40.62 +# SCSI layer
   40.63 +VL_OBJS+= scsi-disk.o cdrom.o lsi53c895a.o
   40.64  
   40.65  # USB layer
   40.66 -VL_OBJS+= usb.o usb-hub.o usb-uhci.o usb-linux.o usb-hid.o
   40.67 +VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o
   40.68  
   40.69  # PCI network cards
   40.70 -VL_OBJS+= ne2000.o rtl8139.o
   40.71 +VL_OBJS+= ne2000.o rtl8139.o pcnet.o
   40.72  
   40.73  ifeq ($(TARGET_BASE_ARCH), i386)
   40.74  # Hardware support
   40.75  VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
   40.76  VL_OBJS+= fdc.o mc146818rtc.o serial.o pc.o
   40.77 -VL_OBJS+= cirrus_vga.o mixeng.o parallel.o
   40.78 +VL_OBJS+= cirrus_vga.o mixeng.o parallel.o acpi.o piix_pci.o
   40.79 +VL_OBJS+= usb-uhci.o
   40.80  VL_OBJS+= piix4acpi.o
   40.81 +VL_OBJS+= xenstore.o
   40.82  DEFINES += -DHAS_AUDIO
   40.83  endif
   40.84  ifeq ($(TARGET_BASE_ARCH), ppc)
   40.85  VL_OBJS+= ppc.o ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
   40.86  VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
   40.87  VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
   40.88 +VL_OBJS+= grackle_pci.o prep_pci.o unin_pci.o
   40.89  DEFINES += -DHAS_AUDIO
   40.90  endif
   40.91  ifeq ($(TARGET_ARCH), mips)
   40.92 @@ -350,7 +374,7 @@ VL_OBJS+= mips_r4k.o dma.o vga.o serial.
   40.93  endif
   40.94  ifeq ($(TARGET_BASE_ARCH), sparc)
   40.95  ifeq ($(TARGET_ARCH), sparc64)
   40.96 -VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o
   40.97 +VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
   40.98  VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
   40.99  VL_OBJS+= cirrus_vga.o parallel.o
  40.100  else
  40.101 @@ -361,6 +385,7 @@ endif
  40.102  ifeq ($(TARGET_BASE_ARCH), arm)
  40.103  VL_OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
  40.104  VL_OBJS+= arm_boot.o pl011.o pl050.o pl080.o pl110.o pl190.o
  40.105 +VL_OBJS+= versatile_pci.o
  40.106  endif
  40.107  ifeq ($(TARGET_BASE_ARCH), sh4)
  40.108  VL_OBJS+= shix.o sh7750.o sh7750_regnames.o tc58128.o
  40.109 @@ -398,7 +423,7 @@ endif
  40.110  ifndef CONFIG_DARWIN
  40.111  ifndef CONFIG_WIN32
  40.112  ifndef CONFIG_SOLARIS
  40.113 -VL_LIBS=-lutil
  40.114 +VL_LIBS=-lutil -lrt
  40.115  endif
  40.116  endif
  40.117  endif
  40.118 @@ -411,6 +436,11 @@ ifeq ($(ARCH),ia64)
  40.119  VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
  40.120  endif
  40.121  
  40.122 +ifeq ($(ARCH),sparc64)
  40.123 +VL_LDFLAGS+=-m64
  40.124 +VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld
  40.125 +endif
  40.126 +
  40.127  ifdef CONFIG_WIN32
  40.128  SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
  40.129  endif
  40.130 @@ -490,6 +520,13 @@ endif
  40.131  
  40.132  loader.o: loader.c elf_ops.h
  40.133  
  40.134 +acpi.o: acpi.c acpi-dsdt.hex
  40.135 +
  40.136 +ifdef BUILD_ACPI_TABLES
  40.137 +$(SRC_PATH)/hw/acpi-dsdt.hex: acpi-dsdt.dsl
  40.138 +	iasl -tc -p $@ $<
  40.139 +endif
  40.140 +
  40.141  ifeq ($(TARGET_ARCH), sh4)
  40.142  op.o: op.c op_mem.c cpu.h
  40.143  op_helper.o: op_helper.c exec.h cpu.h
  40.144 @@ -500,6 +537,8 @@ sh7750_regnames.o: sh7750_regnames.c sh7
  40.145  tc58128.o: tc58128.c
  40.146  endif
  40.147  
  40.148 +$(OBJS) $(LIBOBJS) $(VL_OBJS): config.h ../config-host.h
  40.149 +
  40.150  %.o: %.c
  40.151  	$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
  40.152  
    41.1 --- a/tools/ioemu/TODO	Wed Aug 09 08:01:52 2006 -0600
    41.2 +++ b/tools/ioemu/TODO	Wed Aug 09 08:34:06 2006 -0600
    41.3 @@ -1,24 +1,20 @@
    41.4  short term:
    41.5  ----------
    41.6 +- cycle counter for all archs
    41.7 +- cpu_interrupt() win32/SMP fix
    41.8  - support variable tsc freq
    41.9 -- cpu_interrupt() win32/SMP fix
   41.10  - USB host async
   41.11  - IDE async
   41.12  - debug option in 'configure' script + disable -fomit-frame-pointer
   41.13  - Precise VGA timings for old games/demos (malc patch)
   41.14  - merge PIC spurious interrupt patch
   41.15 -- merge Solaris patch
   41.16  - warning for OS/2: must not use 128 MB memory (merge bochs cmos patch ?)
   41.17  - config file (at least for windows/Mac OS X)
   41.18 -- commit message if execution of code in IO memory
   41.19  - update doc: PCI infos.
   41.20 -- VNC patch + Synaptic patch.
   41.21  - basic VGA optimizations
   41.22 -- physical memory cache (reduce qemu-fast address space size to about 32 MB)
   41.23  - better code fetch (different exception handling + CS.limit support)
   41.24  - do not resize vga if invalid size.
   41.25  - avoid looping if only exceptions
   41.26 -- cycle counter for all archs
   41.27  - TLB code protection support for PPC
   41.28  - see openMosix Doc 
   41.29  - disable SMC handling for ARM/SPARC/PPC (not finished)
   41.30 @@ -31,12 +27,10 @@ short term:
   41.31  - fix CCOP optimisation
   41.32  - fix all remaining thread lock issues (must put TBs in a specific invalid
   41.33    state, find a solution for tb_flush()).
   41.34 -- fix arm fpu rounding (at least for float->integer conversions)
   41.35  
   41.36  ppc specific:
   41.37  ------------
   41.38  - TLB invalidate not needed if msr_pr changes
   41.39 -- SPR_ENCODE() not useful
   41.40  - enable shift optimizations ?
   41.41  
   41.42  linux-user specific:
    42.1 --- a/tools/ioemu/VERSION	Wed Aug 09 08:01:52 2006 -0600
    42.2 +++ b/tools/ioemu/VERSION	Wed Aug 09 08:34:06 2006 -0600
    42.3 @@ -1,1 +1,1 @@
    42.4 -0.8.1
    42.5 \ No newline at end of file
    42.6 +0.8.2
    42.7 \ No newline at end of file
    43.1 --- a/tools/ioemu/audio/.CVS/Entries	Wed Aug 09 08:01:52 2006 -0600
    43.2 +++ b/tools/ioemu/audio/.CVS/Entries	Wed Aug 09 08:34:06 2006 -0600
    43.3 @@ -1,19 +1,20 @@
    43.4 -/alsaaudio.c/1.5/Sun Nov 20 18:53:05 2005//Trelease_0_8_1
    43.5 -/audio.c/1.9/Thu May 25 18:22:31 2006//Trelease_0_8_1
    43.6 -/audio.h/1.5/Thu May 25 18:22:31 2006//Trelease_0_8_1
    43.7 -/audio_int.h/1.7/Thu May 25 18:22:31 2006//Trelease_0_8_1
    43.8 -/audio_template.h/1.4/Sun Nov 20 16:24:34 2005//Trelease_0_8_1
    43.9 -/coreaudio.c/1.5/Sun Nov 20 18:53:42 2005//Trelease_0_8_1
   43.10 -/dsound_template.h/1.2/Sat Nov  5 18:55:27 2005//Trelease_0_8_1
   43.11 -/dsoundaudio.c/1.2/Sat Nov  5 18:55:27 2005//Trelease_0_8_1
   43.12 -/fmodaudio.c/1.5/Thu May 25 18:22:32 2006//Trelease_0_8_1
   43.13 -/mixeng.c/1.4/Thu May 25 18:22:32 2006//Trelease_0_8_1
   43.14 -/mixeng.h/1.2/Thu May 25 18:22:32 2006//Trelease_0_8_1
   43.15 -/mixeng_template.h/1.2/Thu May 25 18:22:32 2006//Trelease_0_8_1
   43.16 -/noaudio.c/1.4/Thu May 25 18:22:32 2006//Trelease_0_8_1
   43.17 -/ossaudio.c/1.9/Thu May 25 18:22:32 2006//Trelease_0_8_1
   43.18 -/rate_template.h/1.2/Sat Nov  5 18:55:27 2005//Trelease_0_8_1
   43.19 -/sdlaudio.c/1.6/Thu May 25 18:22:32 2006//Trelease_0_8_1
   43.20 -/sys-queue.h/1.1/Sun Oct 30 18:58:22 2005//Trelease_0_8_1
   43.21 -/wavaudio.c/1.6/Thu May 25 18:22:32 2006//Trelease_0_8_1
   43.22 +/alsaaudio.c/1.7/Sun Aug  6 01:03:49 2006//Trelease_0_8_2
   43.23 +/audio.c/1.14/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.24 +/audio.h/1.8/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.25 +/audio_int.h/1.10/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.26 +/audio_template.h/1.8/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.27 +/coreaudio.c/1.7/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.28 +/dsound_template.h/1.4/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.29 +/dsoundaudio.c/1.3/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.30 +/fmodaudio.c/1.7/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.31 +/mixeng.c/1.4/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   43.32 +/mixeng.h/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   43.33 +/mixeng_template.h/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   43.34 +/noaudio.c/1.7/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.35 +/ossaudio.c/1.11/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.36 +/rate_template.h/1.3/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.37 +/sdlaudio.c/1.8/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.38 +/sys-queue.h/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   43.39 +/wavaudio.c/1.8/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   43.40 +/wavcapture.c/1.5/Sat Jul 22 17:06:44 2006//Trelease_0_8_2
   43.41  D
    44.1 --- a/tools/ioemu/audio/.CVS/Tag	Wed Aug 09 08:01:52 2006 -0600
    44.2 +++ b/tools/ioemu/audio/.CVS/Tag	Wed Aug 09 08:34:06 2006 -0600
    44.3 @@ -1,1 +1,1 @@
    44.4 -Nrelease_0_8_1
    44.5 +Nrelease_0_8_2
    45.1 --- a/tools/ioemu/audio/alsaaudio.c	Wed Aug 09 08:01:52 2006 -0600
    45.2 +++ b/tools/ioemu/audio/alsaaudio.c	Wed Aug 09 08:34:06 2006 -0600
    45.3 @@ -61,8 +61,8 @@ static struct {
    45.4      .size_in_usec_in = 1,
    45.5      .size_in_usec_out = 1,
    45.6  #endif
    45.7 -    .pcm_name_out = "hw:0,0",
    45.8 -    .pcm_name_in = "hw:0,0",
    45.9 +    .pcm_name_out = "default",
   45.10 +    .pcm_name_in = "default",
   45.11  #ifdef HIGH_LATENCY
   45.12      .buffer_size_in = 400000,
   45.13      .period_size_in = 400000 / 4,
   45.14 @@ -606,7 +606,6 @@ static int alsa_run_out (HWVoiceOut *hw)
   45.15                  }
   45.16              }
   45.17  
   45.18 -            mixeng_clear (src, written);
   45.19              rpos = (rpos + written) % hw->samples;
   45.20              samples -= written;
   45.21              len -= written;
   45.22 @@ -663,12 +662,9 @@ static int alsa_init_out (HWVoiceOut *hw
   45.23      obt_as.freq = obt.freq;
   45.24      obt_as.nchannels = obt.nchannels;
   45.25      obt_as.fmt = effective_fmt;
   45.26 +    obt_as.endianness = endianness;
   45.27  
   45.28 -    audio_pcm_init_info (
   45.29 -        &hw->info,
   45.30 -        &obt_as,
   45.31 -        audio_need_to_swap_endian (endianness)
   45.32 -        );
   45.33 +    audio_pcm_init_info (&hw->info, &obt_as);
   45.34      hw->samples = obt.samples;
   45.35  
   45.36      alsa->pcm_buf = audio_calloc (AUDIO_FUNC, obt.samples, 1 << hw->info.shift);
   45.37 @@ -752,12 +748,9 @@ static int alsa_init_in (HWVoiceIn *hw, 
   45.38      obt_as.freq = obt.freq;
   45.39      obt_as.nchannels = obt.nchannels;
   45.40      obt_as.fmt = effective_fmt;
   45.41 +    obt_as.endianness = endianness;
   45.42  
   45.43 -    audio_pcm_init_info (
   45.44 -        &hw->info,
   45.45 -        &obt_as,
   45.46 -        audio_need_to_swap_endian (endianness)
   45.47 -        );
   45.48 +    audio_pcm_init_info (&hw->info, &obt_as);
   45.49      hw->samples = obt.samples;
   45.50  
   45.51      alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
    46.1 --- a/tools/ioemu/audio/audio.c	Wed Aug 09 08:01:52 2006 -0600
    46.2 +++ b/tools/ioemu/audio/audio.c	Wed Aug 09 08:34:06 2006 -0600
    46.3 @@ -29,6 +29,7 @@
    46.4  /* #define DEBUG_PLIVE */
    46.5  /* #define DEBUG_LIVE */
    46.6  /* #define DEBUG_OUT */
    46.7 +/* #define DEBUG_CAPTURE */
    46.8  
    46.9  #define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown"
   46.10  
   46.11 @@ -137,7 +138,7 @@ int audio_bug (const char *funcname, int
   46.12      if (cond) {
   46.13          static int shown;
   46.14  
   46.15 -        AUD_log (NULL, "Error a bug that was just triggered in %s\n", funcname);
   46.16 +        AUD_log (NULL, "A bug was just triggered in %s\n", funcname);
   46.17          if (!shown) {
   46.18              shown = 1;
   46.19              AUD_log (NULL, "Save all your work and restart without audio\n");
   46.20 @@ -509,14 +510,28 @@ static void audio_print_settings (audset
   46.21          AUD_log (NULL, "invalid(%d)", as->fmt);
   46.22          break;
   46.23      }
   46.24 +
   46.25 +    AUD_log (NULL, " endianness=");
   46.26 +    switch (as->endianness) {
   46.27 +    case 0:
   46.28 +        AUD_log (NULL, "little");
   46.29 +        break;
   46.30 +    case 1:
   46.31 +        AUD_log (NULL, "big");
   46.32 +        break;
   46.33 +    default:
   46.34 +        AUD_log (NULL, "invalid");
   46.35 +        break;
   46.36 +    }
   46.37      AUD_log (NULL, "\n");
   46.38  }
   46.39  
   46.40 -static int audio_validate_settigs (audsettings_t *as)
   46.41 +static int audio_validate_settings (audsettings_t *as)
   46.42  {
   46.43      int invalid;
   46.44  
   46.45      invalid = as->nchannels != 1 && as->nchannels != 2;
   46.46 +    invalid |= as->endianness != 0 && as->endianness != 1;
   46.47  
   46.48      switch (as->fmt) {
   46.49      case AUD_FMT_S8:
   46.50 @@ -530,11 +545,7 @@ static int audio_validate_settigs (audse
   46.51      }
   46.52  
   46.53      invalid |= as->freq <= 0;
   46.54 -
   46.55 -    if (invalid) {
   46.56 -        return -1;
   46.57 -    }
   46.58 -    return 0;
   46.59 +    return invalid ? -1 : 0;
   46.60  }
   46.61  
   46.62  static int audio_pcm_info_eq (struct audio_pcm_info *info, audsettings_t *as)
   46.63 @@ -556,14 +567,11 @@ static int audio_pcm_info_eq (struct aud
   46.64      return info->freq == as->freq
   46.65          && info->nchannels == as->nchannels
   46.66          && info->sign == sign
   46.67 -        && info->bits == bits;
   46.68 +        && info->bits == bits
   46.69 +        && info->swap_endianness == (as->endianness != AUDIO_HOST_ENDIANNESS);
   46.70  }
   46.71  
   46.72 -void audio_pcm_init_info (
   46.73 -    struct audio_pcm_info *info,
   46.74 -    audsettings_t *as,
   46.75 -    int swap_endian
   46.76 -    )
   46.77 +void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as)
   46.78  {
   46.79      int bits = 8, sign = 0;
   46.80  
   46.81 @@ -587,7 +595,7 @@ void audio_pcm_init_info (
   46.82      info->shift = (as->nchannels == 2) + (bits == 16);
   46.83      info->align = (1 << info->shift) - 1;
   46.84      info->bytes_per_second = info->freq << info->shift;
   46.85 -    info->swap_endian = swap_endian;
   46.86 +    info->swap_endianness = (as->endianness != AUDIO_HOST_ENDIANNESS);
   46.87  }
   46.88  
   46.89  void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len)
   46.90 @@ -597,11 +605,11 @@ void audio_pcm_info_clear_buf (struct au
   46.91      }
   46.92  
   46.93      if (info->sign) {
   46.94 -        memset (buf, len << info->shift, 0x00);
   46.95 +        memset (buf, 0x00, len << info->shift);
   46.96      }
   46.97      else {
   46.98          if (info->bits == 8) {
   46.99 -            memset (buf, len << info->shift, 0x80);
  46.100 +            memset (buf, 0x80, len << info->shift);
  46.101          }
  46.102          else {
  46.103              int i;
  46.104 @@ -609,7 +617,7 @@ void audio_pcm_info_clear_buf (struct au
  46.105              int shift = info->nchannels - 1;
  46.106              short s = INT16_MAX;
  46.107  
  46.108 -            if (info->swap_endian) {
  46.109 +            if (info->swap_endianness) {
  46.110                  s = bswap16 (s);
  46.111              }
  46.112  
  46.113 @@ -621,6 +629,143 @@ void audio_pcm_info_clear_buf (struct au
  46.114  }
  46.115  
  46.116  /*
  46.117 + * Capture
  46.118 + */
  46.119 +static void noop_conv (st_sample_t *dst, const void *src,
  46.120 +                       int samples, volume_t *vol)
  46.121 +{
  46.122 +    (void) src;
  46.123 +    (void) dst;
  46.124 +    (void) samples;
  46.125 +    (void) vol;
  46.126 +}
  46.127 +
  46.128 +static CaptureVoiceOut *audio_pcm_capture_find_specific (
  46.129 +    AudioState *s,
  46.130 +    audsettings_t *as
  46.131 +    )
  46.132 +{
  46.133 +    CaptureVoiceOut *cap;
  46.134 +
  46.135 +    for (cap = s->cap_head.lh_first; cap; cap = cap->entries.le_next) {
  46.136 +        if (audio_pcm_info_eq (&cap->hw.info, as)) {
  46.137 +            return cap;
  46.138 +        }
  46.139 +    }
  46.140 +    return NULL;
  46.141 +}
  46.142 +
  46.143 +static void audio_notify_capture (CaptureVoiceOut *cap, audcnotification_e cmd)
  46.144 +{
  46.145 +    struct capture_callback *cb;
  46.146 +
  46.147 +#ifdef DEBUG_CAPTURE
  46.148 +    dolog ("notification %d sent\n", cmd);
  46.149 +#endif
  46.150 +    for (cb = cap->cb_head.lh_first; cb; cb = cb->entries.le_next) {
  46.151 +        cb->ops.notify (cb->opaque, cmd);
  46.152 +    }
  46.153 +}
  46.154 +
  46.155 +static void audio_capture_maybe_changed (CaptureVoiceOut *cap, int enabled)
  46.156 +{
  46.157 +    if (cap->hw.enabled != enabled) {
  46.158 +        audcnotification_e cmd;
  46.159 +        cap->hw.enabled = enabled;
  46.160 +        cmd = enabled ? AUD_CNOTIFY_ENABLE : AUD_CNOTIFY_DISABLE;
  46.161 +        audio_notify_capture (cap, cmd);
  46.162 +    }
  46.163 +}
  46.164 +
  46.165 +static void audio_recalc_and_notify_capture (CaptureVoiceOut *cap)
  46.166 +{
  46.167 +    HWVoiceOut *hw = &cap->hw;
  46.168 +    SWVoiceOut *sw;
  46.169 +    int enabled = 0;
  46.170 +
  46.171 +    for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
  46.172 +        if (sw->active) {
  46.173 +            enabled = 1;
  46.174 +            break;
  46.175 +        }
  46.176 +    }
  46.177 +    audio_capture_maybe_changed (cap, enabled);
  46.178 +}
  46.179 +
  46.180 +static void audio_detach_capture (HWVoiceOut *hw)
  46.181 +{
  46.182 +    SWVoiceCap *sc = hw->cap_head.lh_first;
  46.183 +
  46.184 +    while (sc) {
  46.185 +        SWVoiceCap *sc1 = sc->entries.le_next;
  46.186 +        SWVoiceOut *sw = &sc->sw;
  46.187 +        CaptureVoiceOut *cap = sc->cap;
  46.188 +        int was_active = sw->active;
  46.189 +
  46.190 +        if (sw->rate) {
  46.191 +            st_rate_stop (sw->rate);
  46.192 +            sw->rate = NULL;
  46.193 +        }
  46.194 +
  46.195 +        LIST_REMOVE (sw, entries);
  46.196 +        LIST_REMOVE (sc, entries);
  46.197 +        qemu_free (sc);
  46.198 +        if (was_active) {
  46.199 +            /* We have removed soft voice from the capture:
  46.200 +               this might have changed the overall status of the capture
  46.201 +               since this might have been the only active voice */
  46.202 +            audio_recalc_and_notify_capture (cap);
  46.203 +        }
  46.204 +        sc = sc1;
  46.205 +    }
  46.206 +}
  46.207 +
  46.208 +static int audio_attach_capture (AudioState *s, HWVoiceOut *hw)
  46.209 +{
  46.210 +    CaptureVoiceOut *cap;
  46.211 +
  46.212 +    audio_detach_capture (hw);
  46.213 +    for (cap = s->cap_head.lh_first; cap; cap = cap->entries.le_next) {
  46.214 +        SWVoiceCap *sc;
  46.215 +        SWVoiceOut *sw;
  46.216 +        HWVoiceOut *hw_cap = &cap->hw;
  46.217 +
  46.218 +        sc = audio_calloc (AUDIO_FUNC, 1, sizeof (*sc));
  46.219 +        if (!sc) {
  46.220 +            dolog ("Could not allocate soft capture voice (%zu bytes)\n",
  46.221 +                   sizeof (*sc));
  46.222 +            return -1;
  46.223 +        }
  46.224 +
  46.225 +        sc->cap = cap;
  46.226 +        sw = &sc->sw;
  46.227 +        sw->hw = hw_cap;
  46.228 +        sw->info = hw->info;
  46.229 +        sw->empty = 1;
  46.230 +        sw->active = hw->enabled;
  46.231 +        sw->conv = noop_conv;
  46.232 +        sw->ratio = ((int64_t) hw_cap->info.freq << 32) / sw->info.freq;
  46.233 +        sw->rate = st_rate_start (sw->info.freq, hw_cap->info.freq);
  46.234 +        if (!sw->rate) {
  46.235 +            dolog ("Could not start rate conversion for `%s'\n", SW_NAME (sw));
  46.236 +            qemu_free (sw);
  46.237 +            return -1;
  46.238 +        }
  46.239 +        LIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries);
  46.240 +        LIST_INSERT_HEAD (&hw->cap_head, sc, entries);
  46.241 +#ifdef DEBUG_CAPTURE
  46.242 +        asprintf (&sw->name, "for %p %d,%d,%d",
  46.243 +                  hw, sw->info.freq, sw->info.bits, sw->info.nchannels);
  46.244 +        dolog ("Added %s active = %d\n", sw->name, sw->active);
  46.245 +#endif
  46.246 +        if (sw->active) {
  46.247 +            audio_capture_maybe_changed (cap, 1);
  46.248 +        }
  46.249 +    }
  46.250 +    return 0;
  46.251 +}
  46.252 +
  46.253 +/*
  46.254   * Hard voice (capture)
  46.255   */
  46.256  static int audio_pcm_hw_find_min_in (HWVoiceIn *hw)
  46.257 @@ -796,6 +941,9 @@ int audio_pcm_sw_write (SWVoiceOut *sw, 
  46.258      }
  46.259  
  46.260      if (live == hwsamples) {
  46.261 +#ifdef DEBUG_OUT
  46.262 +        dolog ("%s is full %d\n", sw->name, live);
  46.263 +#endif
  46.264          return 0;
  46.265      }
  46.266  
  46.267 @@ -914,19 +1062,14 @@ void AUD_set_active_out (SWVoiceOut *sw,
  46.268      hw = sw->hw;
  46.269      if (sw->active != on) {
  46.270          SWVoiceOut *temp_sw;
  46.271 +        SWVoiceCap *sc;
  46.272  
  46.273          if (on) {
  46.274 -            int total;
  46.275 -
  46.276              hw->pending_disable = 0;
  46.277              if (!hw->enabled) {
  46.278                  hw->enabled = 1;
  46.279                  hw->pcm_ops->ctl_out (hw, VOICE_ENABLE);
  46.280              }
  46.281 -
  46.282 -            if (sw->empty) {
  46.283 -                total = 0;
  46.284 -            }
  46.285          }
  46.286          else {
  46.287              if (hw->enabled) {
  46.288 @@ -940,6 +1083,13 @@ void AUD_set_active_out (SWVoiceOut *sw,
  46.289                  hw->pending_disable = nb_active == 1;
  46.290              }
  46.291          }
  46.292 +
  46.293 +        for (sc = hw->cap_head.lh_first; sc; sc = sc->entries.le_next) {
  46.294 +            sc->sw.active = hw->enabled;
  46.295 +            if (hw->enabled) {
  46.296 +                audio_capture_maybe_changed (sc->cap, 1);
  46.297 +            }
  46.298 +        }
  46.299          sw->active = on;
  46.300      }
  46.301  }
  46.302 @@ -997,7 +1147,7 @@ static int audio_get_avail (SWVoiceIn *s
  46.303      }
  46.304  
  46.305      ldebug (
  46.306 -        "%s: get_avail live %d ret %lld\n",
  46.307 +        "%s: get_avail live %d ret %" PRId64 "\n",
  46.308          SW_NAME (sw),
  46.309          live, (((int64_t) live << 32) / sw->ratio) << sw->info.shift
  46.310          );
  46.311 @@ -1023,7 +1173,7 @@ static int audio_get_free (SWVoiceOut *s
  46.312      dead = sw->hw->samples - live;
  46.313  
  46.314  #ifdef DEBUG_OUT
  46.315 -    dolog ("%s: get_free live %d dead %d ret %lld\n",
  46.316 +    dolog ("%s: get_free live %d dead %d ret %" PRId64 "\n",
  46.317             SW_NAME (sw),
  46.318             live, dead, (((int64_t) dead << 32) / sw->ratio) << sw->info.shift);
  46.319  #endif
  46.320 @@ -1031,6 +1181,43 @@ static int audio_get_free (SWVoiceOut *s
  46.321      return (((int64_t) dead << 32) / sw->ratio) << sw->info.shift;
  46.322  }
  46.323  
  46.324 +static void audio_capture_mix_and_clear (HWVoiceOut *hw, int rpos, int samples)
  46.325 +{
  46.326 +    int n;
  46.327 +
  46.328 +    if (hw->enabled) {
  46.329 +        SWVoiceCap *sc;
  46.330 +
  46.331 +        for (sc = hw->cap_head.lh_first; sc; sc = sc->entries.le_next) {
  46.332 +            SWVoiceOut *sw = &sc->sw;
  46.333 +            int rpos2 = rpos;
  46.334 +
  46.335 +            n = samples;
  46.336 +            while (n) {
  46.337 +                int till_end_of_hw = hw->samples - rpos2;
  46.338 +                int to_write = audio_MIN (till_end_of_hw, n);
  46.339 +                int bytes = to_write << hw->info.shift;
  46.340 +                int written;
  46.341 +
  46.342 +                sw->buf = hw->mix_buf + rpos2;
  46.343 +                written = audio_pcm_sw_write (sw, NULL, bytes);
  46.344 +                if (written - bytes) {
  46.345 +                    dolog ("Could not mix %d bytes into a capture "
  46.346 +                           "buffer, mixed %d\n",
  46.347 +                           bytes, written);
  46.348 +                    break;
  46.349 +                }
  46.350 +                n -= to_write;
  46.351 +                rpos2 = (rpos2 + to_write) % hw->samples;
  46.352 +            }
  46.353 +        }
  46.354 +    }
  46.355 +
  46.356 +    n = audio_MIN (samples, hw->samples - rpos);
  46.357 +    mixeng_clear (hw->mix_buf + rpos, n);
  46.358 +    mixeng_clear (hw->mix_buf, samples - n);
  46.359 +}
  46.360 +
  46.361  static void audio_run_out (AudioState *s)
  46.362  {
  46.363      HWVoiceOut *hw = NULL;
  46.364 @@ -1038,7 +1225,7 @@ static void audio_run_out (AudioState *s
  46.365  
  46.366      while ((hw = audio_pcm_hw_find_any_enabled_out (s, hw))) {
  46.367          int played;
  46.368 -        int live, free, nb_live, cleanup_required;
  46.369 +        int live, free, nb_live, cleanup_required, prev_rpos;
  46.370  
  46.371          live = audio_pcm_hw_get_live_out2 (hw, &nb_live);
  46.372          if (!nb_live) {
  46.373 @@ -1051,12 +1238,17 @@ static void audio_run_out (AudioState *s
  46.374          }
  46.375  
  46.376          if (hw->pending_disable && !nb_live) {
  46.377 +            SWVoiceCap *sc;
  46.378  #ifdef DEBUG_OUT
  46.379              dolog ("Disabling voice\n");
  46.380  #endif
  46.381              hw->enabled = 0;
  46.382              hw->pending_disable = 0;
  46.383              hw->pcm_ops->ctl_out (hw, VOICE_DISABLE);
  46.384 +            for (sc = hw->cap_head.lh_first; sc; sc = sc->entries.le_next) {
  46.385 +                sc->sw.active = 0;
  46.386 +                audio_recalc_and_notify_capture (sc->cap);
  46.387 +            }
  46.388              continue;
  46.389          }
  46.390  
  46.391 @@ -1072,6 +1264,7 @@ static void audio_run_out (AudioState *s
  46.392              continue;
  46.393          }
  46.394  
  46.395 +        prev_rpos = hw->rpos;
  46.396          played = hw->pcm_ops->run_out (hw);
  46.397          if (audio_bug (AUDIO_FUNC, hw->rpos >= hw->samples)) {
  46.398              dolog ("hw->rpos=%d hw->samples=%d played=%d\n",
  46.399 @@ -1085,6 +1278,7 @@ static void audio_run_out (AudioState *s
  46.400  
  46.401          if (played) {
  46.402              hw->ts_helper += played;
  46.403 +            audio_capture_mix_and_clear (hw, prev_rpos, played);
  46.404          }
  46.405  
  46.406          cleanup_required = 0;
  46.407 @@ -1115,15 +1309,18 @@ static void audio_run_out (AudioState *s
  46.408          }
  46.409  
  46.410          if (cleanup_required) {
  46.411 -        restart:
  46.412 -            for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
  46.413 +            SWVoiceOut *sw1;
  46.414 +
  46.415 +            sw = hw->sw_head.lh_first;
  46.416 +            while (sw) {
  46.417 +                sw1 = sw->entries.le_next;
  46.418                  if (!sw->active && !sw->callback.fn) {
  46.419  #ifdef DEBUG_PLIVE
  46.420                      dolog ("Finishing with old voice\n");
  46.421  #endif
  46.422                      audio_close_out (s, sw);
  46.423 -                    goto restart; /* play it safe */
  46.424                  }
  46.425 +                sw = sw1;
  46.426              }
  46.427          }
  46.428      }
  46.429 @@ -1158,12 +1355,60 @@ static void audio_run_in (AudioState *s)
  46.430      }
  46.431  }
  46.432  
  46.433 +static void audio_run_capture (AudioState *s)
  46.434 +{
  46.435 +    CaptureVoiceOut *cap;
  46.436 +
  46.437 +    for (cap = s->cap_head.lh_first; cap; cap = cap->entries.le_next) {
  46.438 +        int live, rpos, captured;
  46.439 +        HWVoiceOut *hw = &cap->hw;
  46.440 +        SWVoiceOut *sw;
  46.441 +
  46.442 +        captured = live = audio_pcm_hw_get_live_out (hw);
  46.443 +        rpos = hw->rpos;
  46.444 +        while (live) {
  46.445 +            int left = hw->samples - rpos;
  46.446 +            int to_capture = audio_MIN (live, left);
  46.447 +            st_sample_t *src;
  46.448 +            struct capture_callback *cb;
  46.449 +
  46.450 +            src = hw->mix_buf + rpos;
  46.451 +            hw->clip (cap->buf, src, to_capture);
  46.452 +            mixeng_clear (src, to_capture);
  46.453 +
  46.454 +            for (cb = cap->cb_head.lh_first; cb; cb = cb->entries.le_next) {
  46.455 +                cb->ops.capture (cb->opaque, cap->buf,
  46.456 +                                 to_capture << hw->info.shift);
  46.457 +            }
  46.458 +            rpos = (rpos + to_capture) % hw->samples;
  46.459 +            live -= to_capture;
  46.460 +        }
  46.461 +        hw->rpos = rpos;
  46.462 +
  46.463 +        for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
  46.464 +            if (!sw->active && sw->empty) {
  46.465 +                continue;
  46.466 +            }
  46.467 +
  46.468 +            if (audio_bug (AUDIO_FUNC, captured > sw->total_hw_samples_mixed)) {
  46.469 +                dolog ("captured=%d sw->total_hw_samples_mixed=%d\n",
  46.470 +                       captured, sw->total_hw_samples_mixed);
  46.471 +                captured = sw->total_hw_samples_mixed;
  46.472 +            }
  46.473 +
  46.474 +            sw->total_hw_samples_mixed -= captured;
  46.475 +            sw->empty = sw->total_hw_samples_mixed == 0;
  46.476 +        }
  46.477 +    }
  46.478 +}
  46.479 +
  46.480  static void audio_timer (void *opaque)
  46.481  {
  46.482      AudioState *s = opaque;
  46.483  
  46.484      audio_run_out (s);
  46.485      audio_run_in (s);
  46.486 +    audio_run_capture (s);
  46.487  
  46.488      qemu_mod_timer (s->ts, qemu_get_clock (vm_clock) + conf.period.ticks);
  46.489  }
  46.490 @@ -1327,8 +1572,19 @@ static void audio_atexit (void)
  46.491      HWVoiceIn *hwi = NULL;
  46.492  
  46.493      while ((hwo = audio_pcm_hw_find_any_enabled_out (s, hwo))) {
  46.494 +        SWVoiceCap *sc;
  46.495 +
  46.496          hwo->pcm_ops->ctl_out (hwo, VOICE_DISABLE);
  46.497          hwo->pcm_ops->fini_out (hwo);
  46.498 +
  46.499 +        for (sc = hwo->cap_head.lh_first; sc; sc = sc->entries.le_next) {
  46.500 +            CaptureVoiceOut *cap = sc->cap;
  46.501 +            struct capture_callback *cb;
  46.502 +
  46.503 +            for (cb = cap->cb_head.lh_first; cb; cb = cb->entries.le_next) {
  46.504 +                cb->ops.destroy (cb->opaque);
  46.505 +            }
  46.506 +        }
  46.507      }
  46.508  
  46.509      while ((hwi = audio_pcm_hw_find_any_enabled_in (s, hwi))) {
  46.510 @@ -1383,6 +1639,7 @@ AudioState *AUD_init (void)
  46.511  
  46.512      LIST_INIT (&s->hw_head_out);
  46.513      LIST_INIT (&s->hw_head_in);
  46.514 +    LIST_INIT (&s->cap_head);
  46.515      atexit (audio_atexit);
  46.516  
  46.517      s->ts = qemu_new_timer (vm_clock, audio_timer, s);
  46.518 @@ -1479,3 +1736,136 @@ AudioState *AUD_init (void)
  46.519      qemu_mod_timer (s->ts, qemu_get_clock (vm_clock) + conf.period.ticks);
  46.520      return s;
  46.521  }
  46.522 +
  46.523 +CaptureVoiceOut *AUD_add_capture (
  46.524 +    AudioState *s,
  46.525 +    audsettings_t *as,
  46.526 +    struct audio_capture_ops *ops,
  46.527 +    void *cb_opaque
  46.528 +    )
  46.529 +{
  46.530 +    CaptureVoiceOut *cap;
  46.531 +    struct capture_callback *cb;
  46.532 +
  46.533 +    if (!s) {
  46.534 +        /* XXX suppress */
  46.535 +        s = &glob_audio_state;
  46.536 +    }
  46.537 +
  46.538 +    if (audio_validate_settings (as)) {
  46.539 +        dolog ("Invalid settings were passed when trying to add capture\n");
  46.540 +        audio_print_settings (as);
  46.541 +        goto err0;
  46.542 +    }
  46.543 +
  46.544 +    cb = audio_calloc (AUDIO_FUNC, 1, sizeof (*cb));
  46.545 +    if (!cb) {
  46.546 +        dolog ("Could not allocate capture callback information, size %zu\n",
  46.547 +               sizeof (*cb));
  46.548 +        goto err0;
  46.549 +    }
  46.550 +    cb->ops = *ops;
  46.551 +    cb->opaque = cb_opaque;
  46.552 +
  46.553 +    cap = audio_pcm_capture_find_specific (s, as);
  46.554 +    if (cap) {
  46.555 +        LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
  46.556 +        return cap;
  46.557 +    }
  46.558 +    else {
  46.559 +        HWVoiceOut *hw;
  46.560 +        CaptureVoiceOut *cap;
  46.561 +
  46.562 +        cap = audio_calloc (AUDIO_FUNC, 1, sizeof (*cap));
  46.563 +        if (!cap) {
  46.564 +            dolog ("Could not allocate capture voice, size %zu\n",
  46.565 +                   sizeof (*cap));
  46.566 +            goto err1;
  46.567 +        }
  46.568 +
  46.569 +        hw = &cap->hw;
  46.570 +        LIST_INIT (&hw->sw_head);
  46.571 +        LIST_INIT (&cap->cb_head);
  46.572 +
  46.573 +        /* XXX find a more elegant way */
  46.574 +        hw->samples = 4096 * 4;
  46.575 +        hw->mix_buf = audio_calloc (AUDIO_FUNC, hw->samples,
  46.576 +                                    sizeof (st_sample_t));
  46.577 +        if (!hw->mix_buf) {
  46.578 +            dolog ("Could not allocate capture mix buffer (%d samples)\n",
  46.579 +                   hw->samples);
  46.580 +            goto err2;
  46.581 +        }
  46.582 +
  46.583 +        audio_pcm_init_info (&hw->info, as);
  46.584 +
  46.585 +        cap->buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
  46.586 +        if (!cap->buf) {
  46.587 +            dolog ("Could not allocate capture buffer "
  46.588 +                   "(%d samples, each %d bytes)\n",
  46.589 +                   hw->samples, 1 << hw->info.shift);
  46.590 +            goto err3;
  46.591 +        }
  46.592 +
  46.593 +        hw->clip = mixeng_clip
  46.594 +            [hw->info.nchannels == 2]
  46.595 +            [hw->info.sign]
  46.596 +            [hw->info.swap_endianness]
  46.597 +            [hw->info.bits == 16];
  46.598 +
  46.599 +        LIST_INSERT_HEAD (&s->cap_head, cap, entries);
  46.600 +        LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
  46.601 +
  46.602 +        hw = NULL;
  46.603 +        while ((hw = audio_pcm_hw_find_any_out (s, hw))) {
  46.604 +            audio_attach_capture (s, hw);
  46.605 +        }
  46.606 +        return cap;
  46.607 +
  46.608 +    err3:
  46.609 +        qemu_free (cap->hw.mix_buf);
  46.610 +    err2:
  46.611 +        qemu_free (cap);
  46.612 +    err1:
  46.613 +        qemu_free (cb);
  46.614 +    err0:
  46.615 +        return NULL;
  46.616 +    }
  46.617 +}
  46.618 +
  46.619 +void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque)
  46.620 +{
  46.621 +    struct capture_callback *cb;
  46.622 +
  46.623 +    for (cb = cap->cb_head.lh_first; cb; cb = cb->entries.le_next) {
  46.624 +        if (cb->opaque == cb_opaque) {
  46.625 +            cb->ops.destroy (cb_opaque);
  46.626 +            LIST_REMOVE (cb, entries);
  46.627 +            qemu_free (cb);
  46.628 +
  46.629 +            if (!cap->cb_head.lh_first) {
  46.630 +                SWVoiceOut *sw = cap->hw.sw_head.lh_first, *sw1;
  46.631 +
  46.632 +                while (sw) {
  46.633 +                    SWVoiceCap *sc = (SWVoiceCap *) sw;
  46.634 +#ifdef DEBUG_CAPTURE
  46.635 +                    dolog ("freeing %s\n", sw->name);
  46.636 +#endif
  46.637 +
  46.638 +                    sw1 = sw->entries.le_next;
  46.639 +                    if (sw->rate) {
  46.640 +                        st_rate_stop (sw->rate);
  46.641 +                        sw->rate = NULL;
  46.642 +                    }
  46.643 +                    LIST_REMOVE (sw, entries);
  46.644 +                    LIST_REMOVE (sc, entries);
  46.645 +                    qemu_free (sc);
  46.646 +                    sw = sw1;
  46.647 +                }
  46.648 +                LIST_REMOVE (cap, entries);
  46.649 +                qemu_free (cap);
  46.650 +            }
  46.651 +            return;
  46.652 +        }
  46.653 +    }
  46.654 +}
    47.1 --- a/tools/ioemu/audio/audio.h	Wed Aug 09 08:01:52 2006 -0600
    47.2 +++ b/tools/ioemu/audio/audio.h	Wed Aug 09 08:34:06 2006 -0600
    47.3 @@ -24,6 +24,7 @@
    47.4  #ifndef QEMU_AUDIO_H
    47.5  #define QEMU_AUDIO_H
    47.6  
    47.7 +#include "config.h"
    47.8  #include "sys-queue.h"
    47.9  
   47.10  typedef void (*audio_callback_fn_t) (void *opaque, int avail);
   47.11 @@ -35,14 +36,44 @@ typedef enum {
   47.12      AUD_FMT_S16
   47.13  } audfmt_e;
   47.14  
   47.15 +#ifdef WORDS_BIGENDIAN
   47.16 +#define AUDIO_HOST_ENDIANNESS 1
   47.17 +#else
   47.18 +#define AUDIO_HOST_ENDIANNESS 0
   47.19 +#endif
   47.20 +
   47.21  typedef struct {
   47.22      int freq;
   47.23      int nchannels;
   47.24      audfmt_e fmt;
   47.25 +    int endianness;
   47.26  } audsettings_t;
   47.27  
   47.28 +typedef enum {
   47.29 +    AUD_CNOTIFY_ENABLE,
   47.30 +    AUD_CNOTIFY_DISABLE
   47.31 +} audcnotification_e;
   47.32 +
   47.33 +struct audio_capture_ops {
   47.34 +    void (*notify) (void *opaque, audcnotification_e cmd);
   47.35 +    void (*capture) (void *opaque, void *buf, int size);
   47.36 +    void (*destroy) (void *opaque);
   47.37 +};
   47.38 +
   47.39 +struct capture_ops {
   47.40 +    void (*info) (void *opaque);
   47.41 +    void (*destroy) (void *opaque);
   47.42 +};
   47.43 +
   47.44 +typedef struct CaptureState {
   47.45 +    void *opaque;
   47.46 +    struct capture_ops ops;
   47.47 +    LIST_ENTRY (CaptureState) entries;
   47.48 +} CaptureState;
   47.49 +
   47.50  typedef struct AudioState AudioState;
   47.51  typedef struct SWVoiceOut SWVoiceOut;
   47.52 +typedef struct CaptureVoiceOut CaptureVoiceOut;
   47.53  typedef struct SWVoiceIn SWVoiceIn;
   47.54  
   47.55  typedef struct QEMUSoundCard {
   47.56 @@ -66,6 +97,13 @@ AudioState *AUD_init (void);
   47.57  void AUD_help (void);
   47.58  void AUD_register_card (AudioState *s, const char *name, QEMUSoundCard *card);
   47.59  void AUD_remove_card (QEMUSoundCard *card);
   47.60 +CaptureVoiceOut *AUD_add_capture (
   47.61 +    AudioState *s,
   47.62 +    audsettings_t *as,
   47.63 +    struct audio_capture_ops *ops,
   47.64 +    void *opaque
   47.65 +    );
   47.66 +void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque);
   47.67  
   47.68  SWVoiceOut *AUD_open_out (
   47.69      QEMUSoundCard *card,
   47.70 @@ -73,8 +111,7 @@ SWVoiceOut *AUD_open_out (
   47.71      const char *name,
   47.72      void *callback_opaque,
   47.73      audio_callback_fn_t callback_fn,
   47.74 -    audsettings_t *settings,
   47.75 -    int sw_endian
   47.76 +    audsettings_t *settings
   47.77      );
   47.78  
   47.79  void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
   47.80 @@ -92,8 +129,7 @@ SWVoiceIn *AUD_open_in (
   47.81      const char *name,
   47.82      void *callback_opaque,
   47.83      audio_callback_fn_t callback_fn,
   47.84 -    audsettings_t *settings,
   47.85 -    int sw_endian
   47.86 +    audsettings_t *settings
   47.87      );
   47.88  
   47.89  void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
   47.90 @@ -111,7 +147,7 @@ static inline void *advance (void *p, in
   47.91  }
   47.92  
   47.93  uint32_t popcount (uint32_t u);
   47.94 -inline uint32_t lsbindex (uint32_t u);
   47.95 +uint32_t lsbindex (uint32_t u);
   47.96  
   47.97  #ifdef __GNUC__
   47.98  #define audio_MIN(a, b) ( __extension__ ({      \
    48.1 --- a/tools/ioemu/audio/audio_int.h	Wed Aug 09 08:01:52 2006 -0600
    48.2 +++ b/tools/ioemu/audio/audio_int.h	Wed Aug 09 08:34:06 2006 -0600
    48.3 @@ -61,13 +61,14 @@ struct audio_pcm_info {
    48.4      int align;
    48.5      int shift;
    48.6      int bytes_per_second;
    48.7 -    int swap_endian;
    48.8 +    int swap_endianness;
    48.9  };
   48.10  
   48.11 +typedef struct SWVoiceCap SWVoiceCap;
   48.12 +
   48.13  typedef struct HWVoiceOut {
   48.14      int enabled;
   48.15      int pending_disable;
   48.16 -    int valid;
   48.17      struct audio_pcm_info info;
   48.18  
   48.19      f_sample *clip;
   48.20 @@ -79,6 +80,7 @@ typedef struct HWVoiceOut {
   48.21  
   48.22      int samples;
   48.23      LIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
   48.24 +    LIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head;
   48.25      struct audio_pcm_ops *pcm_ops;
   48.26      LIST_ENTRY (HWVoiceOut) entries;
   48.27  } HWVoiceOut;
   48.28 @@ -160,14 +162,34 @@ struct audio_pcm_ops {
   48.29      int  (*ctl_in)  (HWVoiceIn *hw, int cmd, ...);
   48.30  };
   48.31  
   48.32 +struct capture_callback {
   48.33 +    struct audio_capture_ops ops;
   48.34 +    void *opaque;
   48.35 +    LIST_ENTRY (capture_callback) entries;
   48.36 +};
   48.37 +
   48.38 +struct CaptureVoiceOut {
   48.39 +    HWVoiceOut hw;
   48.40 +    void *buf;
   48.41 +    LIST_HEAD (cb_listhead, capture_callback) cb_head;
   48.42 +    LIST_ENTRY (CaptureVoiceOut) entries;
   48.43 +};
   48.44 +
   48.45 +struct SWVoiceCap {
   48.46 +    SWVoiceOut sw;
   48.47 +    CaptureVoiceOut *cap;
   48.48 +    LIST_ENTRY (SWVoiceCap) entries;
   48.49 +};
   48.50 +
   48.51  struct AudioState {
   48.52      struct audio_driver *drv;
   48.53      void *drv_opaque;
   48.54  
   48.55      QEMUTimer *ts;
   48.56 -    LIST_HEAD (card_head, QEMUSoundCard) card_head;
   48.57 +    LIST_HEAD (card_listhead, QEMUSoundCard) card_head;
   48.58      LIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in;
   48.59      LIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out;
   48.60 +    LIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
   48.61      int nb_hw_voices_out;
   48.62      int nb_hw_voices_in;
   48.63  };
   48.64 @@ -182,8 +204,7 @@ extern struct audio_driver coreaudio_aud
   48.65  extern struct audio_driver dsound_audio_driver;
   48.66  extern volume_t nominal_volume;
   48.67  
   48.68 -void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as,
   48.69 -                          int swap_endian);
   48.70 +void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as);
   48.71  void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
   48.72  
   48.73  int  audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int len);
   48.74 @@ -204,15 +225,6 @@ static inline int audio_ring_dist (int d
   48.75      return (dst >= src) ? (dst - src) : (len - src + dst);
   48.76  }
   48.77  
   48.78 -static inline int audio_need_to_swap_endian (int endianness)
   48.79 -{
   48.80 -#ifdef WORDS_BIGENDIAN
   48.81 -    return endianness != 1;
   48.82 -#else
   48.83 -    return endianness != 0;
   48.84 -#endif
   48.85 -}
   48.86 -
   48.87  #if defined __GNUC__
   48.88  #define GCC_ATTR __attribute__ ((__unused__, __format__ (__printf__, 1, 2)))
   48.89  #define INIT_FIELD(f) . f
    49.1 --- a/tools/ioemu/audio/audio_template.h	Wed Aug 09 08:01:52 2006 -0600
    49.2 +++ b/tools/ioemu/audio/audio_template.h	Wed Aug 09 08:34:06 2006 -0600
    49.3 @@ -140,13 +140,12 @@ static int glue (audio_pcm_sw_init_, TYP
    49.4      SW *sw,
    49.5      HW *hw,
    49.6      const char *name,
    49.7 -    audsettings_t *as,
    49.8 -    int endian
    49.9 +    audsettings_t *as
   49.10      )
   49.11  {
   49.12      int err;
   49.13  
   49.14 -    audio_pcm_init_info (&sw->info, as, audio_need_to_swap_endian (endian));
   49.15 +    audio_pcm_init_info (&sw->info, as);
   49.16      sw->hw = hw;
   49.17      sw->active = 0;
   49.18  #ifdef DAC
   49.19 @@ -164,7 +163,7 @@ static int glue (audio_pcm_sw_init_, TYP
   49.20  #endif
   49.21          [sw->info.nchannels == 2]
   49.22          [sw->info.sign]
   49.23 -        [sw->info.swap_endian]
   49.24 +        [sw->info.swap_endianness]
   49.25          [sw->info.bits == 16];
   49.26  
   49.27      sw->name = qemu_strdup (name);
   49.28 @@ -200,6 +199,9 @@ static void glue (audio_pcm_hw_gc_, TYPE
   49.29      HW *hw = *hwp;
   49.30  
   49.31      if (!hw->sw_head.lh_first) {
   49.32 +#ifdef DAC
   49.33 +        audio_detach_capture (hw);
   49.34 +#endif
   49.35          LIST_REMOVE (hw, entries);
   49.36          glue (s->nb_hw_voices_, TYPE) += 1;
   49.37          glue (audio_pcm_hw_free_resources_ ,TYPE) (hw);
   49.38 @@ -266,7 +268,9 @@ static HW *glue (audio_pcm_hw_add_new_, 
   49.39  
   49.40      hw->pcm_ops = drv->pcm_ops;
   49.41      LIST_INIT (&hw->sw_head);
   49.42 -
   49.43 +#ifdef DAC
   49.44 +    LIST_INIT (&hw->cap_head);
   49.45 +#endif
   49.46      if (glue (hw->pcm_ops->init_, TYPE) (hw, as)) {
   49.47          goto err0;
   49.48      }
   49.49 @@ -283,7 +287,7 @@ static HW *glue (audio_pcm_hw_add_new_, 
   49.50  #endif
   49.51          [hw->info.nchannels == 2]
   49.52          [hw->info.sign]
   49.53 -        [hw->info.swap_endian]
   49.54 +        [hw->info.swap_endianness]
   49.55          [hw->info.bits == 16];
   49.56  
   49.57      if (glue (audio_pcm_hw_alloc_resources_, TYPE) (hw)) {
   49.58 @@ -292,6 +296,9 @@ static HW *glue (audio_pcm_hw_add_new_, 
   49.59  
   49.60      LIST_INSERT_HEAD (&s->glue (hw_head_, TYPE), hw, entries);
   49.61      glue (s->nb_hw_voices_, TYPE) -= 1;
   49.62 +#ifdef DAC
   49.63 +    audio_attach_capture (s, hw);
   49.64 +#endif
   49.65      return hw;
   49.66  
   49.67   err1:
   49.68 @@ -328,8 +335,7 @@ static HW *glue (audio_pcm_hw_add_, TYPE
   49.69  static SW *glue (audio_pcm_create_voice_pair_, TYPE) (
   49.70      AudioState *s,
   49.71      const char *sw_name,
   49.72 -    audsettings_t *as,
   49.73 -    int sw_endian
   49.74 +    audsettings_t *as
   49.75      )
   49.76  {
   49.77      SW *sw;
   49.78 @@ -357,7 +363,7 @@ static SW *glue (audio_pcm_create_voice_
   49.79  
   49.80      glue (audio_pcm_hw_add_sw_, TYPE) (hw, sw);
   49.81  
   49.82 -    if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, sw_name, as, sw_endian)) {
   49.83 +    if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, sw_name, as)) {
   49.84          goto err3;
   49.85      }
   49.86  
   49.87 @@ -399,8 +405,7 @@ SW *glue (AUD_open_, TYPE) (
   49.88      const char *name,
   49.89      void *callback_opaque ,
   49.90      audio_callback_fn_t callback_fn,
   49.91 -    audsettings_t *as,
   49.92 -    int sw_endian
   49.93 +    audsettings_t *as
   49.94      )
   49.95  {
   49.96      AudioState *s;
   49.97 @@ -421,7 +426,7 @@ SW *glue (AUD_open_, TYPE) (
   49.98  
   49.99      s = card->audio;
  49.100  
  49.101 -    if (audio_bug (AUDIO_FUNC, audio_validate_settigs (as))) {
  49.102 +    if (audio_bug (AUDIO_FUNC, audio_validate_settings (as))) {
  49.103          audio_print_settings (as);
  49.104          goto fail;
  49.105      }
  49.106 @@ -473,12 +478,12 @@ SW *glue (AUD_open_, TYPE) (
  49.107          }
  49.108  
  49.109          glue (audio_pcm_sw_fini_, TYPE) (sw);
  49.110 -        if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, name, as, sw_endian)) {
  49.111 +        if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, name, as)) {
  49.112              goto fail;
  49.113          }
  49.114      }
  49.115      else {
  49.116 -        sw = glue (audio_pcm_create_voice_pair_, TYPE) (s, name, as, sw_endian);
  49.117 +        sw = glue (audio_pcm_create_voice_pair_, TYPE) (s, name, as);
  49.118          if (!sw) {
  49.119              dolog ("Failed to create voice `%s'\n", name);
  49.120              return NULL;
    50.1 --- a/tools/ioemu/audio/coreaudio.c	Wed Aug 09 08:01:52 2006 -0600
    50.2 +++ b/tools/ioemu/audio/coreaudio.c	Wed Aug 09 08:34:06 2006 -0600
    50.3 @@ -275,8 +275,6 @@ static OSStatus audioDeviceIOProc(
    50.4  #endif
    50.5      }
    50.6  
    50.7 -    /* cleanup */
    50.8 -    mixeng_clear (src, frameCount);
    50.9      rpos = (rpos + frameCount) % hw->samples;
   50.10      core->decr += frameCount;
   50.11      core->rpos = rpos;
   50.12 @@ -297,7 +295,6 @@ static int coreaudio_init_out (HWVoiceOu
   50.13      UInt32 propertySize;
   50.14      int err;
   50.15      int bits = 8;
   50.16 -    int endianess = 0;
   50.17      const char *typ = "playback";
   50.18      AudioValueRange frameRange;
   50.19  
   50.20 @@ -310,16 +307,9 @@ static int coreaudio_init_out (HWVoiceOu
   50.21  
   50.22      if (as->fmt == AUD_FMT_S16 || as->fmt == AUD_FMT_U16) {
   50.23          bits = 16;
   50.24 -        endianess = 1;
   50.25      }
   50.26  
   50.27 -    audio_pcm_init_info (
   50.28 -        &hw->info,
   50.29 -        as,
   50.30 -        /* Following is irrelevant actually since we do not use
   50.31 -           mixengs clipping routines */
   50.32 -        audio_need_to_swap_endian (endianess)
   50.33 -        );
   50.34 +    audio_pcm_init_info (&hw->info, as);
   50.35  
   50.36      /* open default output device */
   50.37      propertySize = sizeof(core->outputDeviceID);
    51.1 --- a/tools/ioemu/audio/dsound_template.h	Wed Aug 09 08:01:52 2006 -0600
    51.2 +++ b/tools/ioemu/audio/dsound_template.h	Wed Aug 09 08:34:06 2006 -0600
    51.3 @@ -70,7 +70,13 @@ static int glue (dsound_lock_, TYPE) (
    51.4      int i;
    51.5      LPVOID p1 = NULL, p2 = NULL;
    51.6      DWORD blen1 = 0, blen2 = 0;
    51.7 +    DWORD flag;
    51.8  
    51.9 +#ifdef DSBTYPE_IN
   51.10 +    flag = entire ? DSCBLOCK_ENTIREBUFFER : 0;
   51.11 +#else
   51.12 +    flag = entire ? DSBLOCK_ENTIREBUFFER : 0;
   51.13 +#endif
   51.14      for (i = 0; i < conf.lock_retries; ++i) {
   51.15          hr = glue (IFACE, _Lock) (
   51.16              buf,
   51.17 @@ -80,13 +86,7 @@ static int glue (dsound_lock_, TYPE) (
   51.18              &blen1,
   51.19              &p2,
   51.20              &blen2,
   51.21 -            (entire
   51.22 -#ifdef DSBTYPE_IN
   51.23 -             ? DSCBLOCK_ENTIREBUFFER
   51.24 -#else
   51.25 -             ? DSBLOCK_ENTIREBUFFER
   51.26 -#endif
   51.27 -             : 0)
   51.28 +            flag
   51.29              );
   51.30  
   51.31          if (FAILED (hr)) {
   51.32 @@ -250,8 +250,8 @@ static int dsound_init_out (HWVoiceOut *
   51.33      }
   51.34  
   51.35      ds->first_time = 1;
   51.36 -
   51.37 -    audio_pcm_init_info (&hw->info, &obt_as, audio_need_to_swap_endian (0));
   51.38 +    obt_as.endianness = 0;
   51.39 +    audio_pcm_init_info (&hw->info, &obt_as);
   51.40  
   51.41      if (bc.dwBufferBytes & hw->info.align) {
   51.42          dolog (
    52.1 --- a/tools/ioemu/audio/dsoundaudio.c	Wed Aug 09 08:01:52 2006 -0600
    52.2 +++ b/tools/ioemu/audio/dsoundaudio.c	Wed Aug 09 08:34:06 2006 -0600
    52.3 @@ -453,13 +453,11 @@ static void dsound_write_sample (HWVoice
    52.4  
    52.5      if (src_len1) {
    52.6          hw->clip (dst, src1, src_len1);
    52.7 -        mixeng_clear (src1, src_len1);
    52.8      }
    52.9  
   52.10      if (src_len2) {
   52.11          dst = advance (dst, src_len1 << hw->info.shift);
   52.12          hw->clip (dst, src2, src_len2);
   52.13 -        mixeng_clear (src2, src_len2);
   52.14      }
   52.15  
   52.16      hw->rpos = pos % hw->samples;
   52.17 @@ -987,6 +985,12 @@ static void *dsound_audio_init (void)
   52.18      hr = IDirectSound_Initialize (s->dsound, NULL);
   52.19      if (FAILED (hr)) {
   52.20          dsound_logerr (hr, "Could not initialize DirectSound\n");
   52.21 +
   52.22 +        hr = IDirectSound_Release (s->dsound);
   52.23 +        if (FAILED (hr)) {
   52.24 +            dsound_logerr (hr, "Could not release DirectSound\n");
   52.25 +        }
   52.26 +        s->dsound = NULL;
   52.27          return NULL;
   52.28      }
   52.29  
    53.1 --- a/tools/ioemu/audio/fmodaudio.c	Wed Aug 09 08:01:52 2006 -0600
    53.2 +++ b/tools/ioemu/audio/fmodaudio.c	Wed Aug 09 08:34:06 2006 -0600
    53.3 @@ -153,13 +153,11 @@ static void fmod_write_sample (HWVoiceOu
    53.4  
    53.5      if (src_len1) {
    53.6          hw->clip (dst, src1, src_len1);
    53.7 -        mixeng_clear (src1, src_len1);
    53.8      }
    53.9  
   53.10      if (src_len2) {
   53.11          dst = advance (dst, src_len1 << hw->info.shift);
   53.12          hw->clip (dst, src2, src_len2);
   53.13 -        mixeng_clear (src2, src_len2);
   53.14      }
   53.15  
   53.16      hw->rpos = pos % hw->samples;
   53.17 @@ -360,6 +358,7 @@ static int fmod_init_out (HWVoiceOut *hw
   53.18  {
   53.19      int bits16, mode, channel;
   53.20      FMODVoiceOut *fmd = (FMODVoiceOut *) hw;
   53.21 +    audsettings_t obt_as = *as;
   53.22  
   53.23      mode = aud_to_fmodfmt (as->fmt, as->nchannels == 2 ? 1 : 0);
   53.24      fmd->fmod_sample = FSOUND_Sample_Alloc (
   53.25 @@ -386,7 +385,8 @@ static int fmod_init_out (HWVoiceOut *hw
   53.26      fmd->channel = channel;
   53.27  
   53.28      /* FMOD always operates on little endian frames? */
   53.29 -    audio_pcm_init_info (&hw->info, as, audio_need_to_swap_endian (0));
   53.30 +    obt_as.endianness = 0;
   53.31 +    audio_pcm_init_info (&hw->info, &obt_as);
   53.32      bits16 = (mode & FSOUND_16BITS) != 0;
   53.33      hw->samples = conf.nb_samples;
   53.34      return 0;
   53.35 @@ -420,6 +420,7 @@ static int fmod_init_in (HWVoiceIn *hw, 
   53.36  {
   53.37      int bits16, mode;
   53.38      FMODVoiceIn *fmd = (FMODVoiceIn *) hw;
   53.39 +    audsettings_t obt_as = *as;
   53.40  
   53.41      if (conf.broken_adc) {
   53.42          return -1;
   53.43 @@ -442,7 +443,8 @@ static int fmod_init_in (HWVoiceIn *hw, 
   53.44      }
   53.45  
   53.46      /* FMOD always operates on little endian frames? */
   53.47 -    audio_pcm_init_info (&hw->info, as, audio_need_to_swap_endian (0));
   53.48 +    obt_as.endianness = 0;
   53.49 +    audio_pcm_init_info (&hw->info, &obt_as);
   53.50      bits16 = (mode & FSOUND_16BITS) != 0;
   53.51      hw->samples = conf.nb_samples;
   53.52      return 0;
    54.1 --- a/tools/ioemu/audio/noaudio.c	Wed Aug 09 08:01:52 2006 -0600
    54.2 +++ b/tools/ioemu/audio/noaudio.c	Wed Aug 09 08:34:06 2006 -0600
    54.3 @@ -40,22 +40,21 @@ static int no_run_out (HWVoiceOut *hw)
    54.4  {
    54.5      NoVoiceOut *no = (NoVoiceOut *) hw;
    54.6      int live, decr, samples;
    54.7 -    int64_t now = qemu_get_clock (vm_clock);
    54.8 -    int64_t ticks = now - no->old_ticks;
    54.9 -    int64_t bytes = (ticks * hw->info.bytes_per_second) / ticks_per_sec;
   54.10 -
   54.11 -    if (bytes > INT_MAX) {
   54.12 -        samples = INT_MAX >> hw->info.shift;
   54.13 -    }
   54.14 -    else {
   54.15 -        samples = bytes >> hw->info.shift;
   54.16 -    }
   54.17 +    int64_t now;
   54.18 +    int64_t ticks;
   54.19 +    int64_t bytes;
   54.20  
   54.21      live = audio_pcm_hw_get_live_out (&no->hw);
   54.22      if (!live) {
   54.23          return 0;
   54.24      }
   54.25  
   54.26 +    now = qemu_get_clock (vm_clock);
   54.27 +    ticks = now - no->old_ticks;
   54.28 +    bytes = (ticks * hw->info.bytes_per_second) / ticks_per_sec;
   54.29 +    bytes = audio_MIN (bytes, INT_MAX);
   54.30 +    samples = bytes >> hw->info.shift;
   54.31 +
   54.32      no->old_ticks = now;
   54.33      decr = audio_MIN (live, samples);
   54.34      hw->rpos = (hw->rpos + decr) % hw->samples;
   54.35 @@ -69,7 +68,7 @@ static int no_write (SWVoiceOut *sw, voi
   54.36  
   54.37  static int no_init_out (HWVoiceOut *hw, audsettings_t *as)
   54.38  {
   54.39 -    audio_pcm_init_info (&hw->info, as, 0);
   54.40 +    audio_pcm_init_info (&hw->info, as);
   54.41      hw->samples = 1024;
   54.42      return 0;
   54.43  }
   54.44 @@ -88,7 +87,7 @@ static int no_ctl_out (HWVoiceOut *hw, i
   54.45  
   54.46  static int no_init_in (HWVoiceIn *hw, audsettings_t *as)
   54.47  {
   54.48 -    audio_pcm_init_info (&hw->info, as, 0);
   54.49 +    audio_pcm_init_info (&hw->info, as);
   54.50      hw->samples = 1024;
   54.51      return 0;
   54.52  }
   54.53 @@ -101,17 +100,20 @@ static void no_fini_in (HWVoiceIn *hw)
   54.54  static int no_run_in (HWVoiceIn *hw)
   54.55  {
   54.56      NoVoiceIn *no = (NoVoiceIn *) hw;
   54.57 -    int64_t now = qemu_get_clock (vm_clock);
   54.58 -    int64_t ticks = now - no->old_ticks;
   54.59 -    int64_t bytes = (ticks * hw->info.bytes_per_second) / ticks_per_sec;
   54.60      int live = audio_pcm_hw_get_live_in (hw);
   54.61      int dead = hw->samples - live;
   54.62 -    int samples;
   54.63 +    int samples = 0;
   54.64  
   54.65 -    bytes = audio_MIN (bytes, INT_MAX);
   54.66 -    samples = bytes >> hw->info.shift;
   54.67 -    samples = audio_MIN (samples, dead);
   54.68 +    if (dead) {
   54.69 +        int64_t now = qemu_get_clock (vm_clock);
   54.70 +        int64_t ticks = now - no->old_ticks;
   54.71 +        int64_t bytes = (ticks * hw->info.bytes_per_second) / ticks_per_sec;
   54.72  
   54.73 +        no->old_ticks = now;
   54.74 +        bytes = audio_MIN (bytes, INT_MAX);
   54.75 +        samples = bytes >> hw->info.shift;
   54.76 +        samples = audio_MIN (samples, dead);
   54.77 +    }
   54.78      return samples;
   54.79  }
   54.80  
    55.1 --- a/tools/ioemu/audio/ossaudio.c	Wed Aug 09 08:01:52 2006 -0600
    55.2 +++ b/tools/ioemu/audio/ossaudio.c	Wed Aug 09 08:34:06 2006 -0600
    55.3 @@ -55,12 +55,14 @@ static struct {
    55.4      int fragsize;
    55.5      const char *devpath_out;
    55.6      const char *devpath_in;
    55.7 +    int debug;
    55.8  } conf = {
    55.9      .try_mmap = 0,
   55.10      .nfrags = 4,
   55.11      .fragsize = 4096,
   55.12      .devpath_out = "/dev/dsp",
   55.13 -    .devpath_in = "/dev/dsp"
   55.14 +    .devpath_in = "/dev/dsp",
   55.15 +    .debug = 0
   55.16  };
   55.17  
   55.18  struct oss_params {
   55.19 @@ -324,9 +326,20 @@ static int oss_run_out (HWVoiceOut *hw)
   55.20              return 0;
   55.21          }
   55.22  
   55.23 -        if (abinfo.bytes < 0 || abinfo.bytes > bufsize) {
   55.24 -            ldebug ("warning: Invalid available size, size=%d bufsize=%d\n",
   55.25 -                    abinfo.bytes, bufsize);
   55.26 +        if (abinfo.bytes > bufsize) {
   55.27 +            if (conf.debug) {
   55.28 +                dolog ("warning: Invalid available size, size=%d bufsize=%d\n"
   55.29 +                       "please report your OS/audio hw to malc@pulsesoft.com\n",
   55.30 +                       abinfo.bytes, bufsize);
   55.31 +            }
   55.32 +            abinfo.bytes = bufsize;
   55.33 +        }
   55.34 +
   55.35 +        if (abinfo.bytes < 0) {
   55.36 +            if (conf.debug) {
   55.37 +                dolog ("warning: Invalid available size, size=%d bufsize=%d\n",
   55.38 +                       abinfo.bytes, bufsize);
   55.39 +            }
   55.40              return 0;
   55.41          }
   55.42  
   55.43 @@ -369,15 +382,12 @@ static int oss_run_out (HWVoiceOut *hw)
   55.44                             "alignment %d\n",
   55.45                             wbytes, written, hw->info.align + 1);
   55.46                  }
   55.47 -                mixeng_clear (src, wsamples);
   55.48                  decr -= wsamples;
   55.49                  rpos = (rpos + wsamples) % hw->samples;
   55.50                  break;
   55.51              }
   55.52          }
   55.53  
   55.54 -        mixeng_clear (src, convert_samples);
   55.55 -
   55.56          rpos = (rpos + convert_samples) % hw->samples;
   55.57          samples -= convert_samples;
   55.58      }
   55.59 @@ -443,12 +453,9 @@ static int oss_init_out (HWVoiceOut *hw,
   55.60      obt_as.freq = obt.freq;
   55.61      obt_as.nchannels = obt.nchannels;
   55.62      obt_as.fmt = effective_fmt;
   55.63 +    obt_as.endianness = endianness;
   55.64  
   55.65 -    audio_pcm_init_info (
   55.66 -        &hw->info,
   55.67 -        &obt_as,
   55.68 -        audio_need_to_swap_endian (endianness)
   55.69 -        );
   55.70 +    audio_pcm_init_info (&hw->info, &obt_as);
   55.71      oss->nfrags = obt.nfrags;
   55.72      oss->fragsize = obt.fragsize;
   55.73  
   55.74 @@ -587,12 +594,9 @@ static int oss_init_in (HWVoiceIn *hw, a
   55.75      obt_as.freq = obt.freq;
   55.76      obt_as.nchannels = obt.nchannels;
   55.77      obt_as.fmt = effective_fmt;
   55.78 +    obt_as.endianness = endianness;
   55.79  
   55.80 -    audio_pcm_init_info (
   55.81 -        &hw->info,
   55.82 -        &obt_as,
   55.83 -        audio_need_to_swap_endian (endianness)
   55.84 -        );
   55.85 +    audio_pcm_init_info (&hw->info, &obt_as);
   55.86      oss->nfrags = obt.nfrags;
   55.87      oss->fragsize = obt.fragsize;
   55.88  
   55.89 @@ -730,6 +734,8 @@ static struct audio_option oss_options[]
   55.90       "Path to DAC device", NULL, 0},
   55.91      {"ADC_DEV", AUD_OPT_STR, &conf.devpath_in,
   55.92       "Path to ADC device", NULL, 0},
   55.93 +    {"DEBUG", AUD_OPT_BOOL, &conf.debug,
   55.94 +     "Turn on some debugging messages", NULL, 0},
   55.95      {NULL, 0, NULL, NULL, NULL, 0}
   55.96  };
   55.97  
    56.1 --- a/tools/ioemu/audio/rate_template.h	Wed Aug 09 08:01:52 2006 -0600
    56.2 +++ b/tools/ioemu/audio/rate_template.h	Wed Aug 09 08:34:06 2006 -0600
    56.3 @@ -51,7 +51,7 @@ void NAME (void *opaque, st_sample_t *ib
    56.4      if (rate->opos_inc == (1ULL + UINT_MAX)) {
    56.5          int i, n = *isamp > *osamp ? *osamp : *isamp;
    56.6          for (i = 0; i < n; i++) {
    56.7 -            OP (obuf[i].l, ibuf[i].r);
    56.8 +            OP (obuf[i].l, ibuf[i].l);
    56.9              OP (obuf[i].r, ibuf[i].r);
   56.10          }
   56.11          *isamp = n;
    57.1 --- a/tools/ioemu/audio/sdlaudio.c	Wed Aug 09 08:01:52 2006 -0600
    57.2 +++ b/tools/ioemu/audio/sdlaudio.c	Wed Aug 09 08:34:06 2006 -0600
    57.3 @@ -240,7 +240,6 @@ static void sdl_callback (void *opaque, 
    57.4  
    57.5              /* dolog ("in callback to_mix %d, chunk %d\n", to_mix, chunk); */
    57.6              hw->clip (buf, src, chunk);
    57.7 -            mixeng_clear (src, chunk);
    57.8              sdl->rpos = (sdl->rpos + chunk) % hw->samples;
    57.9              to_mix -= chunk;
   57.10              buf += chunk << hw->info.shift;
   57.11 @@ -336,12 +335,9 @@ static int sdl_init_out (HWVoiceOut *hw,
   57.12      obt_as.freq = obt.freq;
   57.13      obt_as.nchannels = obt.channels;
   57.14      obt_as.fmt = effective_fmt;
   57.15 +    obt_as.endianness = endianess;
   57.16  
   57.17 -    audio_pcm_init_info (
   57.18 -        &hw->info,
   57.19 -        &obt_as,
   57.20 -        audio_need_to_swap_endian (endianess)
   57.21 -        );
   57.22 +    audio_pcm_init_info (&hw->info, &obt_as);
   57.23      hw->samples = obt.samples;
   57.24  
   57.25      s->initialized = 1;
    58.1 --- a/tools/ioemu/audio/wavaudio.c	Wed Aug 09 08:01:52 2006 -0600
    58.2 +++ b/tools/ioemu/audio/wavaudio.c	Wed Aug 09 08:34:06 2006 -0600
    58.3 @@ -81,7 +81,6 @@ static int wav_run_out (HWVoiceOut *hw)
    58.4  
    58.5          hw->clip (dst, src, convert_samples);
    58.6          qemu_put_buffer (wav->f, dst, convert_samples << hw->info.shift);
    58.7 -        mixeng_clear (src, convert_samples);
    58.8  
    58.9          rpos = (rpos + convert_samples) % hw->samples;
   58.10          samples -= convert_samples;
   58.11 @@ -136,7 +135,8 @@ static int wav_init_out (HWVoiceOut *hw,
   58.12  
   58.13      hdr[34] = bits16 ? 0x10 : 0x08;
   58.14  
   58.15 -    audio_pcm_init_info (&hw->info, &wav_as, audio_need_to_swap_endian (0));
   58.16 +    wav_as.endianness = 0;
   58.17 +    audio_pcm_init_info (&hw->info, &wav_as);
   58.18  
   58.19      hw->samples = 1024;
   58.20      wav->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/tools/ioemu/audio/wavcapture.c	Wed Aug 09 08:34:06 2006 -0600
    59.3 @@ -0,0 +1,164 @@
    59.4 +#include "vl.h"
    59.5 +
    59.6 +typedef struct {
    59.7 +    QEMUFile *f;
    59.8 +    int bytes;
    59.9 +    char *path;
   59.10 +    int freq;
   59.11 +    int bits;
   59.12 +    int nchannels;
   59.13 +    CaptureVoiceOut *cap;
   59.14 +} WAVState;
   59.15 +
   59.16 +/* VICE code: Store number as little endian. */
   59.17 +static void le_store (uint8_t *buf, uint32_t val, int len)
   59.18 +{
   59.19 +    int i;
   59.20 +    for (i = 0; i < len; i++) {
   59.21 +        buf[i] = (uint8_t) (val & 0xff);
   59.22 +        val >>= 8;
   59.23 +    }
   59.24 +}
   59.25 +
   59.26 +static void wav_notify (void *opaque, audcnotification_e cmd)
   59.27 +{
   59.28 +    (void) opaque;
   59.29 +    (void) cmd;
   59.30 +}
   59.31 +
   59.32 +static void wav_destroy (void *opaque)
   59.33 +{
   59.34 +    WAVState *wav = opaque;
   59.35 +    uint8_t rlen[4];
   59.36 +    uint8_t dlen[4];
   59.37 +    uint32_t datalen = wav->bytes;
   59.38 +    uint32_t rifflen = datalen + 36;
   59.39 +
   59.40 +    if (!wav->f) {
   59.41 +        return;
   59.42 +    }
   59.43 +
   59.44 +    le_store (rlen, rifflen, 4);
   59.45 +    le_store (dlen, datalen, 4);
   59.46 +
   59.47 +    qemu_fseek (wav->f, 4, SEEK_SET);
   59.48 +    qemu_put_buffer (wav->f, rlen, 4);
   59.49 +
   59.50 +    qemu_fseek (wav->f, 32, SEEK_CUR);
   59.51 +    qemu_put_buffer (wav->f, dlen, 4);
   59.52 +    fclose (wav->f);
   59.53 +    if (wav->path) {
   59.54 +        qemu_free (wav->path);
   59.55 +    }
   59.56 +}
   59.57 +
   59.58 +static void wav_capture (void *opaque, void *buf, int size)
   59.59 +{
   59.60 +    WAVState *wav = opaque;
   59.61 +
   59.62 +    qemu_put_buffer (wav->f, buf, size);
   59.63 +    wav->bytes += size;
   59.64 +}
   59.65 +
   59.66 +static void wav_capture_destroy (void *opaque)
   59.67 +{
   59.68 +    WAVState *wav = opaque;
   59.69 +
   59.70 +    AUD_del_capture (wav->cap, wav);
   59.71 +}
   59.72 +
   59.73 +static void wav_capture_info (void *opaque)
   59.74 +{
   59.75 +    WAVState *wav = opaque;
   59.76 +    char *path = wav->path;
   59.77 +
   59.78 +    term_printf ("Capturing audio(%d,%d,%d) to %s: %d bytes\n",
   59.79 +                 wav->freq, wav->bits, wav->nchannels,
   59.80 +                 path ? path : "<not available>", wav->bytes);
   59.81 +}
   59.82 +
   59.83 +static struct capture_ops wav_capture_ops = {
   59.84 +    .destroy = wav_capture_destroy,
   59.85 +    .info = wav_capture_info
   59.86 +};
   59.87 +
   59.88 +int wav_start_capture (CaptureState *s, const char *path, int freq,
   59.89 +                       int bits, int nchannels)
   59.90 +{
   59.91 +    WAVState *wav;
   59.92 +    uint8_t hdr[] = {
   59.93 +        0x52, 0x49, 0x46, 0x46, 0x00, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56,
   59.94 +        0x45, 0x66, 0x6d, 0x74, 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00,
   59.95 +        0x02, 0x00, 0x44, 0xac, 0x00, 0x00, 0x10, 0xb1, 0x02, 0x00, 0x04,
   59.96 +        0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0x00, 0x00, 0x00, 0x00
   59.97 +    };
   59.98 +    audsettings_t as;
   59.99 +    struct audio_capture_ops ops;
  59.100 +    int stereo, bits16, shift;
  59.101 +    CaptureVoiceOut *cap;
  59.102 +
  59.103 +    if (bits != 8 && bits != 16) {
  59.104 +        term_printf ("incorrect bit count %d, must be 8 or 16\n", bits);
  59.105 +        return -1;
  59.106 +    }
  59.107 +
  59.108 +    if (nchannels != 1 && nchannels != 2) {
  59.109 +        term_printf ("incorrect channel count %d, must be 1 or 2\n",
  59.110 +                     nchannels);
  59.111 +        return -1;
  59.112 +    }
  59.113 +
  59.114 +    stereo = nchannels == 2;
  59.115 +    bits16 = bits == 16;
  59.116 +
  59.117 +    as.freq = freq;
  59.118 +    as.nchannels = 1 << stereo;
  59.119 +    as.fmt = bits16 ? AUD_FMT_S16 : AUD_FMT_U8;
  59.120 +    as.endianness = 0;
  59.121 +
  59.122 +    ops.notify = wav_notify;
  59.123 +    ops.capture = wav_capture;
  59.124 +    ops.destroy = wav_destroy;
  59.125 +
  59.126 +    wav = qemu_mallocz (sizeof (*wav));
  59.127 +    if (!wav) {
  59.128 +        term_printf ("Could not allocate memory for wav capture (%zu bytes)",
  59.129 +                     sizeof (*wav));
  59.130 +        return -1;
  59.131 +    }
  59.132 +
  59.133 +    shift = bits16 + stereo;
  59.134 +    hdr[34] = bits16 ? 0x10 : 0x08;
  59.135 +
  59.136 +    le_store (hdr + 22, as.nchannels, 2);
  59.137 +    le_store (hdr + 24, freq, 4);
  59.138 +    le_store (hdr + 28, freq << shift, 4);
  59.139 +    le_store (hdr + 32, 1 << shift, 2);
  59.140 +
  59.141 +    wav->f = fopen (path, "wb");
  59.142 +    if (!wav->f) {
  59.143 +        term_printf ("Failed to open wave file `%s'\nReason: %s\n",
  59.144 +                     path, strerror (errno));
  59.145 +        qemu_free (wav);
  59.146 +        return -1;
  59.147 +    }
  59.148 +
  59.149 +    wav->path = qemu_strdup (path);
  59.150 +    wav->bits = bits;
  59.151 +    wav->nchannels = nchannels;
  59.152 +    wav->freq = freq;
  59.153 +
  59.154 +    qemu_put_buffer (wav->f, hdr, sizeof (hdr));
  59.155 +
  59.156 +    cap = AUD_add_capture (NULL, &as, &ops, wav);
  59.157 +    if (!cap) {
  59.158 +        term_printf ("Failed to add audio capture\n");
  59.159 +        qemu_free (wav);
  59.160 +        return -1;
  59.161 +    }
  59.162 +
  59.163 +    wav->cap = cap;
  59.164 +    s->opaque = wav;
  59.165 +    s->ops = wav_capture_ops;
  59.166 +    return 0;
  59.167 +}
    60.1 --- a/tools/ioemu/block-bochs.c	Wed Aug 09 08:01:52 2006 -0600
    60.2 +++ b/tools/ioemu/block-bochs.c	Wed Aug 09 08:34:06 2006 -0600
    60.3 @@ -91,7 +91,7 @@ static int bochs_open(BlockDriverState *
    60.4      int fd, i;
    60.5      struct bochs_header bochs;
    60.6  
    60.7 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
    60.8 +    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
    60.9      if (fd < 0) {
   60.10          fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
   60.11          if (fd < 0)
    61.1 --- a/tools/ioemu/block-cloop.c	Wed Aug 09 08:01:52 2006 -0600
    61.2 +++ b/tools/ioemu/block-cloop.c	Wed Aug 09 08:34:06 2006 -0600
    61.3 @@ -55,7 +55,7 @@ static int cloop_open(BlockDriverState *
    61.4      BDRVCloopState *s = bs->opaque;
    61.5      uint32_t offsets_size,max_compressed_block_size=1,i;
    61.6  
    61.7 -    s->fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
    61.8 +    s->fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE | O_SYNC);
    61.9      if (s->fd < 0)
   61.10          return -1;
   61.11      bs->read_only = 1;
    62.1 --- a/tools/ioemu/block-cow.c	Wed Aug 09 08:01:52 2006 -0600
    62.2 +++ b/tools/ioemu/block-cow.c	Wed Aug 09 08:34:06 2006 -0600
    62.3 @@ -69,7 +69,7 @@ static int cow_open(BlockDriverState *bs
    62.4      struct cow_header_v2 cow_header;
    62.5      int64_t size;
    62.6  
    62.7 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
    62.8 +    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
    62.9      if (fd < 0) {
   62.10          fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
   62.11          if (fd < 0)
   62.12 @@ -250,6 +250,12 @@ static int cow_create(const char *filena
   62.13      return 0;
   62.14  }
   62.15  
   62.16 +static void cow_flush(BlockDriverState *bs)
   62.17 +{
   62.18 +    BDRVCowState *s = bs->opaque;
   62.19 +    fsync(s->fd);
   62.20 +}
   62.21 +
   62.22  BlockDriver bdrv_cow = {
   62.23      "cow",
   62.24      sizeof(BDRVCowState),
   62.25 @@ -259,6 +265,7 @@ BlockDriver bdrv_cow = {
   62.26      cow_write,
   62.27      cow_close,
   62.28      cow_create,
   62.29 +    cow_flush,
   62.30      cow_is_allocated,
   62.31  };
   62.32  #endif
    63.1 --- a/tools/ioemu/block-qcow.c	Wed Aug 09 08:01:52 2006 -0600
    63.2 +++ b/tools/ioemu/block-qcow.c	Wed Aug 09 08:34:06 2006 -0600
    63.3 @@ -95,7 +95,7 @@ static int qcow_open(BlockDriverState *b
    63.4      int fd, len, i, shift;
    63.5      QCowHeader header;
    63.6      
    63.7 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
    63.8 +    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
    63.9      if (fd < 0) {
   63.10          fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
   63.11          if (fd < 0)
   63.12 @@ -693,6 +693,12 @@ int qcow_compress_cluster(BlockDriverSta
   63.13      return 0;
   63.14  }
   63.15  
   63.16 +static void qcow_flush(BlockDriverState *bs)
   63.17 +{
   63.18 +    BDRVQcowState *s = bs->opaque;
   63.19 +    fsync(s->fd);
   63.20 +}
   63.21 +
   63.22  BlockDriver bdrv_qcow = {
   63.23      "qcow",
   63.24      sizeof(BDRVQcowState),
   63.25 @@ -702,6 +708,7 @@ BlockDriver bdrv_qcow = {
   63.26      qcow_write,
   63.27      qcow_close,
   63.28      qcow_create,
   63.29 +    qcow_flush,
   63.30      qcow_is_allocated,
   63.31      qcow_set_key,
   63.32      qcow_make_empty
    64.1 --- a/tools/ioemu/block-vmdk.c	Wed Aug 09 08:01:52 2006 -0600
    64.2 +++ b/tools/ioemu/block-vmdk.c	Wed Aug 09 08:34:06 2006 -0600
    64.3 @@ -96,7 +96,7 @@ static int vmdk_open(BlockDriverState *b
    64.4      uint32_t magic;
    64.5      int l1_size;
    64.6  
    64.7 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
    64.8 +    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
    64.9      if (fd < 0) {
   64.10          fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
   64.11          if (fd < 0)
   64.12 @@ -426,6 +426,12 @@ static void vmdk_close(BlockDriverState 
   64.13      close(s->fd);
   64.14  }
   64.15  
   64.16 +static void vmdk_flush(BlockDriverState *bs)
   64.17 +{
   64.18 +    BDRVVmdkState *s = bs->opaque;
   64.19 +    fsync(s->fd);
   64.20 +}
   64.21 +
   64.22  BlockDriver bdrv_vmdk = {
   64.23      "vmdk",
   64.24      sizeof(BDRVVmdkState),
   64.25 @@ -435,5 +441,6 @@ BlockDriver bdrv_vmdk = {
   64.26      vmdk_write,
   64.27      vmdk_close,
   64.28      vmdk_create,
   64.29 +    vmdk_flush,
   64.30      vmdk_is_allocated,
   64.31  };
    65.1 --- a/tools/ioemu/block-vpc.c	Wed Aug 09 08:01:52 2006 -0600
    65.2 +++ b/tools/ioemu/block-vpc.c	Wed Aug 09 08:34:06 2006 -0600
    65.3 @@ -163,7 +163,7 @@ static inline int seek_to_sector(BlockDr
    65.4      bitmap_offset = 512 * s->pagetable[pagetable_index];
    65.5      block_offset = bitmap_offset + 512 + (512 * pageentry_index);
    65.6      
    65.7 -//    printf("sector: %llx, index: %x, offset: %x, bioff: %llx, bloff: %llx\n",
    65.8 +//    printf("sector: %" PRIx64 ", index: %x, offset: %x, bioff: %" PRIx64 ", bloff: %" PRIx64 "\n",
    65.9  //	sector_num, pagetable_index, pageentry_index,
   65.10  //	bitmap_offset, block_offset);
   65.11  
    66.1 --- a/tools/ioemu/block-vvfat.c	Wed Aug 09 08:01:52 2006 -0600
    66.2 +++ b/tools/ioemu/block-vvfat.c	Wed Aug 09 08:34:06 2006 -0600
    66.3 @@ -2772,6 +2772,7 @@ BlockDriver bdrv_vvfat = {
    66.4      vvfat_read,
    66.5      vvfat_write,
    66.6      vvfat_close,
    66.7 +    NULL, /* ??? Not sure if we can do any meaningful flushing.  */
    66.8      NULL,
    66.9      vvfat_is_allocated
   66.10  };
    67.1 --- a/tools/ioemu/block.c	Wed Aug 09 08:01:52 2006 -0600
    67.2 +++ b/tools/ioemu/block.c	Wed Aug 09 08:34:06 2006 -0600
    67.3 @@ -615,6 +615,14 @@ const char *bdrv_get_device_name(BlockDr
    67.4      return bs->device_name;
    67.5  }
    67.6  
    67.7 +void bdrv_flush(BlockDriverState *bs)
    67.8 +{
    67.9 +    if (bs->drv->bdrv_flush)
   67.10 +        bs->drv->bdrv_flush(bs);
   67.11 +    if (bs->backing_hd)
   67.12 +        bdrv_flush(bs->backing_hd);
   67.13 +}
   67.14 +
   67.15  void bdrv_info(void)
   67.16  {
   67.17      BlockDriverState *bs;
   67.18 @@ -677,7 +685,7 @@ static int raw_open(BlockDriverState *bs
   67.19      int rv;
   67.20  #endif
   67.21  
   67.22 -    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
   67.23 +    fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE | O_SYNC);
   67.24      if (fd < 0) {
   67.25          fd = open(filename, O_RDONLY | O_BINARY | O_LARGEFILE);
   67.26          if (fd < 0)
   67.27 @@ -750,9 +758,55 @@ static int raw_write(BlockDriverState *b
   67.28  static void raw_close(BlockDriverState *bs)
   67.29  {
   67.30      BDRVRawState *s = bs->opaque;
   67.31 +    bs->total_sectors = 0;
   67.32      close(s->fd);
   67.33  }
   67.34  
   67.35 +#ifdef _WIN32
   67.36 +#include <windows.h>
   67.37 +#include <winioctl.h>
   67.38 +
   67.39 +int qemu_ftruncate64(int fd, int64_t length)
   67.40 +{
   67.41 +    LARGE_INTEGER li;
   67.42 +    LONG high;
   67.43 +    HANDLE h;
   67.44 +    BOOL res;
   67.45 +
   67.46 +    if ((GetVersion() & 0x80000000UL) && (length >> 32) != 0)
   67.47 +	return -1;
   67.48 +
   67.49 +    h = (HANDLE)_get_osfhandle(fd);
   67.50 +
   67.51 +    /* get current position, ftruncate do not change position */
   67.52 +    li.HighPart = 0;
   67.53 +    li.LowPart = SetFilePointer (h, 0, &li.HighPart, FILE_CURRENT);
   67.54 +    if (li.LowPart == 0xffffffffUL && GetLastError() != NO_ERROR)
   67.55 +	return -1;
   67.56 +
   67.57 +    high = length >> 32;
   67.58 +    if (!SetFilePointer(h, (DWORD) length, &high, FILE_BEGIN))
   67.59 +	return -1;
   67.60 +    res = SetEndOfFile(h);
   67.61 +
   67.62 +    /* back to old position */
   67.63 +    SetFilePointer(h, li.LowPart, &li.HighPart, FILE_BEGIN);
   67.64 +    return res ? 0 : -1;
   67.65 +}
   67.66 +
   67.67 +static int set_sparse(int fd)
   67.68 +{
   67.69 +    DWORD returned;
   67.70 +    return (int) DeviceIoControl((HANDLE)_get_osfhandle(fd), FSCTL_SET_SPARSE,
   67.71 +				 NULL, 0, NULL, 0, &returned, NULL);
   67.72 +}
   67.73 +#else
   67.74 +static inline int set_sparse(int fd)
   67.75 +{
   67.76 +    return 1;
   67.77 +}
   67.78 +#endif
   67.79 +
   67.80  static int raw_create(const char *filename, int64_t total_size,
   67.81                        const char *backing_file, int flags)
   67.82  {
   67.83 @@ -765,11 +819,18 @@ static int raw_create(const char *filena
   67.84                0644);
   67.85      if (fd < 0)
   67.86          return -EIO;
   67.87 +    set_sparse(fd);
   67.88      ftruncate(fd, total_size * 512);
   67.89      close(fd);
   67.90      return 0;
   67.91  }
   67.92  
   67.93 +static void raw_flush(BlockDriverState *bs)
   67.94 +{
   67.95 +    BDRVRawState *s = bs->opaque;
   67.96 +    fsync(s->fd);
   67.97 +}
   67.98 +
   67.99  BlockDriver bdrv_raw = {
  67.100      "raw",
  67.101      sizeof(BDRVRawState),
  67.102 @@ -779,6 +840,7 @@ BlockDriver bdrv_raw = {
  67.103      raw_write,
  67.104      raw_close,
  67.105      raw_create,
  67.106 +    raw_flush,
  67.107  };
  67.108  
  67.109  void bdrv_init(void)
    68.1 --- a/tools/ioemu/block_int.h	Wed Aug 09 08:01:52 2006 -0600
    68.2 +++ b/tools/ioemu/block_int.h	Wed Aug 09 08:34:06 2006 -0600
    68.3 @@ -36,6 +36,7 @@ struct BlockDriver {
    68.4      void (*bdrv_close)(BlockDriverState *bs);
    68.5      int (*bdrv_create)(const char *filename, int64_t total_sectors, 
    68.6                         const char *backing_file, int flags);
    68.7 +    void (*bdrv_flush)(BlockDriverState *bs);
    68.8      int (*bdrv_is_allocated)(BlockDriverState *bs, int64_t sector_num,
    68.9                               int nb_sectors, int *pnum);
   68.10      int (*bdrv_set_key)(BlockDriverState *bs, const char *key);
    69.1 --- a/tools/ioemu/cocoa.m	Wed Aug 09 08:01:52 2006 -0600
    69.2 +++ b/tools/ioemu/cocoa.m	Wed Aug 09 08:34:06 2006 -0600
    69.3 @@ -439,23 +439,40 @@ static void cocoa_refresh(DisplayState *
    69.4                                  kbd_put_keycode(keycode & 0x7f); //remove e0 bit in front
    69.5                              /* handle monitor key events */
    69.6                              } else {
    69.7 +                                int keysym = 0;
    69.8 +
    69.9                                  switch([event keyCode]) {
   69.10 -                                    case 123:
   69.11 -                                        kbd_put_keysym(QEMU_KEY_LEFT);
   69.12 -                                        break;
   69.13 -                                    case 124:
   69.14 -                                        kbd_put_keysym(QEMU_KEY_RIGHT);
   69.15 -                                        break;
   69.16 -                                    case 125:
   69.17 -                                        kbd_put_keysym(QEMU_KEY_DOWN);
   69.18 -                                        break;
   69.19 -                                    case 126:
   69.20 -                                        kbd_put_keysym(QEMU_KEY_UP);
   69.21 -                                        break;
   69.22 -                                    default:
   69.23 -                                        kbd_put_keysym([[event characters] characterAtIndex:0]);
   69.24 -                                        break;
   69.25 +                                case 115:
   69.26 +                                    keysym = QEMU_KEY_HOME;
   69.27 +                                    break;
   69.28 +                                case 117:
   69.29 +                                    keysym = QEMU_KEY_DELETE;
   69.30 +                                    break;
   69.31 +                                case 119:
   69.32 +                                    keysym = QEMU_KEY_END;
   69.33 +                                    break;
   69.34 +                                case 123:
   69.35 +                                    keysym = QEMU_KEY_LEFT;
   69.36 +                                    break;
   69.37 +                                case 124:
   69.38 +                                    keysym = QEMU_KEY_RIGHT;
   69.39 +                                    break;
   69.40 +                                case 125:
   69.41 +                                    keysym = QEMU_KEY_DOWN;
   69.42 +                                    break;
   69.43 +                                case 126:
   69.44 +                                    keysym = QEMU_KEY_UP;
   69.45 +                                    break;
   69.46 +                                default:
   69.47 +                                    {
   69.48 +                                        NSString *ks = [event characters];
   69.49 +
   69.50 +                                        if ([ks length] > 0)
   69.51 +                                            keysym = [ks characterAtIndex:0];
   69.52 +                                    }
   69.53                                  }
   69.54 +                                if (keysym)
   69.55 +                                    kbd_put_keysym(keysym);
   69.56                              }
   69.57                          }
   69.58                      }
   69.59 @@ -867,10 +884,9 @@ static void setupWindowMenu(void)
   69.60      /* Finally give up our references to the objects */
   69.61      [windowMenu release];
   69.62      [windowMenuItem release];
   69.63 - 
   69.64  }
   69.65  
   69.66 -static void CustomApplicationMain (argc, argv)
   69.67 +static void CustomApplicationMain(void)
   69.68  {
   69.69      NSAutoreleasePool   *pool = [[NSAutoreleasePool alloc] init];
   69.70      QemuCocoaGUIController *gui_controller;
   69.71 @@ -904,8 +920,8 @@ int main(int argc, char **argv)
   69.72  {
   69.73      gArgc = argc;
   69.74      gArgv = argv;
   69.75 -    
   69.76 -    CustomApplicationMain (argc, argv);
   69.77 -    
   69.78 +
   69.79 +    CustomApplicationMain();
   69.80 +
   69.81      return 0;
   69.82  }
    70.1 --- a/tools/ioemu/configure	Wed Aug 09 08:01:52 2006 -0600
    70.2 +++ b/tools/ioemu/configure	Wed Aug 09 08:34:06 2006 -0600
    70.3 @@ -96,6 +96,8 @@ check_gcc="no"
    70.4  softmmu="yes"
    70.5  user="no"
    70.6  build_docs="no"
    70.7 +build_acpi_tables="no"
    70.8 +uname_release=""
    70.9  
   70.10  # OS specific
   70.11  targetos=`uname -s`
   70.12 @@ -212,7 +214,7 @@ for opt do
   70.13    ;;
   70.14    --fmod-inc=*) fmod_inc="$optarg"
   70.15    ;;
   70.16 -  --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-"
   70.17 +  --enable-mingw32) mingw32="yes" ; cross_prefix="i386-mingw32-" ; user="no"
   70.18    ;;
   70.19    --disable-slirp) slirp="no"
   70.20    ;;
   70.21 @@ -226,8 +228,6 @@ for opt do
   70.22    ;;
   70.23    --enable-cocoa) cocoa="yes" ; coreaudio="yes" ; sdl="no"
   70.24    ;;
   70.25 -  --disable-gfx-check) check_gfx="no"
   70.26 -  ;;
   70.27    --disable-gcc-check) check_gcc="no"
   70.28    ;;
   70.29    --disable-system) softmmu="no"
   70.30 @@ -238,6 +238,10 @@ for opt do
   70.31    ;;
   70.32    --enable-user) user="yes"
   70.33    ;;
   70.34 +  --enable-uname-release=*) uname_release="$optarg"
   70.35 +  ;;
   70.36 +  --enable-iasl) build_acpi_tables="yes"
   70.37 +  ;;
   70.38    esac
   70.39  done
   70.40  
   70.41 @@ -285,6 +289,8 @@ echo "  --enable-user            enable 
   70.42  echo "  --disable-user           disable all linux usermode emulation targets"
   70.43  echo "  --fmod-lib               path to FMOD library"
   70.44  echo "  --fmod-inc               path to FMOD includes"
   70.45 +echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
   70.46 +echo "  --enable-iasl            compilation of ACPI tables with the IASL compiler"
   70.47  echo ""
   70.48  echo "NOTE: The object files are build at the place where configure is launched"
   70.49  exit 1
   70.50 @@ -294,15 +300,21 @@ cc="${cross_prefix}${cc}"
   70.51  ar="${cross_prefix}${ar}"
   70.52  strip="${cross_prefix}${strip}"
   70.53  
   70.54 -if [ ! -x "`which $cc`" ] ; then
   70.55 -    echo "Compiler $cc could not be found"
   70.56 -    exit
   70.57 +# check that the C compiler works.
   70.58 +cat > $TMPC <<EOF
   70.59 +int main(void) {}
   70.60 +EOF
   70.61 +
   70.62 +if $cc -c -o $TMPO $TMPC 2>/dev/null ; then
   70.63 +  : C compiler works ok
   70.64 +else
   70.65 +    echo "ERROR: \"$cc\" either does not exist or does not work"
   70.66 +    exit 1
   70.67  fi
   70.68  
   70.69  if test "$mingw32" = "yes" ; then
   70.70      linux="no"
   70.71      EXESUF=".exe"
   70.72 -    gdbstub="no"
   70.73      oss="no"
   70.74      if [ "$cpu" = "i386" ] ; then
   70.75          kqemu="yes"
   70.76 @@ -553,6 +565,8 @@ fi
   70.77  echo "FMOD support      $fmod $fmod_support"
   70.78  echo "kqemu support     $kqemu"
   70.79  echo "Documentation     $build_docs"
   70.80 +[ ! -z "$uname_release" ] && \
   70.81 +echo "uname -r          $uname_release"
   70.82  
   70.83  if test $sdl_too_old = "yes"; then
   70.84  echo "-> Your SDL version is too old - please upgrade to have SDL support"
   70.85 @@ -705,6 +719,9 @@ echo "TARGET_DIRS=$target_list" >> $conf
   70.86  if [ "$build_docs" = "yes" ] ; then
   70.87    echo "BUILD_DOCS=yes" >> $config_mak
   70.88  fi
   70.89 +if [ "$build_acpi_tables" = "yes" ] ; then
   70.90 +  echo "BUILD_ACPI_TABLES=yes" >> $config_mak
   70.91 +fi
   70.92  
   70.93  # XXX: suppress that
   70.94  if [ "$bsd" = "yes" ] ; then
   70.95 @@ -713,6 +730,8 @@ if [ "$bsd" = "yes" ] ; then
   70.96    echo "#define _BSD 1" >> $config_h
   70.97  fi
   70.98  
   70.99 +echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h
  70.100 +
  70.101  for target in $target_list; do
  70.102  target_dir="$target"
  70.103  config_mak=$target_dir/config.mak
  70.104 @@ -725,6 +744,7 @@ target_bigendian="no"
  70.105  [ "$target_cpu" = "ppc" ] && target_bigendian=yes
  70.106  [ "$target_cpu" = "ppc64" ] && target_bigendian=yes
  70.107  [ "$target_cpu" = "mips" ] && target_bigendian=yes
  70.108 +[ "$target_cpu" = "sh4eb" ] && target_bigendian=yes
  70.109  target_softmmu="no"
  70.110  if expr $target : '.*-softmmu' > /dev/null ; then
  70.111    target_softmmu="yes"
  70.112 @@ -736,14 +756,6 @@ if expr $target : '.*-user' > /dev/null 
  70.113    target_user_only="yes"
  70.114  fi
  70.115  
  70.116 -if test "$target_user_only" = "no" -a "$check_gfx" = "yes" \
  70.117 -        -a "$sdl" = "no" -a "$cocoa" = "no" ; then
  70.118 -    echo "ERROR: QEMU requires SDL or Cocoa for graphical output"
  70.119 -    echo "To build QEMU without graphical output configure with --disable-gfx-check"
  70.120 -    echo "Note that this will disable all output from the virtual graphics card."
  70.121 -    exit 1;
  70.122 -fi
  70.123 -
  70.124  #echo "Creating $config_mak, $config_h and $target_dir/Makefile"
  70.125  
  70.126  mkdir -p $target_dir
  70.127 @@ -769,6 +781,7 @@ echo "/* Automatically generated by conf
  70.128  echo "include ../config-host.mak" >> $config_mak
  70.129  echo "#include \"../config-host.h\"" >> $config_h
  70.130  
  70.131 +bflt="no"
  70.132  interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
  70.133  echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
  70.134  
  70.135 @@ -789,6 +802,7 @@ elif test "$target_cpu" = "arm" -o "$tar
  70.136    echo "TARGET_ARCH=arm" >> $config_mak
  70.137    echo "#define TARGET_ARCH \"arm\"" >> $config_h
  70.138    echo "#define TARGET_ARM 1" >> $config_h
  70.139 +  bflt="yes"
  70.140  elif test "$target_cpu" = "sparc" ; then
  70.141    echo "TARGET_ARCH=sparc" >> $config_mak
  70.142    echo "#define TARGET_ARCH \"sparc\"" >> $config_h
  70.143 @@ -819,10 +833,13 @@ elif test "$target_cpu" = "mips" -o "$ta
  70.144    echo "TARGET_ARCH=mips" >> $config_mak
  70.145    echo "#define TARGET_ARCH \"mips\"" >> $config_h
  70.146    echo "#define TARGET_MIPS 1" >> $config_h
  70.147 -elif test "$target_cpu" = "sh4" ; then
  70.148 +  echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
  70.149 +  echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
  70.150 +elif test "$target_cpu" = "sh4" -o "$target_cpu" = "sh4eb" ; then
  70.151    echo "TARGET_ARCH=sh4" >> $config_mak
  70.152    echo "#define TARGET_ARCH \"sh4\"" >> $config_h
  70.153    echo "#define TARGET_SH4 1" >> $config_h
  70.154 +  bflt="yes"
  70.155  else
  70.156    echo "Unsupported target CPU"
  70.157    exit 1
  70.158 @@ -844,10 +861,14 @@ if expr $target : '.*-dm' > /dev/null ; 
  70.159    echo "#define CONFIG_DM 1" >> $config_h
  70.160  fi
  70.161  
  70.162 -if test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" ; then
  70.163 +if test "$target_cpu" = "arm" -o "$target_cpu" = "armeb" -o "$target_cpu" = "sparc" -o "$target_cpu" = "sparc64"; then
  70.164    echo "CONFIG_SOFTFLOAT=yes" >> $config_mak
  70.165    echo "#define CONFIG_SOFTFLOAT 1" >> $config_h
  70.166  fi
  70.167 +if test "$target_user_only" = "yes" -a "$bflt" = "yes"; then
  70.168 +  echo "TARGET_HAS_BFLT=yes" >> $config_mak
  70.169 +  echo "#define TARGET_HAS_BFLT 1" >> $config_h
  70.170 +fi
  70.171  # sdl defines
  70.172  
  70.173  if test "$target_user_only" = "no"; then
    71.1 --- a/tools/ioemu/console.c	Wed Aug 09 08:01:52 2006 -0600
    71.2 +++ b/tools/ioemu/console.c	Wed Aug 09 08:34:06 2006 -0600
    71.3 @@ -27,8 +27,8 @@
    71.4  #define DEFAULT_BACKSCROLL 512
    71.5  #define MAX_CONSOLES 12
    71.6  
    71.7 -#define RGBA(r, g, b, a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
    71.8 -#define RGB(r, g, b) RGBA(r, g, b, 0xff)
    71.9 +#define QEMU_RGBA(r, g, b, a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
   71.10 +#define QEMU_RGB(r, g, b) QEMU_RGBA(r, g, b, 0xff)
   71.11  
   71.12  typedef struct TextAttributes {
   71.13      uint8_t fgcol:4;
   71.14 @@ -53,6 +53,57 @@ enum TTYState {
   71.15      TTY_STATE_CSI,
   71.16  };
   71.17  
   71.18 +typedef struct QEMUFIFO {
   71.19 +    uint8_t *buf;
   71.20 +    int buf_size;
   71.21 +    int count, wptr, rptr;
   71.22 +} QEMUFIFO;
   71.23 +
   71.24 +int qemu_fifo_write(QEMUFIFO *f, const uint8_t *buf, int len1)
   71.25 +{
   71.26 +    int l, len;
   71.27 +
   71.28 +    l = f->buf_size - f->count;
   71.29 +    if (len1 > l)
   71.30 +        len1 = l;
   71.31 +    len = len1;
   71.32 +    while (len > 0) {
   71.33 +        l = f->buf_size - f->wptr;
   71.34 +        if (l > len)
   71.35 +            l = len;
   71.36 +        memcpy(f->buf + f->wptr, buf, l);
   71.37 +        f->wptr += l;
   71.38 +        if (f->wptr >= f->buf_size)
   71.39 +            f->wptr = 0;
   71.40 +        buf += l;
   71.41 +        len -= l;
   71.42 +    }
   71.43 +    f->count += len1;
   71.44 +    return len1;
   71.45 +}
   71.46 +
   71.47 +int qemu_fifo_read(QEMUFIFO *f, uint8_t *buf, int len1)
   71.48 +{
   71.49 +    int l, len;
   71.50 +
   71.51 +    if (len1 > f->count)
   71.52 +        len1 = f->count;
   71.53 +    len = len1;
   71.54 +    while (len > 0) {
   71.55 +        l = f->buf_size - f->rptr;
   71.56 +        if (l > len)
   71.57 +            l = len;
   71.58 +        memcpy(buf, f->buf + f->rptr, l);
   71.59 +        f->rptr += l;
   71.60 +        if (f->rptr >= f->buf_size)
   71.61 +            f->rptr = 0;
   71.62 +        buf += l;
   71.63 +        len -= l;
   71.64 +    }
   71.65 +    f->count -= len1;
   71.66 +    return len1;
   71.67 +}
   71.68 +
   71.69  /* ??? This is mis-named.
   71.70     It is used for both text and graphical consoles.  */
   71.71  struct TextConsole {
   71.72 @@ -81,8 +132,13 @@ struct TextConsole {
   71.73      int nb_esc_params;
   71.74  
   71.75      /* kbd read handler */
   71.76 +    IOCanRWHandler *fd_can_read; 
   71.77      IOReadHandler *fd_read;
   71.78      void *fd_opaque;
   71.79 +    /* fifo for key pressed */
   71.80 +    QEMUFIFO out_fifo;
   71.81 +    uint8_t out_fifo_buf[16];
   71.82 +    QEMUTimer *kbd_timer;
   71.83  };
   71.84  
   71.85  static TextConsole *active_console;
   71.86 @@ -274,24 +330,24 @@ enum color_names {
   71.87  
   71.88  static const uint32_t color_table_rgb[2][8] = {
   71.89      {   /* dark */
   71.90 -        RGB(0x00, 0x00, 0x00),  /* black */
   71.91 -        RGB(0xaa, 0x00, 0x00),  /* red */
   71.92 -        RGB(0x00, 0xaa, 0x00),  /* green */
   71.93 -        RGB(0xaa, 0xaa, 0x00),  /* yellow */
   71.94 -        RGB(0x00, 0x00, 0xaa),  /* blue */
   71.95 -        RGB(0xaa, 0x00, 0xaa),  /* magenta */
   71.96 -        RGB(0x00, 0xaa, 0xaa),  /* cyan */
   71.97 -        RGB(0xaa, 0xaa, 0xaa),  /* white */
   71.98 +        QEMU_RGB(0x00, 0x00, 0x00),  /* black */
   71.99 +        QEMU_RGB(0xaa, 0x00, 0x00),  /* red */
  71.100 +        QEMU_RGB(0x00, 0xaa, 0x00),  /* green */
  71.101 +        QEMU_RGB(0xaa, 0xaa, 0x00),  /* yellow */
  71.102 +        QEMU_RGB(0x00, 0x00, 0xaa),  /* blue */
  71.103 +        QEMU_RGB(0xaa, 0x00, 0xaa),  /* magenta */
  71.104 +        QEMU_RGB(0x00, 0xaa, 0xaa),  /* cyan */
  71.105 +        QEMU_RGB(0xaa, 0xaa, 0xaa),  /* white */
  71.106      },
  71.107      {   /* bright */
  71.108 -        RGB(0x00, 0x00, 0x00),  /* black */
  71.109 -        RGB(0xff, 0x00, 0x00),  /* red */
  71.110 -        RGB(0x00, 0xff, 0x00),  /* green */
  71.111 -        RGB(0xff, 0xff, 0x00),  /* yellow */
  71.112 -        RGB(0x00, 0x00, 0xff),  /* blue */
  71.113 -        RGB(0xff, 0x00, 0xff),  /* magenta */
  71.114 -        RGB(0x00, 0xff, 0xff),  /* cyan */
  71.115 -        RGB(0xff, 0xff, 0xff),  /* white */
  71.116 +        QEMU_RGB(0x00, 0x00, 0x00),  /* black */
  71.117 +        QEMU_RGB(0xff, 0x00, 0x00),  /* red */
  71.118 +        QEMU_RGB(0x00, 0xff, 0x00),  /* green */
  71.119 +        QEMU_RGB(0xff, 0xff, 0x00),  /* yellow */
  71.120 +        QEMU_RGB(0x00, 0x00, 0xff),  /* blue */
  71.121 +        QEMU_RGB(0xff, 0x00, 0xff),  /* magenta */
  71.122 +        QEMU_RGB(0x00, 0xff, 0xff),  /* cyan */
  71.123 +        QEMU_RGB(0xff, 0xff, 0xff),  /* white */
  71.124      }
  71.125  };
  71.126  
  71.127 @@ -563,7 +619,6 @@ static void console_put_lf(TextConsole *
  71.128      TextCell *c;
  71.129      int x, y1;
  71.130  
  71.131 -    s->x = 0;
  71.132      s->y++;
  71.133      if (s->y >= s->height) {
  71.134          s->y = s->height - 1;
  71.135 @@ -712,15 +767,12 @@ static void console_putchar(TextConsole 
  71.136              console_put_lf(s);
  71.137              break;
  71.138          case '\b':  /* backspace */
  71.139 -            if(s->x > 0) s->x--;
  71.140 -            y1 = (s->y_base + s->y) % s->total_height;
  71.141 -            c = &s->cells[y1 * s->width + s->x];
  71.142 -            c->ch = ' ';
  71.143 -            c->t_attrib = s->t_attrib;
  71.144 -            update_xy(s, s->x, s->y);
  71.145 +            if (s->x > 0) 
  71.146 +                s->x--;
  71.147              break;
  71.148          case '\t':  /* tabspace */
  71.149              if (s->x + (8 - (s->x % 8)) > s->width) {
  71.150 +                s->x = 0;
  71.151                  console_put_lf(s);
  71.152              } else {
  71.153                  s->x = s->x + (8 - (s->x % 8));
  71.154 @@ -739,8 +791,10 @@ static void console_putchar(TextConsole 
  71.155              c->t_attrib = s->t_attrib;
  71.156              update_xy(s, s->x, s->y);
  71.157              s->x++;
  71.158 -            if (s->x >= s->width)
  71.159 +            if (s->x >= s->width) {
  71.160 +                s->x = 0;
  71.161                  console_put_lf(s);
  71.162 +            }
  71.163              break;
  71.164          }
  71.165          break;
  71.166 @@ -835,6 +889,7 @@ static void console_chr_add_read_handler
  71.167                                           IOReadHandler *fd_read, void *opaque)
  71.168  {
  71.169      TextConsole *s = chr->opaque;
  71.170 +    s->fd_can_read = fd_can_read;
  71.171      s->fd_read = fd_read;
  71.172      s->fd_opaque = opaque;
  71.173  }
  71.174 @@ -854,6 +909,28 @@ static void console_send_event(CharDrive
  71.175      }
  71.176  }
  71.177  
  71.178 +static void kbd_send_chars(void *opaque)
  71.179 +{
  71.180 +    TextConsole *s = opaque;
  71.181 +    int len;
  71.182 +    uint8_t buf[16];
  71.183 +    
  71.184 +    len = s->fd_can_read(s->fd_opaque);
  71.185 +    if (len > s->out_fifo.count)
  71.186 +        len = s->out_fifo.count;
  71.187 +    if (len > 0) {
  71.188 +        if (len > sizeof(buf))
  71.189 +            len = sizeof(buf);
  71.190 +        qemu_fifo_read(&s->out_fifo, buf, len);
  71.191 +        s->fd_read(s->fd_opaque, buf, len);
  71.192 +    }
  71.193 +    /* characters are pending: we send them a bit later (XXX:
  71.194 +       horrible, should change char device API) */
  71.195 +    if (s->out_fifo.count > 0) {
  71.196 +        qemu_mod_timer(s->kbd_timer, qemu_get_clock(rt_clock) + 1);
  71.197 +    }
  71.198 +}
  71.199 +
  71.200  /* called when an ascii key is pressed */
  71.201  void kbd_put_keysym(int keysym)
  71.202  {
  71.203 @@ -879,25 +956,26 @@ void kbd_put_keysym(int keysym)
  71.204          console_scroll(10);
  71.205          break;
  71.206      default:
  71.207 +        /* convert the QEMU keysym to VT100 key string */
  71.208 +        q = buf;
  71.209 +        if (keysym >= 0xe100 && keysym <= 0xe11f) {
  71.210 +            *q++ = '\033';
  71.211 +            *q++ = '[';
  71.212 +            c = keysym - 0xe100;
  71.213 +            if (c >= 10)
  71.214 +                *q++ = '0' + (c / 10);
  71.215 +            *q++ = '0' + (c % 10);
  71.216 +            *q++ = '~';
  71.217 +        } else if (keysym >= 0xe120 && keysym <= 0xe17f) {
  71.218 +            *q++ = '\033';
  71.219 +            *q++ = '[';
  71.220 +            *q++ = keysym & 0xff;
  71.221 +        } else {
  71.222 +                *q++ = keysym;
  71.223 +        }
  71.224          if (s->fd_read) {
  71.225 -            /* convert the QEMU keysym to VT100 key string */
  71.226 -            q = buf;
  71.227 -            if (keysym >= 0xe100 && keysym <= 0xe11f) {
  71.228 -                *q++ = '\033';
  71.229 -                *q++ = '[';
  71.230 -                c = keysym - 0xe100;
  71.231 -                if (c >= 10)
  71.232 -                    *q++ = '0' + (c / 10);
  71.233 -                *q++ = '0' + (c % 10);
  71.234 -                *q++ = '~';
  71.235 -            } else if (keysym >= 0xe120 && keysym <= 0xe17f) {
  71.236 -                *q++ = '\033';
  71.237 -                *q++ = '[';
  71.238 -                *q++ = keysym & 0xff;
  71.239 -            } else {
  71.240 -                *q++ = keysym;
  71.241 -            }
  71.242 -            s->fd_read(s->fd_opaque, buf, q - buf);
  71.243 +            qemu_fifo_write(&s->out_fifo, buf, q - buf);
  71.244 +            kbd_send_chars(s);
  71.245          }
  71.246          break;
  71.247      }
  71.248 @@ -984,6 +1062,10 @@ CharDriverState *text_console_init(Displ
  71.249      chr->chr_add_read_handler = console_chr_add_read_handler;
  71.250      chr->chr_send_event = console_send_event;
  71.251  
  71.252 +    s->out_fifo.buf = s->out_fifo_buf;
  71.253 +    s->out_fifo.buf_size = sizeof(s->out_fifo_buf);
  71.254 +    s->kbd_timer = qemu_new_timer(rt_clock, kbd_send_chars, s);
  71.255 +    
  71.256      if (!color_inited) {
  71.257          color_inited = 1;
  71.258          set_color_table(ds);
    72.1 --- a/tools/ioemu/cpu-all.h	Wed Aug 09 08:01:52 2006 -0600
    72.2 +++ b/tools/ioemu/cpu-all.h	Wed Aug 09 08:34:06 2006 -0600
    72.3 @@ -878,6 +878,10 @@ extern uint8_t *phys_ram_dirty;
    72.4  #define IO_MEM_ROM         (1 << IO_MEM_SHIFT) /* hardcoded offset */
    72.5  #define IO_MEM_UNASSIGNED  (2 << IO_MEM_SHIFT)
    72.6  #define IO_MEM_NOTDIRTY    (4 << IO_MEM_SHIFT) /* used internally, never use directly */
    72.7 +/* acts like a ROM when read and like a device when written. As an
    72.8 +   exception, the write memory callback gets the ram offset instead of
    72.9 +   the physical address */
   72.10 +#define IO_MEM_ROMD        (1)
   72.11  
   72.12  typedef void CPUWriteMemoryFunc(void *opaque, target_phys_addr_t addr, uint32_t value);
   72.13  typedef uint32_t CPUReadMemoryFunc(void *opaque, target_phys_addr_t addr);
   72.14 @@ -946,13 +950,105 @@ void cpu_tlb_update_dirty(CPUState *env)
   72.15  void dump_exec_info(FILE *f,
   72.16                      int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
   72.17  
   72.18 +/*******************************************/
   72.19 +/* host CPU ticks (if available) */
   72.20 +
   72.21 +#if defined(__powerpc__)
   72.22 +
   72.23 +static inline uint32_t get_tbl(void) 
   72.24 +{
   72.25 +    uint32_t tbl;
   72.26 +    asm volatile("mftb %0" : "=r" (tbl));
   72.27 +    return tbl;
   72.28 +}
   72.29 +
   72.30 +static inline uint32_t get_tbu(void) 
   72.31 +{
   72.32 +	uint32_t tbl;
   72.33 +	asm volatile("mftbu %0" : "=r" (tbl));
   72.34 +	return tbl;
   72.35 +}
   72.36 +
   72.37 +static inline int64_t cpu_get_real_ticks(void)
   72.38 +{
   72.39 +    uint32_t l, h, h1;
   72.40 +    /* NOTE: we test if wrapping has occurred */
   72.41 +    do {
   72.42 +        h = get_tbu();
   72.43 +        l = get_tbl();
   72.44 +        h1 = get_tbu();
   72.45 +    } while (h != h1);
   72.46 +    return ((int64_t)h << 32) | l;
   72.47 +}
   72.48 +
   72.49 +#elif defined(__i386__)
   72.50 +
   72.51 +static inline int64_t cpu_get_real_ticks(void)
   72.52 +{
   72.53 +    int64_t val;
   72.54 +    asm volatile ("rdtsc" : "=A" (val));
   72.55 +    return val;
   72.56 +}
   72.57 +
   72.58 +#elif defined(__x86_64__)
   72.59 +
   72.60 +static inline int64_t cpu_get_real_ticks(void)
   72.61 +{
   72.62 +    uint32_t low,high;
   72.63 +    int64_t val;
   72.64 +    asm volatile("rdtsc" : "=a" (low), "=d" (high));
   72.65 +    val = high;
   72.66 +    val <<= 32;
   72.67 +    val |= low;
   72.68 +    return val;
   72.69 +}
   72.70 +
   72.71 +#elif defined(__ia64)
   72.72 +
   72.73 +static inline int64_t cpu_get_real_ticks(void)
   72.74 +{
   72.75 +	int64_t val;
   72.76 +	asm volatile ("mov %0 = ar.itc" : "=r"(val) :: "memory");
   72.77 +	return val;
   72.78 +}
   72.79 +
   72.80 +#elif defined(__s390__)
   72.81 +
   72.82 +static inline int64_t cpu_get_real_ticks(void)
   72.83 +{
   72.84 +    int64_t val;
   72.85 +    asm volatile("stck 0(%1)" : "=m" (val) : "a" (&val) : "cc");
   72.86 +    return val;
   72.87 +}
   72.88 +
   72.89 +#elif defined(__sparc_v9__)
   72.90 +
   72.91 +static inline int64_t cpu_get_real_ticks (void)
   72.92 +{
   72.93 +#if     defined(_LP64)
   72.94 +        uint64_t        rval;
   72.95 +        asm volatile("rd %%tick,%0" : "=r"(rval));
   72.96 +        return rval;
   72.97 +#else
   72.98 +        union {
   72.99 +                uint64_t i64;
  72.100 +                struct {
  72.101 +                        uint32_t high;
  72.102 +                        uint32_t low;
  72.103 +                }       i32;
  72.104 +        } rval;
  72.105 +        asm volatile("rd %%tick,%1; srlx %1,32,%0"
  72.106 +                : "=r"(rval.i32.high), "=r"(rval.i32.low));
  72.107 +        return rval.i64;
  72.108 +#endif
  72.109 +}
  72.110 +#endif
  72.111 +
  72.112  /* profiling */
  72.113  #ifdef CONFIG_PROFILER
  72.114  static inline int64_t profile_getclock(void)
  72.115  {
  72.116 -    int64_t val;
  72.117 -    asm volatile ("rdtsc" : "=A" (val));
  72.118 -    return val;
  72.119 +    return cpu_get_real_ticks();
  72.120  }
  72.121  
  72.122  extern int64_t kqemu_time, kqemu_time_start;
    73.1 --- a/tools/ioemu/cpu-defs.h	Wed Aug 09 08:01:52 2006 -0600
    73.2 +++ b/tools/ioemu/cpu-defs.h	Wed Aug 09 08:34:06 2006 -0600
    73.3 @@ -47,7 +47,7 @@ typedef uint32_t target_ulong;
    73.4  #elif TARGET_LONG_SIZE == 8
    73.5  typedef int64_t target_long;
    73.6  typedef uint64_t target_ulong;
    73.7 -#define TARGET_FMT_lx "%016llx"
    73.8 +#define TARGET_FMT_lx "%016" PRIx64
    73.9  #else
   73.10  #error TARGET_LONG_SIZE undefined
   73.11  #endif
    74.1 --- a/tools/ioemu/cpu-exec.c	Wed Aug 09 08:01:52 2006 -0600
    74.2 +++ b/tools/ioemu/cpu-exec.c	Wed Aug 09 08:34:06 2006 -0600
    74.3 @@ -47,7 +47,7 @@ void cpu_loop_exit(void)
    74.4      longjmp(env->jmp_env, 1);
    74.5  }
    74.6  #endif
    74.7 -#ifndef TARGET_SPARC
    74.8 +#if !(defined(TARGET_SPARC) || defined(TARGET_SH4))
    74.9  #define reg_T2
   74.10  #endif
   74.11  
   74.12 @@ -175,9 +175,13 @@ static inline TranslationBlock *tb_find_
   74.13      pc = env->regs[15];
   74.14  #elif defined(TARGET_SPARC)
   74.15  #ifdef TARGET_SPARC64
   74.16 -    flags = (env->pstate << 2) | ((env->lsu & (DMMU_E | IMMU_E)) >> 2);
   74.17 +    // Combined FPU enable bits . PRIV . DMMU enabled . IMMU enabled
   74.18 +    flags = (((env->pstate & PS_PEF) >> 1) | ((env->fprs & FPRS_FEF) << 2))
   74.19 +        | (env->pstate & PS_PRIV) | ((env->lsu & (DMMU_E | IMMU_E)) >> 2);
   74.20  #else
   74.21 -    flags = env->psrs | ((env->mmuregs[0] & (MMU_E | MMU_NF)) << 1);
   74.22 +    // FPU enable . MMU enabled . MMU no-fault . Supervisor
   74.23 +    flags = (env->psref << 3) | ((env->mmuregs[0] & (MMU_E | MMU_NF)) << 1)
   74.24 +        | env->psrs;
   74.25  #endif
   74.26      cs_base = env->npc;
   74.27      pc = env->pc;
   74.28 @@ -253,7 +257,7 @@ int cpu_exec(CPUState *env1)
   74.29      uint32_t *saved_regwptr;
   74.30  #endif
   74.31  #endif
   74.32 -#ifdef __sparc__
   74.33 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
   74.34      int saved_i7, tmp_T0;
   74.35  #endif
   74.36      int ret, interrupt_request;
   74.37 @@ -323,7 +327,7 @@ int cpu_exec(CPUState *env1)
   74.38  #if defined(reg_T2)
   74.39      saved_T2 = T2;
   74.40  #endif
   74.41 -#ifdef __sparc__
   74.42 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
   74.43      /* we also save i7 because longjmp may not restore it */
   74.44      asm volatile ("mov %%i7, %0" : "=r" (saved_i7));
   74.45  #endif
   74.46 @@ -447,7 +451,7 @@ int cpu_exec(CPUState *env1)
   74.47  
   74.48              T0 = 0; /* force lookup of first TB */
   74.49              for(;;) {
   74.50 -#ifdef __sparc__
   74.51 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
   74.52                  /* g1 can be modified by some libc? functions */ 
   74.53                  tmp_T0 = T0;
   74.54  #endif	    
   74.55 @@ -467,7 +471,7 @@ int cpu_exec(CPUState *env1)
   74.56                          do_interrupt(intno, 0, 0, 0, 1);
   74.57                          /* ensure that no TB jump will be modified as
   74.58                             the program flow was changed */
   74.59 -#ifdef __sparc__
   74.60 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
   74.61                          tmp_T0 = 0;
   74.62  #else
   74.63                          T0 = 0;
   74.64 @@ -486,7 +490,7 @@ int cpu_exec(CPUState *env1)
   74.65  			    env->error_code = 0;
   74.66                              do_interrupt(env);
   74.67                              env->interrupt_request &= ~CPU_INTERRUPT_HARD;
   74.68 -#ifdef __sparc__
   74.69 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
   74.70                              tmp_T0 = 0;
   74.71  #else
   74.72                              T0 = 0;
   74.73 @@ -497,7 +501,7 @@ int cpu_exec(CPUState *env1)
   74.74                              env->error_code = 0;
   74.75                              do_interrupt(env);
   74.76                              env->interrupt_request &= ~CPU_INTERRUPT_TIMER;
   74.77 -#ifdef __sparc__
   74.78 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
   74.79                              tmp_T0 = 0;
   74.80  #else
   74.81                              T0 = 0;
   74.82 @@ -516,7 +520,7 @@ int cpu_exec(CPUState *env1)
   74.83                          env->error_code = 0;
   74.84                          do_interrupt(env);
   74.85                          env->interrupt_request &= ~CPU_INTERRUPT_HARD;
   74.86 -#ifdef __sparc__
   74.87 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
   74.88                          tmp_T0 = 0;
   74.89  #else
   74.90                          T0 = 0;
   74.91 @@ -534,7 +538,7 @@ int cpu_exec(CPUState *env1)
   74.92  			    env->interrupt_request &= ~CPU_INTERRUPT_HARD;
   74.93  			    do_interrupt(env->interrupt_index);
   74.94  			    env->interrupt_index = 0;
   74.95 -#ifdef __sparc__
   74.96 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
   74.97                              tmp_T0 = 0;
   74.98  #else
   74.99                              T0 = 0;
  74.100 @@ -561,11 +565,13 @@ int cpu_exec(CPUState *env1)
  74.101  #elif defined(TARGET_SH4)
  74.102  		    /* XXXXX */
  74.103  #endif
  74.104 +                   /* Don't use the cached interupt_request value,
  74.105 +                      do_interrupt may have updated the EXITTB flag. */
  74.106                      if (env->interrupt_request & CPU_INTERRUPT_EXITTB) {
  74.107                          env->interrupt_request &= ~CPU_INTERRUPT_EXITTB;
  74.108                          /* ensure that no TB jump will be modified as
  74.109                             the program flow was changed */
  74.110 -#ifdef __sparc__
  74.111 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
  74.112                          tmp_T0 = 0;
  74.113  #else
  74.114                          T0 = 0;
  74.115 @@ -633,7 +639,7 @@ int cpu_exec(CPUState *env1)
  74.116                              lookup_symbol(tb->pc));
  74.117                  }
  74.118  #endif
  74.119 -#ifdef __sparc__
  74.120 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
  74.121                  T0 = tmp_T0;
  74.122  #endif	    
  74.123                  /* see if we can patch the calling TB. When the TB
  74.124 @@ -669,7 +675,9 @@ int cpu_exec(CPUState *env1)
  74.125                                       "mov	%%o7,%%i0"
  74.126                                       : /* no outputs */
  74.127                                       : "r" (gen_func) 
  74.128 -                                     : "i0", "i1", "i2", "i3", "i4", "i5");
  74.129 +                                     : "i0", "i1", "i2", "i3", "i4", "i5",
  74.130 +                                       "l0", "l1", "l2", "l3", "l4", "l5",
  74.131 +                                       "l6", "l7");
  74.132  #elif defined(__arm__)
  74.133                  asm volatile ("mov pc, %0\n\t"
  74.134                                ".global exec_loop\n\t"
  74.135 @@ -834,7 +842,7 @@ int cpu_exec(CPUState *env1)
  74.136  #else
  74.137  #error unsupported target CPU
  74.138  #endif
  74.139 -#ifdef __sparc__
  74.140 +#if defined(__sparc__) && !defined(HOST_SOLARIS)
  74.141      asm volatile ("mov %0, %%i7" : : "r" (saved_i7));
  74.142  #endif
  74.143      T0 = saved_T0;
  74.144 @@ -1168,19 +1176,14 @@ static inline int handle_cpu_signal(unsi
  74.145             a virtual CPU fault */
  74.146          cpu_restore_state(tb, env, pc, puc);
  74.147      }
  74.148 -    if (ret == 1) {
  74.149  #if 0
  74.150          printf("PF exception: NIP=0x%08x error=0x%x %p\n", 
  74.151                 env->nip, env->error_code, tb);
  74.152  #endif
  74.153      /* we restore the process signal mask as the sigreturn should
  74.154         do it (XXX: use sigsetjmp) */
  74.155 -        sigprocmask(SIG_SETMASK, old_set, NULL);
  74.156 -        //        do_raise_exception_err(env->exception_index, env->error_code);
  74.157 -    } else {
  74.158 -        /* activate soft MMU for this block */
  74.159 -        cpu_resume_from_signal(env, puc);
  74.160 -    }
  74.161 +    sigprocmask(SIG_SETMASK, old_set, NULL);
  74.162 +    cpu_loop_exit();
  74.163      /* never comes here */
  74.164      return 1;
  74.165  }
    75.1 --- a/tools/ioemu/disas.c	Wed Aug 09 08:01:52 2006 -0600
    75.2 +++ b/tools/ioemu/disas.c	Wed Aug 09 08:34:06 2006 -0600
    75.3 @@ -58,7 +58,7 @@ perror_memory (status, memaddr, info)
    75.4      /* Actually, address between memaddr and memaddr + len was
    75.5         out of bounds.  */
    75.6      (*info->fprintf_func) (info->stream,
    75.7 -			   "Address 0x%llx is out of bounds.\n", memaddr);
    75.8 +			   "Address 0x%" PRIx64 " is out of bounds.\n", memaddr);
    75.9  }
   75.10  
   75.11  /* This could be in a separate file, to save miniscule amounts of space
   75.12 @@ -73,7 +73,7 @@ generic_print_address (addr, info)
   75.13       bfd_vma addr;
   75.14       struct disassemble_info *info;
   75.15  {
   75.16 -    (*info->fprintf_func) (info->stream, "0x%llx", addr);
   75.17 +    (*info->fprintf_func) (info->stream, "0x%" PRIx64, addr);
   75.18  }
   75.19  
   75.20  /* Just return the given address.  */
    76.1 --- a/tools/ioemu/dyngen-exec.h	Wed Aug 09 08:01:52 2006 -0600
    76.2 +++ b/tools/ioemu/dyngen-exec.h	Wed Aug 09 08:34:06 2006 -0600
    76.3 @@ -35,12 +35,15 @@
    76.4  typedef unsigned char uint8_t;
    76.5  typedef unsigned short uint16_t;
    76.6  typedef unsigned int uint32_t;
    76.7 +// Linux/Sparc64 defines uint64_t
    76.8 +#if !(defined (__sparc_v9__) && defined(__linux__))
    76.9  /* XXX may be done for all 64 bits targets ? */
   76.10  #if defined (__x86_64__) || defined(__ia64)
   76.11  typedef unsigned long uint64_t;
   76.12  #else
   76.13  typedef unsigned long long uint64_t;
   76.14  #endif
   76.15 +#endif
   76.16  
   76.17  /* if Solaris/__sun__, don't typedef int8_t, as it will be typedef'd
   76.18     prior to this and will cause an error in compliation, conflicting
   76.19 @@ -50,11 +53,14 @@ typedef signed char int8_t;
   76.20  #endif
   76.21  typedef signed short int16_t;
   76.22  typedef signed int int32_t;
   76.23 +// Linux/Sparc64 defines int64_t
   76.24 +#if !(defined (__sparc_v9__) && defined(__linux__))
   76.25  #if defined (__x86_64__) || defined(__ia64)
   76.26  typedef signed long int64_t;
   76.27  #else
   76.28  typedef signed long long int64_t;
   76.29  #endif
   76.30 +#endif
   76.31  
   76.32  #define INT8_MIN		(-128)
   76.33  #define INT16_MIN		(-32767-1)
   76.34 @@ -121,6 +127,19 @@ extern int printf(const char *, ...);
   76.35  #define AREG3 "s2"
   76.36  #endif
   76.37  #ifdef __sparc__
   76.38 +#ifdef HOST_SOLARIS
   76.39 +#define AREG0 "g2"
   76.40 +#define AREG1 "g3"
   76.41 +#define AREG2 "g4"
   76.42 +#define AREG3 "g5"
   76.43 +#define AREG4 "g6"
   76.44 +#else
   76.45 +#ifdef __sparc_v9__
   76.46 +#define AREG0 "g1"
   76.47 +#define AREG1 "g4"
   76.48 +#define AREG2 "g5"
   76.49 +#define AREG3 "g7"
   76.50 +#else
   76.51  #define AREG0 "g6"
   76.52  #define AREG1 "g1"
   76.53  #define AREG2 "g2"
   76.54 @@ -133,6 +152,8 @@ extern int printf(const char *, ...);
   76.55  #define AREG9 "l5"
   76.56  #define AREG10 "l6"
   76.57  #define AREG11 "l7"
   76.58 +#endif
   76.59 +#endif
   76.60  #define USE_FP_CONVERT
   76.61  #endif
   76.62  #ifdef __s390__
   76.63 @@ -241,10 +262,8 @@ extern int __op_jmp0, __op_jmp1, __op_jm
   76.64  					  ASM_NAME(__op_gen_label) #n)
   76.65  #endif
   76.66  #ifdef __sparc__
   76.67 -#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0\n" \
   76.68 -                                "nop")
   76.69 -#define        GOTO_LABEL_PARAM(n) asm volatile ( \
   76.70 -               "set " ASM_NAME(__op_gen_label) #n ", %g1; jmp %g1; nop")
   76.71 +#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0; nop")
   76.72 +#define GOTO_LABEL_PARAM(n) asm volatile ("ba " ASM_NAME(__op_gen_label) #n ";nop")
   76.73  #endif
   76.74  #ifdef __arm__
   76.75  #define EXIT_TB() asm volatile ("b exec_loop")
    77.1 --- a/tools/ioemu/dyngen.c	Wed Aug 09 08:01:52 2006 -0600
    77.2 +++ b/tools/ioemu/dyngen.c	Wed Aug 09 08:34:06 2006 -0600
    77.3 @@ -1196,7 +1196,7 @@ void get_reloc_expr(char *name, int name
    77.4      } else {
    77.5  #ifdef HOST_SPARC
    77.6          if (sym_name[0] == '.')
    77.7 -            snprintf(name, sizeof(name),
    77.8 +            snprintf(name, name_size,
    77.9                       "(long)(&__dot_%s)",
   77.10                       sym_name + 1);
   77.11          else
   77.12 @@ -1440,6 +1440,15 @@ void gen_code(const char *name, host_ulo
   77.13      }
   77.14  #elif defined(HOST_SPARC)
   77.15      {
   77.16 +#define INSN_SAVE       0x9de3a000
   77.17 +#define INSN_RET        0x81c7e008
   77.18 +#define INSN_RETL       0x81c3e008
   77.19 +#define INSN_RESTORE    0x81e80000
   77.20 +#define INSN_RETURN     0x81cfe008
   77.21 +#define INSN_NOP        0x01000000
   77.22 +#define INSN_ADD_SP     0x9c03a000 // add %sp, nn, %sp
   77.23 +#define INSN_SUB_SP     0x9c23a000 // sub %sp, nn, %sp
   77.24 +
   77.25          uint32_t start_insn, end_insn1, end_insn2;
   77.26          uint8_t *p;
   77.27          p = (void *)(p_end - 8);
   77.28 @@ -1448,13 +1457,21 @@ void gen_code(const char *name, host_ulo
   77.29          start_insn = get32((uint32_t *)(p_start + 0x0));
   77.30          end_insn1 = get32((uint32_t *)(p + 0x0));
   77.31          end_insn2 = get32((uint32_t *)(p + 0x4));
   77.32 -        if ((start_insn & ~0x1fff) == 0x9de3a000) {
   77.33 +        if (((start_insn & ~0x1fff) == INSN_SAVE) ||
   77.34 +            (start_insn & ~0x1fff) == INSN_ADD_SP) {
   77.35              p_start += 0x4;
   77.36              start_offset += 0x4;
   77.37 -            if ((int)(start_insn | ~0x1fff) < -128)
   77.38 -                error("Found bogus save at the start of %s", name);
   77.39 -            if (end_insn1 != 0x81c7e008 || end_insn2 != 0x81e80000)
   77.40 +            if (end_insn1 == INSN_RET && end_insn2 == INSN_RESTORE)
   77.41 +                /* SPARC v7: ret; restore; */ ;
   77.42 +            else if (end_insn1 == INSN_RETURN && end_insn2 == INSN_NOP)
   77.43 +                /* SPARC v9: return; nop; */ ;
   77.44 +            else if (end_insn1 == INSN_RETL && (end_insn2 & ~0x1fff) == INSN_SUB_SP)
   77.45 +                /* SPARC v7: retl; sub %sp, nn, %sp; */ ;
   77.46 +            else
   77.47 +
   77.48                  error("ret; restore; not found at end of %s", name);
   77.49 +        } else if (end_insn1 == INSN_RETL && end_insn2 == INSN_NOP) {
   77.50 +            ;
   77.51          } else {
   77.52              error("No save at the beginning of %s", name);
   77.53          }
   77.54 @@ -1462,7 +1479,7 @@ void gen_code(const char *name, host_ulo
   77.55          /* Skip a preceeding nop, if present.  */
   77.56          if (p > p_start) {
   77.57              skip_insn = get32((uint32_t *)(p - 0x4));
   77.58 -            if (skip_insn == 0x01000000)
   77.59 +            if (skip_insn == INSN_NOP)
   77.60                  p -= 4;
   77.61          }
   77.62  #endif
   77.63 @@ -1470,21 +1487,41 @@ void gen_code(const char *name, host_ulo
   77.64      }
   77.65  #elif defined(HOST_SPARC64)
   77.66      {
   77.67 +#define INSN_SAVE       0x9de3a000
   77.68 +#define INSN_RET        0x81c7e008
   77.69 +#define INSN_RETL       0x81c3e008
   77.70 +#define INSN_RESTORE    0x81e80000
   77.71 +#define INSN_RETURN     0x81cfe008
   77.72 +#define INSN_NOP        0x01000000
   77.73 +#define INSN_ADD_SP     0x9c03a000 // add %sp, nn, %sp
   77.74 +#define INSN_SUB_SP     0x9c23a000 // sub %sp, nn, %sp
   77.75 +
   77.76          uint32_t start_insn, end_insn1, end_insn2, skip_insn;
   77.77          uint8_t *p;
   77.78          p = (void *)(p_end - 8);
   77.79 +#if 0
   77.80 +        /* XXX: check why it occurs */
   77.81          if (p <= p_start)
   77.82              error("empty code for %s", name);
   77.83 +#endif
   77.84          start_insn = get32((uint32_t *)(p_start + 0x0));
   77.85          end_insn1 = get32((uint32_t *)(p + 0x0));
   77.86          end_insn2 = get32((uint32_t *)(p + 0x4));
   77.87 -        if ((start_insn & ~0x1fff) == 0x9de3a000) {
   77.88 +        if (((start_insn & ~0x1fff) == INSN_SAVE) ||
   77.89 +            (start_insn & ~0x1fff) == INSN_ADD_SP) {
   77.90              p_start += 0x4;
   77.91              start_offset += 0x4;
   77.92 -            if ((int)(start_insn | ~0x1fff) < -256)
   77.93 -                error("Found bogus save at the start of %s", name);
   77.94 -            if (end_insn1 != 0x81c7e008 || end_insn2 != 0x81e80000)
   77.95 +            if (end_insn1 == INSN_RET && end_insn2 == INSN_RESTORE)
   77.96 +                /* SPARC v7: ret; restore; */ ;
   77.97 +            else if (end_insn1 == INSN_RETURN && end_insn2 == INSN_NOP)
   77.98 +                /* SPARC v9: return; nop; */ ;
   77.99 +            else if (end_insn1 == INSN_RETL && (end_insn2 & ~0x1fff) == INSN_SUB_SP)
  77.100 +                /* SPARC v7: retl; sub %sp, nn, %sp; */ ;
  77.101 +            else
  77.102 +
  77.103                  error("ret; restore; not found at end of %s", name);
  77.104 +        } else if (end_insn1 == INSN_RETL && end_insn2 == INSN_NOP) {
  77.105 +            ;
  77.106          } else {
  77.107              error("No save at the beginning of %s", name);
  77.108          }
  77.109 @@ -2151,6 +2188,18 @@ void gen_code(const char *name, host_ulo
  77.110  				    reloc_offset, reloc_offset, name, addend,
  77.111  				    reloc_offset);
  77.112  			    break;
  77.113 +                        case R_SPARC_WDISP22:
  77.114 +                            fprintf(outfile,
  77.115 +                                    "    *(uint32_t *)(gen_code_ptr + %d) = "
  77.116 +                                    "((*(uint32_t *)(gen_code_ptr + %d)) "
  77.117 +                                    " & ~0x3fffff) "
  77.118 +                                    " | ((((%s + %d) - (long)(gen_code_ptr + %d))>>2) "
  77.119 +                                    "    & 0x3fffff);\n",
  77.120 +                                    rel->r_offset - start_offset,
  77.121 +                                    rel->r_offset - start_offset,
  77.122 +                                    name, addend,
  77.123 +                                    rel->r_offset - start_offset);
  77.124 +                            break;
  77.125                          default:
  77.126                              error("unsupported sparc relocation (%d)", type);
  77.127                          }
  77.128 @@ -2168,7 +2217,7 @@ void gen_code(const char *name, host_ulo
  77.129  			rel->r_offset < start_offset + copy_size) {
  77.130                          sym_name = strtab + symtab[ELF64_R_SYM(rel->r_info)].st_name;
  77.131                          get_reloc_expr(name, sizeof(name), sym_name);
  77.132 -                        type = ELF64_R_TYPE(rel->r_info);
  77.133 +                        type = ELF32_R_TYPE(rel->r_info);
  77.134                          addend = rel->r_addend;
  77.135                          reloc_offset = rel->r_offset - start_offset;
  77.136                          switch(type) {
  77.137 @@ -2192,6 +2241,15 @@ void gen_code(const char *name, host_ulo
  77.138  				    " | ((%s + %d) & 0x3ff);\n",
  77.139                                      reloc_offset, reloc_offset, name, addend);
  77.140  			    break;
  77.141 +                        case R_SPARC_OLO10:
  77.142 +                            addend += ELF64_R_TYPE_DATA (rel->r_info);
  77.143 +                            fprintf(outfile,
  77.144 +				    "    *(uint32_t *)(gen_code_ptr + %d) = "
  77.145 +				    "((*(uint32_t *)(gen_code_ptr + %d)) "
  77.146 +				    " & ~0x3ff) "
  77.147 +				    " | ((%s + %d) & 0x3ff);\n",
  77.148 +                                    reloc_offset, reloc_offset, name, addend);
  77.149 +			    break;
  77.150  			case R_SPARC_WDISP30:
  77.151  			    fprintf(outfile,
  77.152  				    "    *(uint32_t *)(gen_code_ptr + %d) = "
  77.153 @@ -2202,8 +2260,18 @@ void gen_code(const char *name, host_ulo
  77.154  				    reloc_offset, reloc_offset, name, addend,
  77.155  				    reloc_offset);
  77.156  			    break;
  77.157 +                        case R_SPARC_WDISP22:
  77.158 +                            fprintf(outfile,
  77.159 +                                    "    *(uint32_t *)(gen_code_ptr + %d) = "
  77.160 +                                    "((*(uint32_t *)(gen_code_ptr + %d)) "
  77.161 +                                    " & ~0x3fffff) "
  77.162 +                                    " | ((((%s + %d) - (long)(gen_code_ptr + %d))>>2) "
  77.163 +                                    "    & 0x3fffff);\n",
  77.164 +                                    reloc_offset, reloc_offset, name, addend,
  77.165 +				    reloc_offset);
  77.166 +                            break;
  77.167                          default:
  77.168 -			    error("unsupported sparc64 relocation (%d)", type);
  77.169 +			    error("unsupported sparc64 relocation (%d) for symbol %s", type, name);
  77.170                          }
  77.171                      }
  77.172                  }
    78.1 --- a/tools/ioemu/dyngen.h	Wed Aug 09 08:01:52 2006 -0600
    78.2 +++ b/tools/ioemu/dyngen.h	Wed Aug 09 08:34:06 2006 -0600
    78.3 @@ -19,7 +19,13 @@
    78.4   */
    78.5  
    78.6  int __op_param1, __op_param2, __op_param3;
    78.7 -int __op_gen_label1, __op_gen_label2, __op_gen_label3;
    78.8 +#ifdef __sparc__
    78.9 +  void __op_gen_label1(){}
   78.10 +  void __op_gen_label2(){}
   78.11 +  void __op_gen_label3(){}
   78.12 +#else
   78.13 +  int __op_gen_label1, __op_gen_label2, __op_gen_label3;
   78.14 +#endif
   78.15  int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3;
   78.16  
   78.17  #ifdef __i386__
    79.1 --- a/tools/ioemu/elf.h	Wed Aug 09 08:01:52 2006 -0600
    79.2 +++ b/tools/ioemu/elf.h	Wed Aug 09 08:34:06 2006 -0600
    79.3 @@ -227,6 +227,7 @@ typedef struct {
    79.4  
    79.5  #define ELF64_R_SYM(i)			((i) >> 32)
    79.6  #define ELF64_R_TYPE(i)			((i) & 0xffffffff)
    79.7 +#define ELF64_R_TYPE_DATA(i)            (((ELF64_R_TYPE(i) >> 8) ^ 0x00800000) - 0x00800000)
    79.8  
    79.9  #define R_386_NONE	0
   79.10  #define R_386_32	1
   79.11 @@ -326,6 +327,7 @@ typedef struct {
   79.12  #define R_SPARC_10		30
   79.13  #define R_SPARC_11		31
   79.14  #define R_SPARC_64		32
   79.15 +#define R_SPARC_OLO10           33
   79.16  #define R_SPARC_WDISP16		40
   79.17  #define R_SPARC_WDISP19		41
   79.18  #define R_SPARC_7		43
    80.1 --- a/tools/ioemu/exec-all.h	Wed Aug 09 08:01:52 2006 -0600
    80.2 +++ b/tools/ioemu/exec-all.h	Wed Aug 09 08:34:06 2006 -0600
    80.3 @@ -571,7 +571,7 @@ static inline target_ulong get_phys_addr
    80.4          ldub_code(addr);
    80.5      }
    80.6      pd = env->tlb_table[is_user][index].addr_code & ~TARGET_PAGE_MASK;
    80.7 -    if (pd > IO_MEM_ROM) {
    80.8 +    if (pd > IO_MEM_ROM && !(pd & IO_MEM_ROMD)) {
    80.9          cpu_abort(env, "Trying to execute code outside RAM or ROM at 0x%08lx\n", addr);
   80.10      }
   80.11      return addr + env->tlb_table[is_user][index].addend - (unsigned long)phys_ram_base;
    81.1 --- a/tools/ioemu/exec.c	Wed Aug 09 08:01:52 2006 -0600
    81.2 +++ b/tools/ioemu/exec.c	Wed Aug 09 08:34:06 2006 -0600
    81.3 @@ -1488,7 +1488,7 @@ int tlb_set_page_exec(CPUState *env, tar
    81.4      if (is_softmmu) 
    81.5  #endif
    81.6      {
    81.7 -        if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM) {
    81.8 +        if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM && !(pd & IO_MEM_ROMD)) {
    81.9              /* IO memory case */
   81.10              address = vaddr | pd;
   81.11              addend = paddr;
   81.12 @@ -1513,9 +1513,11 @@ int tlb_set_page_exec(CPUState *env, tar
   81.13              te->addr_code = -1;
   81.14          }
   81.15          if (prot & PAGE_WRITE) {
   81.16 -            if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_ROM) {
   81.17 -                /* ROM: access is ignored (same as unassigned) */
   81.18 -                te->addr_write = vaddr | IO_MEM_ROM;
   81.19 +            if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_ROM || 
   81.20 +                (pd & IO_MEM_ROMD)) {
   81.21 +                /* write access calls the I/O callback */
   81.22 +                te->addr_write = vaddr | 
   81.23 +                    (pd & ~(TARGET_PAGE_MASK | IO_MEM_ROMD));
   81.24              } else if ((pd & ~TARGET_PAGE_MASK) == IO_MEM_RAM && 
   81.25                         !cpu_physical_memory_is_dirty(pd)) {
   81.26                  te->addr_write = vaddr | IO_MEM_NOTDIRTY;
   81.27 @@ -1779,15 +1781,24 @@ void cpu_register_physical_memory(target
   81.28  {
   81.29      target_phys_addr_t addr, end_addr;
   81.30      PhysPageDesc *p;
   81.31 +    CPUState *env;
   81.32  
   81.33      size = (size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK;
   81.34      end_addr = start_addr + size;
   81.35      for(addr = start_addr; addr != end_addr; addr += TARGET_PAGE_SIZE) {
   81.36          p = phys_page_find_alloc(addr >> TARGET_PAGE_BITS, 1);
   81.37          p->phys_offset = phys_offset;
   81.38 -        if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM)
   81.39 +        if ((phys_offset & ~TARGET_PAGE_MASK) <= IO_MEM_ROM ||
   81.40 +            (phys_offset & IO_MEM_ROMD))
   81.41              phys_offset += TARGET_PAGE_SIZE;
   81.42      }
   81.43 +    
   81.44 +    /* since each CPU stores ram addresses in its TLB cache, we must
   81.45 +       reset the modified entries */
   81.46 +    /* XXX: slow ! */
   81.47 +    for(env = first_cpu; env != NULL; env = env->next_cpu) {
   81.48 +        tlb_flush(env, 1);
   81.49 +    }
   81.50  }
   81.51  
   81.52  static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)
   81.53 @@ -2048,7 +2059,8 @@ void cpu_physical_memory_rw(target_phys_
   81.54                  }
   81.55              }
   81.56          } else {
   81.57 -            if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM) {
   81.58 +            if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM && 
   81.59 +                !(pd & IO_MEM_ROMD)) {
   81.60                  /* I/O case */
   81.61                  io_index = (pd >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
   81.62                  if (l >= 4 && ((addr & 3) == 0)) {
   81.63 @@ -2103,7 +2115,8 @@ void cpu_physical_memory_write_rom(targe
   81.64          }
   81.65          
   81.66          if ((pd & ~TARGET_PAGE_MASK) != IO_MEM_RAM &&
   81.67 -            (pd & ~TARGET_PAGE_MASK) != IO_MEM_ROM) {
   81.68 +            (pd & ~TARGET_PAGE_MASK) != IO_MEM_ROM &&
   81.69 +            !(pd & IO_MEM_ROMD)) {
   81.70              /* do nothing */
   81.71          } else {
   81.72              unsigned long addr1;
   81.73 @@ -2135,7 +2148,8 @@ uint32_t ldl_phys(target_phys_addr_t add
   81.74          pd = p->phys_offset;
   81.75      }
   81.76          
   81.77 -    if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM) {
   81.78 +    if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM && 
   81.79 +        !(pd & IO_MEM_ROMD)) {
   81.80          /* I/O case */
   81.81          io_index = (pd >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
   81.82          val = io_mem_read[io_index][2](io_mem_opaque[io_index], addr);
   81.83 @@ -2164,7 +2178,8 @@ uint64_t ldq_phys(target_phys_addr_t add
   81.84          pd = p->phys_offset;
   81.85      }
   81.86          
   81.87 -    if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM) {
   81.88 +    if ((pd & ~TARGET_PAGE_MASK) > IO_MEM_ROM &&
   81.89 +        !(pd & IO_MEM_ROMD)) {
   81.90          /* I/O case */
   81.91          io_index = (pd >> IO_MEM_SHIFT) & (IO_MEM_NB_ENTRIES - 1);
   81.92  #ifdef TARGET_WORDS_BIGENDIAN
    82.1 --- a/tools/ioemu/fpu/.CVS/Entries	Wed Aug 09 08:01:52 2006 -0600
    82.2 +++ b/tools/ioemu/fpu/.CVS/Entries	Wed Aug 09 08:34:06 2006 -0600
    82.3 @@ -1,7 +1,7 @@
    82.4 -/softfloat-macros.h/1.1/Sun Mar 13 16:54:06 2005//Trelease_0_8_1
    82.5 -/softfloat-native.c/1.3/Thu May 25 18:22:32 2006//Trelease_0_8_1
    82.6 -/softfloat-native.h/1.6/Thu May 25 18:22:32 2006//Trelease_0_8_1
    82.7 -/softfloat-specialize.h/1.1/Sun Mar 13 16:54:06 2005//Trelease_0_8_1
    82.8 -/softfloat.c/1.2/Sun Mar 13 18:52:28 2005//Trelease_0_8_1
    82.9 -/softfloat.h/1.3/Thu May 25 18:22:32 2006//Trelease_0_8_1
   82.10 +/softfloat-macros.h/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   82.11 +/softfloat-native.c/1.4/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   82.12 +/softfloat-native.h/1.6/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   82.13 +/softfloat-specialize.h/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   82.14 +/softfloat.c/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   82.15 +/softfloat.h/1.3/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   82.16  D
    83.1 --- a/tools/ioemu/fpu/.CVS/Tag	Wed Aug 09 08:01:52 2006 -0600
    83.2 +++ b/tools/ioemu/fpu/.CVS/Tag	Wed Aug 09 08:34:06 2006 -0600
    83.3 @@ -1,1 +1,1 @@
    83.4 -Nrelease_0_8_1
    83.5 +Nrelease_0_8_2
    84.1 --- a/tools/ioemu/fpu/softfloat-native.c	Wed Aug 09 08:01:52 2006 -0600
    84.2 +++ b/tools/ioemu/fpu/softfloat-native.c	Wed Aug 09 08:34:06 2006 -0600
    84.3 @@ -6,7 +6,7 @@
    84.4  void set_float_rounding_mode(int val STATUS_PARAM)
    84.5  {
    84.6      STATUS(float_rounding_mode) = val;
    84.7 -#if defined(_BSD) && !defined(__APPLE__)
    84.8 +#if defined(_BSD) && !defined(__APPLE__) || (defined(HOST_SOLARIS) && HOST_SOLARIS < 10)
    84.9      fpsetround(val);
   84.10  #elif defined(__arm__)
   84.11      /* nothing to do */
   84.12 @@ -22,9 +22,14 @@ void set_floatx80_rounding_precision(int
   84.13  }
   84.14  #endif
   84.15  
   84.16 -#if defined(_BSD)
   84.17 -#define lrint(d)		((long)rint(d))
   84.18 -#define llrint(d)		((long long)rint(d))
   84.19 +#if defined(_BSD) || (defined(HOST_SOLARIS) && HOST_SOLARIS < 10)
   84.20 +#define lrint(d)		((int32_t)rint(d))
   84.21 +#define llrint(d)		((int64_t)rint(d))
   84.22 +#define lrintf(f)		((int32_t)rint(f))
   84.23 +#define llrintf(f)		((int64_t)rint(f))
   84.24 +#define sqrtf(f)		((float)sqrt(f))
   84.25 +#define remainderf(fa, fb)	((float)remainder(fa, fb))
   84.26 +#define rintf(f)		((float)rint(f))
   84.27  #endif
   84.28  
   84.29  #if defined(__powerpc__)
    85.1 --- a/tools/ioemu/gdbstub.c	Wed Aug 09 08:01:52 2006 -0600
    85.2 +++ b/tools/ioemu/gdbstub.c	Wed Aug 09 08:34:06 2006 -0600
    85.3 @@ -17,6 +17,7 @@
    85.4   * License along with this library; if not, write to the Free Software
    85.5   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    85.6   */
    85.7 +#include "config.h"
    85.8  #ifdef CONFIG_USER_ONLY
    85.9  #include <stdlib.h>
   85.10  #include <stdio.h>
   85.11 @@ -24,16 +25,25 @@
   85.12  #include <string.h>
   85.13  #include <errno.h>
   85.14  #include <unistd.h>
   85.15 +#include <fcntl.h>
   85.16  
   85.17  #include "qemu.h"
   85.18  #else
   85.19  #include "vl.h"
   85.20  #endif
   85.21  
   85.22 -#include <sys/socket.h>
   85.23 -#include <netinet/in.h>
   85.24 -#include <netinet/tcp.h>
   85.25 +#include "qemu_socket.h"
   85.26 +#ifdef _WIN32
   85.27 +/* XXX: these constants may be independent of the host ones even for Unix */
   85.28 +#ifndef SIGTRAP
   85.29 +#define SIGTRAP 5
   85.30 +#endif
   85.31 +#ifndef SIGINT
   85.32 +#define SIGINT 2
   85.33 +#endif
   85.34 +#else
   85.35  #include <signal.h>
   85.36 +#endif
   85.37  
   85.38  //#define DEBUG_GDB
   85.39  
   85.40 @@ -69,7 +79,7 @@ static int get_char(GDBState *s)
   85.41      int ret;
   85.42  
   85.43      for(;;) {
   85.44 -        ret = read(s->fd, &ch, 1);
   85.45 +        ret = recv(s->fd, &ch, 1, 0);
   85.46          if (ret < 0) {
   85.47              if (errno != EINTR && errno != EAGAIN)
   85.48                  return -1;
   85.49 @@ -87,7 +97,7 @@ static void put_buffer(GDBState *s, cons
   85.50      int ret;
   85.51  
   85.52      while (len > 0) {
   85.53 -        ret = write(s->fd, buf, len);
   85.54 +        ret = send(s->fd, buf, len, 0);
   85.55          if (ret < 0) {
   85.56              if (errno != EINTR && errno != EAGAIN)
   85.57                  return;
   85.58 @@ -305,11 +315,11 @@ static int cpu_gdb_read_registers(CPUSta
   85.59      for(i = 0; i < 24; i++) {
   85.60          registers[i + 8] = tswapl(env->regwptr[i]);
   85.61      }
   85.62 +#ifndef TARGET_SPARC64
   85.63      /* fill in fprs */
   85.64      for (i = 0; i < 32; i++) {
   85.65          registers[i + 32] = tswapl(*((uint32_t *)&env->fpr[i]));
   85.66      }
   85.67 -#ifndef TARGET_SPARC64
   85.68      /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
   85.69      registers[64] = tswapl(env->y);
   85.70      {
   85.71 @@ -327,16 +337,21 @@ static int cpu_gdb_read_registers(CPUSta
   85.72      registers[72] = 0;
   85.73      return 73 * sizeof(target_ulong);
   85.74  #else
   85.75 -    for (i = 0; i < 32; i += 2) {
   85.76 -        registers[i/2 + 64] = tswapl(*((uint64_t *)&env->fpr[i]));
   85.77 +    /* fill in fprs */
   85.78 +    for (i = 0; i < 64; i += 2) {
   85.79 +	uint64_t tmp;
   85.80 +
   85.81 +        tmp = (uint64_t)tswap32(*((uint32_t *)&env->fpr[i])) << 32;
   85.82 +        tmp |= tswap32(*((uint32_t *)&env->fpr[i + 1]));
   85.83 +        registers[i/2 + 32] = tmp;
   85.84      }
   85.85 -    registers[81] = tswapl(env->pc);
   85.86 -    registers[82] = tswapl(env->npc);
   85.87 -    registers[83] = tswapl(env->tstate[env->tl]);
   85.88 -    registers[84] = tswapl(env->fsr);
   85.89 -    registers[85] = tswapl(env->fprs);
   85.90 -    registers[86] = tswapl(env->y);
   85.91 -    return 87 * sizeof(target_ulong);
   85.92 +    registers[64] = tswapl(env->pc);
   85.93 +    registers[65] = tswapl(env->npc);
   85.94 +    registers[66] = tswapl(env->tstate[env->tl]);
   85.95 +    registers[67] = tswapl(env->fsr);
   85.96 +    registers[68] = tswapl(env->fprs);
   85.97 +    registers[69] = tswapl(env->y);
   85.98 +    return 70 * sizeof(target_ulong);
   85.99  #endif
  85.100  }
  85.101  
  85.102 @@ -353,11 +368,11 @@ static void cpu_gdb_write_registers(CPUS
  85.103      for(i = 0; i < 24; i++) {
  85.104          env->regwptr[i] = tswapl(registers[i + 8]);
  85.105      }
  85.106 +#ifndef TARGET_SPARC64
  85.107      /* fill in fprs */
  85.108      for (i = 0; i < 32; i++) {
  85.109          *((uint32_t *)&env->fpr[i]) = tswapl(registers[i + 32]);
  85.110      }
  85.111 -#ifndef TARGET_SPARC64
  85.112      /* Y, PSR, WIM, TBR, PC, NPC, FPSR, CPSR */
  85.113      env->y = tswapl(registers[64]);
  85.114      PUT_PSR(env, tswapl(registers[65]));
  85.115 @@ -367,18 +382,16 @@ static void cpu_gdb_write_registers(CPUS
  85.116      env->npc = tswapl(registers[69]);
  85.117      env->fsr = tswapl(registers[70]);
  85.118  #else
  85.119 -    for (i = 0; i < 32; i += 2) {
  85.120 -	uint64_t tmp;
  85.121 -	tmp = tswapl(registers[i/2 + 64]) << 32;
  85.122 -	tmp |= tswapl(registers[i/2 + 64 + 1]);
  85.123 -        *((uint64_t *)&env->fpr[i]) = tmp;
  85.124 +    for (i = 0; i < 64; i += 2) {
  85.125 +	*((uint32_t *)&env->fpr[i]) = tswap32(registers[i/2 + 32] >> 32);
  85.126 +	*((uint32_t *)&env->fpr[i + 1]) = tswap32(registers[i/2 + 32] & 0xffffffff);
  85.127      }
  85.128 -    env->pc = tswapl(registers[81]);
  85.129 -    env->npc = tswapl(registers[82]);
  85.130 -    env->tstate[env->tl] = tswapl(registers[83]);
  85.131 -    env->fsr = tswapl(registers[84]);
  85.132 -    env->fprs = tswapl(registers[85]);
  85.133 -    env->y = tswapl(registers[86]);
  85.134 +    env->pc = tswapl(registers[64]);
  85.135 +    env->npc = tswapl(registers[65]);
  85.136 +    env->tstate[env->tl] = tswapl(registers[66]);
  85.137 +    env->fsr = tswapl(registers[67]);
  85.138 +    env->fprs = tswapl(registers[68]);
  85.139 +    env->y = tswapl(registers[69]);
  85.140  #endif
  85.141  }
  85.142  #elif defined (TARGET_ARM)
  85.143 @@ -494,7 +507,12 @@ static int cpu_gdb_read_registers(CPUSta
  85.144    int i;
  85.145  
  85.146  #define SAVE(x) *ptr++=tswapl(x)
  85.147 -  for (i = 0; i < 16; i++) SAVE(env->gregs[i]);
  85.148 +  if ((env->sr & (SR_MD | SR_RB)) == (SR_MD | SR_RB)) {
  85.149 +      for (i = 0; i < 8; i++) SAVE(env->gregs[i + 16]);
  85.150 +  } else {
  85.151 +      for (i = 0; i < 8; i++) SAVE(env->gregs[i]);
  85.152 +  }
  85.153 +  for (i = 8; i < 16; i++) SAVE(env->gregs[i]);
  85.154    SAVE (env->pc);
  85.155    SAVE (env->pr);
  85.156    SAVE (env->gbr);
  85.157 @@ -517,7 +535,12 @@ static void cpu_gdb_write_registers(CPUS
  85.158    int i;
  85.159  
  85.160  #define LOAD(x) (x)=*ptr++;
  85.161 -  for (i = 0; i < 16; i++) LOAD(env->gregs[i]);
  85.162 +  if ((env->sr & (SR_MD | SR_RB)) == (SR_MD | SR_RB)) {
  85.163 +      for (i = 0; i < 8; i++) LOAD(env->gregs[i + 16]);
  85.164 +  } else {
  85.165 +      for (i = 0; i < 8; i++) LOAD(env->gregs[i]);
  85.166 +  }
  85.167 +  for (i = 8; i < 16; i++) LOAD(env->gregs[i]);
  85.168    LOAD (env->pc);
  85.169    LOAD (env->pr);
  85.170    LOAD (env->gbr);
  85.171 @@ -545,7 +568,7 @@ static int gdb_handle_packet(GDBState *s
  85.172      char buf[4096];
  85.173      uint8_t mem_buf[2000];
  85.174      uint32_t *registers;
  85.175 -    uint32_t addr, len;
  85.176 +    target_ulong addr, len;
  85.177      
  85.178  #ifdef DEBUG_GDB
  85.179      printf("command='%s'\n", line_buf);
  85.180 @@ -560,7 +583,7 @@ static int gdb_handle_packet(GDBState *s
  85.181          break;
  85.182      case 'c':
  85.183          if (*p != '\0') {
  85.184 -            addr = strtoul(p, (char **)&p, 16);
  85.185 +            addr = strtoull(p, (char **)&p, 16);
  85.186  #if defined(TARGET_I386)
  85.187              env->eip = addr;
  85.188  #elif defined (TARGET_PPC)
  85.189 @@ -616,10 +639,10 @@ static int gdb_handle_packet(GDBState *s
  85.190          put_packet(s, "OK");
  85.191          break;
  85.192      case 'm':
  85.193 -        addr = strtoul(p, (char **)&p, 16);
  85.194 +        addr = strtoull(p, (char **)&p, 16);
  85.195          if (*p == ',')
  85.196              p++;
  85.197 -        len = strtoul(p, NULL, 16);
  85.198 +        len = strtoull(p, NULL, 16);
  85.199          if (cpu_memory_rw_debug(env, addr, mem_buf, len, 0) != 0) {
  85.200              put_packet (s, "E14");
  85.201          } else {
  85.202 @@ -628,10 +651,10 @@ static int gdb_handle_packet(GDBState *s
  85.203          }
  85.204          break;
  85.205      case 'M':
  85.206 -        addr = strtoul(p, (char **)&p, 16);
  85.207 +        addr = strtoull(p, (char **)&p, 16);
  85.208          if (*p == ',')
  85.209              p++;
  85.210 -        len = strtoul(p, (char **)&p, 16);
  85.211 +        len = strtoull(p, (char **)&p, 16);
  85.212          if (*p == ':')
  85.213              p++;
  85.214          hextomem(mem_buf, p, len);
  85.215 @@ -644,10 +667,10 @@ static int gdb_handle_packet(GDBState *s
  85.216          type = strtoul(p, (char **)&p, 16);
  85.217          if (*p == ',')
  85.218              p++;
  85.219 -        addr = strtoul(p, (char **)&p, 16);
  85.220 +        addr = strtoull(p, (char **)&p, 16);
  85.221          if (*p == ',')
  85.222              p++;
  85.223 -        len = strtoul(p, (char **)&p, 16);
  85.224 +        len = strtoull(p, (char **)&p, 16);
  85.225          if (type == 0 || type == 1) {
  85.226              if (cpu_breakpoint_insert(env, addr) < 0)
  85.227                  goto breakpoint_error;
  85.228 @@ -661,10 +684,10 @@ static int gdb_handle_packet(GDBState *s
  85.229          type = strtoul(p, (char **)&p, 16);
  85.230          if (*p == ',')
  85.231              p++;
  85.232 -        addr = strtoul(p, (char **)&p, 16);
  85.233 +        addr = strtoull(p, (char **)&p, 16);
  85.234          if (*p == ',')
  85.235              p++;
  85.236 -        len = strtoul(p, (char **)&p, 16);
  85.237 +        len = strtoull(p, (char **)&p, 16);
  85.238          if (type == 0 || type == 1) {
  85.239              cpu_breakpoint_remove(env, addr);
  85.240              put_packet(s, "OK");
  85.241 @@ -672,6 +695,18 @@ static int gdb_handle_packet(GDBState *s
  85.242              goto breakpoint_error;
  85.243          }
  85.244          break;
  85.245 +#ifdef CONFIG_USER_ONLY
  85.246 +    case 'q':
  85.247 +        if (strncmp(p, "Offsets", 7) == 0) {
  85.248 +            TaskState *ts = env->opaque;
  85.249 +
  85.250 +            sprintf(buf, "Text=%x;Data=%x;Bss=%x", ts->info->code_offset,
  85.251 +                ts->info->data_offset, ts->info->data_offset);
  85.252 +            put_packet(s, buf);
  85.253 +            break;
  85.254 +        }
  85.255 +        /* Fall through.  */
  85.256 +#endif
  85.257      default:
  85.258          //        unknown_command:
  85.259          /* put empty packet */
  85.260 @@ -829,7 +864,7 @@ static void gdb_read(void *opaque)
  85.261      int i, size;
  85.262      uint8_t buf[4096];
  85.263  
  85.264 -    size = read(s->fd, buf, sizeof(buf));
  85.265 +    size = recv(s->fd, buf, sizeof(buf), 0);
  85.266      if (size < 0)
  85.267          return;
  85.268      if (size == 0) {
  85.269 @@ -866,7 +901,7 @@ static void gdb_accept(void *opaque)
  85.270  
  85.271      /* set short latency */
  85.272      val = 1;
  85.273 -    setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
  85.274 +    setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&val, sizeof(val));
  85.275      
  85.276  #ifdef CONFIG_USER_ONLY
  85.277      s = &gdbserver_state;
  85.278 @@ -881,9 +916,11 @@ static void gdb_accept(void *opaque)
  85.279      s->env = first_cpu; /* XXX: allow to change CPU */
  85.280      s->fd = fd;
  85.281  
  85.282 +#ifdef CONFIG_USER_ONLY
  85.283      fcntl(fd, F_SETFL, O_NONBLOCK);
  85.284 +#else
  85.285 +    socket_set_nonblock(fd);
  85.286  
  85.287 -#ifndef CONFIG_USER_ONLY
  85.288      /* stop the VM */
  85.289      vm_stop(EXCP_INTERRUPT);
  85.290  
  85.291 @@ -907,7 +944,7 @@ static int gdbserver_open(int port)
  85.292  
  85.293      /* allow fast reuse */
  85.294      val = 1;
  85.295 -    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
  85.296 +    setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
  85.297  
  85.298      sockaddr.sin_family = AF_INET;
  85.299      sockaddr.sin_port = htons(port);
  85.300 @@ -923,7 +960,7 @@ static int gdbserver_open(int port)
  85.301          return -1;
  85.302      }
  85.303  #ifndef CONFIG_USER_ONLY
  85.304 -    fcntl(fd, F_SETFL, O_NONBLOCK);
  85.305 +    socket_set_nonblock(fd);
  85.306  #endif
  85.307      return fd;
  85.308  }
    86.1 --- a/tools/ioemu/hw/.CVS/Entries	Wed Aug 09 08:01:52 2006 -0600
    86.2 +++ b/tools/ioemu/hw/.CVS/Entries	Wed Aug 09 08:34:06 2006 -0600
    86.3 @@ -1,72 +1,89 @@
    86.4 -/adb.c/1.6/Thu May 25 18:22:32 2006//Trelease_0_8_1
    86.5 -/adlib.c/1.5/Thu May 25 18:22:32 2006//Trelease_0_8_1
    86.6 -/apic.c/1.8/Thu May 25 18:22:32 2006//Trelease_0_8_1
    86.7 -/arm_boot.c/1.1/Thu Apr 27 23:15:07 2006//Trelease_0_8_1
    86.8 -/arm_pic.c/1.1/Sun Apr  9 01:32:52 2006//Trelease_0_8_1
    86.9 -/arm_pic.h/1.1/Sun Apr  9 01:32:52 2006//Trelease_0_8_1
   86.10 -/arm_timer.c/1.1/Sun Apr  9 01:32:52 2006//Trelease_0_8_1
   86.11 -/cirrus_vga.c/1.21/Thu May 25 18:22:32 2006//Trelease_0_8_1
   86.12 -/cirrus_vga_rop.h/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
   86.13 -/cirrus_vga_rop2.h/1.7/Thu May 25 12:52:49 2006//Trelease_0_8_1
   86.14 -/cuda.c/1.10/Thu May 25 12:38:51 2006//Trelease_0_8_1
   86.15 -/dma.c/1.14/Thu May 25 18:22:32 2006//Trelease_0_8_1
   86.16 -/es1370.c/1.4/Sun Nov 20 16:20:39 2005//Trelease_0_8_1
   86.17 -/esp.c/1.6/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.18 -/fdc.c/1.18/Wed May 24 10:40:13 2006//Trelease_0_8_1
   86.19 -/fmopl.c/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
   86.20 -/fmopl.h/1.1/Wed May 17 14:47:01 2006//Trelease_0_8_1
   86.21 -/heathrow_pic.c/1.2/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.22 -/i8254.c/1.8/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.23 -/i8259.c/1.18/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.24 -/ide.c/1.42/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.25 -/integratorcp.c/1.9/Thu Apr 27 23:15:07 2006//Trelease_0_8_1
   86.26 -/iommu.c/1.6/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.27 -/lance.c/1.7/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.28 -/m48t59.c/1.7/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.29 -/m48t59.h/1.5/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.30 -/mc146818rtc.c/1.6/Wed May 17 14:47:01 2006//Trelease_0_8_1
   86.31 -/mips_r4k.c/1.16/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.32 -/ne2000.c/1.19/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.33 -/openpic.c/1.9/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.34 -/parallel.c/1.4/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.35 -/pc.c/1.53/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.36 -/pci.c/1.24/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.37 -/pckbd.c/1.15/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.38 -/pcspk.c/1.1/Mon Apr 24 21:58:30 2006//Trelease_0_8_1
   86.39 -/pl011.c/1.1/Sun Apr  9 01:32:52 2006//Trelease_0_8_1
   86.40 -/pl050.c/1.1/Sun Apr  9 01:32:52 2006//Trelease_0_8_1
   86.41 -/pl080.c/1.1/Sun Apr  9 01:32:52 2006//Trelease_0_8_1
   86.42 -/pl110.c/1.6/Tue Apr 18 19:02:59 2006//Trelease_0_8_1
   86.43 -/pl110_template.h/1.2/Sun Feb 19 12:31:32 2006//Trelease_0_8_1
   86.44 -/pl190.c/1.1/Sun Apr  9 01:32:52 2006//Trelease_0_8_1
   86.45 -/ppc.c/1.9/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.46 -/ppc_chrp.c/1.21/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.47 -/ppc_prep.c/1.26/Thu May 25 18:22:33 2006//Trelease_0_8_1
   86.48 -/ps2.c/1.4/Wed Apr 12 21:09:07 2006//Trelease_0_8_1
   86.49 -/rtl8139.c/1.1/Sun Feb  5 04:14:41 2006//Trelease_0_8_1
   86.50 -/sb16.c/1.19/Thu May 25 18:22:34 2006//Trelease_0_8_1
   86.51 -/serial.c/1.12/Thu May 25 18:22:34 2006//Trelease_0_8_1
   86.52 -/sh7750.c/1.1/Thu Apr 27 21:32:09 2006//Trelease_0_8_1
   86.53 -/sh7750_regnames.c/1.1/Thu Apr 27 21:32:09 2006//Trelease_0_8_1
   86.54 -/sh7750_regnames.h/1.1/Thu Apr 27 21:32:09 2006//Trelease_0_8_1
   86.55 -/sh7750_regs.h/1.1/Thu Apr 27 21:32:09 2006//Trelease_0_8_1
   86.56 -/shix.c/1.1/Thu Apr 27 21:32:09 2006//Trelease_0_8_1
   86.57 -/slavio_intctl.c/1.6/Thu May 25 18:22:35 2006//Trelease_0_8_1
   86.58 -/slavio_misc.c/1.3/Thu May 25 18:22:35 2006//Trelease_0_8_1
   86.59 -/slavio_serial.c/1.6/Thu May 25 18:22:35 2006//Trelease_0_8_1
   86.60 -/slavio_timer.c/1.3/Thu May 25 18:22:35 2006//Trelease_0_8_1
   86.61 -/smc91c111.c/1.3/Sat Feb  4 22:15:28 2006//Trelease_0_8_1
   86.62 -/sun4m.c/1.16/Thu May 25 18:22:35 2006//Trelease_0_8_1
   86.63 -/sun4u.c/1.8/Thu May 25 18:22:35 2006//Trelease_0_8_1
   86.64 -/tc58128.c/1.1/Thu Apr 27 21:32:09 2006//Trelease_0_8_1
   86.65 -/tcx.c/1.7/Thu May 25 18:22:35 2006//Trelease_0_8_1
   86.66 -/usb-hid.c/1.2/Wed Apr 12 21:09:07 2006//Trelease_0_8_1
   86.67 -/usb-hub.c/1.3/Sun Apr 30 21:53:59 2006//Trelease_0_8_1
   86.68 -/usb-uhci.c/1.8/Tue Apr 25 21:01:19 2006//Trelease_0_8_1
   86.69 -/usb.c/1.6/Mon Apr 24 21:18:20 2006//Trelease_0_8_1
   86.70 -/usb.h/1.4/Wed Apr 12 21:09:07 2006//Trelease_0_8_1
   86.71 -/versatilepb.c/1.2/Thu Apr 27 23:15:07 2006//Trelease_0_8_1
   86.72 -/vga.c/1.42/Thu May 25 18:22:36 2006//Trelease_0_8_1
   86.73 -/vga_int.h/1.6/Thu May 25 18:20:53 2006//Trelease_0_8_1
   86.74 -/vga_template.h/1.11/Wed May 17 14:47:01 2006//Trelease_0_8_1
   86.75 +/acpi-dsdt.dsl/1.3/Wed Jun 14 18:17:04 2006//Trelease_0_8_2
   86.76 +/acpi-dsdt.hex/1.3/Wed Jun 14 18:17:04 2006//Trelease_0_8_2
   86.77 +/acpi.c/1.5/Wed Jun 14 18:17:04 2006//Trelease_0_8_2
   86.78 +/adb.c/1.6/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   86.79 +/adlib.c/1.6/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   86.80 +/apb_pci.c/1.1/Sat May 13 16:11:23 2006//Trelease_0_8_2
   86.81 +/apic.c/1.9/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   86.82 +/arm_boot.c/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   86.83 +/arm_pic.c/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   86.84 +/arm_pic.h/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   86.85 +/arm_timer.c/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   86.86 +/cdrom.c/1.1/Thu May 25 23:58:51 2006//Trelease_0_8_2
   86.87 +/cirrus_vga.c/1.21/Sun Aug  6 00:55:02 2006//Trelease_0_8_2
   86.88 +/cirrus_vga_rop.h/1.1/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
   86.89 +/cirrus_vga_rop2.h/1.7/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   86.90 +/cuda.c/1.11/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   86.91 +/dma.c/1.14/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   86.92 +/es1370.c/1.6/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   86.93 +/esp.c/1.12/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
   86.94 +/fdc.c/1.18/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   86.95 +/fmopl.c/1.1/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
   86.96 +/fmopl.h/1.1/Thu Jul 13 09:23:22 2006//Trelease_0_8_2
   86.97 +/grackle_pci.c/1.1/Sat May 13 16:11:23 2006//Trelease_0_8_2
   86.98 +/heathrow_pic.c/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
   86.99 +/i8254.c/1.8/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.100 +/i8259.c/1.19/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
  86.101 +/ide.c/1.45/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
  86.102 +/integratorcp.c/1.9/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.103 +/iommu.c/1.6/Sun Aug  6 00:55:03 2006//Trelease_0_8_2
  86.104 +/lance.c/1.7/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.105 +/lsi53c895a.c/1.1/Tue May 30 01:48:12 2006//Trelease_0_8_2
  86.106 +/m48t59.c/1.8/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
  86.107 +/m48t59.h/1.5/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.108 +/mc146818rtc.c/1.6/Sun Aug  6 00:55:02 2006//Trelease_0_8_2
  86.109 +/mips_r4k.c/1.18/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
  86.110 +/ne2000.c/1.20/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
  86.111 +/openpic.c/1.9/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.112 +/parallel.c/1.4/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.113 +/pc.c/1.60/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
  86.114 +/pci.c/1.27/Sun Aug  6 01:03:50 2006//Trelease_0_8_2
  86.115 +/pci_host.h/1.1/Sat May 13 16:11:23 2006//Trelease_0_8_2
  86.116 +/pckbd.c/1.15/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.117 +/pcnet.c/1.4/Fri Jul 14 09:40:02 2006//Trelease_0_8_2
  86.118 +/pcspk.c/1.2/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.119 +/pflash_cfi02.c/1.2/Tue Jul  4 09:46:31 2006//Trelease_0_8_2
  86.120 +/piix_pci.c/1.1/Sat May 13 16:11:23 2006//Trelease_0_8_2
  86.121 +/pl011.c/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.122 +/pl050.c/1.2/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.123 +/pl080.c/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.124 +/pl110.c/1.6/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.125 +/pl110_template.h/1.2/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.126 +/pl190.c/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.127 +/ppc.c/1.9/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.128 +/ppc_chrp.c/1.23/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.129 +/ppc_prep.c/1.27/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.130 +/prep_pci.c/1.1/Sat May 13 16:11:23 2006//Trelease_0_8_2
  86.131 +/ps2.c/1.4/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.132 +/rtl8139.c/1.4/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.133 +/sb16.c/1.22/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.134 +/scsi-disk.c/1.7/Sun Jun  4 11:39:07 2006//Trelease_0_8_2
  86.135 +/serial.c/1.12/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.136 +/sh7750.c/1.2/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.137 +/sh7750_regnames.c/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.138 +/sh7750_regnames.h/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.139 +/sh7750_regs.h/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.140 +/shix.c/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.141 +/slavio_intctl.c/1.7/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.142 +/slavio_misc.c/1.3/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.143 +/slavio_serial.c/1.6/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.144 +/slavio_timer.c/1.4/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.145 +/smc91c111.c/1.3/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.146 +/sun4m.c/1.18/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.147 +/sun4u.c/1.11/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.148 +/tc58128.c/1.1/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.149 +/tcx.c/1.7/Fri Jul 14 12:43:45 2006//Trelease_0_8_2
  86.150 +/unin_pci.c/1.1/Sat May 13 16:11:23 2006//Trelease_0_8_2
  86.151 +/usb-hid.c/1.5/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.152 +/usb-hub.c/1.8/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.153 +/usb-msd.c/1.4/Wed Jul 19 18:06:15 2006//Trelease_0_8_2
  86.154 +/usb-ohci.c/1.3/Thu May 25 23:37:07 2006//Trelease_0_8_2
  86.155 +/usb-uhci.c/1.11/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.156 +/usb.c/1.8/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.157 +/usb.h/1.9/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.158 +/versatile_pci.c/1.1/Sat May 13 16:11:23 2006//Trelease_0_8_2
  86.159 +/versatilepb.c/1.5/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.160 +/vga.c/1.44/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.161 +/vga_int.h/1.7/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.162 +/vga_template.h/1.13/Sun Aug  6 01:03:51 2006//Trelease_0_8_2
  86.163  D
    87.1 --- a/tools/ioemu/hw/.CVS/Tag	Wed Aug 09 08:01:52 2006 -0600
    87.2 +++ b/tools/ioemu/hw/.CVS/Tag	Wed Aug 09 08:34:06 2006 -0600
    87.3 @@ -1,1 +1,1 @@
    87.4 -Nrelease_0_8_1
    87.5 +Nrelease_0_8_2
    88.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.2 +++ b/tools/ioemu/hw/acpi-dsdt.dsl	Wed Aug 09 08:34:06 2006 -0600
    88.3 @@ -0,0 +1,559 @@
    88.4 +/*
    88.5 + * QEMU ACPI DSDT ASL definition
    88.6 + * 
    88.7 + * Copyright (c) 2006 Fabrice Bellard
    88.8 + * 
    88.9 + * This library is free software; you can redistribute it and/or
   88.10 + * modify it under the terms of the GNU Lesser General Public
   88.11 + * License version 2 as published by the Free Software Foundation.
   88.12 + *
   88.13 + * This library is distributed in the hope that it will be useful,
   88.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   88.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   88.16 + * Lesser General Public License for more details.
   88.17 + *
   88.18 + * You should have received a copy of the GNU Lesser General Public
   88.19 + * License along with this library; if not, write to the Free Software
   88.20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   88.21 + */
   88.22 +DefinitionBlock (
   88.23 +    "acpi-dsdt.aml",    // Output Filename
   88.24 +    "DSDT",             // Signature
   88.25 +    0x01,               // DSDT Compliance Revision
   88.26 +    "QEMU",             // OEMID
   88.27 +    "QEMUDSDT",         // TABLE ID
   88.28 +    0x1                 // OEM Revision
   88.29 +    )
   88.30 +{
   88.31 +    Scope (\)
   88.32 +    {
   88.33 +        /* CMOS memory access */
   88.34 +        OperationRegion (CMS, SystemIO, 0x70, 0x02)
   88.35 +        Field (CMS, ByteAcc, NoLock, Preserve)
   88.36 +        {
   88.37 +            CMSI,   8, 
   88.38 +            CMSD,   8
   88.39 +        }
   88.40 +        Method (CMRD, 1, NotSerialized)
   88.41 +        {
   88.42 +            Store (Arg0, CMSI)
   88.43 +            Store (CMSD, Local0)
   88.44 +            Return (Local0)
   88.45 +        }
   88.46 +
   88.47 +        /* Debug Output */
   88.48 +        OperationRegion (DBG, SystemIO, 0xb044, 0x04)
   88.49 +        Field (DBG, DWordAcc, NoLock, Preserve)
   88.50 +        {
   88.51 +            DBGL,   32, 
   88.52 +        }
   88.53 +    }
   88.54 +
   88.55 +
   88.56 +    /* PCI Bus definition */
   88.57 +    Scope(\_SB) {
   88.58 +        Device(PCI0) {
   88.59 +            Name (_HID, EisaId ("PNP0A03"))
   88.60 +            Name (_ADR, 0x00)
   88.61 +            Name (_UID, 1)
   88.62 +            Name(_PRT, Package() {
   88.63 +                /* PCI IRQ routing table, example from ACPI 2.0a specification,
   88.64 +                   section 6.2.8.1 */
   88.65 +                /* Note: we provide the same info as the PCI routing
   88.66 +                   table of the Bochs BIOS */
   88.67 +                   
   88.68 +                // PCI Slot 0
   88.69 +                Package() {0x0000ffff, 0, LNKD, 0}, 
   88.70 +                Package() {0x0000ffff, 1, LNKA, 0}, 
   88.71 +                Package() {0x0000ffff, 2, LNKB, 0}, 
   88.72 +                Package() {0x0000ffff, 3, LNKC, 0}, 
   88.73 +
   88.74 +                // PCI Slot 1
   88.75 +                Package() {0x0001ffff, 0, LNKA, 0}, 
   88.76 +                Package() {0x0001ffff, 1, LNKB, 0}, 
   88.77 +                Package() {0x0001ffff, 2, LNKC, 0}, 
   88.78 +                Package() {0x0001ffff, 3, LNKD, 0}, 
   88.79 +                
   88.80 +                // PCI Slot 2
   88.81 +                Package() {0x0002ffff, 0, LNKB, 0}, 
   88.82 +                Package() {0x0002ffff, 1, LNKC, 0}, 
   88.83 +                Package() {0x0002ffff, 2, LNKD, 0}, 
   88.84 +                Package() {0x0002ffff, 3, LNKA, 0}, 
   88.85 +
   88.86 +                // PCI Slot 3
   88.87 +                Package() {0x0003ffff, 0, LNKC, 0}, 
   88.88 +                Package() {0x0003ffff, 1, LNKD, 0}, 
   88.89 +                Package() {0x0003ffff, 2, LNKA, 0}, 
   88.90 +                Package() {0x0003ffff, 3, LNKB, 0}, 
   88.91 +
   88.92 +                // PCI Slot 4
   88.93 +                Package() {0x0004ffff, 0, LNKD, 0}, 
   88.94 +                Package() {0x0004ffff, 1, LNKA, 0}, 
   88.95 +                Package() {0x0004ffff, 2, LNKB, 0}, 
   88.96 +                Package() {0x0004ffff, 3, LNKC, 0}, 
   88.97 +
   88.98 +                // PCI Slot 5
   88.99 +                Package() {0x0005ffff, 0, LNKA, 0}, 
  88.100 +                Package() {0x0005ffff, 1, LNKB, 0}, 
  88.101 +                Package() {0x0005ffff, 2, LNKC, 0}, 
  88.102 +                Package() {0x0005ffff, 3, LNKD, 0}, 
  88.103 +            })
  88.104 +
  88.105 +            Method (_CRS, 0, NotSerialized)
  88.106 +            {
  88.107 +            Name (MEMP, ResourceTemplate ()
  88.108 +            {
  88.109 +                WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
  88.110 +                    0x0000,             // Address Space Granularity
  88.111 +                    0x0000,             // Address Range Minimum
  88.112 +                    0x00FF,             // Address Range Maximum
  88.113 +                    0x0000,             // Address Translation Offset
  88.114 +                    0x0100,             // Address Length
  88.115 +                    ,, )
  88.116 +                IO (Decode16,
  88.117 +                    0x0CF8,             // Address Range Minimum
  88.118 +                    0x0CF8,             // Address Range Maximum
  88.119 +                    0x01,               // Address Alignment
  88.120 +                    0x08,               // Address Length
  88.121 +                    )
  88.122 +                WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
  88.123 +                    0x0000,             // Address Space Granularity
  88.124 +                    0x0000,             // Address Range Minimum
  88.125 +                    0x0CF7,             // Address Range Maximum
  88.126 +                    0x0000,             // Address Translation Offset
  88.127 +                    0x0CF8,             // Address Length
  88.128 +                    ,, , TypeStatic)
  88.129 +                WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
  88.130 +                    0x0000,             // Address Space Granularity
  88.131 +                    0x0D00,             // Address Range Minimum
  88.132 +                    0xFFFF,             // Address Range Maximum
  88.133 +                    0x0000,             // Address Translation Offset
  88.134 +                    0xF300,             // Address Length
  88.135 +                    ,, , TypeStatic)
  88.136 +                DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
  88.137 +                    0x00000000,         // Address Space Granularity
  88.138 +                    0x000A0000,         // Address Range Minimum
  88.139 +                    0x000BFFFF,         // Address Range Maximum
  88.140 +                    0x00000000,         // Address Translation Offset
  88.141 +                    0x00020000,         // Address Length
  88.142 +                    ,, , AddressRangeMemory, TypeStatic)
  88.143 +                DWordMemory (ResourceProducer, PosDecode, MinNotFixed, MaxFixed, NonCacheable, ReadWrite,
  88.144 +                    0x00000000,         // Address Space Granularity
  88.145 +                    0x00000000,         // Address Range Minimum
  88.146 +                    0xFEBFFFFF,         // Address Range Maximum
  88.147 +                    0x00000000,         // Address Translation Offset
  88.148 +                    0x00000000,         // Address Length
  88.149 +                    ,, MEMF, AddressRangeMemory, TypeStatic)
  88.150 +            })
  88.151 +                CreateDWordField (MEMP, \_SB.PCI0._CRS.MEMF._MIN, PMIN)
  88.152 +                CreateDWordField (MEMP, \_SB.PCI0._CRS.MEMF._MAX, PMAX)
  88.153 +                CreateDWordField (MEMP, \_SB.PCI0._CRS.MEMF._LEN, PLEN)
  88.154 +                /* compute available RAM */
  88.155 +                Add(CMRD(0x34), ShiftLeft(CMRD(0x35), 8), Local0)
  88.156 +                ShiftLeft(Local0, 16, Local0)
  88.157 +                Add(Local0, 0x1000000, Local0)
  88.158 +                /* update field of last region */
  88.159 +                Store(Local0, PMIN)
  88.160 +                Subtract (PMAX, PMIN, PLEN)
  88.161 +                Increment (PLEN)
  88.162 +                Return (MEMP)
  88.163 +            }
  88.164 +        }
  88.165 +    }
  88.166 +
  88.167 +    Scope(\_SB.PCI0) {
  88.168 +
  88.169 +	/* PIIX3 ISA bridge */
  88.170 +        Device (ISA) {
  88.171 +            Name (_ADR, 0x00010000)
  88.172 +        
  88.173 +            /* PIIX PCI to ISA irq remapping */
  88.174 +            OperationRegion (P40C, PCI_Config, 0x60, 0x04)
  88.175 +
  88.176 +
  88.177 +            /* Keyboard seems to be important for WinXP install */
  88.178 +            Device (KBD)
  88.179 +            {
  88.180 +                Name (_HID, EisaId ("PNP0303"))
  88.181 +                Method (_STA, 0, NotSerialized)
  88.182 +                {
  88.183 +                    Return (0x0f)
  88.184 +                }
  88.185 +
  88.186 +                Method (_CRS, 0, NotSerialized)
  88.187 +                {
  88.188 +                     Name (TMP, ResourceTemplate ()
  88.189 +                     {
  88.190 +                    IO (Decode16,
  88.191 +                        0x0060,             // Address Range Minimum
  88.192 +                        0x0060,             // Address Range Maximum
  88.193 +                        0x01,               // Address Alignment
  88.194 +                        0x01,               // Address Length
  88.195 +                        )
  88.196 +                    IO (Decode16,
  88.197 +                        0x0064,             // Address Range Minimum
  88.198 +                        0x0064,             // Address Range Maximum
  88.199 +                        0x01,               // Address Alignment
  88.200 +                        0x01,               // Address Length
  88.201 +                        )
  88.202 +                    IRQNoFlags ()
  88.203 +                        {1}
  88.204 +                    })
  88.205 +                    Return (TMP)
  88.206 +                }
  88.207 +            }
  88.208 +
  88.209 +	    /* PS/2 mouse */
  88.210 +            Device (MOU) 
  88.211 +            {
  88.212 +                Name (_HID, EisaId ("PNP0F13"))
  88.213 +                Method (_STA, 0, NotSerialized)
  88.214 +                {
  88.215 +                    Return (0x0f)
  88.216 +                }
  88.217 +
  88.218 +                Method (_CRS, 0, NotSerialized)
  88.219 +                {
  88.220 +                    Name (TMP, ResourceTemplate ()
  88.221 +                    {
  88.222 +                         IRQNoFlags () {12}
  88.223 +                    })
  88.224 +                    Return (TMP)
  88.225 +                }
  88.226 +            }
  88.227 +
  88.228 +	    /* PS/2 floppy controller */
  88.229 +	    Device (FDC0)
  88.230 +	    {
  88.231 +	        Name (_HID, EisaId ("PNP0700"))
  88.232 +		Method (_STA, 0, NotSerialized)
  88.233 +		{
  88.234 +		    Return (0x0F)
  88.235 +		}
  88.236 +		Method (_CRS, 0, NotSerialized)
  88.237 +		{
  88.238 +		    Name (BUF0, ResourceTemplate ()
  88.239 +                    {
  88.240 +                        IO (Decode16, 0x03F2, 0x03F2, 0x00, 0x04)
  88.241 +                        IO (Decode16, 0x03F7, 0x03F7, 0x00, 0x01)
  88.242 +                        IRQNoFlags () {6}
  88.243 +                        DMA (Compatibility, NotBusMaster, Transfer8) {2}
  88.244 +                    })
  88.245 +		    Return (BUF0)
  88.246 +		}
  88.247 +	    }
  88.248 +
  88.249 +	    /* Parallel port */
  88.250 +	    Device (LPT)
  88.251 +	    {
  88.252 +	        Name (_HID, EisaId ("PNP0400"))
  88.253 +		Method (_STA, 0, NotSerialized)
  88.254 +		{
  88.255 +		    Store (\_SB.PCI0.PX13.DRSA, Local0)
  88.256 +		    And (Local0, 0x80000000, Local0)
  88.257 +		    If (LEqual (Local0, 0))
  88.258 +		    {
  88.259 +			Return (0x00)
  88.260 +		    }
  88.261 +		    Else
  88.262 +		    {
  88.263 +			Return (0x0F)
  88.264 +		    }
  88.265 +		}
  88.266 +		Method (_CRS, 0, NotSerialized)
  88.267 +		{
  88.268 +		    Name (BUF0, ResourceTemplate ()
  88.269 +                    {
  88.270 +			IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
  88.271 +			IRQNoFlags () {7}
  88.272 +		    })
  88.273 +		    Return (BUF0)
  88.274 +		}
  88.275 +	    }
  88.276 +
  88.277 +	    /* Serial Ports */
  88.278 +	    Device (COM1)
  88.279 +	    {
  88.280 +	        Name (_HID, EisaId ("PNP0501"))
  88.281 +		Name (_UID, 0x01)
  88.282 +		Method (_STA, 0, NotSerialized)
  88.283 +		{
  88.284 +		    Store (\_SB.PCI0.PX13.DRSC, Local0)
  88.285 +		    And (Local0, 0x08000000, Local0)
  88.286 +		    If (LEqual (Local0, 0))
  88.287 +		    {
  88.288 +			Return (0x00)
  88.289 +		    }
  88.290 +		    Else
  88.291 +		    {
  88.292 +			Return (0x0F)
  88.293 +		    }
  88.294 +		}
  88.295 +		Method (_CRS, 0, NotSerialized)
  88.296 +		{
  88.297 +		    Name (BUF0, ResourceTemplate ()
  88.298 +                    {
  88.299 +			IO (Decode16, 0x03F8, 0x03F8, 0x00, 0x08)
  88.300 +                	IRQNoFlags () {4}
  88.301 +		    })
  88.302 +		    Return (BUF0)
  88.303 +		}
  88.304 +	    }
  88.305 +
  88.306 +	    Device (COM2)
  88.307 +	    {
  88.308 +	        Name (_HID, EisaId ("PNP0501"))
  88.309 +		Name (_UID, 0x02)
  88.310 +		Method (_STA, 0, NotSerialized)
  88.311 +		{
  88.312 +		    Store (\_SB.PCI0.PX13.DRSC, Local0)
  88.313 +		    And (Local0, 0x80000000, Local0)
  88.314 +		    If (LEqual (Local0, 0))
  88.315 +		    {
  88.316 +			Return (0x00)
  88.317 +		    }
  88.318 +		    Else
  88.319 +		    {
  88.320 +			Return (0x0F)
  88.321 +		    }
  88.322 +		}
  88.323 +		Method (_CRS, 0, NotSerialized)
  88.324 +		{
  88.325 +		    Name (BUF0, ResourceTemplate ()
  88.326 +                    {
  88.327 +			IO (Decode16, 0x02F8, 0x02F8, 0x00, 0x08)
  88.328 +                	IRQNoFlags () {3}
  88.329 +		    })
  88.330 +		    Return (BUF0)
  88.331 +		}
  88.332 +	    }
  88.333 +        }
  88.334 +
  88.335 +	/* PIIX4 PM */
  88.336 +        Device (PX13) {
  88.337 +	    Name (_ADR, 0x00010003)
  88.338 +
  88.339 +	    OperationRegion (P13C, PCI_Config, 0x5c, 0x24)
  88.340 +	    Field (P13C, DWordAcc, NoLock, Preserve)
  88.341 +	    {
  88.342 +		DRSA, 32,
  88.343 +		DRSB, 32,
  88.344 +		DRSC, 32,
  88.345 +		DRSE, 32,
  88.346 +		DRSF, 32,
  88.347 +		DRSG, 32,
  88.348 +		DRSH, 32,
  88.349 +		DRSI, 32,
  88.350 +		DRSJ, 32
  88.351 +	    }
  88.352 +	}
  88.353 +    }
  88.354 +
  88.355 +    /* PCI IRQs */
  88.356 +    Scope(\_SB) {
  88.357 +         Field (\_SB.PCI0.ISA.P40C, ByteAcc, NoLock, Preserve)
  88.358 +         {
  88.359 +             PRQ0,   8, 
  88.360 +             PRQ1,   8, 
  88.361 +             PRQ2,   8, 
  88.362 +             PRQ3,   8
  88.363 +         }
  88.364 +
  88.365 +        Device(LNKA){
  88.366 +                Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
  88.367 +                Name(_UID, 1)
  88.368 +                Name(_PRS, ResourceTemplate(){
  88.369 +                    IRQ (Level, ActiveLow, Shared)
  88.370 +                        {3,4,5,6,7,9,10,11,12}
  88.371 +                })
  88.372 +                Method (_STA, 0, NotSerialized)
  88.373 +                {
  88.374 +                    Store (0x0B, Local0)
  88.375 +                    If (And (0x80, PRQ0, Local1))
  88.376 +                    {
  88.377 +                         Store (0x09, Local0)
  88.378 +                    }
  88.379 +                    Return (Local0)
  88.380 +                }
  88.381 +                Method (_DIS, 0, NotSerialized)
  88.382 +                {
  88.383 +                    Or (PRQ0, 0x80, PRQ0)
  88.384 +                }
  88.385 +                Method (_CRS, 0, NotSerialized)
  88.386 +                {
  88.387 +                    Name (PRR0, ResourceTemplate ()
  88.388 +                    {
  88.389 +                        IRQ (Level, ActiveLow, Shared)
  88.390 +                            {1}
  88.391 +                    })
  88.392 +                    CreateWordField (PRR0, 0x01, TMP)
  88.393 +                    Store (PRQ0, Local0)
  88.394 +                    If (LLess (Local0, 0x80))
  88.395 +                    {
  88.396 +                        ShiftLeft (One, Local0, TMP)
  88.397 +                    }
  88.398 +                    Else
  88.399 +                    {
  88.400 +                        Store (Zero, TMP)
  88.401 +                    }
  88.402 +                    Return (PRR0)
  88.403 +                }
  88.404 +                Method (_SRS, 1, NotSerialized)
  88.405 +                {
  88.406 +                    CreateWordField (Arg0, 0x01, TMP)
  88.407 +                    FindSetRightBit (TMP, Local0)
  88.408 +                    Decrement (Local0)
  88.409 +                    Store (Local0, PRQ0)
  88.410 +                }
  88.411 +        }
  88.412 +        Device(LNKB){
  88.413 +                Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
  88.414 +                Name(_UID, 2)
  88.415 +                Name(_PRS, ResourceTemplate(){
  88.416 +                    IRQ (Level, ActiveLow, Shared)
  88.417 +                        {3,4,5,6,7,9,10,11,12}
  88.418 +                })
  88.419 +                Method (_STA, 0, NotSerialized)
  88.420 +                {
  88.421 +                    Store (0x0B, Local0)
  88.422 +                    If (And (0x80, PRQ1, Local1))
  88.423 +                    {
  88.424 +                         Store (0x09, Local0)
  88.425 +                    }
  88.426 +                    Return (Local0)
  88.427 +                }
  88.428 +                Method (_DIS, 0, NotSerialized)
  88.429 +                {
  88.430 +                    Or (PRQ1, 0x80, PRQ1)
  88.431 +                }
  88.432 +                Method (_CRS, 0, NotSerialized)
  88.433 +                {
  88.434 +                    Name (PRR0, ResourceTemplate ()
  88.435 +                    {
  88.436 +                        IRQ (Level, ActiveLow, Shared)
  88.437 +                            {1}
  88.438 +                    })
  88.439 +                    CreateWordField (PRR0, 0x01, TMP)
  88.440 +                    Store (PRQ1, Local0)
  88.441 +                    If (LLess (Local0, 0x80))
  88.442 +                    {
  88.443 +                        ShiftLeft (One, Local0, TMP)
  88.444 +                    }
  88.445 +                    Else
  88.446 +                    {
  88.447 +                        Store (Zero, TMP)
  88.448 +                    }
  88.449 +                    Return (PRR0)
  88.450 +                }
  88.451 +                Method (_SRS, 1, NotSerialized)
  88.452 +                {
  88.453 +                    CreateWordField (Arg0, 0x01, TMP)
  88.454 +                    FindSetRightBit (TMP, Local0)
  88.455 +                    Decrement (Local0)
  88.456 +                    Store (Local0, PRQ1)
  88.457 +                }
  88.458 +        }
  88.459 +        Device(LNKC){
  88.460 +                Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
  88.461 +                Name(_UID, 3)
  88.462 +                Name(_PRS, ResourceTemplate(){
  88.463 +                    IRQ (Level, ActiveLow, Shared)
  88.464 +                        {3,4,5,6,7,9,10,11,12}
  88.465 +                })
  88.466 +                Method (_STA, 0, NotSerialized)
  88.467 +                {
  88.468 +                    Store (0x0B, Local0)
  88.469 +                    If (And (0x80, PRQ2, Local1))
  88.470 +                    {
  88.471 +                         Store (0x09, Local0)
  88.472 +                    }
  88.473 +                    Return (Local0)
  88.474 +                }
  88.475 +                Method (_DIS, 0, NotSerialized)
  88.476 +                {
  88.477 +                    Or (PRQ2, 0x80, PRQ2)
  88.478 +                }
  88.479 +                Method (_CRS, 0, NotSerialized)
  88.480 +                {
  88.481 +                    Name (PRR0, ResourceTemplate ()
  88.482 +                    {
  88.483 +                        IRQ (Level, ActiveLow, Shared)
  88.484 +                            {1}
  88.485 +                    })
  88.486 +                    CreateWordField (PRR0, 0x01, TMP)
  88.487 +                    Store (PRQ2, Local0)
  88.488 +                    If (LLess (Local0, 0x80))
  88.489 +                    {
  88.490 +                        ShiftLeft (One, Local0, TMP)
  88.491 +                    }
  88.492 +                    Else
  88.493 +                    {
  88.494 +                        Store (Zero, TMP)
  88.495 +                    }
  88.496 +                    Return (PRR0)
  88.497 +                }
  88.498 +                Method (_SRS, 1, NotSerialized)
  88.499 +                {
  88.500 +                    CreateWordField (Arg0, 0x01, TMP)
  88.501 +                    FindSetRightBit (TMP, Local0)
  88.502 +                    Decrement (Local0)
  88.503 +                    Store (Local0, PRQ2)
  88.504 +                }
  88.505 +        }
  88.506 +        Device(LNKD){
  88.507 +                Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
  88.508 +                Name(_UID, 4)
  88.509 +                Name(_PRS, ResourceTemplate(){
  88.510 +                    IRQ (Level, ActiveLow, Shared)
  88.511 +                        {3,4,5,6,7,9,10,11,12}
  88.512 +                })
  88.513 +                Method (_STA, 0, NotSerialized)
  88.514 +                {
  88.515 +                    Store (0x0B, Local0)
  88.516 +                    If (And (0x80, PRQ3, Local1))
  88.517 +                    {
  88.518 +                         Store (0x09, Local0)
  88.519 +                    }
  88.520 +                    Return (Local0)
  88.521 +                }
  88.522 +                Method (_DIS, 0, NotSerialized)
  88.523 +                {
  88.524 +                    Or (PRQ3, 0x80, PRQ3)
  88.525 +                }
  88.526 +                Method (_CRS, 0, NotSerialized)
  88.527 +                {
  88.528 +                    Name (PRR0, ResourceTemplate ()
  88.529 +                    {
  88.530 +                        IRQ (Level, ActiveLow, Shared)
  88.531 +                            {1}
  88.532 +                    })
  88.533 +                    CreateWordField (PRR0, 0x01, TMP)
  88.534 +                    Store (PRQ3, Local0)
  88.535 +                    If (LLess (Local0, 0x80))
  88.536 +                    {
  88.537 +                        ShiftLeft (One, Local0, TMP)
  88.538 +                    }
  88.539 +                    Else
  88.540 +                    {
  88.541 +                        Store (Zero, TMP)
  88.542 +                    }
  88.543 +                    Return (PRR0)
  88.544 +                }
  88.545 +                Method (_SRS, 1, NotSerialized)
  88.546 +                {
  88.547 +                    CreateWordField (Arg0, 0x01, TMP)
  88.548 +                    FindSetRightBit (TMP, Local0)
  88.549 +                    Decrement (Local0)
  88.550 +                    Store (Local0, PRQ3)
  88.551 +                }
  88.552 +        }
  88.553 +    }
  88.554 +
  88.555 +    /* S5 = power off state */
  88.556 +    Name (_S5, Package (4) {
  88.557 +        0x00, // PM1a_CNT.SLP_TYP 
  88.558 +        0x00, // PM2a_CNT.SLP_TYP 
  88.559 +        0x00, // reserved
  88.560 +        0x00, // reserved
  88.561 +    })
  88.562 +}
    89.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.2 +++ b/tools/ioemu/hw/acpi-dsdt.hex	Wed Aug 09 08:34:06 2006 -0600
    89.3 @@ -0,0 +1,278 @@
    89.4 +/*
    89.5 + * 
    89.6 + * Intel ACPI Component Architecture
    89.7 + * ASL Optimizing Compiler version 20060421 [Apr 29 2006]
    89.8 + * Copyright (C) 2000 - 2006 Intel Corporation
    89.9 + * Supports ACPI Specification Revision 3.0a
   89.10 + * 
   89.11 + * Compilation of "/usr/local/home/bellard/qemu-current/hw/acpi-dsdt.dsl" - Wed Jun 14 20:09:53 2006
   89.12 + * 
   89.13 + * C source code output
   89.14 + *
   89.15 + */
   89.16 +unsigned char AmlCode[] =
   89.17 +{
   89.18 +    0x44,0x53,0x44,0x54,0x32,0x08,0x00,0x00,  /* 00000000    "DSDT2..." */
   89.19 +    0x01,0x5B,0x51,0x45,0x4D,0x55,0x00,0x00,  /* 00000008    ".[QEMU.." */
   89.20 +    0x51,0x45,0x4D,0x55,0x44,0x53,0x44,0x54,  /* 00000010    "QEMUDSDT" */
   89.21 +    0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
   89.22 +    0x21,0x04,0x06,0x20,0x10,0x4F,0x04,0x5C,  /* 00000020    "!.. .O.\" */
   89.23 +    0x00,0x5B,0x80,0x43,0x4D,0x53,0x5F,0x01,  /* 00000028    ".[.CMS_." */
   89.24 +    0x0A,0x70,0x0A,0x02,0x5B,0x81,0x10,0x43,  /* 00000030    ".p..[..C" */
   89.25 +    0x4D,0x53,0x5F,0x01,0x43,0x4D,0x53,0x49,  /* 00000038    "MS_.CMSI" */
   89.26 +    0x08,0x43,0x4D,0x53,0x44,0x08,0x14,0x14,  /* 00000040    ".CMSD..." */
   89.27 +    0x43,0x4D,0x52,0x44,0x01,0x70,0x68,0x43,  /* 00000048    "CMRD.phC" */
   89.28 +    0x4D,0x53,0x49,0x70,0x43,0x4D,0x53,0x44,  /* 00000050    "MSIpCMSD" */
   89.29 +    0x60,0xA4,0x60,0x5B,0x80,0x44,0x42,0x47,  /* 00000058    "`.`[.DBG" */
   89.30 +    0x5F,0x01,0x0B,0x44,0xB0,0x0A,0x04,0x5B,  /* 00000060    "_..D...[" */
   89.31 +    0x81,0x0B,0x44,0x42,0x47,0x5F,0x03,0x44,  /* 00000068    "..DBG_.D" */
   89.32 +    0x42,0x47,0x4C,0x20,0x10,0x4E,0x25,0x5F,  /* 00000070    "BGL .N%_" */
   89.33 +    0x53,0x42,0x5F,0x5B,0x82,0x46,0x25,0x50,  /* 00000078    "SB_[.F%P" */
   89.34 +    0x43,0x49,0x30,0x08,0x5F,0x48,0x49,0x44,  /* 00000080    "CI0._HID" */
   89.35 +    0x0C,0x41,0xD0,0x0A,0x03,0x08,0x5F,0x41,  /* 00000088    ".A...._A" */
   89.36 +    0x44,0x52,0x00,0x08,0x5F,0x55,0x49,0x44,  /* 00000090    "DR.._UID" */
   89.37 +    0x01,0x08,0x5F,0x50,0x52,0x54,0x12,0x47,  /* 00000098    ".._PRT.G" */
   89.38 +    0x15,0x18,0x12,0x0B,0x04,0x0B,0xFF,0xFF,  /* 000000A0    "........" */
   89.39 +    0x00,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0B,  /* 000000A8    ".LNKD..." */
   89.40 +    0x04,0x0B,0xFF,0xFF,0x01,0x4C,0x4E,0x4B,  /* 000000B0    ".....LNK" */
   89.41 +    0x41,0x00,0x12,0x0C,0x04,0x0B,0xFF,0xFF,  /* 000000B8    "A......." */
   89.42 +    0x0A,0x02,0x4C,0x4E,0x4B,0x42,0x00,0x12,  /* 000000C0    "..LNKB.." */
   89.43 +    0x0C,0x04,0x0B,0xFF,0xFF,0x0A,0x03,0x4C,  /* 000000C8    ".......L" */
   89.44 +    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 000000D0    "NKC....." */
   89.45 +    0xFF,0xFF,0x01,0x00,0x00,0x4C,0x4E,0x4B,  /* 000000D8    ".....LNK" */
   89.46 +    0x41,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000000E0    "A......." */
   89.47 +    0x01,0x00,0x01,0x4C,0x4E,0x4B,0x42,0x00,  /* 000000E8    "...LNKB." */
   89.48 +    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x01,0x00,  /* 000000F0    "........" */
   89.49 +    0x0A,0x02,0x4C,0x4E,0x4B,0x43,0x00,0x12,  /* 000000F8    "..LNKC.." */
   89.50 +    0x0E,0x04,0x0C,0xFF,0xFF,0x01,0x00,0x0A,  /* 00000100    "........" */
   89.51 +    0x03,0x4C,0x4E,0x4B,0x44,0x00,0x12,0x0D,  /* 00000108    ".LNKD..." */
   89.52 +    0x04,0x0C,0xFF,0xFF,0x02,0x00,0x00,0x4C,  /* 00000110    ".......L" */
   89.53 +    0x4E,0x4B,0x42,0x00,0x12,0x0D,0x04,0x0C,  /* 00000118    "NKB....." */
   89.54 +    0xFF,0xFF,0x02,0x00,0x01,0x4C,0x4E,0x4B,  /* 00000120    ".....LNK" */
   89.55 +    0x43,0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,  /* 00000128    "C......." */
   89.56 +    0x02,0x00,0x0A,0x02,0x4C,0x4E,0x4B,0x44,  /* 00000130    "....LNKD" */
   89.57 +    0x00,0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x02,  /* 00000138    "........" */
   89.58 +    0x00,0x0A,0x03,0x4C,0x4E,0x4B,0x41,0x00,  /* 00000140    "...LNKA." */
   89.59 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x03,0x00,  /* 00000148    "........" */
   89.60 +    0x00,0x4C,0x4E,0x4B,0x43,0x00,0x12,0x0D,  /* 00000150    ".LNKC..." */
   89.61 +    0x04,0x0C,0xFF,0xFF,0x03,0x00,0x01,0x4C,  /* 00000158    ".......L" */
   89.62 +    0x4E,0x4B,0x44,0x00,0x12,0x0E,0x04,0x0C,  /* 00000160    "NKD....." */
   89.63 +    0xFF,0xFF,0x03,0x00,0x0A,0x02,0x4C,0x4E,  /* 00000168    "......LN" */
   89.64 +    0x4B,0x41,0x00,0x12,0x0E,0x04,0x0C,0xFF,  /* 00000170    "KA......" */
   89.65 +    0xFF,0x03,0x00,0x0A,0x03,0x4C,0x4E,0x4B,  /* 00000178    ".....LNK" */
   89.66 +    0x42,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 00000180    "B......." */
   89.67 +    0x04,0x00,0x00,0x4C,0x4E,0x4B,0x44,0x00,  /* 00000188    "...LNKD." */
   89.68 +    0x12,0x0D,0x04,0x0C,0xFF,0xFF,0x04,0x00,  /* 00000190    "........" */
   89.69 +    0x01,0x4C,0x4E,0x4B,0x41,0x00,0x12,0x0E,  /* 00000198    ".LNKA..." */
   89.70 +    0x04,0x0C,0xFF,0xFF,0x04,0x00,0x0A,0x02,  /* 000001A0    "........" */
   89.71 +    0x4C,0x4E,0x4B,0x42,0x00,0x12,0x0E,0x04,  /* 000001A8    "LNKB...." */
   89.72 +    0x0C,0xFF,0xFF,0x04,0x00,0x0A,0x03,0x4C,  /* 000001B0    ".......L" */
   89.73 +    0x4E,0x4B,0x43,0x00,0x12,0x0D,0x04,0x0C,  /* 000001B8    "NKC....." */
   89.74 +    0xFF,0xFF,0x05,0x00,0x00,0x4C,0x4E,0x4B,  /* 000001C0    ".....LNK" */
   89.75 +    0x41,0x00,0x12,0x0D,0x04,0x0C,0xFF,0xFF,  /* 000001C8    "A......." */
   89.76 +    0x05,0x00,0x01,0x4C,0x4E,0x4B,0x42,0x00,  /* 000001D0    "...LNKB." */
   89.77 +    0x12,0x0E,0x04,0x0C,0xFF,0xFF,0x05,0x00,  /* 000001D8    "........" */
   89.78 +    0x0A,0x02,0x4C,0x4E,0x4B,0x43,0x00,0x12,  /* 000001E0    "..LNKC.." */
   89.79 +    0x0E,0x04,0x0C,0xFF,0xFF,0x05,0x00,0x0A,  /* 000001E8    "........" */
   89.80 +    0x03,0x4C,0x4E,0x4B,0x44,0x00,0x14,0x4C,  /* 000001F0    ".LNKD..L" */
   89.81 +    0x0D,0x5F,0x43,0x52,0x53,0x00,0x08,0x4D,  /* 000001F8    "._CRS..M" */
   89.82 +    0x45,0x4D,0x50,0x11,0x42,0x07,0x0A,0x6E,  /* 00000200    "EMP.B..n" */
   89.83 +    0x88,0x0D,0x00,0x02,0x0C,0x00,0x00,0x00,  /* 00000208    "........" */
   89.84 +    0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x01,  /* 00000210    "........" */
   89.85 +    0x47,0x01,0xF8,0x0C,0xF8,0x0C,0x01,0x08,  /* 00000218    "G......." */
   89.86 +    0x88,0x0D,0x00,0x01,0x0C,0x03,0x00,0x00,  /* 00000220    "........" */
   89.87 +    0x00,0x00,0xF7,0x0C,0x00,0x00,0xF8,0x0C,  /* 00000228    "........" */
   89.88 +    0x88,0x0D,0x00,0x01,0x0C,0x03,0x00,0x00,  /* 00000230    "........" */
   89.89 +    0x00,0x0D,0xFF,0xFF,0x00,0x00,0x00,0xF3,  /* 00000238    "........" */
   89.90 +    0x87,0x17,0x00,0x00,0x0C,0x03,0x00,0x00,  /* 00000240    "........" */
   89.91 +    0x00,0x00,0x00,0x00,0x0A,0x00,0xFF,0xFF,  /* 00000248    "........" */
   89.92 +    0x0B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000250    "........" */
   89.93 +    0x02,0x00,0x87,0x17,0x00,0x00,0x08,0x01,  /* 00000258    "........" */
   89.94 +    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  /* 00000260    "........" */
   89.95 +    0xFF,0xFF,0xBF,0xFE,0x00,0x00,0x00,0x00,  /* 00000268    "........" */
   89.96 +    0x00,0x00,0x00,0x00,0x79,0x00,0x8A,0x4D,  /* 00000270    "....y..M" */
   89.97 +    0x45,0x4D,0x50,0x0A,0x5C,0x50,0x4D,0x49,  /* 00000278    "EMP.\PMI" */
   89.98 +    0x4E,0x8A,0x4D,0x45,0x4D,0x50,0x0A,0x60,  /* 00000280    "N.MEMP.`" */
   89.99 +    0x50,0x4D,0x41,0x58,0x8A,0x4D,0x45,0x4D,  /* 00000288    "PMAX.MEM" */
  89.100 +    0x50,0x0A,0x68,0x50,0x4C,0x45,0x4E,0x72,  /* 00000290    "P.hPLENr" */
  89.101 +    0x43,0x4D,0x52,0x44,0x0A,0x34,0x79,0x43,  /* 00000298    "CMRD.4yC" */
  89.102 +    0x4D,0x52,0x44,0x0A,0x35,0x0A,0x08,0x00,  /* 000002A0    "MRD.5..." */
  89.103 +    0x60,0x79,0x60,0x0A,0x10,0x60,0x72,0x60,  /* 000002A8    "`y`..`r`" */
  89.104 +    0x0C,0x00,0x00,0x00,0x01,0x60,0x70,0x60,  /* 000002B0    ".....`p`" */
  89.105 +    0x50,0x4D,0x49,0x4E,0x74,0x50,0x4D,0x41,  /* 000002B8    "PMINtPMA" */
  89.106 +    0x58,0x50,0x4D,0x49,0x4E,0x50,0x4C,0x45,  /* 000002C0    "XPMINPLE" */
  89.107 +    0x4E,0x75,0x50,0x4C,0x45,0x4E,0xA4,0x4D,  /* 000002C8    "NuPLEN.M" */
  89.108 +    0x45,0x4D,0x50,0x10,0x42,0x26,0x2E,0x5F,  /* 000002D0    "EMP.B&._" */
  89.109 +    0x53,0x42,0x5F,0x50,0x43,0x49,0x30,0x5B,  /* 000002D8    "SB_PCI0[" */
  89.110 +    0x82,0x43,0x20,0x49,0x53,0x41,0x5F,0x08,  /* 000002E0    ".C ISA_." */
  89.111 +    0x5F,0x41,0x44,0x52,0x0C,0x00,0x00,0x01,  /* 000002E8    "_ADR...." */
  89.112 +    0x00,0x5B,0x80,0x50,0x34,0x30,0x43,0x02,  /* 000002F0    ".[.P40C." */
  89.113 +    0x0A,0x60,0x0A,0x04,0x5B,0x82,0x44,0x04,  /* 000002F8    ".`..[.D." */
  89.114 +    0x4B,0x42,0x44,0x5F,0x08,0x5F,0x48,0x49,  /* 00000300    "KBD_._HI" */
  89.115 +    0x44,0x0C,0x41,0xD0,0x03,0x03,0x14,0x09,  /* 00000308    "D.A....." */
  89.116 +    0x5F,0x53,0x54,0x41,0x00,0xA4,0x0A,0x0F,  /* 00000310    "_STA...." */
  89.117 +    0x14,0x29,0x5F,0x43,0x52,0x53,0x00,0x08,  /* 00000318    ".)_CRS.." */
  89.118 +    0x54,0x4D,0x50,0x5F,0x11,0x18,0x0A,0x15,  /* 00000320    "TMP_...." */
  89.119 +    0x47,0x01,0x60,0x00,0x60,0x00,0x01,0x01,  /* 00000328    "G.`.`..." */
  89.120 +    0x47,0x01,0x64,0x00,0x64,0x00,0x01,0x01,  /* 00000330    "G.d.d..." */
  89.121 +    0x22,0x02,0x00,0x79,0x00,0xA4,0x54,0x4D,  /* 00000338    ""..y..TM" */
  89.122 +    0x50,0x5F,0x5B,0x82,0x33,0x4D,0x4F,0x55,  /* 00000340    "P_[.3MOU" */
  89.123 +    0x5F,0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,  /* 00000348    "_._HID.A" */
  89.124 +    0xD0,0x0F,0x13,0x14,0x09,0x5F,0x53,0x54,  /* 00000350    "....._ST" */
  89.125 +    0x41,0x00,0xA4,0x0A,0x0F,0x14,0x19,0x5F,  /* 00000358    "A......_" */
  89.126 +    0x43,0x52,0x53,0x00,0x08,0x54,0x4D,0x50,  /* 00000360    "CRS..TMP" */
  89.127 +    0x5F,0x11,0x08,0x0A,0x05,0x22,0x00,0x10,  /* 00000368    "_....".." */
  89.128 +    0x79,0x00,0xA4,0x54,0x4D,0x50,0x5F,0x5B,  /* 00000370    "y..TMP_[" */
  89.129 +    0x82,0x47,0x04,0x46,0x44,0x43,0x30,0x08,  /* 00000378    ".G.FDC0." */
  89.130 +    0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,0x07,  /* 00000380    "_HID.A.." */
  89.131 +    0x00,0x14,0x09,0x5F,0x53,0x54,0x41,0x00,  /* 00000388    "..._STA." */
  89.132 +    0xA4,0x0A,0x0F,0x14,0x2C,0x5F,0x43,0x52,  /* 00000390    "....,_CR" */
  89.133 +    0x53,0x00,0x08,0x42,0x55,0x46,0x30,0x11,  /* 00000398    "S..BUF0." */
  89.134 +    0x1B,0x0A,0x18,0x47,0x01,0xF2,0x03,0xF2,  /* 000003A0    "...G...." */
  89.135 +    0x03,0x00,0x04,0x47,0x01,0xF7,0x03,0xF7,  /* 000003A8    "...G...." */
  89.136 +    0x03,0x00,0x01,0x22,0x40,0x00,0x2A,0x04,  /* 000003B0    "..."@.*." */
  89.137 +    0x00,0x79,0x00,0xA4,0x42,0x55,0x46,0x30,  /* 000003B8    ".y..BUF0" */
  89.138 +    0x5B,0x82,0x4B,0x05,0x4C,0x50,0x54,0x5F,  /* 000003C0    "[.K.LPT_" */
  89.139 +    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 000003C8    "._HID.A." */
  89.140 +    0x04,0x00,0x14,0x28,0x5F,0x53,0x54,0x41,  /* 000003D0    "...(_STA" */
  89.141 +    0x00,0x70,0x5E,0x5E,0x5E,0x2E,0x50,0x58,  /* 000003D8    ".p^^^.PX" */
  89.142 +    0x31,0x33,0x44,0x52,0x53,0x41,0x60,0x7B,  /* 000003E0    "13DRSA`{" */
  89.143 +    0x60,0x0C,0x00,0x00,0x00,0x80,0x60,0xA0,  /* 000003E8    "`.....`." */
  89.144 +    0x06,0x93,0x60,0x00,0xA4,0x00,0xA1,0x04,  /* 000003F0    "..`....." */
  89.145 +    0xA4,0x0A,0x0F,0x14,0x21,0x5F,0x43,0x52,  /* 000003F8    "....!_CR" */
  89.146 +    0x53,0x00,0x08,0x42,0x55,0x46,0x30,0x11,  /* 00000400    "S..BUF0." */
  89.147 +    0x10,0x0A,0x0D,0x47,0x01,0x78,0x03,0x78,  /* 00000408    "...G.x.x" */
  89.148 +    0x03,0x08,0x08,0x22,0x80,0x00,0x79,0x00,  /* 00000410    "..."..y." */
  89.149 +    0xA4,0x42,0x55,0x46,0x30,0x5B,0x82,0x41,  /* 00000418    ".BUF0[.A" */
  89.150 +    0x06,0x43,0x4F,0x4D,0x31,0x08,0x5F,0x48,  /* 00000420    ".COM1._H" */
  89.151 +    0x49,0x44,0x0C,0x41,0xD0,0x05,0x01,0x08,  /* 00000428    "ID.A...." */
  89.152 +    0x5F,0x55,0x49,0x44,0x01,0x14,0x28,0x5F,  /* 00000430    "_UID..(_" */
  89.153 +    0x53,0x54,0x41,0x00,0x70,0x5E,0x5E,0x5E,  /* 00000438    "STA.p^^^" */
  89.154 +    0x2E,0x50,0x58,0x31,0x33,0x44,0x52,0x53,  /* 00000440    ".PX13DRS" */
  89.155 +    0x43,0x60,0x7B,0x60,0x0C,0x00,0x00,0x00,  /* 00000448    "C`{`...." */
  89.156 +    0x08,0x60,0xA0,0x06,0x93,0x60,0x00,0xA4,  /* 00000450    ".`...`.." */
  89.157 +    0x00,0xA1,0x04,0xA4,0x0A,0x0F,0x14,0x21,  /* 00000458    ".......!" */
  89.158 +    0x5F,0x43,0x52,0x53,0x00,0x08,0x42,0x55,  /* 00000460    "_CRS..BU" */
  89.159 +    0x46,0x30,0x11,0x10,0x0A,0x0D,0x47,0x01,  /* 00000468    "F0....G." */
  89.160 +    0xF8,0x03,0xF8,0x03,0x00,0x08,0x22,0x10,  /* 00000470    "......"." */
  89.161 +    0x00,0x79,0x00,0xA4,0x42,0x55,0x46,0x30,  /* 00000478    ".y..BUF0" */
  89.162 +    0x5B,0x82,0x42,0x06,0x43,0x4F,0x4D,0x32,  /* 00000480    "[.B.COM2" */
  89.163 +    0x08,0x5F,0x48,0x49,0x44,0x0C,0x41,0xD0,  /* 00000488    "._HID.A." */
  89.164 +    0x05,0x01,0x08,0x5F,0x55,0x49,0x44,0x0A,  /* 00000490    "..._UID." */
  89.165 +    0x02,0x14,0x28,0x5F,0x53,0x54,0x41,0x00,  /* 00000498    "..(_STA." */
  89.166 +    0x70,0x5E,0x5E,0x5E,0x2E,0x50,0x58,0x31,  /* 000004A0    "p^^^.PX1" */
  89.167 +    0x33,0x44,0x52,0x53,0x43,0x60,0x7B,0x60,  /* 000004A8    "3DRSC`{`" */
  89.168 +    0x0C,0x00,0x00,0x00,0x80,0x60,0xA0,0x06,  /* 000004B0    ".....`.." */
  89.169 +    0x93,0x60,0x00,0xA4,0x00,0xA1,0x04,0xA4,  /* 000004B8    ".`......" */
  89.170 +    0x0A,0x0F,0x14,0x21,0x5F,0x43,0x52,0x53,  /* 000004C0    "...!_CRS" */
  89.171 +    0x00,0x08,0x42,0x55,0x46,0x30,0x11,0x10,  /* 000004C8    "..BUF0.." */
  89.172 +    0x0A,0x0D,0x47,0x01,0xF8,0x02,0xF8,0x02,  /* 000004D0    "..G....." */
  89.173 +    0x00,0x08,0x22,0x08,0x00,0x79,0x00,0xA4,  /* 000004D8    ".."..y.." */
  89.174 +    0x42,0x55,0x46,0x30,0x5B,0x82,0x40,0x05,  /* 000004E0    "BUF0[.@." */
  89.175 +    0x50,0x58,0x31,0x33,0x08,0x5F,0x41,0x44,  /* 000004E8    "PX13._AD" */
  89.176 +    0x52,0x0C,0x03,0x00,0x01,0x00,0x5B,0x80,  /* 000004F0    "R.....[." */
  89.177 +    0x50,0x31,0x33,0x43,0x02,0x0A,0x5C,0x0A,  /* 000004F8    "P13C..\." */
  89.178 +    0x24,0x5B,0x81,0x33,0x50,0x31,0x33,0x43,  /* 00000500    "$[.3P13C" */
  89.179 +    0x03,0x44,0x52,0x53,0x41,0x20,0x44,0x52,  /* 00000508    ".DRSA DR" */
  89.180 +    0x53,0x42,0x20,0x44,0x52,0x53,0x43,0x20,  /* 00000510    "SB DRSC " */
  89.181 +    0x44,0x52,0x53,0x45,0x20,0x44,0x52,0x53,  /* 00000518    "DRSE DRS" */
  89.182 +    0x46,0x20,0x44,0x52,0x53,0x47,0x20,0x44,  /* 00000520    "F DRSG D" */
  89.183 +    0x52,0x53,0x48,0x20,0x44,0x52,0x53,0x49,  /* 00000528    "RSH DRSI" */
  89.184 +    0x20,0x44,0x52,0x53,0x4A,0x20,0x10,0x4F,  /* 00000530    " DRSJ .O" */
  89.185 +    0x2E,0x5F,0x53,0x42,0x5F,0x5B,0x81,0x24,  /* 00000538    "._SB_[.$" */
  89.186 +    0x2F,0x03,0x50,0x43,0x49,0x30,0x49,0x53,  /* 00000540    "/.PCI0IS" */
  89.187 +    0x41,0x5F,0x50,0x34,0x30,0x43,0x01,0x50,  /* 00000548    "A_P40C.P" */
  89.188 +    0x52,0x51,0x30,0x08,0x50,0x52,0x51,0x31,  /* 00000550    "RQ0.PRQ1" */
  89.189 +    0x08,0x50,0x52,0x51,0x32,0x08,0x50,0x52,  /* 00000558    ".PRQ2.PR" */
  89.190 +    0x51,0x33,0x08,0x5B,0x82,0x4E,0x0A,0x4C,  /* 00000560    "Q3.[.N.L" */
  89.191 +    0x4E,0x4B,0x41,0x08,0x5F,0x48,0x49,0x44,  /* 00000568    "NKA._HID" */
  89.192 +    0x0C,0x41,0xD0,0x0C,0x0F,0x08,0x5F,0x55,  /* 00000570    ".A...._U" */
  89.193 +    0x49,0x44,0x01,0x08,0x5F,0x50,0x52,0x53,  /* 00000578    "ID.._PRS" */
  89.194 +    0x11,0x09,0x0A,0x06,0x23,0xF8,0x1E,0x18,  /* 00000580    "....#..." */
  89.195 +    0x79,0x00,0x14,0x1A,0x5F,0x53,0x54,0x41,  /* 00000588    "y..._STA" */
  89.196 +    0x00,0x70,0x0A,0x0B,0x60,0xA0,0x0D,0x7B,  /* 00000590    ".p..`..{" */
  89.197 +    0x0A,0x80,0x50,0x52,0x51,0x30,0x61,0x70,  /* 00000598    "..PRQ0ap" */
  89.198 +    0x0A,0x09,0x60,0xA4,0x60,0x14,0x11,0x5F,  /* 000005A0    "..`.`.._" */
  89.199 +    0x44,0x49,0x53,0x00,0x7D,0x50,0x52,0x51,  /* 000005A8    "DIS.}PRQ" */
  89.200 +    0x30,0x0A,0x80,0x50,0x52,0x51,0x30,0x14,  /* 000005B0    "0..PRQ0." */
  89.201 +    0x3F,0x5F,0x43,0x52,0x53,0x00,0x08,0x50,  /* 000005B8    "?_CRS..P" */
  89.202 +    0x52,0x52,0x30,0x11,0x09,0x0A,0x06,0x23,  /* 000005C0    "RR0....#" */
  89.203 +    0x02,0x00,0x18,0x79,0x00,0x8B,0x50,0x52,  /* 000005C8    "...y..PR" */
  89.204 +    0x52,0x30,0x01,0x54,0x4D,0x50,0x5F,0x70,  /* 000005D0    "R0.TMP_p" */
  89.205 +    0x50,0x52,0x51,0x30,0x60,0xA0,0x0C,0x95,  /* 000005D8    "PRQ0`..." */
  89.206 +    0x60,0x0A,0x80,0x79,0x01,0x60,0x54,0x4D,  /* 000005E0    "`..y.`TM" */
  89.207 +    0x50,0x5F,0xA1,0x07,0x70,0x00,0x54,0x4D,  /* 000005E8    "P_..p.TM" */
  89.208 +    0x50,0x5F,0xA4,0x50,0x52,0x52,0x30,0x14,  /* 000005F0    "P_.PRR0." */
  89.209 +    0x1B,0x5F,0x53,0x52,0x53,0x01,0x8B,0x68,  /* 000005F8    "._SRS..h" */
  89.210 +    0x01,0x54,0x4D,0x50,0x5F,0x82,0x54,0x4D,  /* 00000600    ".TMP_.TM" */
  89.211 +    0x50,0x5F,0x60,0x76,0x60,0x70,0x60,0x50,  /* 00000608    "P_`v`p`P" */
  89.212 +    0x52,0x51,0x30,0x5B,0x82,0x4F,0x0A,0x4C,  /* 00000610    "RQ0[.O.L" */
  89.213 +    0x4E,0x4B,0x42,0x08,0x5F,0x48,0x49,0x44,  /* 00000618    "NKB._HID" */
  89.214 +    0x0C,0x41,0xD0,0x0C,0x0F,0x08,0x5F,0x55,  /* 00000620    ".A...._U" */
  89.215 +    0x49,0x44,0x0A,0x02,0x08,0x5F,0x50,0x52,  /* 00000628    "ID..._PR" */
  89.216 +    0x53,0x11,0x09,0x0A,0x06,0x23,0xF8,0x1E,  /* 00000630    "S....#.." */
  89.217 +    0x18,0x79,0x00,0x14,0x1A,0x5F,0x53,0x54,  /* 00000638    ".y..._ST" */
  89.218 +    0x41,0x00,0x70,0x0A,0x0B,0x60,0xA0,0x0D,  /* 00000640    "A.p..`.." */
  89.219 +    0x7B,0x0A,0x80,0x50,0x52,0x51,0x31,0x61,  /* 00000648    "{..PRQ1a" */
  89.220 +    0x70,0x0A,0x09,0x60,0xA4,0x60,0x14,0x11,  /* 00000650    "p..`.`.." */
  89.221 +    0x5F,0x44,0x49,0x53,0x00,0x7D,0x50,0x52,  /* 00000658    "_DIS.}PR" */
  89.222 +    0x51,0x31,0x0A,0x80,0x50,0x52,0x51,0x31,  /* 00000660    "Q1..PRQ1" */
  89.223 +    0x14,0x3F,0x5F,0x43,0x52,0x53,0x00,0x08,  /* 00000668    ".?_CRS.." */
  89.224 +    0x50,0x52,0x52,0x30,0x11,0x09,0x0A,0x06,  /* 00000670    "PRR0...." */
  89.225 +    0x23,0x02,0x00,0x18,0x79,0x00,0x8B,0x50,  /* 00000678    "#...y..P" */
  89.226 +    0x52,0x52,0x30,0x01,0x54,0x4D,0x50,0x5F,  /* 00000680    "RR0.TMP_" */
  89.227 +    0x70,0x50,0x52,0x51,0x31,0x60,0xA0,0x0C,  /* 00000688    "pPRQ1`.." */
  89.228 +    0x95,0x60,0x0A,0x80,0x79,0x01,0x60,0x54,  /* 00000690    ".`..y.`T" */
  89.229 +    0x4D,0x50,0x5F,0xA1,0x07,0x70,0x00,0x54,  /* 00000698    "MP_..p.T" */
  89.230 +    0x4D,0x50,0x5F,0xA4,0x50,0x52,0x52,0x30,  /* 000006A0    "MP_.PRR0" */
  89.231 +    0x14,0x1B,0x5F,0x53,0x52,0x53,0x01,0x8B,  /* 000006A8    ".._SRS.." */
  89.232 +    0x68,0x01,0x54,0x4D,0x50,0x5F,0x82,0x54,  /* 000006B0    "h.TMP_.T" */
  89.233 +    0x4D,0x50,0x5F,0x60,0x76,0x60,0x70,0x60,  /* 000006B8    "MP_`v`p`" */
  89.234 +    0x50,0x52,0x51,0x31,0x5B,0x82,0x4F,0x0A,  /* 000006C0    "PRQ1[.O." */
  89.235 +    0x4C,0x4E,0x4B,0x43,0x08,0x5F,0x48,0x49,  /* 000006C8    "LNKC._HI" */
  89.236 +    0x44,0x0C,0x41,0xD0,0x0C,0x0F,0x08,0x5F,  /* 000006D0    "D.A...._" */
  89.237 +    0x55,0x49,0x44,0x0A,0x03,0x08,0x5F,0x50,  /* 000006D8    "UID..._P" */
  89.238 +    0x52,0x53,0x11,0x09,0x0A,0x06,0x23,0xF8,  /* 000006E0    "RS....#." */
  89.239 +    0x1E,0x18,0x79,0x00,0x14,0x1A,0x5F,0x53,  /* 000006E8    "..y..._S" */
  89.240 +    0x54,0x41,0x00,0x70,0x0A,0x0B,0x60,0xA0,  /* 000006F0    "TA.p..`." */
  89.241 +    0x0D,0x7B,0x0A,0x80,0x50,0x52,0x51,0x32,  /* 000006F8    ".{..PRQ2" */
  89.242 +    0x61,0x70,0x0A,0x09,0x60,0xA4,0x60,0x14,  /* 00000700    "ap..`.`." */
  89.243 +    0x11,0x5F,0x44,0x49,0x53,0x00,0x7D,0x50,  /* 00000708    "._DIS.}P" */
  89.244 +    0x52,0x51,0x32,0x0A,0x80,0x50,0x52,0x51,  /* 00000710    "RQ2..PRQ" */
  89.245 +    0x32,0x14,0x3F,0x5F,0x43,0x52,0x53,0x00,  /* 00000718    "2.?_CRS." */
  89.246 +    0x08,0x50,0x52,0x52,0x30,0x11,0x09,0x0A,  /* 00000720    ".PRR0..." */
  89.247 +    0x06,0x23,0x02,0x00,0x18,0x79,0x00,0x8B,  /* 00000728    ".#...y.." */
  89.248 +    0x50,0x52,0x52,0x30,0x01,0x54,0x4D,0x50,  /* 00000730    "PRR0.TMP" */
  89.249 +    0x5F,0x70,0x50,0x52,0x51,0x32,0x60,0xA0,  /* 00000738    "_pPRQ2`." */
  89.250 +    0x0C,0x95,0x60,0x0A,0x80,0x79,0x01,0x60,  /* 00000740    "..`..y.`" */
  89.251 +    0x54,0x4D,0x50,0x5F,0xA1,0x07,0x70,0x00,  /* 00000748    "TMP_..p." */
  89.252 +    0x54,0x4D,0x50,0x5F,0xA4,0x50,0x52,0x52,  /* 00000750    "TMP_.PRR" */
  89.253 +    0x30,0x14,0x1B,0x5F,0x53,0x52,0x53,0x01,  /* 00000758    "0.._SRS." */
  89.254 +    0x8B,0x68,0x01,0x54,0x4D,0x50,0x5F,0x82,  /* 00000760    ".h.TMP_." */
  89.255 +    0x54,0x4D,0x50,0x5F,0x60,0x76,0x60,0x70,  /* 00000768    "TMP_`v`p" */
  89.256 +    0x60,0x50,0x52,0x51,0x32,0x5B,0x82,0x4F,  /* 00000770    "`PRQ2[.O" */
  89.257 +    0x0A,0x4C,0x4E,0x4B,0x44,0x08,0x5F,0x48,  /* 00000778    ".LNKD._H" */
  89.258 +    0x49,0x44,0x0C,0x41,0xD0,0x0C,0x0F,0x08,  /* 00000780    "ID.A...." */
  89.259 +    0x5F,0x55,0x49,0x44,0x0A,0x04,0x08,0x5F,  /* 00000788    "_UID..._" */
  89.260 +    0x50,0x52,0x53,0x11,0x09,0x0A,0x06,0x23,  /* 00000790    "PRS....#" */
  89.261 +    0xF8,0x1E,0x18,0x79,0x00,0x14,0x1A,0x5F,  /* 00000798    "...y..._" */
  89.262 +    0x53,0x54,0x41,0x00,0x70,0x0A,0x0B,0x60,  /* 000007A0    "STA.p..`" */
  89.263 +    0xA0,0x0D,0x7B,0x0A,0x80,0x50,0x52,0x51,  /* 000007A8    "..{..PRQ" */
  89.264 +    0x33,0x61,0x70,0x0A,0x09,0x60,0xA4,0x60,  /* 000007B0    "3ap..`.`" */
  89.265 +    0x14,0x11,0x5F,0x44,0x49,0x53,0x00,0x7D,  /* 000007B8    ".._DIS.}" */
  89.266 +    0x50,0x52,0x51,0x33,0x0A,0x80,0x50,0x52,  /* 000007C0    "PRQ3..PR" */
  89.267 +    0x51,0x33,0x14,0x3F,0x5F,0x43,0x52,0x53,  /* 000007C8    "Q3.?_CRS" */
  89.268 +    0x00,0x08,0x50,0x52,0x52,0x30,0x11,0x09,  /* 000007D0    "..PRR0.." */
  89.269 +    0x0A,0x06,0x23,0x02,0x00,0x18,0x79,0x00,  /* 000007D8    "..#...y." */
  89.270 +    0x8B,0x50,0x52,0x52,0x30,0x01,0x54,0x4D,  /* 000007E0    ".PRR0.TM" */
  89.271 +    0x50,0x5F,0x70,0x50,0x52,0x51,0x33,0x60,  /* 000007E8    "P_pPRQ3`" */
  89.272 +    0xA0,0x0C,0x95,0x60,0x0A,0x80,0x79,0x01,  /* 000007F0    "...`..y." */
  89.273 +    0x60,0x54,0x4D,0x50,0x5F,0xA1,0x07,0x70,  /* 000007F8    "`TMP_..p" */
  89.274 +    0x00,0x54,0x4D,0x50,0x5F,0xA4,0x50,0x52,  /* 00000800    ".TMP_.PR" */
  89.275 +    0x52,0x30,0x14,0x1B,0x5F,0x53,0x52,0x53,  /* 00000808    "R0.._SRS" */
  89.276 +    0x01,0x8B,0x68,0x01,0x54,0x4D,0x50,0x5F,  /* 00000810    "..h.TMP_" */
  89.277 +    0x82,0x54,0x4D,0x50,0x5F,0x60,0x76,0x60,  /* 00000818    ".TMP_`v`" */
  89.278 +    0x70,0x60,0x50,0x52,0x51,0x33,0x08,0x5F,  /* 00000820    "p`PRQ3._" */
  89.279 +    0x53,0x35,0x5F,0x12,0x06,0x04,0x00,0x00,  /* 00000828    "S5_....." */
  89.280 +    0x00,0x00,
  89.281 +};
    90.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.2 +++ b/tools/ioemu/hw/acpi.c	Wed Aug 09 08:34:06 2006 -0600
    90.3 @@ -0,0 +1,615 @@
    90.4 +/*
    90.5 + * ACPI implementation
    90.6 + * 
    90.7 + * Copyright (c) 2006 Fabrice Bellard
    90.8 + * 
    90.9 + * This library is free software; you can redistribute it and/or
   90.10 + * modify it under the terms of the GNU Lesser General Public
   90.11 + * License version 2 as published by the Free Software Foundation.
   90.12 + *
   90.13 + * This library is distributed in the hope that it will be useful,
   90.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   90.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   90.16 + * Lesser General Public License for more details.
   90.17 + *
   90.18 + * You should have received a copy of the GNU Lesser General Public
   90.19 + * License along with this library; if not, write to the Free Software
   90.20 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   90.21 + */
   90.22 +#include "vl.h"
   90.23 +
   90.24 +//#define DEBUG
   90.25 +
   90.26 +/* i82731AB (PIIX4) compatible power management function */
   90.27 +#define PM_FREQ 3579545
   90.28 +
   90.29 +/* XXX: make them variable */
   90.30 +#define PM_IO_BASE        0xb000
   90.31 +#define SMI_CMD_IO_ADDR   0xb040
   90.32 +#define ACPI_DBG_IO_ADDR  0xb044
   90.33 +
   90.34 +typedef struct PIIX4PMState {
   90.35 +    PCIDevice dev;
   90.36 +    uint16_t pmsts;
   90.37 +    uint16_t pmen;
   90.38 +    uint16_t pmcntrl;
   90.39 +    QEMUTimer *tmr_timer;
   90.40 +    int64_t tmr_overflow_time;
   90.41 +} PIIX4PMState;
   90.42 +
   90.43 +#define RTC_EN (1 << 10)
   90.44 +#define PWRBTN_EN (1 << 8)
   90.45 +#define GBL_EN (1 << 5)
   90.46 +#define TMROF_EN (1 << 0)
   90.47 +
   90.48 +#define SCI_EN (1 << 0)
   90.49 +
   90.50 +#define SUS_EN (1 << 13)
   90.51 +
   90.52 +/* Note: only used for ACPI bios init. Could be deleted when ACPI init
   90.53 +   is integrated in Bochs BIOS */
   90.54 +static PIIX4PMState *piix4_pm_state;
   90.55 +
   90.56 +static uint32_t get_pmtmr(PIIX4PMState *s)
   90.57 +{
   90.58 +    uint32_t d;
   90.59 +    d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
   90.60 +    return d & 0xffffff;
   90.61 +}
   90.62 +
   90.63 +static int get_pmsts(PIIX4PMState *s)
   90.64 +{
   90.65 +    int64_t d;
   90.66 +    int pmsts;
   90.67 +    pmsts = s->pmsts;
   90.68 +    d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
   90.69 +    if (d >= s->tmr_overflow_time)
   90.70 +        s->pmsts |= TMROF_EN;
   90.71 +    return pmsts;
   90.72 +}
   90.73 +
   90.74 +static void pm_update_sci(PIIX4PMState *s)
   90.75 +{
   90.76 +    int sci_level, pmsts;
   90.77 +    int64_t expire_time;
   90.78 +    
   90.79 +    pmsts = get_pmsts(s);
   90.80 +    sci_level = (((pmsts & s->pmen) & 
   90.81 +                  (RTC_EN | PWRBTN_EN | GBL_EN | TMROF_EN)) != 0);
   90.82 +    pci_set_irq(&s->dev, 0, sci_level);
   90.83 +    /* schedule a timer interruption if needed */
   90.84 +    if ((s->pmen & TMROF_EN) && !(pmsts & TMROF_EN)) {
   90.85 +        expire_time = muldiv64(s->tmr_overflow_time, ticks_per_sec, PM_FREQ);
   90.86 +        qemu_mod_timer(s->tmr_timer, expire_time);
   90.87 +    } else {
   90.88 +        qemu_del_timer(s->tmr_timer);
   90.89 +    }
   90.90 +}
   90.91 +
   90.92 +static void pm_tmr_timer(void *opaque)
   90.93 +{
   90.94 +    PIIX4PMState *s = opaque;
   90.95 +    pm_update_sci(s);
   90.96 +}
   90.97 +
   90.98 +static void pm_ioport_writew(void *opaque, uint32_t addr, uint32_t val)
   90.99 +{
  90.100 +    PIIX4PMState *s = opaque;
  90.101 +    addr &= 0x3f;
  90.102 +    switch(addr) {
  90.103 +    case 0x00:
  90.104 +        {
  90.105 +            int64_t d;
  90.106 +            int pmsts;
  90.107 +            pmsts = get_pmsts(s);
  90.108 +            if (pmsts & val & TMROF_EN) {
  90.109 +                /* if TMRSTS is reset, then compute the new overflow time */
  90.110 +                d = muldiv64(qemu_get_clock(vm_clock), PM_FREQ, ticks_per_sec);
  90.111 +                s->tmr_overflow_time = (d + 0x800000LL) & ~0x7fffffLL;
  90.112 +            }
  90.113 +            s->pmsts &= ~val;
  90.114 +            pm_update_sci(s);
  90.115 +        }
  90.116 +        break;
  90.117 +    case 0x02:
  90.118 +        s->pmen = val;
  90.119 +        pm_update_sci(s);
  90.120 +        break;
  90.121 +    case 0x04:
  90.122 +        {
  90.123 +            int sus_typ;
  90.124 +            s->pmcntrl = val & ~(SUS_EN);
  90.125 +            if (val & SUS_EN) {
  90.126 +                /* change suspend type */
  90.127 +                sus_typ = (val >> 10) & 3;
  90.128 +                switch(sus_typ) {
  90.129 +                case 0: /* soft power off */
  90.130 +                    qemu_system_shutdown_request();
  90.131 +                    break;
  90.132 +                default:
  90.133 +                    break;
  90.134 +                }
  90.135 +            }
  90.136 +        }
  90.137 +        break;
  90.138 +    default:
  90.139 +        break;
  90.140 +    }
  90.141 +#ifdef DEBUG
  90.142 +    printf("PM writew port=0x%04x val=0x%04x\n", addr, val);
  90.143 +#endif
  90.144 +}
  90.145 +
  90.146 +static uint32_t pm_ioport_readw(void *opaque, uint32_t addr)
  90.147 +{
  90.148 +    PIIX4PMState *s = opaque;
  90.149 +    uint32_t val;
  90.150 +
  90.151 +    addr &= 0x3f;
  90.152 +    switch(addr) {
  90.153 +    case 0x00:
  90.154 +        val = get_pmsts(s);
  90.155 +        break;
  90.156 +    case 0x02:
  90.157 +        val = s->pmen;
  90.158 +        break;
  90.159 +    case 0x04:
  90.160 +        val = s->pmcntrl;
  90.161 +        break;
  90.162 +    default:
  90.163 +        val = 0;
  90.164 +        break;
  90.165 +    }
  90.166 +#ifdef DEBUG
  90.167 +    printf("PM readw port=0x%04x val=0x%04x\n", addr, val);
  90.168 +#endif
  90.169 +    return val;
  90.170 +}
  90.171 +
  90.172 +static void pm_ioport_writel(void *opaque, uint32_t addr, uint32_t val)
  90.173 +{
  90.174 +    //    PIIX4PMState *s = opaque;
  90.175 +    addr &= 0x3f;
  90.176 +#ifdef DEBUG
  90.177 +    printf("PM writel port=0x%04x val=0x%08x\n", addr, val);
  90.178 +#endif
  90.179 +}
  90.180 +
  90.181 +static uint32_t pm_ioport_readl(void *opaque, uint32_t addr)
  90.182 +{
  90.183 +    PIIX4PMState *s = opaque;
  90.184 +    uint32_t val;
  90.185 +
  90.186 +    addr &= 0x3f;
  90.187 +    switch(addr) {
  90.188 +    case 0x08:
  90.189 +        val = get_pmtmr(s);
  90.190 +        break;
  90.191 +    default:
  90.192 +        val = 0;
  90.193 +        break;
  90.194 +    }
  90.195 +#ifdef DEBUG
  90.196 +    printf("PM readl port=0x%04x val=0x%08x\n", addr, val);
  90.197 +#endif
  90.198 +    return val;
  90.199 +}
  90.200 +
  90.201 +static void smi_cmd_writeb(void *opaque, uint32_t addr, uint32_t val)
  90.202 +{
  90.203 +    PIIX4PMState *s = opaque;
  90.204 +#ifdef DEBUG
  90.205 +    printf("SMI cmd val=0x%02x\n", val);
  90.206 +#endif
  90.207 +    switch(val) {
  90.208 +    case 0xf0: /* ACPI disable */
  90.209 +        s->pmcntrl &= ~SCI_EN;
  90.210 +        break;
  90.211 +    case 0xf1: /* ACPI enable */
  90.212 +        s->pmcntrl |= SCI_EN;
  90.213 +        break;
  90.214 +    }
  90.215 +}
  90.216 +
  90.217 +static void acpi_dbg_writel(void *opaque, uint32_t addr, uint32_t val)
  90.218 +{
  90.219 +#if defined(DEBUG)
  90.220 +    printf("ACPI: DBG: 0x%08x\n", val);
  90.221 +#endif
  90.222 +}
  90.223 +
  90.224 +/* XXX: we still add it to the PIIX3 and we count on the fact that
  90.225 +   OSes are smart enough to accept this strange configuration */
  90.226 +void piix4_pm_init(PCIBus *bus, int devfn)
  90.227 +{
  90.228 +    PIIX4PMState *s;
  90.229 +    uint8_t *pci_conf;
  90.230 +    uint32_t pm_io_base;
  90.231 +
  90.232 +    s = (PIIX4PMState *)pci_register_device(bus,
  90.233 +                                         "PM", sizeof(PIIX4PMState),
  90.234 +                                         devfn, NULL, NULL);
  90.235 +    pci_conf = s->dev.config;
  90.236 +    pci_conf[0x00] = 0x86;
  90.237 +    pci_conf[0x01] = 0x80;
  90.238 +    pci_conf[0x02] = 0x13;
  90.239 +    pci_conf[0x03] = 0x71;
  90.240 +    pci_conf[0x08] = 0x00; // revision number
  90.241 +    pci_conf[0x09] = 0x00;
  90.242 +    pci_conf[0x0a] = 0x80; // other bridge device
  90.243 +    pci_conf[0x0b] = 0x06; // bridge device
  90.244 +    pci_conf[0x0e] = 0x00; // header_type
  90.245 +    pci_conf[0x3d] = 0x01; // interrupt pin 1
  90.246 +    
  90.247 +    pm_io_base = PM_IO_BASE;
  90.248 +    pci_conf[0x40] = pm_io_base | 1;
  90.249 +    pci_conf[0x41] = pm_io_base >> 8;
  90.250 +    register_ioport_write(pm_io_base, 64, 2, pm_ioport_writew, s);
  90.251 +    register_ioport_read(pm_io_base, 64, 2, pm_ioport_readw, s);
  90.252 +    register_ioport_write(pm_io_base, 64, 4, pm_ioport_writel, s);
  90.253 +    register_ioport_read(pm_io_base, 64, 4, pm_ioport_readl, s);
  90.254 +    
  90.255 +    register_ioport_write(SMI_CMD_IO_ADDR, 1, 1, smi_cmd_writeb, s);
  90.256 +    register_ioport_write(ACPI_DBG_IO_ADDR, 4, 4, acpi_dbg_writel, s);
  90.257 +
  90.258 +    /* XXX: which specification is used ? The i82731AB has different
  90.259 +       mappings */
  90.260 +    pci_conf[0x5f] = (parallel_hds[0] != NULL ? 0x80 : 0) | 0x10;
  90.261 +    pci_conf[0x63] = 0x60;
  90.262 +    pci_conf[0x67] = (serial_hds[0] != NULL ? 0x08 : 0) |
  90.263 +	(serial_hds[1] != NULL ? 0x90 : 0);
  90.264 +
  90.265 +    s->tmr_timer = qemu_new_timer(vm_clock, pm_tmr_timer, s);
  90.266 +    piix4_pm_state = s;
  90.267 +}
  90.268 +
  90.269 +/* ACPI tables */
  90.270 +/* XXX: move them in the Bochs BIOS ? */
  90.271 +
  90.272 +/*************************************************/
  90.273 +
  90.274 +/* Table structure from Linux kernel (the ACPI tables are under the
  90.275 +   BSD license) */
  90.276 +
  90.277 +#define ACPI_TABLE_HEADER_DEF   /* ACPI common table header */ \
  90.278 +	uint8_t                            signature [4];          /* ACPI signature (4 ASCII characters) */\
  90.279 +	uint32_t                             length;                 /* Length of table, in bytes, including header */\
  90.280 +	uint8_t                              revision;               /* ACPI Specification minor version # */\
  90.281 +	uint8_t                              checksum;               /* To make sum of entire table == 0 */\
  90.282 +	uint8_t                            oem_id [6];             /* OEM identification */\
  90.283 +	uint8_t                            oem_table_id [8];       /* OEM table identification */\
  90.284 +	uint32_t                             oem_revision;           /* OEM revision number */\
  90.285 +	uint8_t                            asl_compiler_id [4];    /* ASL compiler vendor ID */\
  90.286 +	uint32_t                             asl_compiler_revision;  /* ASL compiler revision number */
  90.287 +
  90.288 +
  90.289 +struct acpi_table_header         /* ACPI common table header */
  90.290 +{
  90.291 +	ACPI_TABLE_HEADER_DEF
  90.292 +};
  90.293 +
  90.294 +struct rsdp_descriptor         /* Root System Descriptor Pointer */
  90.295 +{
  90.296 +	uint8_t                            signature [8];          /* ACPI signature, contains "RSD PTR " */
  90.297 +	uint8_t                              checksum;               /* To make sum of struct == 0 */
  90.298 +	uint8_t                            oem_id [6];             /* OEM identification */
  90.299 +	uint8_t                              revision;               /* Must be 0 for 1.0, 2 for 2.0 */
  90.300 +	uint32_t                             rsdt_physical_address;  /* 32-bit physical address of RSDT */
  90.301 +	uint32_t                             length;                 /* XSDT Length in bytes including hdr */
  90.302 +	uint64_t                             xsdt_physical_address;  /* 64-bit physical address of XSDT */
  90.303 +	uint8_t                              extended_checksum;      /* Checksum of entire table */
  90.304 +	uint8_t                            reserved [3];           /* Reserved field must be 0 */
  90.305 +};
  90.306 +
  90.307 +/*
  90.308 + * ACPI 1.0 Root System Description Table (RSDT)
  90.309 + */
  90.310 +struct rsdt_descriptor_rev1
  90.311 +{
  90.312 +	ACPI_TABLE_HEADER_DEF                           /* ACPI common table header */
  90.313 +	uint32_t                             table_offset_entry [2]; /* Array of pointers to other */
  90.314 +			 /* ACPI tables */
  90.315 +};
  90.316 +
  90.317 +/*
  90.318 + * ACPI 1.0 Firmware ACPI Control Structure (FACS)
  90.319 + */
  90.320 +struct facs_descriptor_rev1
  90.321 +{
  90.322 +	uint8_t                            signature[4];           /* ACPI Signature */
  90.323 +	uint32_t                             length;                 /* Length of structure, in bytes */
  90.324 +	uint32_t                             hardware_signature;     /* Hardware configuration signature */
  90.325 +	uint32_t                             firmware_waking_vector; /* ACPI OS waking vector */
  90.326 +	uint32_t                             global_lock;            /* Global Lock */
  90.327 +	uint32_t                             S4bios_f        : 1;    /* Indicates if S4BIOS support is present */
  90.328 +	uint32_t                             reserved1       : 31;   /* Must be 0 */
  90.329 +	uint8_t                              resverved3 [40];        /* Reserved - must be zero */
  90.330 +};
  90.331 +
  90.332 +
  90.333 +/*
  90.334 + * ACPI 1.0 Fixed ACPI Description Table (FADT)
  90.335 + */
  90.336 +struct fadt_descriptor_rev1
  90.337 +{
  90.338 +	ACPI_TABLE_HEADER_DEF                           /* ACPI common table header */
  90.339 +	uint32_t                             firmware_ctrl;          /* Physical address of FACS */
  90.340 +	uint32_t                             dsdt;                   /* Physical address of DSDT */
  90.341 +	uint8_t                              model;                  /* System Interrupt Model */
  90.342 +	uint8_t                              reserved1;              /* Reserved */
  90.343 +	uint16_t                             sci_int;                /* System vector of SCI interrupt */
  90.344 +	uint32_t                             smi_cmd;                /* Port address of SMI command port */
  90.345 +	uint8_t                              acpi_enable;            /* Value to write to smi_cmd to enable ACPI */
  90.346 +	uint8_t                              acpi_disable;           /* Value to write to smi_cmd to disable ACPI */
  90.347 +	uint8_t                              S4bios_req;             /* Value to write to SMI CMD to enter S4BIOS state */
  90.348 +	uint8_t                              reserved2;              /* Reserved - must be zero */
  90.349 +	uint32_t                             pm1a_evt_blk;           /* Port address of Power Mgt 1a acpi_event Reg Blk */
  90.350 +	uint32_t                             pm1b_evt_blk;           /* Port address of Power Mgt 1b acpi_event Reg Blk */
  90.351 +	uint32_t                             pm1a_cnt_blk;           /* Port address of Power Mgt 1a Control Reg Blk */
  90.352 +	uint32_t                             pm1b_cnt_blk;           /* Port address of Power Mgt 1b Control Reg Blk */
  90.353 +	uint32_t                             pm2_cnt_blk;            /* Port address of Power Mgt 2 Control Reg Blk */
  90.354 +	uint32_t                             pm_tmr_blk;             /* Port address of Power Mgt Timer Ctrl Reg Blk */
  90.355 +	uint32_t                             gpe0_blk;               /* Port addr of General Purpose acpi_event 0 Reg Blk */
  90.356 +	uint32_t                             gpe1_blk;               /* Port addr of General Purpose acpi_event 1 Reg Blk */
  90.357 +	uint8_t                              pm1_evt_len;            /* Byte length of ports at pm1_x_evt_blk */
  90.358 +	uint8_t                              pm1_cnt_len;            /* Byte length of ports at pm1_x_cnt_blk */
  90.359 +	uint8_t                              pm2_cnt_len;            /* Byte Length of ports at pm2_cnt_blk */
  90.360 +	uint8_t                              pm_tmr_len;              /* Byte Length of ports at pm_tm_blk */
  90.361 +	uint8_t                              gpe0_blk_len;           /* Byte Length of ports at gpe0_blk */
  90.362 +	uint8_t                              gpe1_blk_len;           /* Byte Length of ports at gpe1_blk */
  90.363 +	uint8_t                              gpe1_base;              /* Offset in gpe model where gpe1 events start */
  90.364 +	uint8_t                              reserved3;              /* Reserved */
  90.365 +	uint16_t                             plvl2_lat;              /* Worst case HW latency to enter/exit C2 state */
  90.366 +	uint16_t                             plvl3_lat;              /* Worst case HW latency to enter/exit C3 state */
  90.367 +	uint16_t                             flush_size;             /* Size of area read to flush caches */
  90.368 +	uint16_t                             flush_stride;           /* Stride used in flushing caches */
  90.369 +	uint8_t                              duty_offset;            /* Bit location of duty cycle field in p_cnt reg */
  90.370 +	uint8_t                              duty_width;             /* Bit width of duty cycle field in p_cnt reg */
  90.371 +	uint8_t                              day_alrm;               /* Index to day-of-month alarm in RTC CMOS RAM */
  90.372 +	uint8_t                              mon_alrm;               /* Index to month-of-year alarm in RTC CMOS RAM */
  90.373 +	uint8_t                              century;                /* Index to century in RTC CMOS RAM */
  90.374 +	uint8_t                              reserved4;              /* Reserved */
  90.375 +	uint8_t                              reserved4a;             /* Reserved */
  90.376 +	uint8_t                              reserved4b;             /* Reserved */
  90.377 +#if 0
  90.378 +	uint32_t                             wb_invd         : 1;    /* The wbinvd instruction works properly */
  90.379 +	uint32_t                             wb_invd_flush   : 1;    /* The wbinvd flushes but does not invalidate */
  90.380 +	uint32_t                             proc_c1         : 1;    /* All processors support C1 state */
  90.381 +	uint32_t                             plvl2_up        : 1;    /* C2 state works on MP system */
  90.382 +	uint32_t                             pwr_button      : 1;    /* Power button is handled as a generic feature */
  90.383 +	uint32_t                             sleep_button    : 1;    /* Sleep button is handled as a generic feature, or not present */
  90.384 +	uint32_t                             fixed_rTC       : 1;    /* RTC wakeup stat not in fixed register space */
  90.385 +	uint32_t                             rtcs4           : 1;    /* RTC wakeup stat not possible from S4 */
  90.386 +	uint32_t                             tmr_val_ext     : 1;    /* The tmr_val width is 32 bits (0 = 24 bits) */
  90.387 +	uint32_t                             reserved5       : 23;   /* Reserved - must be zero */
  90.388 +#else
  90.389 +        uint32_t flags;
  90.390 +#endif
  90.391 +};
  90.392 +
  90.393 +/*
  90.394 + * MADT values and structures
  90.395 + */
  90.396 +
  90.397 +/* Values for MADT PCATCompat */
  90.398 +
  90.399 +#define DUAL_PIC                0
  90.400 +#define MULTIPLE_APIC           1
  90.401 +
  90.402 +
  90.403 +/* Master MADT */
  90.404 +
  90.405 +struct multiple_apic_table
  90.406 +{
  90.407 +	ACPI_TABLE_HEADER_DEF                           /* ACPI common table header */
  90.408 +	uint32_t                             local_apic_address;     /* Physical address of local APIC */
  90.409 +#if 0
  90.410 +	uint32_t                             PCATcompat      : 1;    /* A one indicates system also has dual 8259s */
  90.411 +	uint32_t                             reserved1       : 31;
  90.412 +#else
  90.413 +        uint32_t                             flags;
  90.414 +#endif
  90.415 +};
  90.416 +
  90.417 +
  90.418 +/* Values for Type in APIC_HEADER_DEF */
  90.419 +
  90.420 +#define APIC_PROCESSOR          0
  90.421 +#define APIC_IO                 1
  90.422 +#define APIC_XRUPT_OVERRIDE     2
  90.423 +#define APIC_NMI                3
  90.424 +#define APIC_LOCAL_NMI          4
  90.425 +#define APIC_ADDRESS_OVERRIDE   5
  90.426 +#define APIC_IO_SAPIC           6
  90.427 +#define APIC_LOCAL_SAPIC        7
  90.428 +#define APIC_XRUPT_SOURCE       8
  90.429 +#define APIC_RESERVED           9           /* 9 and greater are reserved */
  90.430 +
  90.431 +/*
  90.432 + * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
  90.433 + */
  90.434 +#define APIC_HEADER_DEF                     /* Common APIC sub-structure header */\
  90.435 +	uint8_t                              type; \
  90.436 +	uint8_t                              length;
  90.437 +
  90.438 +/* Sub-structures for MADT */
  90.439 +
  90.440 +struct madt_processor_apic
  90.441 +{
  90.442 +	APIC_HEADER_DEF
  90.443 +	uint8_t                              processor_id;           /* ACPI processor id */
  90.444 +	uint8_t                              local_apic_id;          /* Processor's local APIC id */
  90.445 +#if 0
  90.446 +	uint32_t                             processor_enabled: 1;   /* Processor is usable if set */
  90.447 +	uint32_t                             reserved2       : 31;   /* Reserved, must be zero */
  90.448 +#else
  90.449 +        uint32_t flags;
  90.450 +#endif
  90.451 +};
  90.452 +
  90.453 +struct madt_io_apic
  90.454 +{
  90.455 +	APIC_HEADER_DEF
  90.456 +	uint8_t                              io_apic_id;             /* I/O APIC ID */
  90.457 +	uint8_t                              reserved;               /* Reserved - must be zero */
  90.458 +	uint32_t                             address;                /* APIC physical address */
  90.459 +	uint32_t                             interrupt;              /* Global system interrupt where INTI
  90.460 +			  * lines start */
  90.461 +};
  90.462 +
  90.463 +#include "acpi-dsdt.hex"
  90.464 +
  90.465 +static int acpi_checksum(const uint8_t *data, int len)
  90.466 +{
  90.467 +    int sum, i;
  90.468 +    sum = 0;
  90.469 +    for(i = 0; i < len; i++)
  90.470 +        sum += data[i];
  90.471 +    return (-sum) & 0xff;
  90.472 +}
  90.473 +
  90.474 +static void acpi_build_table_header(struct acpi_table_header *h, 
  90.475 +                                    char *sig, int len)
  90.476 +{
  90.477 +    memcpy(h->signature, sig, 4);
  90.478 +    h->length = cpu_to_le32(len);
  90.479 +    h->revision = 0;
  90.480 +    memcpy(h->oem_id, "QEMU  ", 6);
  90.481 +    memcpy(h->oem_table_id, "QEMU", 4);
  90.482 +    memcpy(h->oem_table_id + 4, sig, 4);
  90.483 +    h->oem_revision = cpu_to_le32(1);
  90.484 +    memcpy(h->asl_compiler_id, "QEMU", 4);
  90.485 +    h->asl_compiler_revision = cpu_to_le32(1);
  90.486 +    h->checksum = acpi_checksum((void *)h, len);
  90.487 +}
  90.488 +
  90.489 +#define ACPI_TABLES_BASE 0x000e8000
  90.490 +
  90.491 +/* base_addr must be a multiple of 4KB */
  90.492 +void acpi_bios_init(void)
  90.493 +{
  90.494 +    struct rsdp_descriptor *rsdp;
  90.495 +    struct rsdt_descriptor_rev1 *rsdt;
  90.496 +    struct fadt_descriptor_rev1 *fadt;
  90.497 +    struct facs_descriptor_rev1 *facs;
  90.498 +    struct multiple_apic_table *madt;
  90.499 +    uint8_t *dsdt;
  90.500 +    uint32_t base_addr, rsdt_addr, fadt_addr, addr, facs_addr, dsdt_addr;
  90.501 +    uint32_t pm_io_base, acpi_tables_size, madt_addr, madt_size;
  90.502 +    int i;
  90.503 +
  90.504 +    /* compute PCI I/O addresses */
  90.505 +    pm_io_base = (piix4_pm_state->dev.config[0x40] | 
  90.506 +        (piix4_pm_state->dev.config[0x41] << 8)) & ~0x3f;
  90.507 +    
  90.508 +    base_addr = ACPI_TABLES_BASE;
  90.509 +
  90.510 +    /* reserve memory space for tables */
  90.511 +    addr = base_addr;
  90.512 +    rsdp = (void *)(phys_ram_base + addr);
  90.513 +    addr += sizeof(*rsdp);
  90.514 +
  90.515 +    rsdt_addr = addr;
  90.516 +    rsdt = (void *)(phys_ram_base + addr);
  90.517 +    addr += sizeof(*rsdt);
  90.518 +    
  90.519 +    fadt_addr = addr;
  90.520 +    fadt = (void *)(phys_ram_base + addr);
  90.521 +    addr += sizeof(*fadt);
  90.522 +
  90.523 +    /* XXX: FACS should be in RAM */
  90.524 +    addr = (addr + 63) & ~63; /* 64 byte alignment for FACS */
  90.525 +    facs_addr = addr;
  90.526 +    facs = (void *)(phys_ram_base + addr);
  90.527 +    addr += sizeof(*facs);
  90.528 +
  90.529 +    dsdt_addr = addr;
  90.530 +    dsdt = (void *)(phys_ram_base + addr);
  90.531 +    addr += sizeof(AmlCode);
  90.532 +
  90.533 +    addr = (addr + 7) & ~7;
  90.534 +    madt_addr = addr;
  90.535 +    madt_size = sizeof(*madt) + 
  90.536 +        sizeof(struct madt_processor_apic) * smp_cpus +
  90.537 +        sizeof(struct madt_io_apic);
  90.538 +    madt = (void *)(phys_ram_base + addr);
  90.539 +    addr += madt_size;
  90.540 +
  90.541 +    acpi_tables_size = addr - base_addr;
  90.542 +
  90.543 +    cpu_register_physical_memory(base_addr, acpi_tables_size, 
  90.544 +                                 base_addr | IO_MEM_ROM);
  90.545 +    
  90.546 +    /* RSDP */
  90.547 +    memset(rsdp, 0, sizeof(*rsdp));
  90.548 +    memcpy(rsdp->signature, "RSD PTR ", 8);
  90.549 +    memcpy(rsdp->oem_id, "QEMU  ", 6);
  90.550 +    rsdp->rsdt_physical_address = cpu_to_le32(rsdt_addr);
  90.551 +    rsdp->checksum = acpi_checksum((void *)rsdp, 20);
  90.552 +    
  90.553 +    /* RSDT */
  90.554 +    rsdt->table_offset_entry[0] = cpu_to_le32(fadt_addr);
  90.555 +    rsdt->table_offset_entry[1] = cpu_to_le32(madt_addr);
  90.556 +    acpi_build_table_header((struct acpi_table_header *)rsdt, 
  90.557 +                            "RSDT", sizeof(*rsdt));
  90.558 +    
  90.559 +    /* FADT */
  90.560 +    memset(fadt, 0, sizeof(*fadt));
  90.561 +    fadt->firmware_ctrl = cpu_to_le32(facs_addr);
  90.562 +    fadt->dsdt = cpu_to_le32(dsdt_addr);
  90.563 +    fadt->model = 1;
  90.564 +    fadt->reserved1 = 0;
  90.565 +    fadt->sci_int = cpu_to_le16(piix4_pm_state->dev.config[0x3c]);
  90.566 +    fadt->smi_cmd = cpu_to_le32(SMI_CMD_IO_ADDR);
  90.567 +    fadt->acpi_enable = 0xf1;
  90.568 +    fadt->acpi_disable = 0xf0;
  90.569 +    fadt->pm1a_evt_blk = cpu_to_le32(pm_io_base);
  90.570 +    fadt->pm1a_cnt_blk = cpu_to_le32(pm_io_base + 0x04);
  90.571 +    fadt->pm_tmr_blk = cpu_to_le32(pm_io_base + 0x08);
  90.572 +    fadt->pm1_evt_len = 4;
  90.573 +    fadt->pm1_cnt_len = 2;
  90.574 +    fadt->pm_tmr_len = 4;
  90.575 +    fadt->plvl2_lat = cpu_to_le16(50);
  90.576 +    fadt->plvl3_lat = cpu_to_le16(50);
  90.577 +    fadt->plvl3_lat = cpu_to_le16(50);
  90.578 +    /* WBINVD + PROC_C1 + PWR_BUTTON + SLP_BUTTON + FIX_RTC */
  90.579 +    fadt->flags = cpu_to_le32((1 << 0) | (1 << 2) | (1 << 4) | (1 << 5) | (1 << 6));
  90.580 +    acpi_build_table_header((struct acpi_table_header *)fadt, "FACP", 
  90.581 +                            sizeof(*fadt));
  90.582 +
  90.583 +    /* FACS */
  90.584 +    memset(facs, 0, sizeof(*facs));
  90.585 +    memcpy(facs->signature, "FACS", 4);
  90.586 +    facs->length = cpu_to_le32(sizeof(*facs));
  90.587 +
  90.588 +    /* DSDT */
  90.589 +    memcpy(dsdt, AmlCode, sizeof(AmlCode));
  90.590 +
  90.591 +    /* MADT */
  90.592 +    {
  90.593 +        struct madt_processor_apic *apic;
  90.594 +        struct madt_io_apic *io_apic;
  90.595 +
  90.596 +        memset(madt, 0, madt_size);
  90.597 +        madt->local_apic_address = cpu_to_le32(0xfee00000);
  90.598 +        madt->flags = cpu_to_le32(1);
  90.599 +        apic = (void *)(madt + 1);
  90.600 +        for(i=0;i<smp_cpus;i++) {
  90.601 +            apic->type = APIC_PROCESSOR;
  90.602 +            apic->length = sizeof(*apic);
  90.603 +            apic->processor_id = i;
  90.604 +            apic->local_apic_id = i;
  90.605 +            apic->flags = cpu_to_le32(1);
  90.606 +            apic++;
  90.607 +        }
  90.608 +        io_apic = (void *)apic;
  90.609 +        io_apic->type = APIC_IO;
  90.610 +        io_apic->length = sizeof(*io_apic);
  90.611 +        io_apic->io_apic_id = smp_cpus;
  90.612 +        io_apic->address = cpu_to_le32(0xfec00000);
  90.613 +        io_apic->interrupt = cpu_to_le32(0);
  90.614 +
  90.615 +        acpi_build_table_header((struct acpi_table_header *)madt, 
  90.616 +                                "APIC", madt_size);
  90.617 +    }
  90.618 +}
    91.1 --- a/tools/ioemu/hw/adlib.c	Wed Aug 09 08:01:52 2006 -0600
    91.2 +++ b/tools/ioemu/hw/adlib.c	Wed Aug 09 08:34:06 2006 -0600
    91.3 @@ -301,6 +301,7 @@ int Adlib_init (AudioState *audio)
    91.4      as.freq = conf.freq;
    91.5      as.nchannels = SHIFT;
    91.6      as.fmt = AUD_FMT_S16;
    91.7 +    as.endianness = AUDIO_HOST_ENDIANNESS;
    91.8  
    91.9      AUD_register_card (audio, "adlib", &s->card);
   91.10  
   91.11 @@ -310,8 +311,7 @@ int Adlib_init (AudioState *audio)
   91.12          "adlib",
   91.13          s,
   91.14          adlib_callback,
   91.15 -        &as,
   91.16 -        0                       /* XXX: little endian? */
   91.17 +        &as
   91.18          );
   91.19      if (!s->voice) {
   91.20          Adlib_fini (s);
    92.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.2 +++ b/tools/ioemu/hw/apb_pci.c	Wed Aug 09 08:34:06 2006 -0600
    92.3 @@ -0,0 +1,232 @@
    92.4 +/*
    92.5 + * QEMU Ultrasparc APB PCI host
    92.6 + *
    92.7 + * Copyright (c) 2006 Fabrice Bellard
    92.8 + * 
    92.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   92.10 + * of this software and associated documentation files (the "Software"), to deal
   92.11 + * in the Software without restriction, including without limitation the rights
   92.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   92.13 + * copies of the Software, and to permit persons to whom the Software is
   92.14 + * furnished to do so, subject to the following conditions:
   92.15 + *
   92.16 + * The above copyright notice and this permission notice shall be included in
   92.17 + * all copies or substantial portions of the Software.
   92.18 + *
   92.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   92.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   92.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   92.22 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   92.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   92.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   92.25 + * THE SOFTWARE.
   92.26 + */
   92.27 +#include "vl.h"
   92.28 +typedef target_phys_addr_t pci_addr_t;
   92.29 +#include "pci_host.h"
   92.30 +
   92.31 +typedef PCIHostState APBState;
   92.32 +
   92.33 +static void pci_apb_config_writel (void *opaque, target_phys_addr_t addr,
   92.34 +                                         uint32_t val)
   92.35 +{
   92.36 +    APBState *s = opaque;
   92.37 +    int i;
   92.38 +
   92.39 +    for (i = 11; i < 32; i++) {
   92.40 +        if ((val & (1 << i)) != 0)
   92.41 +            break;
   92.42 +    }
   92.43 +    s->config_reg = (1 << 16) | (val & 0x7FC) | (i << 11);
   92.44 +}
   92.45 +
   92.46 +static uint32_t pci_apb_config_readl (void *opaque,
   92.47 +                                            target_phys_addr_t addr)
   92.48 +{
   92.49 +    APBState *s = opaque;
   92.50 +    uint32_t val;
   92.51 +    int devfn;
   92.52 +
   92.53 +    devfn = (s->config_reg >> 8) & 0xFF;
   92.54 +    val = (1 << (devfn >> 3)) | ((devfn & 0x07) << 8) | (s->config_reg & 0xFC);
   92.55 +    return val;
   92.56 +}
   92.57 +
   92.58 +static CPUWriteMemoryFunc *pci_apb_config_write[] = {
   92.59 +    &pci_apb_config_writel,
   92.60 +    &pci_apb_config_writel,
   92.61 +    &pci_apb_config_writel,
   92.62 +};
   92.63 +
   92.64 +static CPUReadMemoryFunc *pci_apb_config_read[] = {
   92.65 +    &pci_apb_config_readl,
   92.66 +    &pci_apb_config_readl,
   92.67 +    &pci_apb_config_readl,
   92.68 +};
   92.69 +
   92.70 +static void apb_config_writel (void *opaque, target_phys_addr_t addr,
   92.71 +			       uint32_t val)
   92.72 +{
   92.73 +    //PCIBus *s = opaque;
   92.74 +
   92.75 +    switch (addr & 0x3f) {
   92.76 +    case 0x00: // Control/Status
   92.77 +    case 0x10: // AFSR
   92.78 +    case 0x18: // AFAR
   92.79 +    case 0x20: // Diagnostic
   92.80 +    case 0x28: // Target address space
   92.81 +	// XXX
   92.82 +    default:
   92.83 +	break;
   92.84 +    }
   92.85 +}
   92.86 +
   92.87 +static uint32_t apb_config_readl (void *opaque,
   92.88 +				  target_phys_addr_t addr)
   92.89 +{
   92.90 +    //PCIBus *s = opaque;
   92.91 +    uint32_t val;
   92.92 +
   92.93 +    switch (addr & 0x3f) {
   92.94 +    case 0x00: // Control/Status
   92.95 +    case 0x10: // AFSR
   92.96 +    case 0x18: // AFAR
   92.97 +    case 0x20: // Diagnostic
   92.98 +    case 0x28: // Target address space
   92.99 +	// XXX
  92.100 +    default:
  92.101 +	val = 0;
  92.102 +	break;
  92.103 +    }
  92.104 +    return val;
  92.105 +}
  92.106 +
  92.107 +static CPUWriteMemoryFunc *apb_config_write[] = {
  92.108 +    &apb_config_writel,
  92.109 +    &apb_config_writel,
  92.110 +    &apb_config_writel,
  92.111 +};
  92.112 +
  92.113 +static CPUReadMemoryFunc *apb_config_read[] = {
  92.114 +    &apb_config_readl,
  92.115 +    &apb_config_readl,
  92.116 +    &apb_config_readl,
  92.117 +};
  92.118 +
  92.119 +static CPUWriteMemoryFunc *pci_apb_write[] = {
  92.120 +    &pci_host_data_writeb,
  92.121 +    &pci_host_data_writew,
  92.122 +    &pci_host_data_writel,
  92.123 +};
  92.124 +
  92.125 +static CPUReadMemoryFunc *pci_apb_read[] = {
  92.126 +    &pci_host_data_readb,
  92.127 +    &pci_host_data_readw,
  92.128 +    &pci_host_data_readl,
  92.129 +};
  92.130 +
  92.131 +static void pci_apb_iowriteb (void *opaque, target_phys_addr_t addr,
  92.132 +                                  uint32_t val)
  92.133 +{
  92.134 +    cpu_outb(NULL, addr & 0xffff, val);
  92.135 +}
  92.136 +
  92.137 +static void pci_apb_iowritew (void *opaque, target_phys_addr_t addr,
  92.138 +                                  uint32_t val)
  92.139 +{
  92.140 +    cpu_outw(NULL, addr & 0xffff, val);
  92.141 +}
  92.142 +
  92.143 +static void pci_apb_iowritel (void *opaque, target_phys_addr_t addr,
  92.144 +                                uint32_t val)
  92.145 +{
  92.146 +    cpu_outl(NULL, addr & 0xffff, val);
  92.147 +}
  92.148 +
  92.149 +static uint32_t pci_apb_ioreadb (void *opaque, target_phys_addr_t addr)
  92.150 +{
  92.151 +    uint32_t val;
  92.152 +
  92.153 +    val = cpu_inb(NULL, addr & 0xffff);
  92.154 +    return val;
  92.155 +}
  92.156 +
  92.157 +static uint32_t pci_apb_ioreadw (void *opaque, target_phys_addr_t addr)
  92.158 +{
  92.159 +    uint32_t val;
  92.160 +
  92.161 +    val = cpu_inw(NULL, addr & 0xffff);
  92.162 +    return val;
  92.163 +}
  92.164 +
  92.165 +static uint32_t pci_apb_ioreadl (void *opaque, target_phys_addr_t addr)
  92.166 +{
  92.167 +    uint32_t val;
  92.168 +
  92.169 +    val = cpu_inl(NULL, addr & 0xffff);
  92.170 +    return val;
  92.171 +}
  92.172 +
  92.173 +static CPUWriteMemoryFunc *pci_apb_iowrite[] = {
  92.174 +    &pci_apb_iowriteb,
  92.175 +    &pci_apb_iowritew,
  92.176 +    &pci_apb_iowritel,
  92.177 +};
  92.178 +
  92.179 +static CPUReadMemoryFunc *pci_apb_ioread[] = {
  92.180 +    &pci_apb_ioreadb,
  92.181 +    &pci_apb_ioreadw,
  92.182 +    &pci_apb_ioreadl,
  92.183 +};
  92.184 +
  92.185 +/* ??? This is probably wrong.  */
  92.186 +static void pci_apb_set_irq(PCIDevice *d, void *pic, int irq_num, int level)
  92.187 +{
  92.188 +    pic_set_irq_new(pic, d->config[PCI_INTERRUPT_LINE], level);
  92.189 +}
  92.190 +
  92.191 +PCIBus *pci_apb_init(target_ulong special_base, target_ulong mem_base,
  92.192 +                     void *pic)
  92.193 +{
  92.194 +    APBState *s;
  92.195 +    PCIDevice *d;
  92.196 +    int pci_mem_config, pci_mem_data, apb_config, pci_ioport;
  92.197 +
  92.198 +    s = qemu_mallocz(sizeof(APBState));
  92.199 +    /* Ultrasparc APB main bus */
  92.200 +    s->bus = pci_register_bus(pci_apb_set_irq, pic, 0);
  92.201 +
  92.202 +    pci_mem_config = cpu_register_io_memory(0, pci_apb_config_read,
  92.203 +                                            pci_apb_config_write, s);
  92.204 +    apb_config = cpu_register_io_memory(0, apb_config_read,
  92.205 +					apb_config_write, s);
  92.206 +    pci_mem_data = cpu_register_io_memory(0, pci_apb_read,
  92.207 +                                          pci_apb_write, s);
  92.208 +    pci_ioport = cpu_register_io_memory(0, pci_apb_ioread,
  92.209 +                                          pci_apb_iowrite, s);
  92.210 +
  92.211 +    cpu_register_physical_memory(special_base + 0x2000ULL, 0x40, apb_config);
  92.212 +    cpu_register_physical_memory(special_base + 0x1000000ULL, 0x10, pci_mem_config);
  92.213 +    cpu_register_physical_memory(special_base + 0x2000000ULL, 0x10000, pci_ioport);
  92.214 +    cpu_register_physical_memory(mem_base, 0x10000000, pci_mem_data); // XXX size should be 4G-prom
  92.215 +
  92.216 +    d = pci_register_device(s->bus, "Advanced PCI Bus", sizeof(PCIDevice), 
  92.217 +                            -1, NULL, NULL);
  92.218 +    d->config[0x00] = 0x8e; // vendor_id : Sun
  92.219 +    d->config[0x01] = 0x10;
  92.220 +    d->config[0x02] = 0x00; // device_id
  92.221 +    d->config[0x03] = 0xa0;
  92.222 +    d->config[0x04] = 0x06; // command = bus master, pci mem
  92.223 +    d->config[0x05] = 0x00;
  92.224 +    d->config[0x06] = 0xa0; // status = fast back-to-back, 66MHz, no error
  92.225 +    d->config[0x07] = 0x03; // status = medium devsel
  92.226 +    d->config[0x08] = 0x00; // revision
  92.227 +    d->config[0x09] = 0x00; // programming i/f
  92.228 +    d->config[0x0A] = 0x00; // class_sub = pci host
  92.229 +    d->config[0x0B] = 0x06; // class_base = PCI_bridge
  92.230 +    d->config[0x0D] = 0x10; // latency_timer
  92.231 +    d->config[0x0E] = 0x00; // header_type
  92.232 +    return s->bus;
  92.233 +}
  92.234 +
  92.235 +
    93.1 --- a/tools/ioemu/hw/apic.c	Wed Aug 09 08:01:52 2006 -0600
    93.2 +++ b/tools/ioemu/hw/apic.c	Wed Aug 09 08:34:06 2006 -0600
    93.3 @@ -239,7 +239,7 @@ void cpu_set_apic_base(CPUState *env, ui
    93.4  {
    93.5      APICState *s = env->apic_state;
    93.6  #ifdef DEBUG_APIC
    93.7 -    printf("cpu_set_apic_base: %016llx\n", val);
    93.8 +    printf("cpu_set_apic_base: %016" PRIx64 "\n", val);
    93.9  #endif
   93.10      s->apicbase = (val & 0xfffff000) | 
   93.11          (s->apicbase & (MSR_IA32_APICBASE_BSP | MSR_IA32_APICBASE_ENABLE));
   93.12 @@ -255,7 +255,7 @@ uint64_t cpu_get_apic_base(CPUState *env
   93.13  {
   93.14      APICState *s = env->apic_state;
   93.15  #ifdef DEBUG_APIC
   93.16 -    printf("cpu_get_apic_base: %016llx\n", (uint64_t)s->apicbase);
   93.17 +    printf("cpu_get_apic_base: %016" PRIx64 "\n", (uint64_t)s->apicbase);
   93.18  #endif
   93.19      return s->apicbase;
   93.20  }
    94.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.2 +++ b/tools/ioemu/hw/cdrom.c	Wed Aug 09 08:34:06 2006 -0600
    94.3 @@ -0,0 +1,156 @@
    94.4 +/*
    94.5 + * QEMU ATAPI CD-ROM Emulator
    94.6 + * 
    94.7 + * Copyright (c) 2006 Fabrice Bellard
    94.8 + * 
    94.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   94.10 + * of this software and associated documentation files (the "Software"), to deal
   94.11 + * in the Software without restriction, including without limitation the rights
   94.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   94.13 + * copies of the Software, and to permit persons to whom the Software is
   94.14 + * furnished to do so, subject to the following conditions:
   94.15 + *
   94.16 + * The above copyright notice and this permission notice shall be included in
   94.17 + * all copies or substantial portions of the Software.
   94.18 + *
   94.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   94.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   94.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   94.22 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   94.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   94.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   94.25 + * THE SOFTWARE.
   94.26 + */
   94.27 +
   94.28 +/* ??? Most of the ATAPI emulation is still in ide.c.  It should be moved
   94.29 +   here.  */
   94.30 +
   94.31 +#include <vl.h>
   94.32 +
   94.33 +static void lba_to_msf(uint8_t *buf, int lba)
   94.34 +{
   94.35 +    lba += 150;
   94.36 +    buf[0] = (lba / 75) / 60;
   94.37 +    buf[1] = (lba / 75) % 60;
   94.38 +    buf[2] = lba % 75;
   94.39 +}
   94.40 +
   94.41 +/* same toc as bochs. Return -1 if error or the toc length */
   94.42 +/* XXX: check this */
   94.43 +int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track)
   94.44 +{
   94.45 +    uint8_t *q;
   94.46 +    int len;
   94.47 +    
   94.48 +    if (start_track > 1 && start_track != 0xaa)
   94.49 +        return -1;
   94.50 +    q = buf + 2;
   94.51 +    *q++ = 1; /* first session */
   94.52 +    *q++ = 1; /* last session */
   94.53 +    if (start_track <= 1) {
   94.54 +        *q++ = 0; /* reserved */
   94.55 +        *q++ = 0x14; /* ADR, control */
   94.56 +        *q++ = 1;    /* track number */
   94.57 +        *q++ = 0; /* reserved */
   94.58 +        if (msf) {
   94.59 +            *q++ = 0; /* reserved */
   94.60 +            lba_to_msf(q, 0);
   94.61 +            q += 3;
   94.62 +        } else {
   94.63 +            /* sector 0 */
   94.64 +            cpu_to_be32wu((uint32_t *)q, 0);
   94.65 +            q += 4;
   94.66 +        }
   94.67 +    }
   94.68 +    /* lead out track */
   94.69 +    *q++ = 0; /* reserved */
   94.70 +    *q++ = 0x16; /* ADR, control */
   94.71 +    *q++ = 0xaa; /* track number */
   94.72 +    *q++ = 0; /* reserved */
   94.73 +    if (msf) {
   94.74 +        *q++ = 0; /* reserved */
   94.75 +        lba_to_msf(q, nb_sectors);
   94.76 +        q += 3;
   94.77 +    } else {
   94.78 +        cpu_to_be32wu((uint32_t *)q, nb_sectors);
   94.79 +        q += 4;
   94.80 +    }
   94.81 +    len = q - buf;
   94.82 +    cpu_to_be16wu((uint16_t *)buf, len - 2);
   94.83 +    return len;
   94.84 +}
   94.85 +
   94.86 +/* mostly same info as PearPc */
   94.87 +int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num)
   94.88 +{
   94.89 +    uint8_t *q;
   94.90 +    int len;
   94.91 +    
   94.92 +    q = buf + 2;
   94.93 +    *q++ = 1; /* first session */
   94.94 +    *q++ = 1; /* last session */
   94.95 +
   94.96 +    *q++ = 1; /* session number */
   94.97 +    *q++ = 0x14; /* data track */
   94.98 +    *q++ = 0; /* track number */
   94.99 +    *q++ = 0xa0; /* lead-in */
  94.100 +    *q++ = 0; /* min */
  94.101 +    *q++ = 0; /* sec */
  94.102 +    *q++ = 0; /* frame */
  94.103 +    *q++ = 0;
  94.104 +    *q++ = 1; /* first track */
  94.105 +    *q++ = 0x00; /* disk type */
  94.106 +    *q++ = 0x00;
  94.107 +    
  94.108 +    *q++ = 1; /* session number */
  94.109 +    *q++ = 0x14; /* data track */
  94.110 +    *q++ = 0; /* track number */
  94.111 +    *q++ = 0xa1;
  94.112 +    *q++ = 0; /* min */
  94.113 +    *q++ = 0; /* sec */
  94.114 +    *q++ = 0; /* frame */
  94.115 +    *q++ = 0;
  94.116 +    *q++ = 1; /* last track */
  94.117 +    *q++ = 0x00;
  94.118 +    *q++ = 0x00;
  94.119 +    
  94.120 +    *q++ = 1; /* session number */
  94.121 +    *q++ = 0x14; /* data track */
  94.122 +    *q++ = 0; /* track number */
  94.123 +    *q++ = 0xa2; /* lead-out */
  94.124 +    *q++ = 0; /* min */
  94.125 +    *q++ = 0; /* sec */
  94.126 +    *q++ = 0; /* frame */
  94.127 +    if (msf) {
  94.128 +        *q++ = 0; /* reserved */
  94.129 +        lba_to_msf(q, nb_sectors);
  94.130 +        q += 3;
  94.131 +    } else {
  94.132 +        cpu_to_be32wu((uint32_t *)q, nb_sectors);
  94.133 +        q += 4;
  94.134 +    }
  94.135 +
  94.136 +    *q++ = 1; /* session number */
  94.137 +    *q++ = 0x14; /* ADR, control */
  94.138 +    *q++ = 0;    /* track number */
  94.139 +    *q++ = 1;    /* point */
  94.140 +    *q++ = 0; /* min */
  94.141 +    *q++ = 0; /* sec */
  94.142 +    *q++ = 0; /* frame */
  94.143 +    if (msf) {
  94.144 +        *q++ = 0; 
  94.145 +        lba_to_msf(q, 0);
  94.146 +        q += 3;
  94.147 +    } else {
  94.148 +        *q++ = 0; 
  94.149 +        *q++ = 0; 
  94.150 +        *q++ = 0; 
  94.151 +        *q++ = 0; 
  94.152 +    }
  94.153 +
  94.154 +    len = q - buf;
  94.155 +    cpu_to_be16wu((uint16_t *)buf, len - 2);
  94.156 +    return len;
  94.157 +}
  94.158 +
  94.159 +
    95.1 --- a/tools/ioemu/hw/cuda.c	Wed Aug 09 08:01:52 2006 -0600
    95.2 +++ b/tools/ioemu/hw/cuda.c	Wed Aug 09 08:34:06 2006 -0600
    95.3 @@ -209,7 +209,7 @@ static int64_t get_next_irq_time(CUDATim
    95.4      }
    95.5  #if 0
    95.6  #ifdef DEBUG_CUDA
    95.7 -    printf("latch=%d counter=%lld delta_next=%lld\n", 
    95.8 +    printf("latch=%d counter=%" PRId64 " delta_next=%" PRId64 "\n", 
    95.9             s->latch, d, next_time - d);
   95.10  #endif
   95.11  #endif
    96.1 --- a/tools/ioemu/hw/es1370.c	Wed Aug 09 08:01:52 2006 -0600
    96.2 +++ b/tools/ioemu/hw/es1370.c	Wed Aug 09 08:34:06 2006 -0600
    96.3 @@ -423,6 +423,7 @@ static void es1370_update_voices (ES1370
    96.4                  as.freq = new_freq;
    96.5                  as.nchannels = 1 << (new_fmt & 1);
    96.6                  as.fmt = (new_fmt & 2) ? AUD_FMT_S16 : AUD_FMT_U8;
    96.7 +                as.endianness = 0;
    96.8  
    96.9                  if (i == ADC_CHANNEL) {
   96.10                      s->adc_voice =
   96.11 @@ -432,8 +433,7 @@ static void es1370_update_voices (ES1370
   96.12                              "es1370.adc",
   96.13                              s,
   96.14                              es1370_adc_callback,
   96.15 -                            &as,
   96.16 -                            0   /* little endian */
   96.17 +                            &as
   96.18                              );
   96.19                  }
   96.20                  else {
   96.21 @@ -444,8 +444,7 @@ static void es1370_update_voices (ES1370
   96.22                              i ? "es1370.dac2" : "es1370.dac1",
   96.23                              s,
   96.24                              i ? es1370_dac2_callback : es1370_dac1_callback,
   96.25 -                            &as,
   96.26 -                            0   /* litle endian */
   96.27 +                            &as
   96.28                              );
   96.29                  }
   96.30              }
   96.31 @@ -479,8 +478,9 @@ static inline uint32_t es1370_fixup (ES1
   96.32  IO_WRITE_PROTO (es1370_writeb)
   96.33  {
   96.34      ES1370State *s = opaque;
   96.35 +    uint32_t shift, mask;
   96.36 +
   96.37      addr = es1370_fixup (s, addr);
   96.38 -    uint32_t shift, mask;
   96.39  
   96.40      switch (addr) {
   96.41      case ES1370_REG_CONTROL:
    97.1 --- a/tools/ioemu/hw/esp.c	Wed Aug 09 08:01:52 2006 -0600
    97.2 +++ b/tools/ioemu/hw/esp.c	Wed Aug 09 08:34:06 2006 -0600
    97.3 @@ -38,17 +38,14 @@ do { printf("ESP: set_irq(%d): %d\n", (i
    97.4  #define ESPDMA_REGS 4
    97.5  #define ESPDMA_MAXADDR (ESPDMA_REGS * 4 - 1)
    97.6  #define ESP_MAXREG 0x3f
    97.7 -#define TI_BUFSZ 1024*1024 // XXX
    97.8 +#define TI_BUFSZ 32
    97.9  #define DMA_VER 0xa0000000
   97.10  #define DMA_INTR 1
   97.11  #define DMA_INTREN 0x10
   97.12 +#define DMA_WRITE_MEM 0x100
   97.13  #define DMA_LOADED 0x04000000
   97.14  typedef struct ESPState ESPState;
   97.15  
   97.16 -typedef int ESPDMAFunc(ESPState *s, 
   97.17 -                       target_phys_addr_t phys_addr, 
   97.18 -                       int transfer_size1);
   97.19 -
   97.20  struct ESPState {
   97.21      BlockDriverState **bd;
   97.22      uint8_t rregs[ESP_MAXREG];
   97.23 @@ -57,12 +54,14 @@ struct ESPState {
   97.24      uint32_t espdmaregs[ESPDMA_REGS];
   97.25      uint32_t ti_size;
   97.26      uint32_t ti_rptr, ti_wptr;
   97.27 -    int ti_dir;
   97.28      uint8_t ti_buf[TI_BUFSZ];
   97.29 +    int sense;
   97.30      int dma;
   97.31 -    ESPDMAFunc *dma_cb;
   97.32 -    int64_t offset, len;
   97.33 -    int target;
   97.34 +    SCSIDevice *scsi_dev[MAX_DISKS];
   97.35 +    SCSIDevice *current_dev;
   97.36 +    uint8_t cmdbuf[TI_BUFSZ];
   97.37 +    int cmdlen;
   97.38 +    int do_cmd;
   97.39  };
   97.40  
   97.41  #define STAT_DO 0x00
   97.42 @@ -83,394 +82,200 @@ struct ESPState {
   97.43  #define SEQ_0 0x0
   97.44  #define SEQ_CD 0x4
   97.45  
   97.46 -/* XXX: stolen from ide.c, move to common ATAPI/SCSI library */
   97.47 -static void lba_to_msf(uint8_t *buf, int lba)
   97.48 -{
   97.49 -    lba += 150;
   97.50 -    buf[0] = (lba / 75) / 60;
   97.51 -    buf[1] = (lba / 75) % 60;
   97.52 -    buf[2] = lba % 75;
   97.53 -}
   97.54 -
   97.55 -static inline void cpu_to_ube16(uint8_t *buf, int val)
   97.56 -{
   97.57 -    buf[0] = val >> 8;
   97.58 -    buf[1] = val;
   97.59 -}
   97.60 -
   97.61 -static inline void cpu_to_ube32(uint8_t *buf, unsigned int val)
   97.62 -{
   97.63 -    buf[0] = val >> 24;
   97.64 -    buf[1] = val >> 16;
   97.65 -    buf[2] = val >> 8;
   97.66 -    buf[3] = val;
   97.67 -}
   97.68 -
   97.69 -/* same toc as bochs. Return -1 if error or the toc length */
   97.70 -/* XXX: check this */
   97.71 -static int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track)
   97.72 -{
   97.73 -    uint8_t *q;
   97.74 -    int len;
   97.75 -    
   97.76 -    if (start_track > 1 && start_track != 0xaa)
   97.77 -        return -1;
   97.78 -    q = buf + 2;
   97.79 -    *q++ = 1; /* first session */
   97.80 -    *q++ = 1; /* last session */
   97.81 -    if (start_track <= 1) {
   97.82 -        *q++ = 0; /* reserved */
   97.83 -        *q++ = 0x14; /* ADR, control */
   97.84 -        *q++ = 1;    /* track number */
   97.85 -        *q++ = 0; /* reserved */
   97.86 -        if (msf) {
   97.87 -            *q++ = 0; /* reserved */
   97.88 -            lba_to_msf(q, 0);
   97.89 -            q += 3;
   97.90 -        } else {
   97.91 -            /* sector 0 */
   97.92 -            cpu_to_ube32(q, 0);
   97.93 -            q += 4;
   97.94 -        }
   97.95 -    }
   97.96 -    /* lead out track */
   97.97 -    *q++ = 0; /* reserved */
   97.98 -    *q++ = 0x16; /* ADR, control */
   97.99 -    *q++ = 0xaa; /* track number */
  97.100 -    *q++ = 0; /* reserved */
  97.101 -    if (msf) {
  97.102 -        *q++ = 0; /* reserved */
  97.103 -        lba_to_msf(q, nb_sectors);
  97.104 -        q += 3;
  97.105 -    } else {
  97.106 -        cpu_to_ube32(q, nb_sectors);
  97.107 -        q += 4;
  97.108 -    }
  97.109 -    len = q - buf;
  97.110 -    cpu_to_ube16(buf, len - 2);
  97.111 -    return len;
  97.112 -}
  97.113 -
  97.114 -/* mostly same info as PearPc */
  97.115 -static int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, 
  97.116 -                              int session_num)
  97.117 +static int get_cmd(ESPState *s, uint8_t *buf)
  97.118  {
  97.119 -    uint8_t *q;
  97.120 -    int len;
  97.121 -    
  97.122 -    q = buf + 2;
  97.123 -    *q++ = 1; /* first session */
  97.124 -    *q++ = 1; /* last session */
  97.125 -
  97.126 -    *q++ = 1; /* session number */
  97.127 -    *q++ = 0x14; /* data track */
  97.128 -    *q++ = 0; /* track number */
  97.129 -    *q++ = 0xa0; /* lead-in */
  97.130 -    *q++ = 0; /* min */
  97.131 -    *q++ = 0; /* sec */
  97.132 -    *q++ = 0; /* frame */
  97.133 -    *q++ = 0;
  97.134 -    *q++ = 1; /* first track */
  97.135 -    *q++ = 0x00; /* disk type */
  97.136 -    *q++ = 0x00;
  97.137 -    
  97.138 -    *q++ = 1; /* session number */
  97.139 -    *q++ = 0x14; /* data track */
  97.140 -    *q++ = 0; /* track number */
  97.141 -    *q++ = 0xa1;
  97.142 -    *q++ = 0; /* min */
  97.143 -    *q++ = 0; /* sec */
  97.144 -    *q++ = 0; /* frame */
  97.145 -    *q++ = 0;
  97.146 -    *q++ = 1; /* last track */
  97.147 -    *q++ = 0x00;
  97.148 -    *q++ = 0x00;
  97.149 -    
  97.150 -    *q++ = 1; /* session number */
  97.151 -    *q++ = 0x14; /* data track */
  97.152 -    *q++ = 0; /* track number */
  97.153 -    *q++ = 0xa2; /* lead-out */
  97.154 -    *q++ = 0; /* min */
  97.155 -    *q++ = 0; /* sec */
  97.156 -    *q++ = 0; /* frame */
  97.157 -    if (msf) {
  97.158 -        *q++ = 0; /* reserved */
  97.159 -        lba_to_msf(q, nb_sectors);
  97.160 -        q += 3;
  97.161 -    } else {
  97.162 -        cpu_to_ube32(q, nb_sectors);
  97.163 -        q += 4;
  97.164 -    }
  97.165 -
  97.166 -    *q++ = 1; /* session number */
  97.167 -    *q++ = 0x14; /* ADR, control */
  97.168 -    *q++ = 0;    /* track number */
  97.169 -    *q++ = 1;    /* point */
  97.170 -    *q++ = 0; /* min */
  97.171 -    *q++ = 0; /* sec */
  97.172 -    *q++ = 0; /* frame */
  97.173 -    if (msf) {
  97.174 -        *q++ = 0; 
  97.175 -        lba_to_msf(q, 0);
  97.176 -        q += 3;
  97.177 -    } else {
  97.178 -        *q++ = 0; 
  97.179 -        *q++ = 0; 
  97.180 -        *q++ = 0; 
  97.181 -        *q++ = 0; 
  97.182 -    }
  97.183 -
  97.184 -    len = q - buf;
  97.185 -    cpu_to_ube16(buf, len - 2);
  97.186 -    return len;
  97.187 -}
  97.188 -
  97.189 -static int esp_write_dma_cb(ESPState *s, 
  97.190 -                            target_phys_addr_t phys_addr, 
  97.191 -                            int transfer_size1)
  97.192 -{
  97.193 -    DPRINTF("Write callback (offset %lld len %lld size %d trans_size %d)\n",
  97.194 -            s->offset, s->len, s->ti_size, transfer_size1);
  97.195 -    bdrv_write(s->bd[s->target], s->offset, s->ti_buf, s->len);
  97.196 -    s->offset = 0;
  97.197 -    s->len = 0;
  97.198 -    s->target = 0;
  97.199 -    return 0;
  97.200 -}
  97.201 -
  97.202 -static void handle_satn(ESPState *s)
  97.203 -{
  97.204 -    uint8_t buf[32];
  97.205      uint32_t dmaptr, dmalen;
  97.206 -    unsigned int i;
  97.207 -    int64_t nb_sectors;
  97.208      int target;
  97.209  
  97.210      dmalen = s->wregs[0] | (s->wregs[1] << 8);
  97.211      target = s->wregs[4] & 7;
  97.212 -    DPRINTF("Select with ATN len %d target %d\n", dmalen, target);
  97.213 +    DPRINTF("get_cmd: len %d target %d\n", dmalen, target);
  97.214      if (s->dma) {
  97.215  	dmaptr = iommu_translate(s->espdmaregs[1]);
  97.216 -	DPRINTF("DMA Direction: %c, addr 0x%8.8x\n", s->espdmaregs[0] & 0x100? 'w': 'r', dmaptr);
  97.217 +	DPRINTF("DMA Direction: %c, addr 0x%8.8x\n",
  97.218 +                s->espdmaregs[0] & DMA_WRITE_MEM ? 'w': 'r', dmaptr);
  97.219  	cpu_physical_memory_read(dmaptr, buf, dmalen);
  97.220      } else {
  97.221  	buf[0] = 0;
  97.222  	memcpy(&buf[1], s->ti_buf, dmalen);
  97.223  	dmalen++;
  97.224      }
  97.225 -    for (i = 0; i < dmalen; i++) {
  97.226 -	DPRINTF("Command %2.2x\n", buf[i]);
  97.227 -    }
  97.228 -    s->ti_dir = 0;
  97.229 +
  97.230      s->ti_size = 0;
  97.231      s->ti_rptr = 0;
  97.232      s->ti_wptr = 0;
  97.233  
  97.234 -    if (target >= 4 || !s->bd[target]) { // No such drive
  97.235 +    if (target >= 4 || !s->scsi_dev[target]) {
  97.236 +        // No such drive
  97.237  	s->rregs[4] = STAT_IN;
  97.238  	s->rregs[5] = INTR_DC;
  97.239  	s->rregs[6] = SEQ_0;
  97.240  	s->espdmaregs[0] |= DMA_INTR;
  97.241  	pic_set_irq(s->irq, 1);
  97.242 -	return;
  97.243 +	return 0;
  97.244      }
  97.245 -    switch (buf[1]) {
  97.246 -    case 0x0:
  97.247 -	DPRINTF("Test Unit Ready (len %d)\n", buf[5]);
  97.248 -	break;
  97.249 -    case 0x12:
  97.250 -	DPRINTF("Inquiry (len %d)\n", buf[5]);
  97.251 -	memset(s->ti_buf, 0, 36);
  97.252 -	if (bdrv_get_type_hint(s->bd[target]) == BDRV_TYPE_CDROM) {
  97.253 -	    s->ti_buf[0] = 5;
  97.254 -	    memcpy(&s->ti_buf[16], "QEMU CDROM     ", 16);
  97.255 -	} else {
  97.256 -	    s->ti_buf[0] = 0;
  97.257 -	    memcpy(&s->ti_buf[16], "QEMU HARDDISK  ", 16);
  97.258 -	}
  97.259 -	memcpy(&s->ti_buf[8], "QEMU   ", 8);
  97.260 -	s->ti_buf[2] = 1;
  97.261 -	s->ti_buf[3] = 2;
  97.262 -	s->ti_buf[4] = 32;
  97.263 -	s->ti_dir = 1;
  97.264 -	s->ti_size = 36;
  97.265 -	break;
  97.266 -    case 0x1a:
  97.267 -	DPRINTF("Mode Sense(6) (page %d, len %d)\n", buf[3], buf[5]);
  97.268 -	break;
  97.269 -    case 0x25:
  97.270 -	DPRINTF("Read Capacity (len %d)\n", buf[5]);
  97.271 -	memset(s->ti_buf, 0, 8);
  97.272 -	bdrv_get_geometry(s->bd[target], &nb_sectors);
  97.273 -	s->ti_buf[0] = (nb_sectors >> 24) & 0xff;
  97.274 -	s->ti_buf[1] = (nb_sectors >> 16) & 0xff;
  97.275 -	s->ti_buf[2] = (nb_sectors >> 8) & 0xff;
  97.276 -	s->ti_buf[3] = nb_sectors & 0xff;
  97.277 -	s->ti_buf[4] = 0;
  97.278 -	s->ti_buf[5] = 0;
  97.279 -	if (bdrv_get_type_hint(s->bd[target]) == BDRV_TYPE_CDROM)
  97.280 -	    s->ti_buf[6] = 8; // sector size 2048
  97.281 -	else
  97.282 -	    s->ti_buf[6] = 2; // sector size 512
  97.283 -	s->ti_buf[7] = 0;
  97.284 -	s->ti_dir = 1;
  97.285 -	s->ti_size = 8;
  97.286 -	break;
  97.287 -    case 0x28:
  97.288 -	{
  97.289 -	    int64_t offset, len;
  97.290 +    s->current_dev = s->scsi_dev[target];
  97.291 +    return dmalen;
  97.292 +}
  97.293  
  97.294 -	    if (bdrv_get_type_hint(s->bd[target]) == BDRV_TYPE_CDROM) {
  97.295 -		offset = ((buf[3] << 24) | (buf[4] << 16) | (buf[5] << 8) | buf[6]) * 4;
  97.296 -		len = ((buf[8] << 8) | buf[9]) * 4;
  97.297 -		s->ti_size = len * 2048;
  97.298 -	    } else {
  97.299 -		offset = (buf[3] << 24) | (buf[4] << 16) | (buf[5] << 8) | buf[6];
  97.300 -		len = (buf[8] << 8) | buf[9];
  97.301 -		s->ti_size = len * 512;
  97.302 -	    }
  97.303 -	    DPRINTF("Read (10) (offset %lld len %lld)\n", offset, len);
  97.304 -            if (s->ti_size > TI_BUFSZ) {
  97.305 -                DPRINTF("size too large %d\n", s->ti_size);
  97.306 -            }
  97.307 -	    bdrv_read(s->bd[target], offset, s->ti_buf, len);
  97.308 -	    // XXX error handling
  97.309 -	    s->ti_dir = 1;
  97.310 -	    break;
  97.311 -	}
  97.312 -    case 0x2a:
  97.313 -	{
  97.314 -	    int64_t offset, len;
  97.315 +static void do_cmd(ESPState *s, uint8_t *buf)
  97.316 +{
  97.317 +    int32_t datalen;
  97.318 +    int lun;
  97.319  
  97.320 -	    if (bdrv_get_type_hint(s->bd[target]) == BDRV_TYPE_CDROM) {
  97.321 -		offset = ((buf[3] << 24) | (buf[4] << 16) | (buf[5] << 8) | buf[6]) * 4;
  97.322 -		len = ((buf[8] << 8) | buf[9]) * 4;
  97.323 -		s->ti_size = len * 2048;
  97.324 -	    } else {
  97.325 -		offset = (buf[3] << 24) | (buf[4] << 16) | (buf[5] << 8) | buf[6];
  97.326 -		len = (buf[8] << 8) | buf[9];
  97.327 -		s->ti_size = len * 512;
  97.328 -	    }
  97.329 -	    DPRINTF("Write (10) (offset %lld len %lld)\n", offset, len);
  97.330 -            if (s->ti_size > TI_BUFSZ) {
  97.331 -                DPRINTF("size too large %d\n", s->ti_size);
  97.332 -            }
  97.333 -            s->dma_cb = esp_write_dma_cb;
  97.334 -            s->offset = offset;
  97.335 -            s->len = len;
  97.336 -            s->target = target;
  97.337 -	    // XXX error handling
  97.338 -	    s->ti_dir = 0;
  97.339 -	    break;
  97.340 -	}
  97.341 -    case 0x43:
  97.342 -        {
  97.343 -            int start_track, format, msf, len;
  97.344 -
  97.345 -            msf = buf[2] & 2;
  97.346 -            format = buf[3] & 0xf;
  97.347 -            start_track = buf[7];
  97.348 -            bdrv_get_geometry(s->bd[target], &nb_sectors);
  97.349 -            DPRINTF("Read TOC (track %d format %d msf %d)\n", start_track, format, msf >> 1);
  97.350 -            switch(format) {
  97.351 -            case 0:
  97.352 -                len = cdrom_read_toc(nb_sectors, buf, msf, start_track);
  97.353 -                if (len < 0)
  97.354 -                    goto error_cmd;
  97.355 -                s->ti_size = len;
  97.356 -                break;
  97.357 -            case 1:
  97.358 -                /* multi session : only a single session defined */
  97.359 -                memset(buf, 0, 12);
  97.360 -                buf[1] = 0x0a;
  97.361 -                buf[2] = 0x01;
  97.362 -                buf[3] = 0x01;
  97.363 -                s->ti_size = 12;
  97.364 -                break;
  97.365 -            case 2:
  97.366 -                len = cdrom_read_toc_raw(nb_sectors, buf, msf, start_track);
  97.367 -                if (len < 0)
  97.368 -                    goto error_cmd;
  97.369 -                s->ti_size = len;
  97.370 -                break;
  97.371 -            default:
  97.372 -            error_cmd:
  97.373 -                DPRINTF("Read TOC error\n");
  97.374 -                // XXX error handling
  97.375 -                break;
  97.376 -            }
  97.377 -	    s->ti_dir = 1;
  97.378 -            break;
  97.379 +    DPRINTF("do_cmd: busid 0x%x\n", buf[0]);
  97.380 +    lun = buf[0] & 7;
  97.381 +    datalen = scsi_send_command(s->current_dev, 0, &buf[1], lun);
  97.382 +    if (datalen == 0) {
  97.383 +        s->ti_size = 0;
  97.384 +    } else {
  97.385 +        s->rregs[4] = STAT_IN | STAT_TC;
  97.386 +        if (datalen > 0) {
  97.387 +            s->rregs[4] |= STAT_DI;
  97.388 +            s->ti_size = datalen;
  97.389 +        } else {
  97.390 +            s->rregs[4] |= STAT_DO;
  97.391 +            s->ti_size = -datalen;
  97.392          }
  97.393 -    default:
  97.394 -	DPRINTF("Unknown SCSI command (%2.2x)\n", buf[1]);
  97.395 -	break;
  97.396      }
  97.397 -    s->rregs[4] = STAT_IN | STAT_TC | STAT_DI;
  97.398      s->rregs[5] = INTR_BS | INTR_FC;
  97.399      s->rregs[6] = SEQ_CD;
  97.400      s->espdmaregs[0] |= DMA_INTR;
  97.401      pic_set_irq(s->irq, 1);
  97.402  }
  97.403  
  97.404 -static void dma_write(ESPState *s, const uint8_t *buf, uint32_t len)
  97.405 +static void handle_satn(ESPState *s)
  97.406  {
  97.407 -    uint32_t dmaptr, dmalen;
  97.408 +    uint8_t buf[32];
  97.409 +    int len;
  97.410  
  97.411 -    dmalen = s->wregs[0] | (s->wregs[1] << 8);
  97.412 -    DPRINTF("Transfer status len %d\n", dmalen);
  97.413 +    len = get_cmd(s, buf);
  97.414 +    if (len)
  97.415 +        do_cmd(s, buf);
  97.416 +}
  97.417 +
  97.418 +static void handle_satn_stop(ESPState *s)
  97.419 +{
  97.420 +    s->cmdlen = get_cmd(s, s->cmdbuf);
  97.421 +    if (s->cmdlen) {
  97.422 +        DPRINTF("Set ATN & Stop: cmdlen %d\n", s->cmdlen);
  97.423 +        s->do_cmd = 1;
  97.424 +        s->espdmaregs[1] += s->cmdlen;
  97.425 +        s->rregs[4] = STAT_IN | STAT_TC | STAT_CD;
  97.426 +        s->rregs[5] = INTR_BS | INTR_FC;
  97.427 +        s->rregs[6] = SEQ_CD;
  97.428 +        s->espdmaregs[0] |= DMA_INTR;
  97.429 +        pic_set_irq(s->irq, 1);
  97.430 +    }
  97.431 +}
  97.432 +
  97.433 +static void write_response(ESPState *s)
  97.434 +{
  97.435 +    uint32_t dmaptr;
  97.436 +
  97.437 +    DPRINTF("Transfer status (sense=%d)\n", s->sense);
  97.438 +    s->ti_buf[0] = s->sense;
  97.439 +    s->ti_buf[1] = 0;
  97.440      if (s->dma) {
  97.441  	dmaptr = iommu_translate(s->espdmaregs[1]);
  97.442 -	DPRINTF("DMA Direction: %c\n", s->espdmaregs[0] & 0x100? 'w': 'r');
  97.443 -	cpu_physical_memory_write(dmaptr, buf, len);
  97.444 +	DPRINTF("DMA Direction: %c\n",
  97.445 +                s->espdmaregs[0] & DMA_WRITE_MEM ? 'w': 'r');
  97.446 +	cpu_physical_memory_write(dmaptr, s->ti_buf, 2);
  97.447  	s->rregs[4] = STAT_IN | STAT_TC | STAT_ST;
  97.448  	s->rregs[5] = INTR_BS | INTR_FC;
  97.449  	s->rregs[6] = SEQ_CD;
  97.450      } else {
  97.451 -	memcpy(s->ti_buf, buf, len);
  97.452 -	s->ti_size = dmalen;
  97.453 +	s->ti_size = 2;
  97.454  	s->ti_rptr = 0;
  97.455  	s->ti_wptr = 0;
  97.456 -	s->rregs[7] = dmalen;
  97.457 +	s->rregs[7] = 2;
  97.458      }
  97.459      s->espdmaregs[0] |= DMA_INTR;
  97.460      pic_set_irq(s->irq, 1);
  97.461  
  97.462  }
  97.463  
  97.464 -static const uint8_t okbuf[] = {0, 0};
  97.465 +static void esp_command_complete(void *opaque, uint32_t tag, int sense)
  97.466 +{
  97.467 +    ESPState *s = (ESPState *)opaque;
  97.468 +
  97.469 +    DPRINTF("SCSI Command complete\n");
  97.470 +    if (s->ti_size != 0)
  97.471 +        DPRINTF("SCSI command completed unexpectedly\n");
  97.472 +    s->ti_size = 0;
  97.473 +    if (sense)
  97.474 +        DPRINTF("Command failed\n");
  97.475 +    s->sense = sense;
  97.476 +    s->rregs[4] = STAT_IN | STAT_TC | STAT_ST;
  97.477 +}
  97.478  
  97.479  static void handle_ti(ESPState *s)
  97.480  {
  97.481 -    uint32_t dmaptr, dmalen;
  97.482 +    uint32_t dmaptr, dmalen, minlen, len, from, to;
  97.483      unsigned int i;
  97.484 +    int to_device;
  97.485 +    uint8_t buf[TARGET_PAGE_SIZE];
  97.486  
  97.487      dmalen = s->wregs[0] | (s->wregs[1] << 8);
  97.488 -    DPRINTF("Transfer Information len %d\n", dmalen);
  97.489 +    if (dmalen==0) {
  97.490 +      dmalen=0x10000;
  97.491 +    }
  97.492 +
  97.493 +    if (s->do_cmd)
  97.494 +        minlen = (dmalen < 32) ? dmalen : 32;
  97.495 +    else
  97.496 +        minlen = (dmalen < s->ti_size) ? dmalen : s->ti_size;
  97.497 +    DPRINTF("Transfer Information len %d\n", minlen);
  97.498      if (s->dma) {
  97.499  	dmaptr = iommu_translate(s->espdmaregs[1]);
  97.500 -	DPRINTF("DMA Direction: %c, addr 0x%8.8x\n", s->espdmaregs[0] & 0x100? 'w': 'r', dmaptr);
  97.501 -	for (i = 0; i < s->ti_size; i++) {
  97.502 +        /* Check if the transfer writes to to reads from the device.  */
  97.503 +        to_device = (s->espdmaregs[0] & DMA_WRITE_MEM) == 0;
  97.504 +	DPRINTF("DMA Direction: %c, addr 0x%8.8x %08x\n",
  97.505 +                to_device ? 'r': 'w', dmaptr, s->ti_size);
  97.506 +	from = s->espdmaregs[1];
  97.507 +	to = from + minlen;
  97.508 +	for (i = 0; i < minlen; i += len, from += len) {
  97.509  	    dmaptr = iommu_translate(s->espdmaregs[1] + i);
  97.510 -	    if (s->ti_dir)
  97.511 -		cpu_physical_memory_write(dmaptr, &s->ti_buf[i], 1);
  97.512 -	    else
  97.513 -		cpu_physical_memory_read(dmaptr, &s->ti_buf[i], 1);
  97.514 -	}
  97.515 -        if (s->dma_cb) {
  97.516 -            s->dma_cb(s, s->espdmaregs[1], dmalen);
  97.517 -            s->dma_cb = NULL;
  97.518 +	    if ((from & TARGET_PAGE_MASK) != (to & TARGET_PAGE_MASK)) {
  97.519 +               len = TARGET_PAGE_SIZE - (from & ~TARGET_PAGE_MASK);
  97.520 +            } else {
  97.521 +	       len = to - from;
  97.522 +            }
  97.523 +            DPRINTF("DMA address p %08x v %08x len %08x, from %08x, to %08x\n", dmaptr, s->espdmaregs[1] + i, len, from, to);
  97.524 +            s->ti_size -= len;
  97.525 +            if (s->do_cmd) {
  97.526 +                DPRINTF("command len %d + %d\n", s->cmdlen, len);
  97.527 +                cpu_physical_memory_read(dmaptr, &s->cmdbuf[s->cmdlen], len);
  97.528 +                s->ti_size = 0;
  97.529 +                s->cmdlen = 0;
  97.530 +                s->do_cmd = 0;
  97.531 +                do_cmd(s, s->cmdbuf);
  97.532 +                return;
  97.533 +            } else {
  97.534 +                if (to_device) {
  97.535 +                    cpu_physical_memory_read(dmaptr, buf, len);
  97.536 +                    scsi_write_data(s->current_dev, buf, len);
  97.537 +                } else {
  97.538 +                    scsi_read_data(s->current_dev, buf, len);
  97.539 +                    cpu_physical_memory_write(dmaptr, buf, len);
  97.540 +                }
  97.541 +            }
  97.542          }
  97.543 -	s->rregs[4] = STAT_IN | STAT_TC | STAT_ST;
  97.544 -	s->rregs[5] = INTR_BS;
  97.545 +        if (s->ti_size) {
  97.546 +	    s->rregs[4] = STAT_IN | STAT_TC | (to_device ? STAT_DO : STAT_DI);
  97.547 +        }
  97.548 +        s->rregs[5] = INTR_BS;
  97.549  	s->rregs[6] = 0;
  97.550 +	s->rregs[7] = 0;
  97.551  	s->espdmaregs[0] |= DMA_INTR;
  97.552 -    } else {
  97.553 -	s->ti_size = dmalen;
  97.554 -	s->ti_rptr = 0;
  97.555 -	s->ti_wptr = 0;
  97.556 -	s->rregs[7] = dmalen;
  97.557 -    }	
  97.558 +    } else if (s->do_cmd) {
  97.559 +        DPRINTF("command len %d\n", s->cmdlen);
  97.560 +        s->ti_size = 0;
  97.561 +        s->cmdlen = 0;
  97.562 +        s->do_cmd = 0;
  97.563 +        do_cmd(s, s->cmdbuf);
  97.564 +        return;
  97.565 +    }
  97.566      pic_set_irq(s->irq, 1);
  97.567  }
  97.568  
  97.569 @@ -484,9 +289,8 @@ static void esp_reset(void *opaque)
  97.570      s->ti_size = 0;
  97.571      s->ti_rptr = 0;
  97.572      s->ti_wptr = 0;
  97.573 -    s->ti_dir = 0;
  97.574      s->dma = 0;
  97.575 -    s->dma_cb = NULL;
  97.576 +    s->do_cmd = 0;
  97.577  }
  97.578  
  97.579  static uint32_t esp_mem_readb(void *opaque, target_phys_addr_t addr)
  97.580 @@ -501,7 +305,12 @@ static uint32_t esp_mem_readb(void *opaq
  97.581  	// FIFO
  97.582  	if (s->ti_size > 0) {
  97.583  	    s->ti_size--;
  97.584 -	    s->rregs[saddr] = s->ti_buf[s->ti_rptr++];
  97.585 +            if ((s->rregs[4] & 6) == 0) {
  97.586 +                /* Data in/out.  */
  97.587 +                scsi_read_data(s->current_dev, &s->rregs[2], 0);
  97.588 +            } else {
  97.589 +                s->rregs[2] = s->ti_buf[s->ti_rptr++];
  97.590 +            }
  97.591  	    pic_set_irq(s->irq, 1);
  97.592  	}
  97.593  	if (s->ti_size == 0) {
  97.594 @@ -536,8 +345,17 @@ static void esp_mem_writeb(void *opaque,
  97.595          break;
  97.596      case 2:
  97.597  	// FIFO
  97.598 -	s->ti_size++;
  97.599 -	s->ti_buf[s->ti_wptr++] = val & 0xff;
  97.600 +        if (s->do_cmd) {
  97.601 +            s->cmdbuf[s->cmdlen++] = val & 0xff;
  97.602 +        } else if ((s->rregs[4] & 6) == 0) {
  97.603 +            uint8_t buf;
  97.604 +            buf = val & 0xff;
  97.605 +            s->ti_size--;
  97.606 +            scsi_write_data(s->current_dev, &buf, 0);
  97.607 +        } else {
  97.608 +            s->ti_size++;
  97.609 +            s->ti_buf[s->ti_wptr++] = val & 0xff;
  97.610 +        }
  97.611  	break;
  97.612      case 3:
  97.613          s->rregs[saddr] = val;
  97.614 @@ -574,11 +392,11 @@ static void esp_mem_writeb(void *opaque,
  97.615  	    break;
  97.616  	case 0x11:
  97.617  	    DPRINTF("Initiator Command Complete Sequence (%2.2x)\n", val);
  97.618 -	    dma_write(s, okbuf, 2);
  97.619 +	    write_response(s);
  97.620  	    break;
  97.621  	case 0x12:
  97.622  	    DPRINTF("Message Accepted (%2.2x)\n", val);
  97.623 -	    dma_write(s, okbuf, 2);
  97.624 +	    write_response(s);
  97.625  	    s->rregs[5] = INTR_DC;
  97.626  	    s->rregs[6] = 0;
  97.627  	    break;
  97.628 @@ -586,11 +404,12 @@ static void esp_mem_writeb(void *opaque,
  97.629  	    DPRINTF("Set ATN (%2.2x)\n", val);
  97.630  	    break;
  97.631  	case 0x42:
  97.632 +	    DPRINTF("Set ATN (%2.2x)\n", val);
  97.633  	    handle_satn(s);
  97.634  	    break;
  97.635  	case 0x43:
  97.636  	    DPRINTF("Set ATN & stop (%2.2x)\n", val);
  97.637 -	    handle_satn(s);
  97.638 +	    handle_satn_stop(s);
  97.639  	    break;
  97.640  	default:
  97.641  	    DPRINTF("Unhandled ESP command (%2.2x)\n", val);
  97.642 @@ -660,7 +479,7 @@ static void espdma_mem_writel(void *opaq
  97.643          val |= DMA_VER;
  97.644  	break;
  97.645      case 1:
  97.646 -        s->espdmaregs[0] = DMA_LOADED;
  97.647 +        s->espdmaregs[0] |= DMA_LOADED;
  97.648          break;
  97.649      default:
  97.650  	break;
  97.651 @@ -693,7 +512,6 @@ static void esp_save(QEMUFile *f, void *
  97.652      qemu_put_be32s(f, &s->ti_size);
  97.653      qemu_put_be32s(f, &s->ti_rptr);
  97.654      qemu_put_be32s(f, &s->ti_wptr);
  97.655 -    qemu_put_be32s(f, &s->ti_dir);
  97.656      qemu_put_buffer(f, s->ti_buf, TI_BUFSZ);
  97.657      qemu_put_be32s(f, &s->dma);
  97.658  }
  97.659 @@ -714,7 +532,6 @@ static int esp_load(QEMUFile *f, void *o
  97.660      qemu_get_be32s(f, &s->ti_size);
  97.661      qemu_get_be32s(f, &s->ti_rptr);
  97.662      qemu_get_be32s(f, &s->ti_wptr);
  97.663 -    qemu_get_be32s(f, &s->ti_dir);
  97.664      qemu_get_buffer(f, s->ti_buf, TI_BUFSZ);
  97.665      qemu_get_be32s(f, &s->dma);
  97.666  
  97.667 @@ -725,6 +542,7 @@ void esp_init(BlockDriverState **bd, int
  97.668  {
  97.669      ESPState *s;
  97.670      int esp_io_memory, espdma_io_memory;
  97.671 +    int i;
  97.672  
  97.673      s = qemu_mallocz(sizeof(ESPState));
  97.674      if (!s)
  97.675 @@ -743,5 +561,11 @@ void esp_init(BlockDriverState **bd, int
  97.676  
  97.677      register_savevm("esp", espaddr, 1, esp_save, esp_load, s);
  97.678      qemu_register_reset(esp_reset, s);
  97.679 +    for (i = 0; i < MAX_DISKS; i++) {
  97.680 +        if (bs_table[i]) {
  97.681 +            s->scsi_dev[i] =
  97.682 +                scsi_disk_init(bs_table[i], esp_command_complete, s);
  97.683 +        }
  97.684 +    }
  97.685  }
  97.686  
    98.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    98.2 +++ b/tools/ioemu/hw/grackle_pci.c	Wed Aug 09 08:34:06 2006 -0600
    98.3 @@ -0,0 +1,156 @@
    98.4 +/*
    98.5 + * QEMU Grackle (heathrow PPC) PCI host
    98.6 + *
    98.7 + * Copyright (c) 2006 Fabrice Bellard
    98.8 + * 
    98.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
   98.10 + * of this software and associated documentation files (the "Software"), to deal
   98.11 + * in the Software without restriction, including without limitation the rights
   98.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   98.13 + * copies of the Software, and to permit persons to whom the Software is
   98.14 + * furnished to do so, subject to the following conditions:
   98.15 + *
   98.16 + * The above copyright notice and this permission notice shall be included in
   98.17 + * all copies or substantial portions of the Software.
   98.18 + *
   98.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   98.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   98.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
   98.22 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   98.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   98.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   98.25 + * THE SOFTWARE.
   98.26 + */
   98.27 +
   98.28 +#include "vl.h"
   98.29 +typedef target_phys_addr_t pci_addr_t;
   98.30 +#include "pci_host.h"
   98.31 +
   98.32 +typedef PCIHostState GrackleState;
   98.33 +
   98.34 +static void pci_grackle_config_writel (void *opaque, target_phys_addr_t addr,
   98.35 +                                       uint32_t val)
   98.36 +{
   98.37 +    GrackleState *s = opaque;
   98.38 +#ifdef TARGET_WORDS_BIGENDIAN
   98.39 +    val = bswap32(val);
   98.40 +#endif
   98.41 +    s->config_reg = val;
   98.42 +}
   98.43 +
   98.44 +static uint32_t pci_grackle_config_readl (void *opaque, target_phys_addr_t addr)
   98.45 +{
   98.46 +    GrackleState *s = opaque;
   98.47 +    uint32_t val;
   98.48 +
   98.49 +    val = s->config_reg;
   98.50 +#ifdef TARGET_WORDS_BIGENDIAN
   98.51 +    val = bswap32(val);
   98.52 +#endif
   98.53 +    return val;
   98.54 +}
   98.55 +
   98.56 +static CPUWriteMemoryFunc *pci_grackle_config_write[] = {
   98.57 +    &pci_grackle_config_writel,
   98.58 +    &pci_grackle_config_writel,
   98.59 +    &pci_grackle_config_writel,
   98.60 +};
   98.61 +
   98.62 +static CPUReadMemoryFunc *pci_grackle_config_read[] = {
   98.63 +    &pci_grackle_config_readl,
   98.64 +    &pci_grackle_config_readl,
   98.65 +    &pci_grackle_config_readl,
   98.66 +};
   98.67 +
   98.68 +static CPUWriteMemoryFunc *pci_grackle_write[] = {
   98.69 +    &pci_host_data_writeb,
   98.70 +    &pci_host_data_writew,
   98.71 +    &pci_host_data_writel,
   98.72 +};
   98.73 +
   98.74 +static CPUReadMemoryFunc *pci_grackle_read[] = {
   98.75 +    &pci_host_data_readb,
   98.76 +    &pci_host_data_readw,
   98.77 +    &pci_host_data_readl,
   98.78 +};
   98.79 +
   98.80 +/* XXX: we do not simulate the hardware - we rely on the BIOS to
   98.81 +   set correctly for irq line field */
   98.82 +static void pci_grackle_set_irq(PCIDevice *d, void *pic, int irq_num, int level)
   98.83 +{
   98.84 +    heathrow_pic_set_irq(pic, d->config[PCI_INTERRUPT_LINE], level);
   98.85 +}
   98.86 +
   98.87 +PCIBus *pci_grackle_init(uint32_t base, void *pic)
   98.88 +{
   98.89 +    GrackleState *s;
   98.90 +    PCIDevice *d;
   98.91 +    int pci_mem_config, pci_mem_data;
   98.92 +
   98.93 +    s = qemu_mallocz(sizeof(GrackleState));
   98.94 +    s->bus = pci_register_bus(pci_grackle_set_irq, pic, 0);
   98.95 +
   98.96 +    pci_mem_config = cpu_register_io_memory(0, pci_grackle_config_read, 
   98.97 +                                            pci_grackle_config_write, s);
   98.98 +    pci_mem_data = cpu_register_io_memory(0, pci_grackle_read,
   98.99 +                                          pci_grackle_write, s);
  98.100 +    cpu_register_physical_memory(base, 0x1000, pci_mem_config);
  98.101 +    cpu_register_physical_memory(base + 0x00200000, 0x1000, pci_mem_data);
  98.102 +    d = pci_register_device(s->bus, "Grackle host bridge", sizeof(PCIDevice), 
  98.103 +                            0, NULL, NULL);
  98.104 +    d->config[0x00] = 0x57; // vendor_id
  98.105 +    d->config[0x01] = 0x10;
  98.106 +    d->config[0x02] = 0x02; // device_id
  98.107 +    d->config[0x03] = 0x00;
  98.108 +    d->config[0x08] = 0x00; // revision
  98.109 +    d->config[0x09] = 0x01;
  98.110 +    d->config[0x0a] = 0x00; // class_sub = host
  98.111 +    d->config[0x0b] = 0x06; // class_base = PCI_bridge
  98.112 +    d->config[0x0e] = 0x00; // header_type
  98.113 +
  98.114 +    d->config[0x18] = 0x00;  // primary_bus
  98.115 +    d->config[0x19] = 0x01;  // secondary_bus
  98.116 +    d->config[0x1a] = 0x00;  // subordinate_bus
  98.117 +    d->config[0x1c] = 0x00;
  98.118 +    d->config[0x1d] = 0x00;
  98.119 +    
  98.120 +    d->config[0x20] = 0x00; // memory_base
  98.121 +    d->config[0x21] = 0x00;
  98.122 +    d->config[0x22] = 0x01; // memory_limit
  98.123 +    d->config[0x23] = 0x00;
  98.124 +    
  98.125 +    d->config[0x24] = 0x00; // prefetchable_memory_base
  98.126 +    d->config[0x25] = 0x00;
  98.127 +    d->config[0x26] = 0x00; // prefetchable_memory_limit
  98.128 +    d->config[0x27] = 0x00;
  98.129 +
  98.130 +#if 0
  98.131 +    /* PCI2PCI bridge same values as PearPC - check this */
  98.132 +    d->config[0x00] = 0x11; // vendor_id
  98.133 +    d->config[0x01] = 0x10;
  98.134 +    d->config[0x02] = 0x26; // device_id
  98.135 +    d->config[0x03] = 0x00;
  98.136 +    d->config[0x08] = 0x02; // revision
  98.137 +    d->config[0x0a] = 0x04; // class_sub = pci2pci
  98.138 +    d->config[0x0b] = 0x06; // class_base = PCI_bridge
  98.139 +    d->config[0x0e] = 0x01; // header_type
  98.140 +
  98.141 +    d->config[0x18] = 0x0;  // primary_bus
  98.142 +    d->config[0x19] = 0x1;  // secondary_bus
  98.143 +    d->config[0x1a] = 0x1;  // subordinate_bus
  98.144 +    d->config[0x1c] = 0x10; // io_base
  98.145 +    d->config[0x1d] = 0x20; // io_limit
  98.146 +    
  98.147 +    d->config[0x20] = 0x80; // memory_base
  98.148 +    d->config[0x21] = 0x80;
  98.149 +    d->config[0x22] = 0x90; // memory_limit
  98.150 +    d->config[0x23] = 0x80;
  98.151 +    
  98.152 +    d->config[0x24] = 0x00; // prefetchable_memory_base
  98.153 +    d->config[0x25] = 0x84;
  98.154 +    d->config[0x26] = 0x00; // prefetchable_memory_limit
  98.155 +    d->config[0x27] = 0x85;
  98.156 +#endif
  98.157 +    return s->bus;
  98.158 +}
  98.159 +
    99.1 --- a/tools/ioemu/hw/i8259.c	Wed Aug 09 08:01:52 2006 -0600
    99.2 +++ b/tools/ioemu/hw/i8259.c	Wed Aug 09 08:34:06 2006 -0600
    99.3 @@ -531,7 +531,7 @@ void irq_info(void)
    99.4      for (i = 0; i < 16; i++) {
    99.5          count = irq_count[i];
    99.6          if (count > 0)
    99.7 -            term_printf("%2d: %lld\n", i, count);
    99.8 +            term_printf("%2d: %" PRId64 "\n", i, count);
    99.9      }
   99.10  #endif
   99.11  }
   100.1 --- a/tools/ioemu/hw/ide.c	Wed Aug 09 08:01:52 2006 -0600
   100.2 +++ b/tools/ioemu/hw/ide.c	Wed Aug 09 08:34:06 2006 -0600
   100.3 @@ -1133,127 +1133,6 @@ static void ide_atapi_cmd_read(IDEState 
   100.4      }
   100.5  }
   100.6  
   100.7 -/* same toc as bochs. Return -1 if error or the toc length */
   100.8 -/* XXX: check this */
   100.9 -static int cdrom_read_toc(IDEState *s, uint8_t *buf, int msf, int start_track)
  100.10 -{
  100.11 -    uint8_t *q;
  100.12 -    int nb_sectors, len;
  100.13 -    
  100.14 -    if (start_track > 1 && start_track != 0xaa)
  100.15 -        return -1;
  100.16 -    q = buf + 2;
  100.17 -    *q++ = 1; /* first session */
  100.18 -    *q++ = 1; /* last session */
  100.19 -    if (start_track <= 1) {
  100.20 -        *q++ = 0; /* reserved */
  100.21 -        *q++ = 0x14; /* ADR, control */
  100.22 -        *q++ = 1;    /* track number */
  100.23 -        *q++ = 0; /* reserved */
  100.24 -        if (msf) {
  100.25 -            *q++ = 0; /* reserved */
  100.26 -            lba_to_msf(q, 0);
  100.27 -            q += 3;
  100.28 -        } else {
  100.29 -            /* sector 0 */
  100.30 -            cpu_to_ube32(q, 0);
  100.31 -            q += 4;
  100.32 -        }
  100.33 -    }
  100.34 -    /* lead out track */
  100.35 -    *q++ = 0; /* reserved */
  100.36 -    *q++ = 0x16; /* ADR, control */
  100.37 -    *q++ = 0xaa; /* track number */
  100.38 -    *q++ = 0; /* reserved */
  100.39 -    nb_sectors = s->nb_sectors >> 2;
  100.40 -    if (msf) {
  100.41 -        *q++ = 0; /* reserved */
  100.42 -        lba_to_msf(q, nb_sectors);
  100.43 -        q += 3;
  100.44 -    } else {
  100.45 -        cpu_to_ube32(q, nb_sectors);
  100.46 -        q += 4;
  100.47 -    }
  100.48 -    len = q - buf;
  100.49 -    cpu_to_ube16(buf, len - 2);
  100.50 -    return len;
  100.51 -}
  100.52 -
  100.53 -/* mostly same info as PearPc */
  100.54 -static int cdrom_read_toc_raw(IDEState *s, uint8_t *buf, int msf, 
  100.55 -                              int session_num)
  100.56 -{
  100.57 -    uint8_t *q;
  100.58 -    int nb_sectors, len;
  100.59 -    
  100.60 -    q = buf + 2;
  100.61 -    *q++ = 1; /* first session */
  100.62 -    *q++ = 1; /* last session */
  100.63 -
  100.64 -    *q++ = 1; /* session number */
  100.65 -    *q++ = 0x14; /* data track */
  100.66 -    *q++ = 0; /* track number */
  100.67 -    *q++ = 0xa0; /* lead-in */
  100.68 -    *q++ = 0; /* min */
  100.69 -    *q++ = 0; /* sec */
  100.70 -    *q++ = 0; /* frame */
  100.71 -    *q++ = 0;
  100.72 -    *q++ = 1; /* first track */
  100.73 -    *q++ = 0x00; /* disk type */
  100.74 -    *q++ = 0x00;
  100.75 -    
  100.76 -    *q++ = 1; /* session number */
  100.77 -    *q++ = 0x14; /* data track */
  100.78 -    *q++ = 0; /* track number */
  100.79 -    *q++ = 0xa1;
  100.80 -    *q++ = 0; /* min */
  100.81 -    *q++ = 0; /* sec */
  100.82 -    *q++ = 0; /* frame */
  100.83 -    *q++ = 0;
  100.84 -    *q++ = 1; /* last track */
  100.85 -    *q++ = 0x00;
  100.86 -    *q++ = 0x00;
  100.87 -    
  100.88 -    *q++ = 1; /* session number */
  100.89 -    *q++ = 0x14; /* data track */
  100.90 -    *q++ = 0; /* track number */
  100.91 -    *q++ = 0xa2; /* lead-out */
  100.92 -    *q++ = 0; /* min */
  100.93 -    *q++ = 0; /* sec */
  100.94 -    *q++ = 0; /* frame */
  100.95 -    nb_sectors = s->nb_sectors >> 2;
  100.96 -    if (msf) {
  100.97 -        *q++ = 0; /* reserved */
  100.98 -        lba_to_msf(q, nb_sectors);
  100.99 -        q += 3;
 100.100 -    } else {
 100.101 -        cpu_to_ube32(q, nb_sectors);
 100.102 -        q += 4;
 100.103 -    }
 100.104 -
 100.105 -    *q++ = 1; /* session number */
 100.106 -    *q++ = 0x14; /* ADR, control */
 100.107 -    *q++ = 0;    /* track number */
 100.108 -    *q++ = 1;    /* point */
 100.109 -    *q++ = 0; /* min */
 100.110 -    *q++ = 0; /* sec */
 100.111 -    *q++ = 0; /* frame */
 100.112 -    if (msf) {
 100.113 -        *q++ = 0; 
 100.114 -        lba_to_msf(q, 0);
 100.115 -        q += 3;
 100.116 -    } else {
 100.117 -        *q++ = 0; 
 100.118 -        *q++ = 0; 
 100.119 -        *q++ = 0; 
 100.120 -        *q++ = 0; 
 100.121 -    }
 100.122 -
 100.123 -    len = q - buf;
 100.124 -    cpu_to_ube16(buf, len - 2);
 100.125 -    return len;
 100.126 -}
 100.127 -
 100.128  static void ide_atapi_cmd(IDEState *s)
 100.129  {
 100.130      const uint8_t *packet;
 100.131 @@ -1279,6 +1158,7 @@ static void ide_atapi_cmd(IDEState *s)
 100.132          } else {
 100.133              ide_atapi_cmd_error(s, SENSE_NOT_READY, 
 100.134                                  ASC_MEDIUM_NOT_PRESENT);
 100.135 +            xenstore_check_new_media_present(1000);
 100.136          }
 100.137          break;
 100.138      case GPCMD_MODE_SENSE_10:
 100.139 @@ -1500,7 +1380,7 @@ static void ide_atapi_cmd(IDEState *s)
 100.140              start_track = packet[6];
 100.141              switch(format) {
 100.142              case 0:
 100.143 -                len = cdrom_read_toc(s, buf, msf, start_track);
 100.144 +                len = cdrom_read_toc(s->nb_sectors >> 2, buf, msf, start_track);
 100.145                  if (len < 0)
 100.146                      goto error_cmd;
 100.147                  ide_atapi_cmd_reply(s, len, max_len);
 100.148 @@ -1514,7 +1394,7 @@ static void ide_atapi_cmd(IDEState *s)
 100.149                  ide_atapi_cmd_reply(s, 12, max_len);
 100.150                  break;
 100.151              case 2:
 100.152 -                len = cdrom_read_toc_raw(s, buf, msf, start_track);
 100.153 +                len = cdrom_read_toc_raw(s->nb_sectors >> 2, buf, msf, start_track);
 100.154                  if (len < 0)
 100.155                      goto error_cmd;
 100.156                  ide_atapi_cmd_reply(s, len, max_len);
 100.157 @@ -1828,6 +1708,11 @@ static void ide_ioport_write(void *opaqu
 100.158              break;
 100.159          case WIN_FLUSH_CACHE:
 100.160          case WIN_FLUSH_CACHE_EXT:
 100.161 +            if (s->bs)
 100.162 +                bdrv_flush(s->bs);
 100.163 +	    s->status = READY_STAT;
 100.164 +            ide_set_irq(s);
 100.165 +            break;
 100.166  	case WIN_STANDBYNOW1:
 100.167          case WIN_IDLEIMMEDIATE:
 100.168  	    s->status = READY_STAT;
 100.169 @@ -2562,7 +2447,7 @@ void pci_cmd646_ide_init(PCIBus *bus, Bl
 100.170  
 100.171  /* hd_table must contain 4 block drivers */
 100.172  /* NOTE: for the PIIX3, the IRQs and IOports are hardcoded */
 100.173 -void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table)
 100.174 +void pci_piix3_ide_init(PCIBus *bus, BlockDriverState **hd_table, int devfn)
 100.175  {
 100.176      PCIIDEState *d;
 100.177      uint8_t *pci_conf;
 100.178 @@ -2570,7 +2455,7 @@ void pci_piix3_ide_init(PCIBus *bus, Blo
 100.179      /* register a function 1 of PIIX3 */
 100.180      d = (PCIIDEState *)pci_register_device(bus, "PIIX3 IDE", 
 100.181                                             sizeof(PCIIDEState),
 100.182 -                                           ((PCIDevice *)piix3_state)->devfn + 1, 
 100.183 +                                           devfn,
 100.184                                             NULL, NULL);
 100.185      d->type = IDE_TYPE_PIIX3;
 100.186  
   101.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   101.2 +++ b/tools/ioemu/hw/lsi53c895a.c	Wed Aug 09 08:34:06 2006 -0600
   101.3 @@ -0,0 +1,1571 @@
   101.4 +/* 
   101.5 + * QEMU LSI53C895A SCSI Host Bus Adapter emulation
   101.6 + *
   101.7 + * Copyright (c) 2006 CodeSourcery.
   101.8 + * Written by Paul Brook
   101.9 + *
  101.10 + * This code is licenced under the LGPL.
  101.11 + */
  101.12 +
  101.13 +/* ??? Need to check if the {read,write}[wl] routines work properly on
  101.14 +   big-endian targets.  */
  101.15 +
  101.16 +#include "vl.h"
  101.17 +
  101.18 +//#define DEBUG_LSI
  101.19 +//#define DEBUG_LSI_REG
  101.20 +
  101.21 +#ifdef DEBUG_LSI
  101.22 +#define DPRINTF(fmt, args...) \
  101.23 +do { printf("lsi_scsi: " fmt , ##args); } while (0)
  101.24 +#define BADF(fmt, args...) \
  101.25 +do { fprintf(stderr, "lsi_scsi: " fmt , ##args); exit(1);} while (0)
  101.26 +#else
  101.27 +#define DPRINTF(fmt, args...) do {} while(0)
  101.28 +#define BADF(fmt, args...) \
  101.29 +do { fprintf(stderr, "lsi_scsi: " fmt , ##args); } while (0)
  101.30 +#endif
  101.31 +
  101.32 +#define LSI_SCNTL0_TRG    0x01
  101.33 +#define LSI_SCNTL0_AAP    0x02
  101.34 +#define LSI_SCNTL0_EPC    0x08
  101.35 +#define LSI_SCNTL0_WATN   0x10
  101.36 +#define LSI_SCNTL0_START  0x20
  101.37 +
  101.38 +#define LSI_SCNTL1_SST    0x01
  101.39 +#define LSI_SCNTL1_IARB   0x02
  101.40 +#define LSI_SCNTL1_AESP   0x04
  101.41 +#define LSI_SCNTL1_RST    0x08
  101.42 +#define LSI_SCNTL1_CON    0x10
  101.43 +#define LSI_SCNTL1_DHP    0x20
  101.44 +#define LSI_SCNTL1_ADB    0x40
  101.45 +#define LSI_SCNTL1_EXC    0x80
  101.46 +
  101.47 +#define LSI_SCNTL2_WSR    0x01
  101.48 +#define LSI_SCNTL2_VUE0   0x02
  101.49 +#define LSI_SCNTL2_VUE1   0x04
  101.50 +#define LSI_SCNTL2_WSS    0x08
  101.51 +#define LSI_SCNTL2_SLPHBEN 0x10
  101.52 +#define LSI_SCNTL2_SLPMD  0x20
  101.53 +#define LSI_SCNTL2_CHM    0x40
  101.54 +#define LSI_SCNTL2_SDU    0x80
  101.55 +
  101.56 +#define LSI_ISTAT0_DIP    0x01
  101.57 +#define LSI_ISTAT0_SIP    0x02
  101.58 +#define LSI_ISTAT0_INTF   0x04
  101.59 +#define LSI_ISTAT0_CON    0x08
  101.60 +#define LSI_ISTAT0_SEM    0x10
  101.61 +#define LSI_ISTAT0_SIGP   0x20
  101.62 +#define LSI_ISTAT0_SRST   0x40
  101.63 +#define LSI_ISTAT0_ABRT   0x80
  101.64 +
  101.65 +#define LSI_ISTAT1_SI     0x01
  101.66 +#define LSI_ISTAT1_SRUN   0x02
  101.67 +#define LSI_ISTAT1_FLSH   0x04
  101.68 +
  101.69 +#define LSI_SSTAT0_SDP0   0x01
  101.70 +#define LSI_SSTAT0_RST    0x02
  101.71 +#define LSI_SSTAT0_WOA    0x04
  101.72 +#define LSI_SSTAT0_LOA    0x08
  101.73 +#define LSI_SSTAT0_AIP    0x10
  101.74 +#define LSI_SSTAT0_OLF    0x20
  101.75 +#define LSI_SSTAT0_ORF    0x40
  101.76 +#define LSI_SSTAT0_ILF    0x80
  101.77 +
  101.78 +#define LSI_SIST0_PAR     0x01
  101.79 +#define LSI_SIST0_RST     0x02
  101.80 +#define LSI_SIST0_UDC     0x04
  101.81 +#define LSI_SIST0_SGE     0x08
  101.82 +#define LSI_SIST0_RSL     0x10
  101.83 +#define LSI_SIST0_SEL     0x20
  101.84 +#define LSI_SIST0_CMP     0x40
  101.85 +#define LSI_SIST0_MA      0x80
  101.86 +
  101.87 +#define LSI_SIST1_HTH     0x01
  101.88 +#define LSI_SIST1_GEN     0x02
  101.89 +#define LSI_SIST1_STO     0x04
  101.90 +#define LSI_SIST1_SBMC    0x10
  101.91 +
  101.92 +#define LSI_SOCL_IO       0x01
  101.93 +#define LSI_SOCL_CD       0x02
  101.94 +#define LSI_SOCL_MSG      0x04
  101.95 +#define LSI_SOCL_ATN      0x08
  101.96 +#define LSI_SOCL_SEL      0x10
  101.97 +#define LSI_SOCL_BSY      0x20
  101.98 +#define LSI_SOCL_ACK      0x40
  101.99 +#define LSI_SOCL_REQ      0x80
 101.100 +
 101.101 +#define LSI_DSTAT_IID     0x01
 101.102 +#define LSI_DSTAT_SIR     0x04
 101.103 +#define LSI_DSTAT_SSI     0x08
 101.104 +#define LSI_DSTAT_ABRT    0x10
 101.105 +#define LSI_DSTAT_BF      0x20
 101.106 +#define LSI_DSTAT_MDPE    0x40
 101.107 +#define LSI_DSTAT_DFE     0x80
 101.108 +
 101.109 +#define LSI_DCNTL_COM     0x01
 101.110 +#define LSI_DCNTL_IRQD    0x02
 101.111 +#define LSI_DCNTL_STD     0x04
 101.112 +#define LSI_DCNTL_IRQM    0x08
 101.113 +#define LSI_DCNTL_SSM     0x10
 101.114 +#define LSI_DCNTL_PFEN    0x20
 101.115 +#define LSI_DCNTL_PFF     0x40
 101.116 +#define LSI_DCNTL_CLSE    0x80
 101.117 +
 101.118 +#define LSI_DMODE_MAN     0x01
 101.119 +#define LSI_DMODE_BOF     0x02
 101.120 +#define LSI_DMODE_ERMP    0x04
 101.121 +#define LSI_DMODE_ERL     0x08
 101.122 +#define LSI_DMODE_DIOM    0x10
 101.123 +#define LSI_DMODE_SIOM    0x20
 101.124 +
 101.125 +#define LSI_CTEST2_DACK   0x01
 101.126 +#define LSI_CTEST2_DREQ   0x02
 101.127 +#define LSI_CTEST2_TEOP   0x04
 101.128 +#define LSI_CTEST2_PCICIE 0x08
 101.129 +#define LSI_CTEST2_CM     0x10
 101.130 +#define LSI_CTEST2_CIO    0x20
 101.131 +#define LSI_CTEST2_SIGP   0x40
 101.132 +#define LSI_CTEST2_DDIR   0x80
 101.133 +
 101.134 +#define LSI_CTEST5_BL2    0x04
 101.135 +#define LSI_CTEST5_DDIR   0x08
 101.136 +#define LSI_CTEST5_MASR   0x10
 101.137 +#define LSI_CTEST5_DFSN   0x20
 101.138 +#define LSI_CTEST5_BBCK   0x40
 101.139 +#define LSI_CTEST5_ADCK   0x80
 101.140 +
 101.141 +#define LSI_CCNTL0_DILS   0x01
 101.142 +#define LSI_CCNTL0_DISFC  0x10
 101.143 +#define LSI_CCNTL0_ENNDJ  0x20
 101.144 +#define LSI_CCNTL0_PMJCTL 0x40
 101.145 +#define LSI_CCNTL0_ENPMJ  0x80
 101.146 +
 101.147 +#define PHASE_DO          0
 101.148 +#define PHASE_DI          1
 101.149 +#define PHASE_CMD         2
 101.150 +#define PHASE_ST          3
 101.151 +#define PHASE_MO          6
 101.152 +#define PHASE_MI          7
 101.153 +#define PHASE_MASK        7
 101.154 +
 101.155 +/* The HBA is ID 7, so for simplicitly limit to 7 devices.  */
 101.156 +#define LSI_MAX_DEVS      7
 101.157 +
 101.158 +typedef struct {
 101.159 +    PCIDevice pci_dev;
 101.160 +    int mmio_io_addr;
 101.161 +    int ram_io_addr;
 101.162 +    uint32_t script_ram_base;
 101.163 +    uint32_t data_len;
 101.164 +
 101.165 +    int carry; /* ??? Should this be an a visible register somewhere?  */
 101.166 +    int sense;
 101.167 +    uint8_t msg;
 101.168 +    /* Nonzero if a Wait Reselect instruction has been issued.  */
 101.169 +    int waiting;
 101.170 +    SCSIDevice *scsi_dev[LSI_MAX_DEVS];
 101.171 +    SCSIDevice *current_dev;
 101.172 +    int current_lun;
 101.173 +
 101.174 +    uint32_t dsa;
 101.175 +    uint32_t temp;
 101.176 +    uint32_t dnad;
 101.177 +    uint32_t dbc;
 101.178 +    uint8_t istat0;
 101.179 +    uint8_t istat1;
 101.180 +    uint8_t dcmd;
 101.181 +    uint8_t dstat;
 101.182 +    uint8_t dien;
 101.183 +    uint8_t sist0;
 101.184 +    uint8_t sist1;
 101.185 +    uint8_t sien0;
 101.186 +    uint8_t sien1;
 101.187 +    uint8_t mbox0;
 101.188 +    uint8_t mbox1;
 101.189 +    uint8_t dfifo;
 101.190 +    uint8_t ctest3;
 101.191 +    uint8_t ctest4;
 101.192 +    uint8_t ctest5;
 101.193 +    uint8_t ccntl0;
 101.194 +    uint8_t ccntl1;
 101.195 +    uint32_t dsp;
 101.196 +    uint32_t dsps;
 101.197 +    uint8_t dmode;
 101.198 +    uint8_t dcntl;
 101.199 +    uint8_t scntl0;
 101.200 +    uint8_t scntl1;
 101.201 +    uint8_t scntl2;
 101.202 +    uint8_t scntl3;
 101.203 +    uint8_t sstat0;
 101.204 +    uint8_t sstat1;
 101.205 +    uint8_t scid;
 101.206 +    uint8_t sxfer;
 101.207 +    uint8_t socl;
 101.208 +    uint8_t sdid;
 101.209 +    uint8_t sfbr;
 101.210 +    uint8_t stest1;
 101.211 +    uint8_t stest2;
 101.212 +    uint8_t stest3;
 101.213 +    uint8_t stime0;
 101.214 +    uint8_t respid0;
 101.215 +    uint8_t respid1;
 101.216 +    uint32_t mmrs;
 101.217 +    uint32_t mmws;
 101.218 +    uint32_t sfs;
 101.219 +    uint32_t drs;
 101.220 +    uint32_t sbms;
 101.221 +    uint32_t dmbs;
 101.222 +    uint32_t dnad64;
 101.223 +    uint32_t pmjad1;
 101.224 +    uint32_t pmjad2;
 101.225 +    uint32_t rbc;
 101.226 +    uint32_t ua;
 101.227 +    uint32_t ia;
 101.228 +    uint32_t sbc;
 101.229 +    uint32_t csbc;
 101.230 +    uint32_t scratch[13]; /* SCRATCHA-SCRATCHR */
 101.231 +
 101.232 +    /* Script ram is stored as 32-bit words in host byteorder.  */
 101.233 +    uint32_t script_ram[2048];
 101.234 +} LSIState;
 101.235 +
 101.236 +static void lsi_soft_reset(LSIState *s)
 101.237 +{
 101.238 +    DPRINTF("Reset\n");
 101.239 +    s->carry = 0;
 101.240 +
 101.241 +    s->waiting = 0;
 101.242 +    s->dsa = 0;
 101.243 +    s->dnad = 0;
 101.244 +    s->dbc = 0;
 101.245 +    s->temp = 0;
 101.246 +    memset(s->scratch, 0, sizeof(s->scratch));
 101.247 +    s->istat0 = 0;
 101.248 +    s->istat1 = 0;
 101.249 +    s->dcmd = 0;
 101.250 +    s->dstat = 0;
 101.251 +    s->dien = 0;
 101.252 +    s->sist0 = 0;
 101.253 +    s->sist1 = 0;
 101.254 +    s->sien0 = 0;
 101.255 +    s->sien1 = 0;
 101.256 +    s->mbox0 = 0;
 101.257 +    s->mbox1 = 0;
 101.258 +    s->dfifo = 0;
 101.259 +    s->ctest3 = 0;
 101.260 +    s->ctest4 = 0;
 101.261 +    s->ctest5 = 0;
 101.262 +    s->ccntl0 = 0;
 101.263 +    s->ccntl1 = 0;
 101.264 +    s->dsp = 0;
 101.265 +    s->dsps = 0;
 101.266 +    s->dmode = 0;
 101.267 +    s->dcntl = 0;
 101.268 +    s->scntl0 = 0xc0;
 101.269 +    s->scntl1 = 0;
 101.270 +    s->scntl2 = 0;
 101.271 +    s->scntl3 = 0;
 101.272 +    s->sstat0 = 0;
 101.273 +    s->sstat1 = 0;
 101.274 +    s->scid = 7;
 101.275 +    s->sxfer = 0;
 101.276 +    s->socl = 0;
 101.277 +    s->stest1 = 0;
 101.278 +    s->stest2 = 0;
 101.279 +    s->stest3 = 0;
 101.280 +    s->stime0 = 0;
 101.281 +    s->respid0 = 0x80;
 101.282 +    s->respid1 = 0;
 101.283 +    s->mmrs = 0;
 101.284 +    s->mmws = 0;
 101.285 +    s->sfs = 0;
 101.286 +    s->drs = 0;
 101.287 +    s->sbms = 0;
 101.288 +    s->dmbs = 0;
 101.289 +    s->dnad64 = 0;
 101.290 +    s->pmjad1 = 0;
 101.291 +    s->pmjad2 = 0;
 101.292 +    s->rbc = 0;
 101.293 +    s->ua = 0;
 101.294 +    s->ia = 0;
 101.295 +    s->sbc = 0;
 101.296 +    s->csbc = 0;
 101.297 +}
 101.298 +
 101.299 +static uint8_t lsi_reg_readb(LSIState *s, int offset);
 101.300 +static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val);
 101.301 +
 101.302 +static inline uint32_t read_dword(LSIState *s, uint32_t addr)
 101.303 +{
 101.304 +    uint32_t buf;
 101.305 +
 101.306 +    /* Optimize reading from SCRIPTS RAM.  */
 101.307 +    if ((addr & 0xffffe000) == s->script_ram_base) {
 101.308 +        return s->script_ram[(addr & 0x1fff) >> 2];
 101.309 +    }
 101.310 +    cpu_physical_memory_read(addr, (uint8_t *)&buf, 4);
 101.311 +    return cpu_to_le32(buf);
 101.312 +}
 101.313 +
 101.314 +static void lsi_stop_script(LSIState *s)
 101.315 +{
 101.316 +    s->istat1 &= ~LSI_ISTAT1_SRUN;
 101.317 +}
 101.318 +
 101.319 +static void lsi_update_irq(LSIState *s)
 101.320 +{
 101.321 +    int level;
 101.322 +    static int last_level;
 101.323 +
 101.324 +    /* It's unclear whether the DIP/SIP bits should be cleared when the
 101.325 +       Interrupt Status Registers are cleared or when istat0 is read.
 101.326 +       We currently do the formwer, which seems to work.  */
 101.327 +    level = 0;
 101.328 +    if (s->dstat) {
 101.329 +        if (s->dstat & s->dien)
 101.330 +            level = 1;
 101.331 +        s->istat0 |= LSI_ISTAT0_DIP;
 101.332 +    } else {
 101.333 +        s->istat0 &= ~LSI_ISTAT0_DIP;
 101.334 +    }
 101.335 +
 101.336 +    if (s->sist0 || s->sist1) {
 101.337 +        if ((s->sist0 & s->sien0) || (s->sist1 & s->sien1))
 101.338 +            level = 1;
 101.339 +        s->istat0 |= LSI_ISTAT0_SIP;
 101.340 +    } else {
 101.341 +        s->istat0 &= ~LSI_ISTAT0_SIP;
 101.342 +    }
 101.343 +    if (s->istat0 & LSI_ISTAT0_INTF)
 101.344 +        level = 1;
 101.345 +
 101.346 +    if (level != last_level) {
 101.347 +        DPRINTF("Update IRQ level %d dstat %02x sist %02x%02x\n",
 101.348 +                level, s->dstat, s->sist1, s->sist0);
 101.349 +        last_level = level;
 101.350 +    }
 101.351 +    pci_set_irq(&s->pci_dev, 0, level);
 101.352 +}
 101.353 +
 101.354 +/* Stop SCRIPTS execution and raise a SCSI interrupt.  */
 101.355 +static void lsi_script_scsi_interrupt(LSIState *s, int stat0, int stat1)
 101.356 +{
 101.357 +    uint32_t mask0;
 101.358 +    uint32_t mask1;
 101.359 +
 101.360 +    DPRINTF("SCSI Interrupt 0x%02x%02x prev 0x%02x%02x\n",
 101.361 +            stat1, stat0, s->sist1, s->sist0);
 101.362 +    s->sist0 |= stat0;
 101.363 +    s->sist1 |= stat1;
 101.364 +    /* Stop processor on fatal or unmasked interrupt.  As a special hack
 101.365 +       we don't stop processing when raising STO.  Instead continue
 101.366 +       execution and stop at the next insn that accesses the SCSI bus.  */
 101.367 +    mask0 = s->sien0 | ~(LSI_SIST0_CMP | LSI_SIST0_SEL | LSI_SIST0_RSL);
 101.368 +    mask1 = s->sien1 | ~(LSI_SIST1_GEN | LSI_SIST1_HTH);
 101.369 +    mask1 &= ~LSI_SIST1_STO;
 101.370 +    if (s->sist0 & mask0 || s->sist1 & mask1) {
 101.371 +        lsi_stop_script(s);
 101.372 +    }
 101.373 +    lsi_update_irq(s);
 101.374 +}
 101.375 +
 101.376 +/* Stop SCRIPTS execution and raise a DMA interrupt.  */
 101.377 +static void lsi_script_dma_interrupt(LSIState *s, int stat)
 101.378 +{
 101.379 +    DPRINTF("DMA Interrupt 0x%x prev 0x%x\n", stat, s->dstat);
 101.380 +    s->dstat |= stat;
 101.381 +    lsi_update_irq(s);
 101.382 +    lsi_stop_script(s);
 101.383 +}
 101.384 +
 101.385 +static inline void lsi_set_phase(LSIState *s, int phase)
 101.386 +{
 101.387 +    s->sstat1 = (s->sstat1 & ~PHASE_MASK) | phase;
 101.388 +}
 101.389 +
 101.390 +static void lsi_bad_phase(LSIState *s, int out, int new_phase)
 101.391 +{
 101.392 +    /* Trigger a phase mismatch.  */
 101.393 +    if (s->ccntl0 & LSI_CCNTL0_ENPMJ) {
 101.394 +        if ((s->ccntl0 & LSI_CCNTL0_PMJCTL) || out) {
 101.395 +            s->dsp = s->pmjad1;
 101.396 +        } else {
 101.397 +            s->dsp = s->pmjad2;
 101.398 +        }
 101.399 +        DPRINTF("Data phase mismatch jump to %08x\n", s->dsp);
 101.400 +    } else {
 101.401 +        DPRINTF("Phase mismatch interrupt\n");
 101.402 +        lsi_script_scsi_interrupt(s, LSI_SIST0_MA, 0);
 101.403 +        lsi_stop_script(s);
 101.404 +    }
 101.405 +    lsi_set_phase(s, new_phase);
 101.406 +}
 101.407 +
 101.408 +static void lsi_do_dma(LSIState *s, int out)
 101.409 +{
 101.410 +    uint8_t buf[TARGET_PAGE_SIZE];
 101.411 +    uint32_t addr;
 101.412 +    uint32_t count;
 101.413 +    int n;
 101.414 +
 101.415 +    count = s->dbc;
 101.416 +    addr = s->dnad;
 101.417 +    DPRINTF("DMA %s addr=0x%08x len=%d avail=%d\n", out ? "out" : "in",
 101.418 +            addr, count, s->data_len);
 101.419 +    /* ??? Too long transfers are truncated. Don't know if this is the
 101.420 +       correct behavior.  */
 101.421 +    if (count > s->data_len) {
 101.422 +        /* If the DMA length is greater then the device data length then
 101.423 +           a phase mismatch will occur.  */
 101.424 +        count = s->data_len;
 101.425 +        s->dbc = count;
 101.426 +        lsi_bad_phase(s, out, PHASE_ST);
 101.427 +    }
 101.428 +
 101.429 +    s->csbc += count;
 101.430 +
 101.431 +    /* ??? Set SFBR to first data byte.  */
 101.432 +    while (count) {
 101.433 +        n = (count > TARGET_PAGE_SIZE) ? TARGET_PAGE_SIZE : count;
 101.434 +        if (out) {
 101.435 +            cpu_physical_memory_read(addr, buf, n);
 101.436 +            scsi_write_data(s->current_dev, buf, n);
 101.437 +        } else {
 101.438 +            scsi_read_data(s->current_dev, buf, n);
 101.439 +            cpu_physical_memory_write(addr, buf, n);
 101.440 +        }
 101.441 +        addr += n;
 101.442 +        count -= n;
 101.443 +    }
 101.444 +}
 101.445 +
 101.446 +
 101.447 +static void lsi_do_command(LSIState *s)
 101.448 +{
 101.449 +    uint8_t buf[16];
 101.450 +    int n;
 101.451 +
 101.452 +    DPRINTF("Send command len=%d\n", s->dbc);
 101.453 +    if (s->dbc > 16)
 101.454 +        s->dbc = 16;
 101.455 +    cpu_physical_memory_read(s->dnad, buf, s->dbc);
 101.456 +    s->sfbr = buf[0];
 101.457 +    n = scsi_send_command(s->current_dev, 0, buf, s->current_lun);
 101.458 +    if (n > 0) {
 101.459 +        s->data_len = n;
 101.460 +        lsi_set_phase(s, PHASE_DI);
 101.461 +    } else if (n < 0) {
 101.462 +        s->data_len = -n;
 101.463 +        lsi_set_phase(s, PHASE_DO);
 101.464 +    }
 101.465 +}
 101.466 +
 101.467 +static void lsi_command_complete(void *opaque, uint32_t tag, int sense)
 101.468 +{
 101.469 +    LSIState *s = (LSIState *)opaque;
 101.470 +
 101.471 +    DPRINTF("Command complete sense=%d\n", sense);
 101.472 +    s->sense = sense;
 101.473 +    lsi_set_phase(s, PHASE_ST);
 101.474 +}
 101.475 +
 101.476 +static void lsi_do_status(LSIState *s)
 101.477 +{
 101.478 +    DPRINTF("Get status len=%d sense=%d\n", s->dbc, s->sense);
 101.479 +    if (s->dbc != 1)
 101.480 +        BADF("Bad Status move\n");
 101.481 +    s->dbc = 1;
 101.482 +    s->msg = s->sense;
 101.483 +    cpu_physical_memory_write(s->dnad, &s->msg, 1);
 101.484 +    s->sfbr = s->msg;
 101.485 +    lsi_set_phase(s, PHASE_MI);
 101.486 +    s->msg = 0; /* COMMAND COMPLETE */
 101.487 +}
 101.488 +
 101.489 +static void lsi_disconnect(LSIState *s)
 101.490 +{
 101.491 +    s->scntl1 &= ~LSI_SCNTL1_CON;
 101.492 +    s->sstat1 &= ~PHASE_MASK;
 101.493 +}
 101.494 +
 101.495 +static void lsi_do_msgin(LSIState *s)
 101.496 +{
 101.497 +    DPRINTF("Message in len=%d\n", s->dbc);
 101.498 +    s->dbc = 1;
 101.499 +    s->sfbr = s->msg;
 101.500 +    cpu_physical_memory_write(s->dnad, &s->msg, 1);
 101.501 +    if (s->msg == 0) {
 101.502 +        lsi_disconnect(s);
 101.503 +    } else {
 101.504 +        /* ??? Check if ATN (not yet implemented) is asserted and maybe
 101.505 +           switch to PHASE_MO.  */
 101.506 +        lsi_set_phase(s, PHASE_CMD);
 101.507 +    }
 101.508 +}
 101.509 +
 101.510 +static void lsi_do_msgout(LSIState *s)
 101.511 +{
 101.512 +    uint8_t msg;
 101.513 +
 101.514 +    DPRINTF("MSG out len=%d\n", s->dbc);
 101.515 +    if (s->dbc != 1) {
 101.516 +        /* Multibyte messages not implemented.  */
 101.517 +        s->msg = 7; /* MESSAGE REJECT */
 101.518 +        //s->dbc = 1;
 101.519 +        //lsi_bad_phase(s, 1, PHASE_MI);
 101.520 +        lsi_set_phase(s, PHASE_MI);
 101.521 +        return;
 101.522 +    }
 101.523 +    cpu_physical_memory_read(s->dnad, &msg, 1);
 101.524 +    s->sfbr = msg;
 101.525 +    s->dnad++;
 101.526 +
 101.527 +    switch (msg) {
 101.528 +    case 0x00:
 101.529 +        DPRINTF("Got Disconnect\n");
 101.530 +        lsi_disconnect(s);
 101.531 +        return;
 101.532 +    case 0x08:
 101.533 +        DPRINTF("Got No Operation\n");
 101.534 +        lsi_set_phase(s, PHASE_CMD);
 101.535 +        return;
 101.536 +    }
 101.537 +    if ((msg & 0x80) == 0) {
 101.538 +        DPRINTF("Unimplemented message 0x%d\n", msg);
 101.539 +        s->msg = 7; /* MESSAGE REJECT */
 101.540 +        lsi_bad_phase(s, 1, PHASE_MI);
 101.541 +        return;
 101.542 +    }
 101.543 +    s->current_lun = msg & 7;
 101.544 +    DPRINTF("Select LUN %d\n", s->current_lun);
 101.545 +    lsi_set_phase(s, PHASE_CMD);
 101.546 +}
 101.547 +
 101.548 +/* Sign extend a 24-bit value.  */
 101.549 +static inline int32_t sxt24(int32_t n)
 101