ia64/xen-unstable

changeset 15141:0e5c0cde23b1

[IA64] lindent dom_fw_foo code

Lindent the dom_fw_<foo> code to revert formatting that was done as
part of splitting up the files.

Signed-off-by: Jes Sorensen <jes@sgi.com>
author Alex Williamson <alex.williamson@hp.com>
date Fri May 25 09:33:01 2007 -0600 (2007-05-25)
parents 034f3e20ad10
children 2372c3fbf7d2
files xen/arch/ia64/xen/dom_fw_dom0.c xen/arch/ia64/xen/dom_fw_domu.c xen/arch/ia64/xen/dom_fw_utils.c
line diff
     1.1 --- a/xen/arch/ia64/xen/dom_fw_dom0.c	Thu May 24 16:28:48 2007 -0600
     1.2 +++ b/xen/arch/ia64/xen/dom_fw_dom0.c	Fri May 25 09:33:01 2007 -0600
     1.3 @@ -39,354 +39,352 @@ static u32 lsapic_nbr;
     1.4  
     1.5  /* Modify lsapic table.  Provides LPs.  */
     1.6  static int __init
     1.7 -acpi_update_lsapic(acpi_table_entry_header *header, const unsigned long end)
     1.8 +acpi_update_lsapic(acpi_table_entry_header * header, const unsigned long end)
     1.9  {
    1.10 -    struct acpi_table_lsapic *lsapic;
    1.11 -    int enable;
    1.12 +	struct acpi_table_lsapic *lsapic;
    1.13 +	int enable;
    1.14  
    1.15 -    lsapic = (struct acpi_table_lsapic *) header;
    1.16 -    if (!lsapic)
    1.17 -        return -EINVAL;
    1.18 +	lsapic = (struct acpi_table_lsapic *)header;
    1.19 +	if (!lsapic)
    1.20 +		return -EINVAL;
    1.21  
    1.22 -    if (lsapic_nbr < MAX_VIRT_CPUS && dom0->vcpu[lsapic_nbr] != NULL)
    1.23 -        enable = 1;
    1.24 -    else
    1.25 -        enable = 0;
    1.26 +	if (lsapic_nbr < MAX_VIRT_CPUS && dom0->vcpu[lsapic_nbr] != NULL)
    1.27 +		enable = 1;
    1.28 +	else
    1.29 +		enable = 0;
    1.30  
    1.31 -    if (lsapic->flags.enabled && enable) {
    1.32 -        printk("enable lsapic entry: 0x%lx\n", (u64)lsapic);
    1.33 -        lsapic->id = lsapic_nbr;
    1.34 -        lsapic->eid = 0;
    1.35 -        lsapic_nbr++;
    1.36 -    } else if (lsapic->flags.enabled) {
    1.37 -        printk("DISABLE lsapic entry: 0x%lx\n", (u64)lsapic);
    1.38 -        lsapic->flags.enabled = 0;
    1.39 -        lsapic->id = 0;
    1.40 -        lsapic->eid = 0;
    1.41 -    }
    1.42 -    return 0;
    1.43 +	if (lsapic->flags.enabled && enable) {
    1.44 +		printk("enable lsapic entry: 0x%lx\n", (u64) lsapic);
    1.45 +		lsapic->id = lsapic_nbr;
    1.46 +		lsapic->eid = 0;
    1.47 +		lsapic_nbr++;
    1.48 +	} else if (lsapic->flags.enabled) {
    1.49 +		printk("DISABLE lsapic entry: 0x%lx\n", (u64) lsapic);
    1.50 +		lsapic->flags.enabled = 0;
    1.51 +		lsapic->id = 0;
    1.52 +		lsapic->eid = 0;
    1.53 +	}
    1.54 +	return 0;
    1.55  }
    1.56  
    1.57  static int __init
    1.58 -acpi_patch_plat_int_src(acpi_table_entry_header *header,
    1.59 -                        const unsigned long end)
    1.60 +acpi_patch_plat_int_src(acpi_table_entry_header * header,
    1.61 +			const unsigned long end)
    1.62  {
    1.63 -    struct acpi_table_plat_int_src *plintsrc;
    1.64 +	struct acpi_table_plat_int_src *plintsrc;
    1.65  
    1.66 -    plintsrc = (struct acpi_table_plat_int_src *)header;
    1.67 -    if (!plintsrc)
    1.68 -        return -EINVAL;
    1.69 +	plintsrc = (struct acpi_table_plat_int_src *)header;
    1.70 +	if (!plintsrc)
    1.71 +		return -EINVAL;
    1.72  
    1.73 -    if (plintsrc->type == ACPI_INTERRUPT_CPEI) {
    1.74 -        printk("ACPI_INTERRUPT_CPEI disabled for Domain0\n");
    1.75 -        plintsrc->type = -1;
    1.76 -    }
    1.77 -    return 0;
    1.78 +	if (plintsrc->type == ACPI_INTERRUPT_CPEI) {
    1.79 +		printk("ACPI_INTERRUPT_CPEI disabled for Domain0\n");
    1.80 +		plintsrc->type = -1;
    1.81 +	}
    1.82 +	return 0;
    1.83  }
    1.84  
    1.85  static int __init
    1.86  acpi_update_madt_checksum(unsigned long phys_addr, unsigned long size)
    1.87  {
    1.88 -    struct acpi_table_madt* acpi_madt;
    1.89 +	struct acpi_table_madt *acpi_madt;
    1.90  
    1.91 -    if (!phys_addr || !size)
    1.92 -        return -EINVAL;
    1.93 +	if (!phys_addr || !size)
    1.94 +		return -EINVAL;
    1.95  
    1.96 -    acpi_madt = (struct acpi_table_madt *) __va(phys_addr);
    1.97 -    acpi_madt->header.checksum = 0;
    1.98 -    acpi_madt->header.checksum = generate_acpi_checksum(acpi_madt, size);
    1.99 +	acpi_madt = (struct acpi_table_madt *)__va(phys_addr);
   1.100 +	acpi_madt->header.checksum = 0;
   1.101 +	acpi_madt->header.checksum = generate_acpi_checksum(acpi_madt, size);
   1.102  
   1.103 -    return 0;
   1.104 +	return 0;
   1.105  }
   1.106  
   1.107  /* base is physical address of acpi table */
   1.108 -static void __init
   1.109 -touch_acpi_table(void)
   1.110 +static void __init touch_acpi_table(void)
   1.111  {
   1.112 -    lsapic_nbr = 0;
   1.113 +	lsapic_nbr = 0;
   1.114  
   1.115 -    if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_update_lsapic, 0) < 0)
   1.116 -        printk("Error parsing MADT - no LAPIC entries\n");
   1.117 -    if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC,
   1.118 -                              acpi_patch_plat_int_src, 0) < 0)
   1.119 -        printk("Error parsing MADT - no PLAT_INT_SRC entries\n");
   1.120 +	if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_update_lsapic, 0) < 0)
   1.121 +		printk("Error parsing MADT - no LAPIC entries\n");
   1.122 +	if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC,
   1.123 +				  acpi_patch_plat_int_src, 0) < 0)
   1.124 +		printk("Error parsing MADT - no PLAT_INT_SRC entries\n");
   1.125  
   1.126 -    acpi_table_parse(ACPI_APIC, acpi_update_madt_checksum);
   1.127 +	acpi_table_parse(ACPI_APIC, acpi_update_madt_checksum);
   1.128  
   1.129 -    return;
   1.130 +	return;
   1.131  }
   1.132  
   1.133 -void __init
   1.134 -efi_systable_init_dom0(struct fw_tables *tables)
   1.135 +void __init efi_systable_init_dom0(struct fw_tables *tables)
   1.136  {
   1.137 -    int i = 1;
   1.138 +	int i = 1;
   1.139  
   1.140 -    /* Write messages to the console.  */
   1.141 -    touch_acpi_table();
   1.142 +	/* Write messages to the console.  */
   1.143 +	touch_acpi_table();
   1.144  
   1.145 -    printk("Domain0 EFI passthrough:");
   1.146 -    if (efi.mps) {
   1.147 -        tables->efi_tables[i].guid = MPS_TABLE_GUID;
   1.148 -        tables->efi_tables[i].table = __pa(efi.mps);
   1.149 -        printk(" MPS=0x%lx",tables->efi_tables[i].table);
   1.150 -        i++;
   1.151 -    }
   1.152 -    if (efi.acpi20) {
   1.153 -        tables->efi_tables[i].guid = ACPI_20_TABLE_GUID;
   1.154 -        tables->efi_tables[i].table = __pa(efi.acpi20);
   1.155 -        printk(" ACPI 2.0=0x%lx",tables->efi_tables[i].table);
   1.156 -        i++;
   1.157 -    }
   1.158 -    if (efi.acpi) {
   1.159 -        tables->efi_tables[i].guid = ACPI_TABLE_GUID;
   1.160 -        tables->efi_tables[i].table = __pa(efi.acpi);
   1.161 -        printk(" ACPI=0x%lx",tables->efi_tables[i].table);
   1.162 -        i++;
   1.163 -    }
   1.164 -    if (efi.smbios) {
   1.165 -        tables->efi_tables[i].guid = SMBIOS_TABLE_GUID;
   1.166 -        tables->efi_tables[i].table = __pa(efi.smbios);
   1.167 -        printk(" SMBIOS=0x%lx",tables->efi_tables[i].table);
   1.168 -        i++;
   1.169 -    }
   1.170 -    if (efi.hcdp) {
   1.171 -        tables->efi_tables[i].guid = HCDP_TABLE_GUID;
   1.172 -        tables->efi_tables[i].table = __pa(efi.hcdp);
   1.173 -        printk(" HCDP=0x%lx",tables->efi_tables[i].table);
   1.174 -        i++;
   1.175 -    }
   1.176 -    printk("\n");
   1.177 -    BUG_ON(i > NUM_EFI_SYS_TABLES);
   1.178 +	printk("Domain0 EFI passthrough:");
   1.179 +	if (efi.mps) {
   1.180 +		tables->efi_tables[i].guid = MPS_TABLE_GUID;
   1.181 +		tables->efi_tables[i].table = __pa(efi.mps);
   1.182 +		printk(" MPS=0x%lx", tables->efi_tables[i].table);
   1.183 +		i++;
   1.184 +	}
   1.185 +	if (efi.acpi20) {
   1.186 +		tables->efi_tables[i].guid = ACPI_20_TABLE_GUID;
   1.187 +		tables->efi_tables[i].table = __pa(efi.acpi20);
   1.188 +		printk(" ACPI 2.0=0x%lx", tables->efi_tables[i].table);
   1.189 +		i++;
   1.190 +	}
   1.191 +	if (efi.acpi) {
   1.192 +		tables->efi_tables[i].guid = ACPI_TABLE_GUID;
   1.193 +		tables->efi_tables[i].table = __pa(efi.acpi);
   1.194 +		printk(" ACPI=0x%lx", tables->efi_tables[i].table);
   1.195 +		i++;
   1.196 +	}
   1.197 +	if (efi.smbios) {
   1.198 +		tables->efi_tables[i].guid = SMBIOS_TABLE_GUID;
   1.199 +		tables->efi_tables[i].table = __pa(efi.smbios);
   1.200 +		printk(" SMBIOS=0x%lx", tables->efi_tables[i].table);
   1.201 +		i++;
   1.202 +	}
   1.203 +	if (efi.hcdp) {
   1.204 +		tables->efi_tables[i].guid = HCDP_TABLE_GUID;
   1.205 +		tables->efi_tables[i].table = __pa(efi.hcdp);
   1.206 +		printk(" HCDP=0x%lx", tables->efi_tables[i].table);
   1.207 +		i++;
   1.208 +	}
   1.209 +	printk("\n");
   1.210 +	BUG_ON(i > NUM_EFI_SYS_TABLES);
   1.211  }
   1.212  
   1.213  static void __init
   1.214 -setup_dom0_memmap_info(struct domain *d, struct fw_tables *tables,
   1.215 -                       int *num_mds)
   1.216 +setup_dom0_memmap_info(struct domain *d, struct fw_tables *tables, int *num_mds)
   1.217  {
   1.218 -    int i;
   1.219 -    efi_memory_desc_t *md;
   1.220 -    efi_memory_desc_t *last_mem_md = NULL;
   1.221 -    xen_ia64_memmap_info_t* memmap_info;
   1.222 -    unsigned long paddr_start;
   1.223 -    unsigned long paddr_end;
   1.224 +	int i;
   1.225 +	efi_memory_desc_t *md;
   1.226 +	efi_memory_desc_t *last_mem_md = NULL;
   1.227 +	xen_ia64_memmap_info_t *memmap_info;
   1.228 +	unsigned long paddr_start;
   1.229 +	unsigned long paddr_end;
   1.230  
   1.231 -    for (i = *num_mds - 1; i >= 0; i--) {
   1.232 -        md = &tables->efi_memmap[i];
   1.233 -        if (md->attribute == EFI_MEMORY_WB &&
   1.234 -            md->type == EFI_CONVENTIONAL_MEMORY &&
   1.235 -            md->num_pages > 2 * (1UL << (PAGE_SHIFT - EFI_PAGE_SHIFT))) {
   1.236 -            last_mem_md = md;
   1.237 -            break;
   1.238 -        }
   1.239 -    }
   1.240 +	for (i = *num_mds - 1; i >= 0; i--) {
   1.241 +		md = &tables->efi_memmap[i];
   1.242 +		if (md->attribute == EFI_MEMORY_WB &&
   1.243 +		    md->type == EFI_CONVENTIONAL_MEMORY &&
   1.244 +		    md->num_pages >
   1.245 +		    2 * (1UL << (PAGE_SHIFT - EFI_PAGE_SHIFT))) {
   1.246 +			last_mem_md = md;
   1.247 +			break;
   1.248 +		}
   1.249 +	}
   1.250  
   1.251 -    if (last_mem_md == NULL) {
   1.252 -        printk("%s: warning: "
   1.253 -               "no dom0 contiguous memory to hold memory map\n",
   1.254 -               __func__);
   1.255 -        return;
   1.256 -    }
   1.257 -    paddr_end = last_mem_md->phys_addr +
   1.258 -        (last_mem_md->num_pages << EFI_PAGE_SHIFT);
   1.259 -    paddr_start = (paddr_end - PAGE_SIZE) & PAGE_MASK;
   1.260 -    last_mem_md->num_pages -=
   1.261 -        (paddr_end - paddr_start) / (1UL << EFI_PAGE_SHIFT);
   1.262 +	if (last_mem_md == NULL) {
   1.263 +		printk("%s: warning: "
   1.264 +		       "no dom0 contiguous memory to hold memory map\n",
   1.265 +		       __func__);
   1.266 +		return;
   1.267 +	}
   1.268 +	paddr_end = last_mem_md->phys_addr +
   1.269 +	    (last_mem_md->num_pages << EFI_PAGE_SHIFT);
   1.270 +	paddr_start = (paddr_end - PAGE_SIZE) & PAGE_MASK;
   1.271 +	last_mem_md->num_pages -=
   1.272 +	    (paddr_end - paddr_start) / (1UL << EFI_PAGE_SHIFT);
   1.273  
   1.274 -    md = &tables->efi_memmap[*num_mds];
   1.275 -    (*num_mds)++;
   1.276 -    md->type = EFI_RUNTIME_SERVICES_DATA;
   1.277 -    md->phys_addr = paddr_start;
   1.278 -    md->virt_addr = 0;
   1.279 -    md->num_pages = 1UL << (PAGE_SHIFT - EFI_PAGE_SHIFT);
   1.280 -    md->attribute = EFI_MEMORY_WB;
   1.281 +	md = &tables->efi_memmap[*num_mds];
   1.282 +	(*num_mds)++;
   1.283 +	md->type = EFI_RUNTIME_SERVICES_DATA;
   1.284 +	md->phys_addr = paddr_start;
   1.285 +	md->virt_addr = 0;
   1.286 +	md->num_pages = 1UL << (PAGE_SHIFT - EFI_PAGE_SHIFT);
   1.287 +	md->attribute = EFI_MEMORY_WB;
   1.288  
   1.289 -    memmap_info = domain_mpa_to_imva(d, md->phys_addr);
   1.290 -    BUG_ON(*num_mds > NUM_MEM_DESCS);
   1.291 +	memmap_info = domain_mpa_to_imva(d, md->phys_addr);
   1.292 +	BUG_ON(*num_mds > NUM_MEM_DESCS);
   1.293  
   1.294 -    memmap_info->efi_memdesc_size = sizeof(md[0]);
   1.295 -    memmap_info->efi_memdesc_version = EFI_MEMORY_DESCRIPTOR_VERSION;
   1.296 -    memmap_info->efi_memmap_size = *num_mds * sizeof(md[0]);
   1.297 -    memcpy(&memmap_info->memdesc, &tables->efi_memmap[0],
   1.298 -           memmap_info->efi_memmap_size);
   1.299 -    d->shared_info->arch.memmap_info_num_pages = 1;
   1.300 -    d->shared_info->arch.memmap_info_pfn = md->phys_addr >> PAGE_SHIFT;
   1.301 +	memmap_info->efi_memdesc_size = sizeof(md[0]);
   1.302 +	memmap_info->efi_memdesc_version = EFI_MEMORY_DESCRIPTOR_VERSION;
   1.303 +	memmap_info->efi_memmap_size = *num_mds * sizeof(md[0]);
   1.304 +	memcpy(&memmap_info->memdesc, &tables->efi_memmap[0],
   1.305 +	       memmap_info->efi_memmap_size);
   1.306 +	d->shared_info->arch.memmap_info_num_pages = 1;
   1.307 +	d->shared_info->arch.memmap_info_pfn = md->phys_addr >> PAGE_SHIFT;
   1.308  
   1.309 -    sort(tables->efi_memmap, *num_mds, sizeof(efi_memory_desc_t),
   1.310 -         efi_mdt_cmp, NULL);
   1.311 +	sort(tables->efi_memmap, *num_mds, sizeof(efi_memory_desc_t),
   1.312 +	     efi_mdt_cmp, NULL);
   1.313  }
   1.314  
   1.315  /* Complete the dom0 memmap.  */
   1.316  int __init
   1.317  complete_dom0_memmap(struct domain *d,
   1.318 -                     struct fw_tables *tables,
   1.319 -                     unsigned long maxmem,
   1.320 -                     int num_mds)
   1.321 +		     struct fw_tables *tables,
   1.322 +		     unsigned long maxmem, int num_mds)
   1.323  {
   1.324 -    efi_memory_desc_t *md;
   1.325 -    u64 addr;
   1.326 -    void *efi_map_start, *efi_map_end, *p;
   1.327 -    u64 efi_desc_size;
   1.328 -    int i;
   1.329 -    unsigned long dom_mem = maxmem - (d->tot_pages << PAGE_SHIFT);
   1.330 +	efi_memory_desc_t *md;
   1.331 +	u64 addr;
   1.332 +	void *efi_map_start, *efi_map_end, *p;
   1.333 +	u64 efi_desc_size;
   1.334 +	int i;
   1.335 +	unsigned long dom_mem = maxmem - (d->tot_pages << PAGE_SHIFT);
   1.336  
   1.337 -    /* Walk through all MDT entries.
   1.338 -       Copy all interesting entries.  */
   1.339 -    efi_map_start = __va(ia64_boot_param->efi_memmap);
   1.340 -    efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
   1.341 -    efi_desc_size = ia64_boot_param->efi_memdesc_size;
   1.342 +	/* Walk through all MDT entries.
   1.343 +	   Copy all interesting entries.  */
   1.344 +	efi_map_start = __va(ia64_boot_param->efi_memmap);
   1.345 +	efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
   1.346 +	efi_desc_size = ia64_boot_param->efi_memdesc_size;
   1.347  
   1.348 -    for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
   1.349 -        const efi_memory_desc_t *md = p;
   1.350 -        efi_memory_desc_t *dom_md = &tables->efi_memmap[num_mds];
   1.351 -        u64 start = md->phys_addr;
   1.352 -        u64 size = md->num_pages << EFI_PAGE_SHIFT;
   1.353 -        u64 end = start + size;
   1.354 -        u64 mpaddr;
   1.355 -        unsigned long flags;
   1.356 +	for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
   1.357 +		const efi_memory_desc_t *md = p;
   1.358 +		efi_memory_desc_t *dom_md = &tables->efi_memmap[num_mds];
   1.359 +		u64 start = md->phys_addr;
   1.360 +		u64 size = md->num_pages << EFI_PAGE_SHIFT;
   1.361 +		u64 end = start + size;
   1.362 +		u64 mpaddr;
   1.363 +		unsigned long flags;
   1.364  
   1.365 -        switch (md->type) {
   1.366 -        case EFI_RUNTIME_SERVICES_CODE:
   1.367 -        case EFI_RUNTIME_SERVICES_DATA:
   1.368 -        case EFI_ACPI_RECLAIM_MEMORY:
   1.369 -        case EFI_ACPI_MEMORY_NVS:
   1.370 -        case EFI_RESERVED_TYPE:
   1.371 -            /*
   1.372 -             * Map into dom0 - We must respect protection
   1.373 -             * and cache attributes.  Not all of these pages
   1.374 -             * are writable!!!
   1.375 -             */
   1.376 -            flags = ASSIGN_writable;    /* dummy - zero */
   1.377 -            if (md->attribute & EFI_MEMORY_WP)
   1.378 -                flags |= ASSIGN_readonly;
   1.379 -            if ((md->attribute & EFI_MEMORY_UC) &&
   1.380 -                !(md->attribute & EFI_MEMORY_WB))
   1.381 -                flags |= ASSIGN_nocache;
   1.382 +		switch (md->type) {
   1.383 +		case EFI_RUNTIME_SERVICES_CODE:
   1.384 +		case EFI_RUNTIME_SERVICES_DATA:
   1.385 +		case EFI_ACPI_RECLAIM_MEMORY:
   1.386 +		case EFI_ACPI_MEMORY_NVS:
   1.387 +		case EFI_RESERVED_TYPE:
   1.388 +			/*
   1.389 +			 * Map into dom0 - We must respect protection
   1.390 +			 * and cache attributes.  Not all of these pages
   1.391 +			 * are writable!!!
   1.392 +			 */
   1.393 +			flags = ASSIGN_writable;	/* dummy - zero */
   1.394 +			if (md->attribute & EFI_MEMORY_WP)
   1.395 +				flags |= ASSIGN_readonly;
   1.396 +			if ((md->attribute & EFI_MEMORY_UC) &&
   1.397 +			    !(md->attribute & EFI_MEMORY_WB))
   1.398 +				flags |= ASSIGN_nocache;
   1.399  
   1.400 -            assign_domain_mach_page(d, start, size, flags);
   1.401 +			assign_domain_mach_page(d, start, size, flags);
   1.402  
   1.403 -            /* Fall-through.  */
   1.404 -        case EFI_MEMORY_MAPPED_IO:
   1.405 -            /* Will be mapped with ioremap.  */
   1.406 -            /* Copy descriptor.  */
   1.407 -            *dom_md = *md;
   1.408 -            dom_md->virt_addr = 0;
   1.409 -            num_mds++;
   1.410 -            break;
   1.411 +			/* Fall-through.  */
   1.412 +		case EFI_MEMORY_MAPPED_IO:
   1.413 +			/* Will be mapped with ioremap.  */
   1.414 +			/* Copy descriptor.  */
   1.415 +			*dom_md = *md;
   1.416 +			dom_md->virt_addr = 0;
   1.417 +			num_mds++;
   1.418 +			break;
   1.419  
   1.420 -        case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
   1.421 -            flags = ASSIGN_writable;    /* dummy - zero */
   1.422 -            if (md->attribute & EFI_MEMORY_UC)
   1.423 -                flags |= ASSIGN_nocache;
   1.424 +		case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
   1.425 +			flags = ASSIGN_writable;	/* dummy - zero */
   1.426 +			if (md->attribute & EFI_MEMORY_UC)
   1.427 +				flags |= ASSIGN_nocache;
   1.428  
   1.429 -            if (start > 0x1ffffffff0000000UL) {
   1.430 -                mpaddr = 0x4000000000000UL - size;
   1.431 -                printk(XENLOG_INFO "Remapping IO ports from "
   1.432 -                       "%lx to %lx\n", start, mpaddr);
   1.433 -            } else
   1.434 -                mpaddr = start;
   1.435 +			if (start > 0x1ffffffff0000000UL) {
   1.436 +				mpaddr = 0x4000000000000UL - size;
   1.437 +				printk(XENLOG_INFO "Remapping IO ports from "
   1.438 +				       "%lx to %lx\n", start, mpaddr);
   1.439 +			} else
   1.440 +				mpaddr = start;
   1.441  
   1.442 -            /* Map into dom0.  */
   1.443 -            assign_domain_mmio_page(d, mpaddr, start, size, flags);
   1.444 -            /* Copy descriptor.  */
   1.445 -            *dom_md = *md;
   1.446 -            dom_md->phys_addr = mpaddr;
   1.447 -            dom_md->virt_addr = 0;
   1.448 -            num_mds++;
   1.449 -            break;
   1.450 +			/* Map into dom0.  */
   1.451 +			assign_domain_mmio_page(d, mpaddr, start, size, flags);
   1.452 +			/* Copy descriptor.  */
   1.453 +			*dom_md = *md;
   1.454 +			dom_md->phys_addr = mpaddr;
   1.455 +			dom_md->virt_addr = 0;
   1.456 +			num_mds++;
   1.457 +			break;
   1.458  
   1.459 -        case EFI_CONVENTIONAL_MEMORY:
   1.460 -        case EFI_LOADER_CODE:
   1.461 -        case EFI_LOADER_DATA:
   1.462 -        case EFI_BOOT_SERVICES_CODE:
   1.463 -        case EFI_BOOT_SERVICES_DATA:
   1.464 -            if (!(md->attribute & EFI_MEMORY_WB))
   1.465 -                break;
   1.466 +		case EFI_CONVENTIONAL_MEMORY:
   1.467 +		case EFI_LOADER_CODE:
   1.468 +		case EFI_LOADER_DATA:
   1.469 +		case EFI_BOOT_SERVICES_CODE:
   1.470 +		case EFI_BOOT_SERVICES_DATA:
   1.471 +			if (!(md->attribute & EFI_MEMORY_WB))
   1.472 +				break;
   1.473  
   1.474 -            start = max(FW_END_PADDR, start);
   1.475 -            end = min(start + dom_mem, end);
   1.476 -            if (end <= start)
   1.477 -                break;
   1.478 +			start = max(FW_END_PADDR, start);
   1.479 +			end = min(start + dom_mem, end);
   1.480 +			if (end <= start)
   1.481 +				break;
   1.482  
   1.483 -            dom_md->type = EFI_CONVENTIONAL_MEMORY;
   1.484 -            dom_md->phys_addr = start;
   1.485 -            dom_md->virt_addr = 0;
   1.486 -            dom_md->num_pages = (end - start) >> EFI_PAGE_SHIFT;
   1.487 -            dom_md->attribute = EFI_MEMORY_WB;
   1.488 -            num_mds++;
   1.489 +			dom_md->type = EFI_CONVENTIONAL_MEMORY;
   1.490 +			dom_md->phys_addr = start;
   1.491 +			dom_md->virt_addr = 0;
   1.492 +			dom_md->num_pages = (end - start) >> EFI_PAGE_SHIFT;
   1.493 +			dom_md->attribute = EFI_MEMORY_WB;
   1.494 +			num_mds++;
   1.495  
   1.496 -            dom_mem -= dom_md->num_pages << EFI_PAGE_SHIFT;
   1.497 -            break;
   1.498 +			dom_mem -= dom_md->num_pages << EFI_PAGE_SHIFT;
   1.499 +			break;
   1.500  
   1.501 -        case EFI_UNUSABLE_MEMORY:
   1.502 -        case EFI_PAL_CODE:
   1.503 -            /*
   1.504 -             * We don't really need these, but holes in the
   1.505 -             * memory map may cause Linux to assume there are
   1.506 -             * uncacheable ranges within a granule.
   1.507 -             */
   1.508 -            dom_md->type = EFI_UNUSABLE_MEMORY;
   1.509 -            dom_md->phys_addr = start;
   1.510 -            dom_md->virt_addr = 0;
   1.511 -            dom_md->num_pages = (end - start) >> EFI_PAGE_SHIFT;
   1.512 -            dom_md->attribute = EFI_MEMORY_WB;
   1.513 -            num_mds++;
   1.514 -            break;
   1.515 +		case EFI_UNUSABLE_MEMORY:
   1.516 +		case EFI_PAL_CODE:
   1.517 +			/*
   1.518 +			 * We don't really need these, but holes in the
   1.519 +			 * memory map may cause Linux to assume there are
   1.520 +			 * uncacheable ranges within a granule.
   1.521 +			 */
   1.522 +			dom_md->type = EFI_UNUSABLE_MEMORY;
   1.523 +			dom_md->phys_addr = start;
   1.524 +			dom_md->virt_addr = 0;
   1.525 +			dom_md->num_pages = (end - start) >> EFI_PAGE_SHIFT;
   1.526 +			dom_md->attribute = EFI_MEMORY_WB;
   1.527 +			num_mds++;
   1.528 +			break;
   1.529  
   1.530 -        default:
   1.531 -            /* Print a warning but continue.  */
   1.532 -            printk("complete_dom0_memmap: warning: "
   1.533 -                   "unhandled MDT entry type %u\n", md->type);
   1.534 -        }
   1.535 -    }
   1.536 -    BUG_ON(num_mds > NUM_MEM_DESCS);
   1.537 -    
   1.538 -    sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t),
   1.539 -         efi_mdt_cmp, NULL);
   1.540 +		default:
   1.541 +			/* Print a warning but continue.  */
   1.542 +			printk("complete_dom0_memmap: warning: "
   1.543 +			       "unhandled MDT entry type %u\n", md->type);
   1.544 +		}
   1.545 +	}
   1.546 +	BUG_ON(num_mds > NUM_MEM_DESCS);
   1.547  
   1.548 -    /* setup_guest() @ libxc/xc_linux_build() arranges memory for domU.
   1.549 -     * however no one arranges memory for dom0,
   1.550 -     * instead we allocate pages manually.
   1.551 -     */
   1.552 -    for (i = 0; i < num_mds; i++) {
   1.553 -        md = &tables->efi_memmap[i];
   1.554 +	sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t),
   1.555 +	     efi_mdt_cmp, NULL);
   1.556 +
   1.557 +	/* setup_guest() @ libxc/xc_linux_build() arranges memory for domU.
   1.558 +	 * however no one arranges memory for dom0,
   1.559 +	 * instead we allocate pages manually.
   1.560 +	 */
   1.561 +	for (i = 0; i < num_mds; i++) {
   1.562 +		md = &tables->efi_memmap[i];
   1.563  
   1.564 -        if (md->type == EFI_LOADER_DATA ||
   1.565 -            md->type == EFI_PAL_CODE ||
   1.566 -            md->type == EFI_CONVENTIONAL_MEMORY) {
   1.567 -            unsigned long start = md->phys_addr & PAGE_MASK;
   1.568 -            unsigned long end = md->phys_addr +
   1.569 -                                (md->num_pages << EFI_PAGE_SHIFT);
   1.570 +		if (md->type == EFI_LOADER_DATA ||
   1.571 +		    md->type == EFI_PAL_CODE ||
   1.572 +		    md->type == EFI_CONVENTIONAL_MEMORY) {
   1.573 +			unsigned long start = md->phys_addr & PAGE_MASK;
   1.574 +			unsigned long end = md->phys_addr +
   1.575 +			    (md->num_pages << EFI_PAGE_SHIFT);
   1.576 +
   1.577 +			if (end == start) {
   1.578 +				/* md->num_pages = 0 is allowed. */
   1.579 +				continue;
   1.580 +			}
   1.581  
   1.582 -            if (end == start) {
   1.583 -                /* md->num_pages = 0 is allowed. */
   1.584 -                continue;
   1.585 -            }
   1.586 -            
   1.587 -            for (addr = start; addr < end; addr += PAGE_SIZE)
   1.588 -                assign_new_domain0_page(d, addr);
   1.589 -        }
   1.590 -    }
   1.591 -    // Map low-memory holes & unmapped MMIO for legacy drivers
   1.592 -    for (addr = 0; addr < ONE_MB; addr += PAGE_SIZE) {
   1.593 -        if (domain_page_mapped(d, addr))
   1.594 -            continue;
   1.595 -        
   1.596 -        if (efi_mmio(addr, PAGE_SIZE)) {
   1.597 -            unsigned long flags;
   1.598 -            flags = ASSIGN_writable | ASSIGN_nocache;
   1.599 -            assign_domain_mmio_page(d, addr, addr, PAGE_SIZE, flags);
   1.600 -        }
   1.601 -    }
   1.602 -    setup_dom0_memmap_info(d, tables, &num_mds);
   1.603 -    return num_mds;
   1.604 +			for (addr = start; addr < end; addr += PAGE_SIZE)
   1.605 +				assign_new_domain0_page(d, addr);
   1.606 +		}
   1.607 +	}
   1.608 +	// Map low-memory holes & unmapped MMIO for legacy drivers
   1.609 +	for (addr = 0; addr < ONE_MB; addr += PAGE_SIZE) {
   1.610 +		if (domain_page_mapped(d, addr))
   1.611 +			continue;
   1.612 +
   1.613 +		if (efi_mmio(addr, PAGE_SIZE)) {
   1.614 +			unsigned long flags;
   1.615 +			flags = ASSIGN_writable | ASSIGN_nocache;
   1.616 +			assign_domain_mmio_page(d, addr, addr, PAGE_SIZE,
   1.617 +						flags);
   1.618 +		}
   1.619 +	}
   1.620 +	setup_dom0_memmap_info(d, tables, &num_mds);
   1.621 +	return num_mds;
   1.622  }
   1.623  
   1.624  /*
   1.625   * Local variables:
   1.626   * mode: C
   1.627 - * c-set-style: "BSD"
   1.628 - * c-basic-offset: 4
   1.629 - * tab-width: 4
   1.630 - * indent-tabs-mode: nil
   1.631 + * c-set-style: "linux"
   1.632 + * c-basic-offset: 8
   1.633 + * tab-width: 8
   1.634 + * indent-tabs-mode: t
   1.635   * End:
   1.636   */
     2.1 --- a/xen/arch/ia64/xen/dom_fw_domu.c	Thu May 24 16:28:48 2007 -0600
     2.2 +++ b/xen/arch/ia64/xen/dom_fw_domu.c	Fri May 25 09:33:01 2007 -0600
     2.3 @@ -47,173 +47,179 @@
     2.4  #include <asm/dom_fw.h>
     2.5  #include <asm/dom_fw_domu.h>
     2.6  
     2.7 -void
     2.8 -efi_systable_init_domu(struct fw_tables *tables)
     2.9 +void efi_systable_init_domu(struct fw_tables *tables)
    2.10  {
    2.11 -    int i = 1;
    2.12 +	int i = 1;
    2.13  
    2.14 -    printk(XENLOG_GUEST XENLOG_INFO "DomainU EFI build up:");
    2.15 +	printk(XENLOG_GUEST XENLOG_INFO "DomainU EFI build up:");
    2.16  
    2.17 -    tables->efi_tables[i].guid = ACPI_20_TABLE_GUID;
    2.18 -    tables->efi_tables[i].table = FW_ACPI_BASE_PADDR;
    2.19 -    printk(" ACPI 2.0=0x%lx",tables->efi_tables[i].table);
    2.20 -    i++;
    2.21 -    printk("\n");
    2.22 -    BUG_ON(i > NUM_EFI_SYS_TABLES);
    2.23 +	tables->efi_tables[i].guid = ACPI_20_TABLE_GUID;
    2.24 +	tables->efi_tables[i].table = FW_ACPI_BASE_PADDR;
    2.25 +	printk(" ACPI 2.0=0x%lx", tables->efi_tables[i].table);
    2.26 +	i++;
    2.27 +	printk("\n");
    2.28 +	BUG_ON(i > NUM_EFI_SYS_TABLES);
    2.29  }
    2.30  
    2.31  #define MAKE_MD(typ, attr, start, end) \
    2.32  	xen_ia64_efi_make_md((tables), &(i), (typ), (attr), (start), (end))
    2.33  
    2.34  int
    2.35 -complete_domu_memmap(domain_t *d,
    2.36 -                     struct fw_tables *tables,
    2.37 -                     unsigned long maxmem,
    2.38 -                     int num_mds,
    2.39 -                     unsigned long memmap_info_pfn,
    2.40 -                     unsigned long memmap_info_num_pages)
    2.41 +complete_domu_memmap(domain_t * d,
    2.42 +		     struct fw_tables *tables,
    2.43 +		     unsigned long maxmem,
    2.44 +		     int num_mds,
    2.45 +		     unsigned long memmap_info_pfn,
    2.46 +		     unsigned long memmap_info_num_pages)
    2.47  {
    2.48 -    efi_memory_desc_t *md;
    2.49 -    int i = num_mds; /* for MAKE_MD */
    2.50 -    int create_memmap = 0;
    2.51 -    xen_ia64_memmap_info_t* memmap_info;
    2.52 -    unsigned long memmap_info_size;
    2.53 -    unsigned long paddr_start;
    2.54 -    unsigned long paddr_end;
    2.55 -    void *p;
    2.56 -    void *memmap_start;
    2.57 -    void *memmap_end;
    2.58 +	efi_memory_desc_t *md;
    2.59 +	int i = num_mds;	/* for MAKE_MD */
    2.60 +	int create_memmap = 0;
    2.61 +	xen_ia64_memmap_info_t *memmap_info;
    2.62 +	unsigned long memmap_info_size;
    2.63 +	unsigned long paddr_start;
    2.64 +	unsigned long paddr_end;
    2.65 +	void *p;
    2.66 +	void *memmap_start;
    2.67 +	void *memmap_end;
    2.68 +
    2.69 +	if (memmap_info_pfn == 0 || memmap_info_num_pages == 0) {
    2.70 +		/* old domain builder which doesn't setup
    2.71 +		 * memory map. create it for compatibility */
    2.72 +		memmap_info_pfn = (maxmem >> PAGE_SHIFT) - 1;
    2.73 +		memmap_info_num_pages = 1;
    2.74 +		create_memmap = 1;
    2.75 +	}
    2.76 +
    2.77 +	memmap_info_size = memmap_info_num_pages << PAGE_SHIFT;
    2.78 +	paddr_start = memmap_info_pfn << PAGE_SHIFT;
    2.79 +	/* 3 = start info page, xenstore page and console page */
    2.80 +	paddr_end = paddr_start + memmap_info_size + 3 * PAGE_SIZE;
    2.81 +	memmap_info = xen_ia64_dom_fw_map(d, paddr_start);
    2.82  
    2.83 -    if (memmap_info_pfn == 0 || memmap_info_num_pages == 0) {
    2.84 -        /* old domain builder which doesn't setup
    2.85 -         * memory map. create it for compatibility */
    2.86 -        memmap_info_pfn = (maxmem >> PAGE_SHIFT) - 1;
    2.87 -        memmap_info_num_pages = 1;
    2.88 -        create_memmap = 1;
    2.89 -    }
    2.90 -
    2.91 -    memmap_info_size = memmap_info_num_pages << PAGE_SHIFT;
    2.92 -    paddr_start = memmap_info_pfn << PAGE_SHIFT;
    2.93 -    /* 3 = start info page, xenstore page and console page */
    2.94 -    paddr_end = paddr_start + memmap_info_size + 3 * PAGE_SIZE;
    2.95 -    memmap_info = xen_ia64_dom_fw_map(d, paddr_start);
    2.96 +	if (memmap_info->efi_memmap_size == 0) {
    2.97 +		create_memmap = 1;
    2.98 +	} else if (memmap_info->efi_memdesc_size != sizeof(md[0]) ||
    2.99 +		   memmap_info->efi_memdesc_version !=
   2.100 +		   EFI_MEMORY_DESCRIPTOR_VERSION) {
   2.101 +		printk(XENLOG_WARNING
   2.102 +		       "%s: Warning: unknown memory map "
   2.103 +		       "memmap size %" PRIu64 " "
   2.104 +		       "memdesc size %" PRIu64 " "
   2.105 +		       "version %" PRIu32 "\n",
   2.106 +		       __func__,
   2.107 +		       memmap_info->efi_memmap_size,
   2.108 +		       memmap_info->efi_memdesc_size,
   2.109 +		       memmap_info->efi_memdesc_version);
   2.110 +		create_memmap = 1;
   2.111 +	} else if (memmap_info_size < memmap_info->efi_memmap_size) {
   2.112 +		printk(XENLOG_WARNING
   2.113 +		       "%s: Warning: too short memmap info size %" PRIu64 "\n",
   2.114 +		       __func__, memmap_info_size);
   2.115 +		xen_ia64_dom_fw_unmap(d, memmap_info);
   2.116 +		return -EINVAL;
   2.117 +	} else if (memmap_info->efi_memmap_size >
   2.118 +		   PAGE_SIZE - sizeof(*memmap_info)) {
   2.119 +		/*
   2.120 +		 * curently memmap spanning more than single page isn't
   2.121 +		 * supported.
   2.122 +		 */
   2.123 +		printk(XENLOG_WARNING
   2.124 +		       "%s: Warning: too large efi_memmap_size %" PRIu64 "\n",
   2.125 +		       __func__, memmap_info->efi_memmap_size);
   2.126 +		xen_ia64_dom_fw_unmap(d, memmap_info);
   2.127 +		return -ENOSYS;
   2.128 +	}
   2.129  
   2.130 -    if (memmap_info->efi_memmap_size == 0) {
   2.131 -        create_memmap = 1;
   2.132 -    } else if (memmap_info->efi_memdesc_size != sizeof(md[0]) ||
   2.133 -               memmap_info->efi_memdesc_version !=
   2.134 -               EFI_MEMORY_DESCRIPTOR_VERSION) {
   2.135 -        printk(XENLOG_WARNING
   2.136 -               "%s: Warning: unknown memory map "
   2.137 -               "memmap size %"PRIu64" "
   2.138 -               "memdesc size %"PRIu64" "
   2.139 -               "version %"PRIu32"\n",
   2.140 -               __func__,
   2.141 -               memmap_info->efi_memmap_size,
   2.142 -               memmap_info->efi_memdesc_size,
   2.143 -               memmap_info->efi_memdesc_version);
   2.144 -        create_memmap = 1;
   2.145 -    } else if (memmap_info_size < memmap_info->efi_memmap_size) {
   2.146 -        printk(XENLOG_WARNING
   2.147 -               "%s: Warning: too short memmap info size %"PRIu64"\n",
   2.148 -               __func__, memmap_info_size);
   2.149 -        xen_ia64_dom_fw_unmap(d, memmap_info);
   2.150 -        return -EINVAL;
   2.151 -    } else if (memmap_info->efi_memmap_size >
   2.152 -           PAGE_SIZE - sizeof(*memmap_info)) {
   2.153 -        /*
   2.154 -         * curently memmap spanning more than single page isn't
   2.155 -         * supported.
   2.156 -         */
   2.157 -        printk(XENLOG_WARNING
   2.158 -               "%s: Warning: too large efi_memmap_size %"PRIu64"\n",
   2.159 -               __func__, memmap_info->efi_memmap_size);
   2.160 -        xen_ia64_dom_fw_unmap(d, memmap_info);
   2.161 -        return -ENOSYS;
   2.162 -    }
   2.163 -    
   2.164 -    if (create_memmap) {
   2.165 -        /*
   2.166 -         * old domain builder which doesn't setup
   2.167 -         * memory map. create it for compatibility
   2.168 -         */
   2.169 -        memmap_info->efi_memdesc_size = sizeof(md[0]);
   2.170 -        memmap_info->efi_memdesc_version = EFI_MEMORY_DESCRIPTOR_VERSION;
   2.171 -        memmap_info->efi_memmap_size = 1 * sizeof(md[0]);
   2.172 +	if (create_memmap) {
   2.173 +		/*
   2.174 +		 * old domain builder which doesn't setup
   2.175 +		 * memory map. create it for compatibility
   2.176 +		 */
   2.177 +		memmap_info->efi_memdesc_size = sizeof(md[0]);
   2.178 +		memmap_info->efi_memdesc_version =
   2.179 +		    EFI_MEMORY_DESCRIPTOR_VERSION;
   2.180 +		memmap_info->efi_memmap_size = 1 * sizeof(md[0]);
   2.181 +
   2.182 +		md = (efi_memory_desc_t *) & memmap_info->memdesc;
   2.183 +		md[num_mds].type = EFI_CONVENTIONAL_MEMORY;
   2.184 +		md[num_mds].pad = 0;
   2.185 +		md[num_mds].phys_addr = 0;
   2.186 +		md[num_mds].virt_addr = 0;
   2.187 +		md[num_mds].num_pages = maxmem >> EFI_PAGE_SHIFT;
   2.188 +		md[num_mds].attribute = EFI_MEMORY_WB;
   2.189 +	}
   2.190  
   2.191 -        md = (efi_memory_desc_t*)&memmap_info->memdesc;
   2.192 -        md[num_mds].type = EFI_CONVENTIONAL_MEMORY;
   2.193 -        md[num_mds].pad = 0;
   2.194 -        md[num_mds].phys_addr = 0;
   2.195 -        md[num_mds].virt_addr = 0;
   2.196 -        md[num_mds].num_pages = maxmem >> EFI_PAGE_SHIFT;
   2.197 -        md[num_mds].attribute = EFI_MEMORY_WB;
   2.198 -    }
   2.199 +	memmap_start = &memmap_info->memdesc;
   2.200 +	memmap_end = memmap_start + memmap_info->efi_memmap_size;
   2.201 +
   2.202 +	/* XXX Currently the table must be in a single page. */
   2.203 +	if ((unsigned long)memmap_end > (unsigned long)memmap_info + PAGE_SIZE) {
   2.204 +		xen_ia64_dom_fw_unmap(d, memmap_info);
   2.205 +		return -EINVAL;
   2.206 +	}
   2.207 +
   2.208 +	/* sort it bofore use
   2.209 +	 * XXX: this is created by user space domain builder so that
   2.210 +	 * we should check its integrity */
   2.211 +	sort(&memmap_info->memdesc,
   2.212 +	     memmap_info->efi_memmap_size / memmap_info->efi_memdesc_size,
   2.213 +	     memmap_info->efi_memdesc_size, efi_mdt_cmp, NULL);
   2.214 +
   2.215 +	for (p = memmap_start; p < memmap_end;
   2.216 +	     p += memmap_info->efi_memdesc_size) {
   2.217 +		unsigned long start;
   2.218 +		unsigned long end;
   2.219  
   2.220 -    memmap_start = &memmap_info->memdesc;
   2.221 -    memmap_end = memmap_start + memmap_info->efi_memmap_size;
   2.222 -
   2.223 -    /* XXX Currently the table must be in a single page. */
   2.224 -    if ((unsigned long)memmap_end > (unsigned long)memmap_info + PAGE_SIZE) {
   2.225 -        xen_ia64_dom_fw_unmap(d, memmap_info);
   2.226 -        return -EINVAL;
   2.227 -    }
   2.228 +		md = p;
   2.229 +		start = md->phys_addr;
   2.230 +		end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
   2.231  
   2.232 -    /* sort it bofore use
   2.233 -     * XXX: this is created by user space domain builder so that
   2.234 -     * we should check its integrity */
   2.235 -    sort(&memmap_info->memdesc,
   2.236 -         memmap_info->efi_memmap_size / memmap_info->efi_memdesc_size,
   2.237 -         memmap_info->efi_memdesc_size,
   2.238 -         efi_mdt_cmp, NULL);
   2.239 -
   2.240 -    for (p = memmap_start; p < memmap_end; p += memmap_info->efi_memdesc_size) {
   2.241 -        unsigned long start;
   2.242 -        unsigned long end;
   2.243 -
   2.244 -        md = p;
   2.245 -        start = md->phys_addr;
   2.246 -        end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
   2.247 +		if (start < FW_END_PADDR)
   2.248 +			start = FW_END_PADDR;
   2.249 +		if (end <= start)
   2.250 +			continue;
   2.251  
   2.252 -        if (start < FW_END_PADDR)
   2.253 -            start = FW_END_PADDR;
   2.254 -        if (end <= start)
   2.255 -            continue;
   2.256 +		/* exclude [paddr_start, paddr_end) */
   2.257 +		if (paddr_end <= start || end <= paddr_start) {
   2.258 +			MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, start,
   2.259 +				end);
   2.260 +		} else if (paddr_start <= start && paddr_end < end) {
   2.261 +			MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB,
   2.262 +				paddr_end, end);
   2.263 +		} else if (start < paddr_start && end <= paddr_end) {
   2.264 +			MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, start,
   2.265 +				paddr_start);
   2.266 +		} else {
   2.267 +			MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, start,
   2.268 +				paddr_start);
   2.269 +			MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB,
   2.270 +				paddr_end, end);
   2.271 +		}
   2.272 +	}
   2.273  
   2.274 -        /* exclude [paddr_start, paddr_end) */
   2.275 -        if (paddr_end <= start || end <= paddr_start) {
   2.276 -            MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, start, end);
   2.277 -        } else if (paddr_start <= start && paddr_end < end) {
   2.278 -            MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, paddr_end, end);
   2.279 -        } else if (start < paddr_start && end <= paddr_end) {
   2.280 -            MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, start, paddr_start);
   2.281 -        } else {
   2.282 -            MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, start, paddr_start);
   2.283 -            MAKE_MD(EFI_CONVENTIONAL_MEMORY, EFI_MEMORY_WB, paddr_end, end);
   2.284 -        }
   2.285 -    }
   2.286 +	/* memmap info page. */
   2.287 +	MAKE_MD(EFI_RUNTIME_SERVICES_DATA, EFI_MEMORY_WB, paddr_start,
   2.288 +		paddr_end);
   2.289  
   2.290 -    /* memmap info page. */
   2.291 -    MAKE_MD(EFI_RUNTIME_SERVICES_DATA, EFI_MEMORY_WB, paddr_start, paddr_end);
   2.292 -
   2.293 -    /* Create an entry for IO ports.  */
   2.294 -    MAKE_MD(EFI_MEMORY_MAPPED_IO_PORT_SPACE, EFI_MEMORY_UC,
   2.295 -            IO_PORTS_PADDR, IO_PORTS_PADDR + IO_PORTS_SIZE);
   2.296 +	/* Create an entry for IO ports.  */
   2.297 +	MAKE_MD(EFI_MEMORY_MAPPED_IO_PORT_SPACE, EFI_MEMORY_UC,
   2.298 +		IO_PORTS_PADDR, IO_PORTS_PADDR + IO_PORTS_SIZE);
   2.299  
   2.300 -    num_mds = i;
   2.301 -    sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t),
   2.302 -         efi_mdt_cmp, NULL);
   2.303 +	num_mds = i;
   2.304 +	sort(tables->efi_memmap, num_mds, sizeof(efi_memory_desc_t),
   2.305 +	     efi_mdt_cmp, NULL);
   2.306  
   2.307 -    xen_ia64_dom_fw_unmap(d, memmap_info);
   2.308 -    return num_mds;
   2.309 +	xen_ia64_dom_fw_unmap(d, memmap_info);
   2.310 +	return num_mds;
   2.311  }
   2.312  
   2.313  /*
   2.314   * Local variables:
   2.315   * mode: C
   2.316 - * c-set-style: "BSD"
   2.317 - * c-basic-offset: 4
   2.318 - * tab-width: 4
   2.319 - * indent-tabs-mode: nil
   2.320 + * c-set-style: "linux"
   2.321 + * c-basic-offset: 8
   2.322 + * tab-width: 8
   2.323 + * indent-tabs-mode: t
   2.324   * End:
   2.325   */
     3.1 --- a/xen/arch/ia64/xen/dom_fw_utils.c	Thu May 24 16:28:48 2007 -0600
     3.2 +++ b/xen/arch/ia64/xen/dom_fw_utils.c	Fri May 25 09:33:01 2007 -0600
     3.3 @@ -30,103 +30,99 @@
     3.4  
     3.5  #include <linux/sort.h>
     3.6  
     3.7 -uint32_t
     3.8 -xen_ia64_version(struct domain *unused)
     3.9 +uint32_t xen_ia64_version(struct domain *unused)
    3.10  {
    3.11 -    return (xen_major_version() << 16) | xen_minor_version();
    3.12 +	return (xen_major_version() << 16) | xen_minor_version();
    3.13  }
    3.14  
    3.15 -int
    3.16 -xen_ia64_fpswa_revision(struct domain *d, unsigned int *revision)
    3.17 +int xen_ia64_fpswa_revision(struct domain *d, unsigned int *revision)
    3.18  {
    3.19 -    if (fpswa_interface == NULL)
    3.20 -        return -ENOSYS;
    3.21 +	if (fpswa_interface == NULL)
    3.22 +		return -ENOSYS;
    3.23  
    3.24 -    *revision = fpswa_interface->revision;
    3.25 -    return 0;
    3.26 +	*revision = fpswa_interface->revision;
    3.27 +	return 0;
    3.28  }
    3.29  
    3.30 -int
    3.31 -xen_ia64_is_vcpu_allocated(struct domain *d, uint32_t vcpu)
    3.32 +int xen_ia64_is_vcpu_allocated(struct domain *d, uint32_t vcpu)
    3.33  {
    3.34 -    return d->vcpu[vcpu] != NULL;
    3.35 +	return d->vcpu[vcpu] != NULL;
    3.36  }
    3.37  
    3.38  int xen_ia64_is_running_on_sim(struct domain *unused)
    3.39  {
    3.40 -    extern unsigned long running_on_sim;
    3.41 -    return running_on_sim;
    3.42 +	extern unsigned long running_on_sim;
    3.43 +	return running_on_sim;
    3.44  }
    3.45  
    3.46 -int
    3.47 -xen_ia64_is_dom0(struct domain *d)
    3.48 +int xen_ia64_is_dom0(struct domain *d)
    3.49  {
    3.50 -    return d == dom0;
    3.51 +	return d == dom0;
    3.52  }
    3.53  
    3.54 -static void
    3.55 -dom_fw_domain_init(struct domain *d, struct fw_tables *tables)
    3.56 +static void dom_fw_domain_init(struct domain *d, struct fw_tables *tables)
    3.57  {
    3.58 -    /* Initialise for EFI_SET_VIRTUAL_ADDRESS_MAP emulation */
    3.59 -    d->arch.efi_runtime = &tables->efi_runtime;
    3.60 -    d->arch.fpswa_inf   = &tables->fpswa_inf;
    3.61 -    d->arch.sal_data    = &tables->sal_data;
    3.62 +	/* Initialise for EFI_SET_VIRTUAL_ADDRESS_MAP emulation */
    3.63 +	d->arch.efi_runtime = &tables->efi_runtime;
    3.64 +	d->arch.fpswa_inf = &tables->fpswa_inf;
    3.65 +	d->arch.sal_data = &tables->sal_data;
    3.66  }
    3.67  
    3.68 -static int
    3.69 -dom_fw_set_convmem_end(struct domain *d)
    3.70 +static int dom_fw_set_convmem_end(struct domain *d)
    3.71  {
    3.72 -    xen_ia64_memmap_info_t* memmap_info;
    3.73 -    efi_memory_desc_t *md;
    3.74 -    void *p;
    3.75 -    void *memmap_start;
    3.76 -    void *memmap_end;
    3.77 +	xen_ia64_memmap_info_t *memmap_info;
    3.78 +	efi_memory_desc_t *md;
    3.79 +	void *p;
    3.80 +	void *memmap_start;
    3.81 +	void *memmap_end;
    3.82  
    3.83 -    if (d->shared_info->arch.memmap_info_pfn == 0)
    3.84 -        return -EINVAL;
    3.85 +	if (d->shared_info->arch.memmap_info_pfn == 0)
    3.86 +		return -EINVAL;
    3.87  
    3.88 -    memmap_info = domain_mpa_to_imva(d, d->shared_info->arch.memmap_info_pfn << PAGE_SHIFT);
    3.89 -    if (memmap_info->efi_memmap_size == 0 ||
    3.90 -        memmap_info->efi_memdesc_size != sizeof(*md) ||
    3.91 -        memmap_info->efi_memdesc_version !=
    3.92 -        EFI_MEMORY_DESCRIPTOR_VERSION)
    3.93 -        return -EINVAL;
    3.94 +	memmap_info =
    3.95 +	    domain_mpa_to_imva(d,
    3.96 +			       d->shared_info->arch.
    3.97 +			       memmap_info_pfn << PAGE_SHIFT);
    3.98 +	if (memmap_info->efi_memmap_size == 0
    3.99 +	    || memmap_info->efi_memdesc_size != sizeof(*md)
   3.100 +	    || memmap_info->efi_memdesc_version !=
   3.101 +	    EFI_MEMORY_DESCRIPTOR_VERSION)
   3.102 +		return -EINVAL;
   3.103  
   3.104 -    /* only 1page case is supported */
   3.105 -    if (d->shared_info->arch.memmap_info_num_pages != 1)
   3.106 -        return -ENOSYS;
   3.107 +	/* only 1page case is supported */
   3.108 +	if (d->shared_info->arch.memmap_info_num_pages != 1)
   3.109 +		return -ENOSYS;
   3.110  
   3.111 -    memmap_start = &memmap_info->memdesc;
   3.112 -    memmap_end = memmap_start + memmap_info->efi_memmap_size;
   3.113 +	memmap_start = &memmap_info->memdesc;
   3.114 +	memmap_end = memmap_start + memmap_info->efi_memmap_size;
   3.115  
   3.116 -    /* XXX Currently the table must be in a single page. */
   3.117 -    if ((unsigned long)memmap_end > (unsigned long)memmap_info + PAGE_SIZE)
   3.118 -        return -EINVAL;
   3.119 +	/* XXX Currently the table must be in a single page. */
   3.120 +	if ((unsigned long)memmap_end > (unsigned long)memmap_info + PAGE_SIZE)
   3.121 +		return -EINVAL;
   3.122  
   3.123 -    /* sort it bofore use
   3.124 -     * XXX: this is created by user space domain builder so that
   3.125 -     * we should check its integrity */
   3.126 -    sort(&memmap_info->memdesc,
   3.127 -         memmap_info->efi_memmap_size / memmap_info->efi_memdesc_size,
   3.128 -         memmap_info->efi_memdesc_size,
   3.129 -         efi_mdt_cmp, NULL);
   3.130 +	/* sort it bofore use
   3.131 +	 * XXX: this is created by user space domain builder so that
   3.132 +	 * we should check its integrity */
   3.133 +	sort(&memmap_info->memdesc,
   3.134 +	     memmap_info->efi_memmap_size / memmap_info->efi_memdesc_size,
   3.135 +	     memmap_info->efi_memdesc_size, efi_mdt_cmp, NULL);
   3.136 +
   3.137 +	if (d->arch.convmem_end == 0)
   3.138 +		d->arch.convmem_end = d->max_pages << PAGE_SHIFT;
   3.139  
   3.140 -    if (d->arch.convmem_end == 0)
   3.141 -        d->arch.convmem_end = d->max_pages << PAGE_SHIFT;
   3.142 +	for (p = memmap_start; p < memmap_end;
   3.143 +	     p += memmap_info->efi_memdesc_size) {
   3.144 +		unsigned long end;
   3.145  
   3.146 -    for (p = memmap_start; p < memmap_end; p += memmap_info->efi_memdesc_size) {
   3.147 -        unsigned long end;
   3.148 +		md = p;
   3.149 +		end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
   3.150  
   3.151 -        md = p;
   3.152 -        end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT);
   3.153 -
   3.154 -        if (md->attribute == EFI_MEMORY_WB &&
   3.155 -            md->type == EFI_CONVENTIONAL_MEMORY &&
   3.156 -            md->num_pages > 0 &&
   3.157 -            d->arch.convmem_end < end)
   3.158 -            d->arch.convmem_end = end;
   3.159 -    }
   3.160 -    return 0;
   3.161 +		if (md->attribute == EFI_MEMORY_WB &&
   3.162 +		    md->type == EFI_CONVENTIONAL_MEMORY &&
   3.163 +		    md->num_pages > 0 && d->arch.convmem_end < end)
   3.164 +			d->arch.convmem_end = end;
   3.165 +	}
   3.166 +	return 0;
   3.167  }
   3.168  
   3.169  /* allocate a page for fw
   3.170 @@ -135,100 +131,101 @@ dom_fw_set_convmem_end(struct domain *d)
   3.171  static inline void
   3.172  assign_new_domain_page_if_dom0(struct domain *d, unsigned long mpaddr)
   3.173  {
   3.174 -    if (d == dom0)
   3.175 -        assign_new_domain0_page(d, mpaddr);
   3.176 +	if (d == dom0)
   3.177 +		assign_new_domain0_page(d, mpaddr);
   3.178  }
   3.179  
   3.180  static void
   3.181  dom_fw_setup_for_domain_restore(domain_t *d, unsigned long maxmem)
   3.182  {
   3.183 -    assign_new_domain_page(d, FW_HYPERCALL_BASE_PADDR);
   3.184 -    dom_fw_domain_init(d, domain_mpa_to_imva(d, FW_TABLES_BASE_PADDR));
   3.185 -    d->arch.convmem_end = maxmem;
   3.186 +	assign_new_domain_page(d, FW_HYPERCALL_BASE_PADDR);
   3.187 +	dom_fw_domain_init(d, domain_mpa_to_imva(d, FW_TABLES_BASE_PADDR));
   3.188 +	d->arch.convmem_end = maxmem;
   3.189  }
   3.190  
   3.191 -int
   3.192 -dom_fw_setup(domain_t *d, unsigned long bp_mpa, unsigned long maxmem)
   3.193 +int dom_fw_setup(domain_t * d, unsigned long bp_mpa, unsigned long maxmem)
   3.194  {
   3.195 -    int old_domu_builder = 0;
   3.196 -    struct xen_ia64_boot_param *bp;
   3.197 -    struct fw_tables *imva_tables_base;
   3.198 +	int old_domu_builder = 0;
   3.199 +	struct xen_ia64_boot_param *bp;
   3.200 +	struct fw_tables *imva_tables_base;
   3.201  
   3.202 -    BUILD_BUG_ON(sizeof(struct fw_tables) >
   3.203 -                 (FW_TABLES_END_PADDR - FW_TABLES_BASE_PADDR));
   3.204 +	BUILD_BUG_ON(sizeof(struct fw_tables) >
   3.205 +		     (FW_TABLES_END_PADDR - FW_TABLES_BASE_PADDR));
   3.206  
   3.207 -    if (bp_mpa == 0) {
   3.208 -        /* bp_mpa == 0 means this is domain restore case. */
   3.209 -        dom_fw_setup_for_domain_restore(d, maxmem);
   3.210 -        return 0;
   3.211 -    }
   3.212 +	if (bp_mpa == 0) {
   3.213 +		/* bp_mpa == 0 means this is domain restore case. */
   3.214 +		dom_fw_setup_for_domain_restore(d, maxmem);
   3.215 +		return 0;
   3.216 +	}
   3.217  
   3.218 -    /* Create page for boot_param.  */
   3.219 -    assign_new_domain_page_if_dom0(d, bp_mpa);
   3.220 -    bp = domain_mpa_to_imva(d, bp_mpa);
   3.221 -    if (d != dom0) {
   3.222 -        /*
   3.223 -         * XXX kludge.
   3.224 -         * when XEN_DOMCTL_arch_setup is called, shared_info can't
   3.225 -         * be accessed by libxc so that memmap_info_pfn isn't
   3.226 -         * initialized. But dom_fw_set_convmem_end() requires it, 
   3.227 -         * so here we initialize it.
   3.228 -         * note: domain builder may overwrite memmap_info_num_pages,
   3.229 -         *       memmap_info_pfns later.
   3.230 -         */
   3.231 -        if (bp->efi_memmap_size == 0 || 
   3.232 -            XEN_IA64_MEMMAP_INFO_NUM_PAGES(bp) == 0 ||
   3.233 -            XEN_IA64_MEMMAP_INFO_PFN(bp) == 0) {
   3.234 -            /* old domain builder compatibility */
   3.235 -            d->shared_info->arch.memmap_info_num_pages = 1;
   3.236 -            d->shared_info->arch.memmap_info_pfn = (maxmem >> PAGE_SHIFT) - 1;
   3.237 -            old_domu_builder = 1;
   3.238 -        } else {
   3.239 -            d->shared_info->arch.memmap_info_num_pages =
   3.240 -                XEN_IA64_MEMMAP_INFO_NUM_PAGES(bp);
   3.241 -            d->shared_info->arch.memmap_info_pfn =
   3.242 -                XEN_IA64_MEMMAP_INFO_PFN(bp);
   3.243 -            /* currently multi page memmap isn't supported */
   3.244 -            if (d->shared_info->arch.memmap_info_num_pages != 1)
   3.245 -                return -ENOSYS;
   3.246 -        }
   3.247 -    }
   3.248 +	/* Create page for boot_param.  */
   3.249 +	assign_new_domain_page_if_dom0(d, bp_mpa);
   3.250 +	bp = domain_mpa_to_imva(d, bp_mpa);
   3.251 +	if (d != dom0) {
   3.252 +		/*
   3.253 +		 * XXX kludge.
   3.254 +		 * when XEN_DOMCTL_arch_setup is called, shared_info can't
   3.255 +		 * be accessed by libxc so that memmap_info_pfn isn't
   3.256 +		 * initialized. But dom_fw_set_convmem_end() requires it, 
   3.257 +		 * so here we initialize it.
   3.258 +		 * note: domain builder may overwrite memmap_info_num_pages,
   3.259 +		 *       memmap_info_pfns later.
   3.260 +		 */
   3.261 +		if (bp->efi_memmap_size == 0 ||
   3.262 +		    XEN_IA64_MEMMAP_INFO_NUM_PAGES(bp) == 0 ||
   3.263 +		    XEN_IA64_MEMMAP_INFO_PFN(bp) == 0) {
   3.264 +			/* old domain builder compatibility */
   3.265 +			d->shared_info->arch.memmap_info_num_pages = 1;
   3.266 +			d->shared_info->arch.memmap_info_pfn =
   3.267 +			    (maxmem >> PAGE_SHIFT) - 1;
   3.268 +			old_domu_builder = 1;
   3.269 +		} else {
   3.270 +			d->shared_info->arch.memmap_info_num_pages =
   3.271 +			    XEN_IA64_MEMMAP_INFO_NUM_PAGES(bp);
   3.272 +			d->shared_info->arch.memmap_info_pfn =
   3.273 +			    XEN_IA64_MEMMAP_INFO_PFN(bp);
   3.274 +			/* currently multi page memmap isn't supported */
   3.275 +			if (d->shared_info->arch.memmap_info_num_pages != 1)
   3.276 +				return -ENOSYS;
   3.277 +		}
   3.278 +	}
   3.279  
   3.280 -    /* Create page for FW tables.  */
   3.281 -    assign_new_domain_page_if_dom0(d, FW_TABLES_BASE_PADDR);
   3.282 -    imva_tables_base = (struct fw_tables *)domain_mpa_to_imva
   3.283 -                                      (d, FW_TABLES_BASE_PADDR);
   3.284 -    /* Create page for acpi tables.  */
   3.285 -    if (d != dom0 && old_domu_builder) {
   3.286 -        struct fake_acpi_tables *imva;
   3.287 -        imva = domain_mpa_to_imva(d, FW_ACPI_BASE_PADDR);
   3.288 -        dom_fw_fake_acpi(d, imva);
   3.289 -    }
   3.290 -    if (d == dom0 || old_domu_builder) {
   3.291 -        int ret;
   3.292 -        unsigned long imva_hypercall_base;
   3.293 +	/* Create page for FW tables.  */
   3.294 +	assign_new_domain_page_if_dom0(d, FW_TABLES_BASE_PADDR);
   3.295 +	imva_tables_base = (struct fw_tables *)domain_mpa_to_imva
   3.296 +	    (d, FW_TABLES_BASE_PADDR);
   3.297 +	/* Create page for acpi tables.  */
   3.298 +	if (d != dom0 && old_domu_builder) {
   3.299 +		struct fake_acpi_tables *imva;
   3.300 +		imva = domain_mpa_to_imva(d, FW_ACPI_BASE_PADDR);
   3.301 +		dom_fw_fake_acpi(d, imva);
   3.302 +	}
   3.303 +	if (d == dom0 || old_domu_builder) {
   3.304 +		int ret;
   3.305 +		unsigned long imva_hypercall_base;
   3.306  
   3.307 -        /* Create page for hypercalls.  */
   3.308 -        assign_new_domain_page_if_dom0(d, FW_HYPERCALL_BASE_PADDR);
   3.309 -        imva_hypercall_base = (unsigned long)domain_mpa_to_imva
   3.310 -            (d, FW_HYPERCALL_BASE_PADDR);
   3.311 +		/* Create page for hypercalls.  */
   3.312 +		assign_new_domain_page_if_dom0(d, FW_HYPERCALL_BASE_PADDR);
   3.313 +		imva_hypercall_base = (unsigned long)domain_mpa_to_imva
   3.314 +		    (d, FW_HYPERCALL_BASE_PADDR);
   3.315  
   3.316 -        ret = dom_fw_init(d, d->arch.breakimm, bp,
   3.317 -                          imva_tables_base, imva_hypercall_base, maxmem);
   3.318 -        if (ret < 0)
   3.319 -            return ret;
   3.320 -    }
   3.321 +		ret = dom_fw_init(d, d->arch.breakimm, bp,
   3.322 +				  imva_tables_base, imva_hypercall_base,
   3.323 +				  maxmem);
   3.324 +		if (ret < 0)
   3.325 +			return ret;
   3.326 +	}
   3.327  
   3.328 -    dom_fw_domain_init(d, imva_tables_base);
   3.329 -    return dom_fw_set_convmem_end(d);
   3.330 +	dom_fw_domain_init(d, imva_tables_base);
   3.331 +	return dom_fw_set_convmem_end(d);
   3.332  }
   3.333  
   3.334  /*
   3.335   * Local variables:
   3.336   * mode: C
   3.337 - * c-set-style: "BSD"
   3.338 - * c-basic-offset: 4
   3.339 - * tab-width: 4
   3.340 - * indent-tabs-mode: nil
   3.341 + * c-set-style: "linux"
   3.342 + * c-basic-offset: 8
   3.343 + * tab-width: 8
   3.344 + * indent-tabs-mode: t
   3.345   * End:
   3.346   */