Use native-sized accesses when accessing memory from kdb.
Not all MMIO mapped devices supports byte access. MFC after: 4 weeks
This commit is contained in:
parent
1f446a117e
commit
a67687fcd8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=362388
@ -118,12 +118,25 @@ db_read_bytes(vm_offset_t addr, size_t size, char *data)
|
|||||||
void *prev_jb;
|
void *prev_jb;
|
||||||
const char *src;
|
const char *src;
|
||||||
int ret;
|
int ret;
|
||||||
|
uint64_t tmp64;
|
||||||
|
uint32_t tmp32;
|
||||||
|
uint16_t tmp16;
|
||||||
|
|
||||||
prev_jb = kdb_jmpbuf(jb);
|
prev_jb = kdb_jmpbuf(jb);
|
||||||
ret = setjmp(jb);
|
ret = setjmp(jb);
|
||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
src = (const char *)addr;
|
src = (const char *)addr;
|
||||||
|
if (size == 8 && (addr & 7) == 0) {
|
||||||
|
tmp64 = *((const int *)src);
|
||||||
|
src = (const char *)&tmp64;
|
||||||
|
} else if (size == 4 && (addr & 3) == 0) {
|
||||||
|
tmp32 = *((const int *)src);
|
||||||
|
src = (const char *)&tmp32;
|
||||||
|
} else if (size == 2 && (addr & 1) == 0) {
|
||||||
|
tmp16 = *((const short *)src);
|
||||||
|
src = (const char *)&tmp16;
|
||||||
|
}
|
||||||
while (size-- > 0)
|
while (size-- > 0)
|
||||||
*data++ = *src++;
|
*data++ = *src++;
|
||||||
}
|
}
|
||||||
@ -142,14 +155,33 @@ db_write_bytes(vm_offset_t addr, size_t size, char *data)
|
|||||||
void *prev_jb;
|
void *prev_jb;
|
||||||
char *dst;
|
char *dst;
|
||||||
int ret;
|
int ret;
|
||||||
|
uint64_t tmp64;
|
||||||
|
uint32_t tmp32;
|
||||||
|
uint16_t tmp16;
|
||||||
|
|
||||||
prev_jb = kdb_jmpbuf(jb);
|
prev_jb = kdb_jmpbuf(jb);
|
||||||
ret = setjmp(jb);
|
ret = setjmp(jb);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
dst = (char *)addr;
|
if (size == 8 && (addr & 7) == 0) {
|
||||||
while (size-- > 0)
|
dst = (char *)&tmp64;
|
||||||
*dst++ = *data++;
|
while (size-- > 0)
|
||||||
|
*dst++ = *data++;
|
||||||
|
*((uint64_t *)addr) = tmp64;
|
||||||
|
} else if (size == 4 && (addr & 3) == 0) {
|
||||||
|
dst = (char *)&tmp32;
|
||||||
|
while (size-- > 0)
|
||||||
|
*dst++ = *data++;
|
||||||
|
*((uint32_t *)addr) = tmp32;
|
||||||
|
} else if (size == 2 && (addr & 1) == 0) {
|
||||||
|
dst = (char *)&tmp16;
|
||||||
|
while (size-- > 0)
|
||||||
|
*dst++ = *data++;
|
||||||
|
*((uint32_t *)addr) = tmp16;
|
||||||
|
} else {
|
||||||
|
dst = (char *)addr;
|
||||||
|
while (size-- > 0)
|
||||||
|
*dst++ = *data++;
|
||||||
|
}
|
||||||
dsb(ish);
|
dsb(ish);
|
||||||
|
|
||||||
/* Clean D-cache and invalidate I-cache */
|
/* Clean D-cache and invalidate I-cache */
|
||||||
|
Loading…
Reference in New Issue
Block a user