diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2012-03-23 02:19:44 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2012-03-24 02:54:49 +0100 |
commit | 264b750cc2d576beadfd74bcde45ac75edc4aab9 (patch) | |
tree | cd1b50f73e31c9dc577083c49062d695c836933a | |
parent | 7effecf87173a122c95427dafa971abbbdba3493 (diff) |
Add missing phystokv/kvtophys calls
* i386/i386/vm_param.h [!MACH_XEN]: Do not include <xen/public/xen.h>.
* i386/i386at/model_dep.c (init_alloc_aligned): Use phystokv to compare physical
memory addresses with kernel start, end, and symbol table.
* i386/intel/pmap.c (pmap_enter): Use kvtophys to convert ptp pointer to pte
entry.
* linux/dev/init/main.c (alloc_contig_mem, linux_init): Use phystokv to convert
allocated pages to virtual pointer.
* linux/src/include/asm-i386/io.h: Include <machine/vm_param.h>.
(virt_to_phys): Call _kvtophys.
(phys_to_virt): Call phystokv.
* linux/src/include/linux/compatmac.h: Include <asm/io.h>.
(ioremap): Use phys_to_virt to convert physical address to virtual pointer.
(my_iounmap): Likewise.
* linux/dev/include/asm-i386/page.h: Include <mach/vm_param.h>.
(PAGE_SHIFT, PAGE_SIZE, PAGE_MASK): Remove macros.
* linux/src/drivers/scsi/ncr53c8xx.c (vm_size_t): Remove type.
* linux/dev/glue/net.c: Include <machine/vm_param.h>
(device_write): Call phystokv to convert from physical page address to
virtual pointer.
* linux/dev/glue/block.c (alloc_buffer, free_buffer, rdwr_full): Likewise.
-rw-r--r-- | i386/i386/vm_param.h | 2 | ||||
-rw-r--r-- | i386/i386at/model_dep.c | 8 | ||||
-rw-r--r-- | i386/intel/pmap.c | 6 | ||||
-rw-r--r-- | linux/dev/glue/block.c | 8 | ||||
-rw-r--r-- | linux/dev/glue/net.c | 7 | ||||
-rw-r--r-- | linux/dev/include/asm-i386/page.h | 7 | ||||
-rw-r--r-- | linux/dev/init/main.c | 4 | ||||
-rw-r--r-- | linux/src/drivers/scsi/ncr53c8xx.c | 2 | ||||
-rw-r--r-- | linux/src/include/asm-i386/io.h | 6 | ||||
-rw-r--r-- | linux/src/include/linux/compatmac.h | 5 |
10 files changed, 28 insertions, 27 deletions
diff --git a/i386/i386/vm_param.h b/i386/i386/vm_param.h index 6abbf8f..49ba663 100644 --- a/i386/i386/vm_param.h +++ b/i386/i386/vm_param.h @@ -25,7 +25,9 @@ /* XXX use xu/vm_param.h */ #include <mach/vm_param.h> +#ifdef MACH_XEN #include <xen/public/xen.h> +#endif /* The kernel address space is usually 1GB, usually starting at virtual address 0. */ #ifdef MACH_XEN diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index ef2d672..01d515d 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -703,9 +703,9 @@ init_alloc_aligned(vm_size_t size, vm_offset_t *addrp) } /* Skip our own kernel code, data, and bss. */ - if ((avail_next > (vm_offset_t)start) && (addr < (vm_offset_t)end)) + if ((phystokv(avail_next) > (vm_offset_t)start) && (phystokv(addr) < (vm_offset_t)end)) { - avail_next = (vm_offset_t)end; + avail_next = _kvtophys(end); goto retry; } @@ -720,9 +720,9 @@ init_alloc_aligned(vm_size_t size, vm_offset_t *addrp) avail_next = mods_end_pa; goto retry; } - if ((avail_next > kern_sym_start) && (addr < kern_sym_end)) + if ((phystokv(avail_next) > kern_sym_start) && (phystokv(addr) < kern_sym_end)) { - avail_next = kern_sym_end; + avail_next = _kvtophys(kern_sym_end); goto retry; } if (boot_info.flags & MULTIBOOT_MODS) diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 51ca00e..d8865b2 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -1856,9 +1856,9 @@ Retry: | INTEL_PTE_WRITE)) panic("%s:%d could not set pde %p(%p,%p) to %p(%p,%p) %p\n",__FILE__,__LINE__, pdp, kvtophys((vm_offset_t)pdp), (vm_offset_t) pa_to_ma(kvtophys((vm_offset_t)pdp)), ptp, kvtophys(ptp), (vm_offset_t) pa_to_ma(kvtophys(ptp)), (vm_offset_t) pa_to_pte(kv_to_ma(ptp))); #else /* MACH_XEN */ - *pdp = pa_to_pte(ptp) | INTEL_PTE_VALID - | INTEL_PTE_USER - | INTEL_PTE_WRITE; + *pdp = pa_to_pte(kvtophys(ptp)) | INTEL_PTE_VALID + | INTEL_PTE_USER + | INTEL_PTE_WRITE; #endif /* MACH_XEN */ pdp++; ptp += INTEL_PGBYTES; diff --git a/linux/dev/glue/block.c b/linux/dev/glue/block.c index c7b3873..63bc766 100644 --- a/linux/dev/glue/block.c +++ b/linux/dev/glue/block.c @@ -307,7 +307,7 @@ alloc_buffer (int size) d = current_thread ()->pcb->data; assert (d); queue_enter (&d->pages, m, vm_page_t, pageq); - return (void *) m->phys_addr; + return (void *) phystokv(m->phys_addr); } return (void *) __get_free_pages (GFP_KERNEL, 0, ~0UL); } @@ -327,7 +327,7 @@ free_buffer (void *p, int size) assert (d); queue_iterate (&d->pages, m, vm_page_t, pageq) { - if (m->phys_addr == (vm_offset_t) p) + if (phystokv(m->phys_addr) == (vm_offset_t) p) { queue_remove (&d->pages, m, vm_page_t, pageq); VM_PAGE_FREE (m); @@ -600,9 +600,9 @@ rdwr_full (int rw, kdev_t dev, loff_t *off, char **buf, int *resid, int bshift) if (cc > ((nbuf - nb) << bshift)) cc = (nbuf - nb) << bshift; if (! test_bit (BH_Bounce, &bh->b_state)) - bh->b_data = (char *) pmap_extract (vm_map_pmap (device_io_map), + bh->b_data = (char *) phystokv(pmap_extract (vm_map_pmap (device_io_map), (((vm_offset_t) *buf) - + (nb << bshift))); + + (nb << bshift)))); else { bh->b_data = alloc_buffer (cc); diff --git a/linux/dev/glue/net.c b/linux/dev/glue/net.c index a60275f..1573273 100644 --- a/linux/dev/glue/net.c +++ b/linux/dev/glue/net.c @@ -61,6 +61,7 @@ #include <sys/types.h> #include <machine/spl.h> +#include <machine/vm_param.h> #include <mach/mach_types.h> #include <mach/kern_return.h> @@ -449,7 +450,7 @@ device_write (void *d, ipc_port_t reply_port, assert (copy->cpy_npages == 1); skb->copy = copy; - skb->data = ((void *) copy->cpy_page_list[0]->phys_addr + skb->data = ((void *) phystokv(copy->cpy_page_list[0]->phys_addr) + (copy->offset & PAGE_MASK)); skb->len = count; skb->head = skb->data; @@ -463,7 +464,7 @@ device_write (void *d, ipc_port_t reply_port, skb->end = skb->tail; memcpy (skb->data, - ((void *) copy->cpy_page_list[0]->phys_addr + ((void *) phystokv(copy->cpy_page_list[0]->phys_addr) + (copy->offset & PAGE_MASK)), amt); count -= amt; @@ -473,7 +474,7 @@ device_write (void *d, ipc_port_t reply_port, amt = PAGE_SIZE; if (amt > count) amt = count; - memcpy (p, (void *) copy->cpy_page_list[i]->phys_addr, amt); + memcpy (p, (void *) phystokv(copy->cpy_page_list[i]->phys_addr), amt); count -= amt; p += amt; } diff --git a/linux/dev/include/asm-i386/page.h b/linux/dev/include/asm-i386/page.h index 2bb6837..be81848 100644 --- a/linux/dev/include/asm-i386/page.h +++ b/linux/dev/include/asm-i386/page.h @@ -1,12 +1,7 @@ #ifndef _I386_PAGE_H #define _I386_PAGE_H -#ifndef MACH_INCLUDE -/* PAGE_SHIFT determines the page size */ -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1UL << PAGE_SHIFT) -#define PAGE_MASK (~(PAGE_SIZE-1)) -#endif +#include <mach/vm_param.h> #ifdef __KERNEL__ diff --git a/linux/dev/init/main.c b/linux/dev/init/main.c index f5c4832..ecbd0b6 100644 --- a/linux/dev/init/main.c +++ b/linux/dev/init/main.c @@ -149,7 +149,7 @@ linux_init (void) /* * Free unused memory. */ - while (pages && pages->phys_addr < round_page (memory_start)) + while (pages && phystokv(pages->phys_addr) < round_page (memory_start)) pages = (vm_page_t) pages->pageq.next; if (pages) free_contig_mem (pages); @@ -296,7 +296,7 @@ alloc_contig_mem (unsigned size, unsigned limit, kfree ((vm_offset_t) bits, bits_len); if (pages) *pages = page_list; - return (m); + return phystokv(m); } /* diff --git a/linux/src/drivers/scsi/ncr53c8xx.c b/linux/src/drivers/scsi/ncr53c8xx.c index 1be3d9f..22aec32 100644 --- a/linux/src/drivers/scsi/ncr53c8xx.c +++ b/linux/src/drivers/scsi/ncr53c8xx.c @@ -273,7 +273,7 @@ typedef u32 u_int32; #define u_long unsigned long typedef u_long vm_offset_t; -typedef int vm_size_t; +//typedef int vm_size_t; #define bcopy(s, d, n) memcpy((d), (s), (n)) #define bzero(d, n) memset((d), 0, (n)) diff --git a/linux/src/include/asm-i386/io.h b/linux/src/include/asm-i386/io.h index 98e32ce..f961f1d 100644 --- a/linux/src/include/asm-i386/io.h +++ b/linux/src/include/asm-i386/io.h @@ -25,6 +25,8 @@ * Linus */ +#include <machine/vm_param.h> + #ifdef SLOW_IO_BY_JUMPING #define __SLOW_DOWN_IO __asm__ __volatile__("jmp 1f\n1:\tjmp 1f\n1:") #else @@ -45,12 +47,12 @@ */ extern inline unsigned long virt_to_phys(volatile void * address) { - return (unsigned long) address; + return (unsigned long) _kvtophys(address); } extern inline void * phys_to_virt(unsigned long address) { - return (void *) address; + return (void *) phystokv(address); } /* diff --git a/linux/src/include/linux/compatmac.h b/linux/src/include/linux/compatmac.h index b9a4112..9537070 100644 --- a/linux/src/include/linux/compatmac.h +++ b/linux/src/include/linux/compatmac.h @@ -47,6 +47,7 @@ #define COMPATMAC_H #include <linux/version.h> +#include <asm/io.h> #if LINUX_VERSION_CODE < 0x020100 /* Less than 2.1.0 */ #define TWO_ZERO @@ -96,11 +97,11 @@ static inline unsigned char get_irq (unsigned char bus, unsigned char fn) static inline void *ioremap(unsigned long base, long length) { - if (base < 0x100000) return (void *)base; + if (base < 0x100000) return phys_to_virt(base); return vremap (base, length); } -#define my_iounmap(x, b) (((long)x<0x100000)?0:vfree ((void*)x)) +#define my_iounmap(x, b) (((long)x<(long)phys_to_virt(0x100000))?0:vfree ((void*)x)) #define capable(x) suser() |