Some systems don't have dense space; don't require it.
This commit is contained in:
parent
2e7a822ef2
commit
ac20942bc5
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pci_swiz_bus_mem_chipdep.c,v 1.28 1999/12/07 05:44:58 thorpej Exp $ */
|
||||
/* $NetBSD: pci_swiz_bus_mem_chipdep.c,v 1.29 1999/12/07 07:04:39 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
||||
@ -169,12 +169,14 @@ void __C(CHIP,_mem_copy_region_4) __P((void *, bus_space_handle_t,
|
||||
void __C(CHIP,_mem_copy_region_8) __P((void *, bus_space_handle_t,
|
||||
bus_size_t, bus_space_handle_t, bus_size_t, bus_size_t));
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
#ifndef CHIP_D_MEM_EX_STORE
|
||||
static long
|
||||
__C(CHIP,_dmem_ex_storage)[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
|
||||
#define CHIP_D_MEM_EX_STORE(v) (__C(CHIP,_dmem_ex_storage))
|
||||
#define CHIP_D_MEM_EX_STORE_SIZE(v) (sizeof __C(CHIP,_dmem_ex_storage))
|
||||
#endif
|
||||
#endif /* CHIP_D_MEM_BASE */
|
||||
|
||||
#ifndef CHIP_S_MEM_EX_STORE
|
||||
static long
|
||||
@ -278,6 +280,7 @@ __C(CHIP,_bus_mem_init)(t, v)
|
||||
EX_NOWAIT);
|
||||
extent_alloc_region(dex, 0, 0xffffffffffffffffUL, EX_NOWAIT);
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
#ifdef CHIP_D_MEM_W1_BUS_START
|
||||
#ifdef EXTENT_DEBUG
|
||||
printf("dmem: freeing from 0x%lx to 0x%lx\n",
|
||||
@ -292,6 +295,7 @@ __C(CHIP,_bus_mem_init)(t, v)
|
||||
extent_print(dex);
|
||||
#endif
|
||||
CHIP_D_MEM_EXTENT(v) = dex;
|
||||
#endif /* CHIP_D_MEM_BASE */
|
||||
|
||||
/* XXX WE WANT EXTENT_NOCOALESCE, BUT WE CAN'T USE IT. XXX */
|
||||
sex = extent_create(__S(__C(CHIP,_bus_smem)), 0x0UL,
|
||||
@ -349,15 +353,18 @@ __C(CHIP,_bus_mem_init)(t, v)
|
||||
CHIP_S_MEM_EXTENT(v) = sex;
|
||||
}
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
static int __C(CHIP,_xlate_addr_to_dense_handle) __P((void *,
|
||||
bus_addr_t, bus_space_handle_t *));
|
||||
static int __C(CHIP,_xlate_dense_handle_to_addr) __P((void *,
|
||||
bus_space_handle_t, bus_addr_t *));
|
||||
#endif /* CHIP_D_MEM_BASE */
|
||||
static int __C(CHIP,_xlate_addr_to_sparse_handle) __P((void *,
|
||||
bus_addr_t, bus_space_handle_t *));
|
||||
static int __C(CHIP,_xlate_sparse_handle_to_addr) __P((void *,
|
||||
bus_space_handle_t, bus_addr_t *));
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
static int
|
||||
__C(CHIP,_xlate_addr_to_dense_handle)(v, memaddr, memhp)
|
||||
void *v;
|
||||
@ -394,6 +401,7 @@ __C(CHIP,_xlate_dense_handle_to_addr)(v, memh, memaddrp)
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
#endif /* CHIP_D_MEM_BASE */
|
||||
|
||||
static int
|
||||
__C(CHIP,_xlate_addr_to_sparse_handle)(v, memaddr, memhp)
|
||||
@ -485,6 +493,11 @@ __C(CHIP,_mem_map)(v, memaddr, memsize, flags, memhp, acct)
|
||||
int cacheable = flags & BUS_SPACE_MAP_CACHEABLE;
|
||||
int linear = flags & BUS_SPACE_MAP_LINEAR;
|
||||
|
||||
#ifndef CHIP_D_MEM_BASE
|
||||
/* No cacheable space without dense. */
|
||||
cacheable = 0;
|
||||
#endif /* ! CHIP_D_MEM_BASE */
|
||||
|
||||
/* Requests for linear uncacheable space can't be satisfied. */
|
||||
if (linear && !cacheable)
|
||||
return (EOPNOTSUPP);
|
||||
@ -497,7 +510,11 @@ __C(CHIP,_mem_map)(v, memaddr, memsize, flags, memhp, acct)
|
||||
if (acct == 0)
|
||||
return (EOPNOTSUPP);
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
mustd = 1;
|
||||
#else
|
||||
mustd = 0;
|
||||
#endif
|
||||
musts = (cacheable == 0);
|
||||
|
||||
#ifdef EXTENT_DEBUG
|
||||
@ -506,8 +523,12 @@ __C(CHIP,_mem_map)(v, memaddr, memsize, flags, memhp, acct)
|
||||
printf("mem: %s dense, %s sparse\n", mustd ? "need" : "want",
|
||||
musts ? "need" : "want");
|
||||
#endif
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
errord = extent_alloc_region(CHIP_D_MEM_EXTENT(v), memaddr, memsize,
|
||||
EX_NOWAIT | (CHIP_EX_MALLOC_SAFE(v) ? EX_MALLOCOK : 0));
|
||||
#else
|
||||
errord = EINVAL;
|
||||
#endif
|
||||
didd = (errord == 0);
|
||||
errors = extent_alloc_region(CHIP_S_MEM_EXTENT(v), memaddr, memsize,
|
||||
EX_NOWAIT | (CHIP_EX_MALLOC_SAFE(v) ? EX_MALLOCOK : 0));
|
||||
@ -523,6 +544,7 @@ __C(CHIP,_mem_map)(v, memaddr, memsize, flags, memhp, acct)
|
||||
if ((mustd && !didd) || (musts && !dids))
|
||||
goto bad;
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if (didd && !__C(CHIP,_xlate_addr_to_dense_handle)(v, memaddr, &dh)) {
|
||||
printf("\n");
|
||||
#ifdef CHIP_D_MEM_W1_BUS_START
|
||||
@ -532,6 +554,7 @@ __C(CHIP,_mem_map)(v, memaddr, memsize, flags, memhp, acct)
|
||||
panic("%s: don't know how to map %lx cacheable",
|
||||
__S(__C(CHIP,_mem_map)), memaddr);
|
||||
}
|
||||
#endif /* CHIP_D_MEM_BASE */
|
||||
|
||||
if (dids && !__C(CHIP,_xlate_addr_to_sparse_handle)(v, memaddr, &sh)) {
|
||||
printf("\n");
|
||||
@ -561,6 +584,7 @@ bad:
|
||||
#ifdef EXTENT_DEBUG
|
||||
printf("mem: failed\n");
|
||||
#endif
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if (didd) {
|
||||
#ifdef EXTENT_DEBUG
|
||||
printf("mem: freeing dense\n");
|
||||
@ -572,6 +596,7 @@ bad:
|
||||
memaddr + memsize - 1);
|
||||
}
|
||||
}
|
||||
#endif /* CHIP_D_MEM_BASE */
|
||||
if (dids) {
|
||||
#ifdef EXTENT_DEBUG
|
||||
printf("mem: freeing sparse\n");
|
||||
@ -585,7 +610,9 @@ bad:
|
||||
}
|
||||
|
||||
#ifdef EXTENT_DEBUG
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
extent_print(CHIP_D_MEM_EXTENT(v));
|
||||
#endif
|
||||
extent_print(CHIP_S_MEM_EXTENT(v));
|
||||
#endif
|
||||
|
||||
@ -604,7 +631,9 @@ __C(CHIP,_mem_unmap)(v, memh, memsize, acct)
|
||||
int acct;
|
||||
{
|
||||
bus_addr_t memaddr;
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
bus_space_handle_t temph;
|
||||
#endif
|
||||
int sparse, haves, haved;
|
||||
|
||||
if (acct == 0)
|
||||
@ -626,15 +655,18 @@ __C(CHIP,_mem_unmap)(v, memh, memsize, acct)
|
||||
if (sparse)
|
||||
haves = __C(CHIP,_xlate_sparse_handle_to_addr)(v, memh,
|
||||
&memaddr);
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
else
|
||||
haved = __C(CHIP,_xlate_dense_handle_to_addr)(v, memh,
|
||||
&memaddr);
|
||||
#endif /* CHIP_D_MEM_BASE */
|
||||
|
||||
if (!haves && !haved)
|
||||
panic("%s: couldn't get addr from %s handle 0x%lx",
|
||||
__S(__C(CHIP,_mem_unmap)), sparse ? "sparse" : "dense",
|
||||
memh);
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
/*
|
||||
* Find out were/if that address lives in the other space.
|
||||
*/
|
||||
@ -644,6 +676,7 @@ __C(CHIP,_mem_unmap)(v, memh, memsize, acct)
|
||||
else
|
||||
haves = __C(CHIP,_xlate_addr_to_sparse_handle)(v, memaddr,
|
||||
&temph);
|
||||
#endif /* CHIP_D_MEM_BASE */
|
||||
|
||||
/*
|
||||
* Free any ranges we have.
|
||||
@ -652,12 +685,14 @@ __C(CHIP,_mem_unmap)(v, memh, memsize, acct)
|
||||
printf("mem: it's at 0x%lx (%sdense, %ssparse)\n", memaddr,
|
||||
haved ? "" : "not ", haves ? "" : "not ");
|
||||
#endif
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if (haved && extent_free(CHIP_D_MEM_EXTENT(v), memaddr, memsize,
|
||||
EX_NOWAIT | (CHIP_EX_MALLOC_SAFE(v) ? EX_MALLOCOK : 0)) != 0) {
|
||||
printf("%s: WARNING: couldn't free dense 0x%lx-0x%lx\n",
|
||||
__S(__C(CHIP,_mem_map)), memaddr,
|
||||
memaddr + memsize - 1);
|
||||
}
|
||||
#endif
|
||||
if (haves && extent_free(CHIP_S_MEM_EXTENT(v), memaddr, memsize,
|
||||
EX_NOWAIT | (CHIP_EX_MALLOC_SAFE(v) ? EX_MALLOCOK : 0)) != 0) {
|
||||
printf("%s: WARNING: couldn't free sparse 0x%lx-0x%lx\n",
|
||||
@ -729,8 +764,10 @@ __C(CHIP,_mem_read_1)(v, memh, off)
|
||||
|
||||
alpha_mb();
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if ((memh >> 63) != 0)
|
||||
return (*(u_int8_t *)(memh + off));
|
||||
#endif
|
||||
|
||||
tmpmemh = memh + off;
|
||||
offset = tmpmemh & 3;
|
||||
@ -755,8 +792,10 @@ __C(CHIP,_mem_read_2)(v, memh, off)
|
||||
|
||||
alpha_mb();
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if ((memh >> 63) != 0)
|
||||
return (*(u_int16_t *)(memh + off));
|
||||
#endif
|
||||
|
||||
tmpmemh = memh + off;
|
||||
offset = tmpmemh & 3;
|
||||
@ -781,8 +820,10 @@ __C(CHIP,_mem_read_4)(v, memh, off)
|
||||
|
||||
alpha_mb();
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if ((memh >> 63) != 0)
|
||||
return (*(u_int32_t *)(memh + off));
|
||||
#endif
|
||||
|
||||
tmpmemh = memh + off;
|
||||
offset = tmpmemh & 3;
|
||||
@ -807,8 +848,10 @@ __C(CHIP,_mem_read_8)(v, memh, off)
|
||||
|
||||
alpha_mb();
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if ((memh >> 63) != 0)
|
||||
return (*(u_int64_t *)(memh + off));
|
||||
#endif
|
||||
|
||||
/* XXX XXX XXX */
|
||||
panic("%s not implemented", __S(__C(CHIP,_mem_read_8)));
|
||||
@ -864,9 +907,12 @@ __C(CHIP,_mem_write_1)(v, memh, off, val)
|
||||
register u_int32_t *port, nval;
|
||||
register int offset;
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if ((memh >> 63) != 0)
|
||||
(*(u_int8_t *)(memh + off)) = val;
|
||||
else {
|
||||
else
|
||||
#endif
|
||||
{
|
||||
tmpmemh = memh + off;
|
||||
offset = tmpmemh & 3;
|
||||
nval = val << (8 * offset);
|
||||
@ -888,9 +934,12 @@ __C(CHIP,_mem_write_2)(v, memh, off, val)
|
||||
register u_int32_t *port, nval;
|
||||
register int offset;
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if ((memh >> 63) != 0)
|
||||
(*(u_int16_t *)(memh + off)) = val;
|
||||
else {
|
||||
else
|
||||
#endif
|
||||
{
|
||||
tmpmemh = memh + off;
|
||||
offset = tmpmemh & 3;
|
||||
nval = val << (8 * offset);
|
||||
@ -912,9 +961,12 @@ __C(CHIP,_mem_write_4)(v, memh, off, val)
|
||||
register u_int32_t *port, nval;
|
||||
register int offset;
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if ((memh >> 63) != 0)
|
||||
(*(u_int32_t *)(memh + off)) = val;
|
||||
else {
|
||||
else
|
||||
#endif
|
||||
{
|
||||
tmpmemh = memh + off;
|
||||
offset = tmpmemh & 3;
|
||||
nval = val /*<< (8 * offset)*/;
|
||||
@ -933,9 +985,12 @@ __C(CHIP,_mem_write_8)(v, memh, off, val)
|
||||
u_int64_t val;
|
||||
{
|
||||
|
||||
#ifdef CHIP_D_MEM_BASE
|
||||
if ((memh >> 63) != 0)
|
||||
(*(u_int64_t *)(memh + off)) = val;
|
||||
else {
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* XXX XXX XXX */
|
||||
panic("%s not implemented",
|
||||
__S(__C(CHIP,_mem_write_8)));
|
||||
|
Loading…
Reference in New Issue
Block a user