summaryrefslogtreecommitdiffstats
path: root/sys/arm/xscale
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-21 19:57:40 +0000
committerpfg <pfg@FreeBSD.org>2016-04-21 19:57:40 +0000
commit729533413f4e97bb65852c22fb914805e2759b5a (patch)
treecd4dfa8859a5f57124d315ff395b524d7587e1ea /sys/arm/xscale
parent0d55061d05ce55d28aff0c06bad831448d172425 (diff)
downloadFreeBSD-src-729533413f4e97bb65852c22fb914805e2759b5a.zip
FreeBSD-src-729533413f4e97bb65852c22fb914805e2759b5a.tar.gz
sys: use our roundup2/rounddown2() macros when param.h is available.
rounddown2 tends to produce longer lines than the original code and when the code has a high indentation level it was not really advantageous to do the replacement. This tries to strike a balance between readability using the macros and flexibility of having the expressions, so not everything is converted.
Diffstat (limited to 'sys/arm/xscale')
-rw-r--r--sys/arm/xscale/i8134x/crb_machdep.c17
-rw-r--r--sys/arm/xscale/i8134x/i81342_pci.c4
-rw-r--r--sys/arm/xscale/i8134x/i81342_space.c4
-rw-r--r--sys/arm/xscale/ixp425/avila_machdep.c2
-rw-r--r--sys/arm/xscale/pxa/pxa_machdep.c13
5 files changed, 19 insertions, 21 deletions
diff --git a/sys/arm/xscale/i8134x/crb_machdep.c b/sys/arm/xscale/i8134x/crb_machdep.c
index eb3d08c..3ee31b5 100644
--- a/sys/arm/xscale/i8134x/crb_machdep.c
+++ b/sys/arm/xscale/i8134x/crb_machdep.c
@@ -131,8 +131,8 @@ static const struct arm_devmap_entry iq81342_devmap[] = {
* Cheat and map a whole section, this will bring
* both PCI-X and PCI-E outbound I/O
*/
- IOP34X_PCIX_OIOBAR_VADDR &~ (0x100000 - 1),
- IOP34X_PCIX_OIOBAR &~ (0x100000 - 1),
+ rounddown2(IOP34X_PCIX_OIOBAR_VADDR, 0x100000),
+ rounddown2(IOP34X_PCIX_OIOBAR, 0x100000),
0x100000,
},
{
@@ -227,8 +227,8 @@ initarm(struct arm_boot_params *abp)
l1pagetable = kernel_l1pt.pv_va;
/* Map the L2 pages tables in the L1 page table */
- pmap_link_l2pt(l1pagetable, ARM_VECTORS_HIGH & ~(0x00100000 - 1),
- &kernel_pt_table[KERNEL_PT_SYS]);
+ pmap_link_l2pt(l1pagetable, rounddown2(ARM_VECTORS_HIGH, 0x00100000),
+ &kernel_pt_table[KERNEL_PT_SYS]);
pmap_map_chunk(l1pagetable, KERNBASE, SDRAM_START, 0x100000,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
@@ -236,11 +236,10 @@ initarm(struct arm_boot_params *abp)
0x100000, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
pmap_map_chunk(l1pagetable, KERNBASE + 0x200000, SDRAM_START + 0x200000,
- (((uint32_t)(lastaddr) - KERNBASE - 0x200000) + L1_S_SIZE) & ~(L1_S_SIZE - 1),
- VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
- freemem_after = ((int)lastaddr + PAGE_SIZE) & ~(PAGE_SIZE - 1);
- afterkern = round_page(((vm_offset_t)lastaddr + L1_S_SIZE) & ~(L1_S_SIZE
- - 1));
+ rounddown2(((uint32_t)(lastaddr) - KERNBASE - 0x200000) + L1_S_SIZE, L1_S_SIZE),
+ VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
+ freemem_after = rounddown2((int)lastaddr + PAGE_SIZE, PAGE_SIZE);
+ afterkern = round_page(rounddown2((vm_offset_t)lastaddr + L1_S_SIZE, L1_S_SIZE));
for (i = 0; i < KERNEL_PT_AFKERNEL_NUM; i++) {
pmap_link_l2pt(l1pagetable, afterkern + i * 0x00100000,
&kernel_pt_table[KERNEL_PT_AFKERNEL + i]);
diff --git a/sys/arm/xscale/i8134x/i81342_pci.c b/sys/arm/xscale/i8134x/i81342_pci.c
index d17fb14..32716a9 100644
--- a/sys/arm/xscale/i8134x/i81342_pci.c
+++ b/sys/arm/xscale/i8134x/i81342_pci.c
@@ -121,8 +121,8 @@ i81342_pci_attach(device_t dev)
memstart | PCI_MAPREG_MEM_PREFETCHABLE_MASK |
PCI_MAPREG_MEM_TYPE_64BIT);
bus_space_write_4(sc->sc_st, sc->sc_atu_sh, ATU_IAUBAR1, 0);
- bus_space_write_4(sc->sc_st, sc->sc_atu_sh, ATU_IALR1, ~(memsize - 1)
- &~(0xfff));
+ bus_space_write_4(sc->sc_st, sc->sc_atu_sh, ATU_IALR1,
+ rounddown2(~(0xfff), memsize));
bus_space_write_4(sc->sc_st, sc->sc_atu_sh, ATU_IATVR1, memstart);
bus_space_write_4(sc->sc_st, sc->sc_atu_sh, ATU_IAUTVR1, 0);
diff --git a/sys/arm/xscale/i8134x/i81342_space.c b/sys/arm/xscale/i8134x/i81342_space.c
index d5d9143..65ac928 100644
--- a/sys/arm/xscale/i8134x/i81342_space.c
+++ b/sys/arm/xscale/i8134x/i81342_space.c
@@ -178,13 +178,13 @@ i81342_mem_bs_map(bus_space_tag_t tag, bus_addr_t bpa, bus_size_t size, int flag
tmp = tmp->next;
}
addr = allocable;
- endaddr = ((addr + size) &~ (0x1000000 - 1)) + 0x1000000;
+ endaddr = rounddown2(addr + size, 0x1000000) + 0x1000000;
if (endaddr >= IOP34X_VADDR)
panic("PCI virtual memory exhausted");
allocable = endaddr;
tmp = malloc(sizeof(*tmp), M_DEVBUF, M_WAITOK);
tmp->next = NULL;
- paddr = bpa &~ (0x100000 - 1);
+ paddr = rounddown2(bpa, 0x100000);
tmp->paddr = paddr;
tmp->vaddr = addr;
tmp->size = 0;
diff --git a/sys/arm/xscale/ixp425/avila_machdep.c b/sys/arm/xscale/ixp425/avila_machdep.c
index db2be88..272b1a6 100644
--- a/sys/arm/xscale/ixp425/avila_machdep.c
+++ b/sys/arm/xscale/ixp425/avila_machdep.c
@@ -291,7 +291,7 @@ initarm(struct arm_boot_params *abp)
l1pagetable = kernel_l1pt.pv_va;
/* Map the L2 pages tables in the L1 page table */
- pmap_link_l2pt(l1pagetable, ARM_VECTORS_HIGH & ~(0x00100000 - 1),
+ pmap_link_l2pt(l1pagetable, rounddown2(ARM_VECTORS_HIGH, 0x00100000),
&kernel_pt_table[KERNEL_PT_SYS]);
pmap_link_l2pt(l1pagetable, IXP425_IO_VBASE,
&kernel_pt_table[KERNEL_PT_IO]);
diff --git a/sys/arm/xscale/pxa/pxa_machdep.c b/sys/arm/xscale/pxa/pxa_machdep.c
index f80b4e2..d80da1f 100644
--- a/sys/arm/xscale/pxa/pxa_machdep.c
+++ b/sys/arm/xscale/pxa/pxa_machdep.c
@@ -222,8 +222,8 @@ initarm(struct arm_boot_params *abp)
l1pagetable = kernel_l1pt.pv_va;
/* Map the L2 pages tables in the L1 page table */
- pmap_link_l2pt(l1pagetable, ARM_VECTORS_HIGH & ~(0x00100000 - 1),
- &kernel_pt_table[KERNEL_PT_SYS]);
+ pmap_link_l2pt(l1pagetable, rounddown2(ARM_VECTORS_HIGH, 0x00100000),
+ &kernel_pt_table[KERNEL_PT_SYS]);
#if 0 /* XXXBJR: What is this? Don't know if there's an analogue. */
pmap_link_l2pt(l1pagetable, IQ80321_IOPXS_VBASE,
&kernel_pt_table[KERNEL_PT_IOPXS]);
@@ -235,11 +235,10 @@ initarm(struct arm_boot_params *abp)
pmap_map_chunk(l1pagetable, KERNBASE + 0x100000, SDRAM_START + 0x100000,
0x100000, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
pmap_map_chunk(l1pagetable, KERNBASE + 0x200000, SDRAM_START + 0x200000,
- (((uint32_t)(lastaddr) - KERNBASE - 0x200000) + L1_S_SIZE) & ~(L1_S_SIZE - 1),
- VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
- freemem_after = ((int)lastaddr + PAGE_SIZE) & ~(PAGE_SIZE - 1);
- afterkern = round_page(((vm_offset_t)lastaddr + L1_S_SIZE) &
- ~(L1_S_SIZE - 1));
+ rounddown2(((uint32_t)(lastaddr) - KERNBASE - 0x200000) + L1_S_SIZE, L1_S_SIZE),
+ VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
+ freemem_after = rounddown2((int)lastaddr + PAGE_SIZE, PAGE_SIZE);
+ afterkern = round_page(rounddown2((vm_offset_t)lastaddr + L1_S_SIZE, L1_S_SIZE));
for (i = 0; i < KERNEL_PT_AFKERNEL_NUM; i++) {
pmap_link_l2pt(l1pagetable, afterkern + i * 0x00100000,
&kernel_pt_table[KERNEL_PT_AFKERNEL + i]);
OpenPOWER on IntegriCloud