Port-powerpc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

How to use a bus_space at the end of a 32-bit address space?



Hi,

I ran into the following problem:
I need a PPC bus space from 0xff000000 to 0xffffffff, i.e. until the end
of the available 32-bit address space. Defining the bus space as

struct powerpc_bus_space sandpoint_flash_space_tag = {
        _BUS_SPACE_BIG_ENDIAN|_BUS_SPACE_MEM_TYPE,
        0x00000000, 0xff000000, 0xffffffff,
};

is bad, because the end address of the extent will be set to 0xfffffffe
(refer to bus_space_init() in bus_space.c). I lose 1 byte.

Setting the limit to 0x00000000 doesn't work either, because now
bus_space_map(9) will fail, as the start address is always larger than
the limit.

It would have been better to define the powerpc_bus_space limit as
the last address of the region, as already done in the extent.

Another solution is to allow 0x00000000 as limit, as in the following
patch:

--- sys/arch/powerpc/powerpc/bus_space.c        30 Jun 2011 00:53:00 -0000      
1.28
+++ sys/arch/powerpc/powerpc/bus_space.c        4 Dec 2011 12:16:08 -0000
@@ -526,7 +526,7 @@
        size = _BUS_SPACE_STRIDE(t, size);
        bpa = _BUS_SPACE_STRIDE(t, bpa);
 
-       if (bpa + size > t->pbs_limit) {
+       if (t->pbs_limit != 0 && bpa + size > t->pbs_limit) {
 #ifdef DEBUG
                printf("bus_space_map(%p[%x:%x], %#x, %#x) failed: EINVAL\n",
                    t, t->pbs_base, t->pbs_limit, bpa, size);
@@ -702,7 +702,7 @@
        if (t->pbs_extent == NULL)
                return ENOMEM;
 
-       if (rstart + size > t->pbs_limit) {
+       if (t->pbs_limit != 0 && rstart + size > t->pbs_limit) {
 #ifdef DEBUG
                printf("%s(%p[%x:%x], %#x, %#x) failed: EINVAL\n",
                   __func__, t, t->pbs_base, t->pbs_limit, rstart, size);


What do you think? Does that make sense? Should I commit that?

-- 
Frank Wille


Home | Main Index | Thread Index | Old Index