diff options
author | gonzo <gonzo@FreeBSD.org> | 2012-03-15 23:53:24 +0000 |
---|---|---|
committer | gonzo <gonzo@FreeBSD.org> | 2012-03-15 23:53:24 +0000 |
commit | dd9eff8d3914d10be3494051291f65b525a21fda (patch) | |
tree | 7a1852d96154dbcb357b63eb360c52dc9d2b617a /sys/mips | |
parent | 6a20b9d5e1b5cb14c03717b65c2e6acd19edb28a (diff) | |
download | FreeBSD-src-dd9eff8d3914d10be3494051291f65b525a21fda.zip FreeBSD-src-dd9eff8d3914d10be3494051291f65b525a21fda.tar.gz |
Clean-up fake preload data generator:
- Use macros to push scalar values
- Fix type mismatch for module size
Diffstat (limited to 'sys/mips')
-rw-r--r-- | sys/mips/mips/machdep.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/sys/mips/mips/machdep.c b/sys/mips/mips/machdep.c index 21b85c5..99d6a8f 100644 --- a/sys/mips/mips/machdep.c +++ b/sys/mips/mips/machdep.c @@ -384,46 +384,41 @@ mips_postboot_fixup(void) caddr_t preload_ptr = (caddr_t)&fake_preload[0]; size_t size = 0; +#define PRELOAD_PUSH_VALUE(type, value) do { \ + *(type *)(preload_ptr + size) = (value); \ + size += sizeof(type); \ +} while (0); + /* * Provide kernel module file information */ - *(uint32_t*)(preload_ptr + size) = MODINFO_NAME; - size += sizeof(uint32_t); - *(uint32_t*)(preload_ptr + size) = strlen("kernel") + 1; - size += sizeof(uint32_t); + PRELOAD_PUSH_VALUE(uint32_t, MODINFO_NAME); + PRELOAD_PUSH_VALUE(uint32_t, strlen("kernel") + 1); strcpy((char*)(preload_ptr + size), "kernel"); size += strlen("kernel") + 1; size = roundup(size, sizeof(u_long)); - *(uint32_t*)(preload_ptr + size) = MODINFO_TYPE; - size += sizeof(uint32_t); - *(uint32_t*)(preload_ptr + size) = strlen("elf kernel") + 1; - size += sizeof(uint32_t); + PRELOAD_PUSH_VALUE(uint32_t, MODINFO_TYPE); + PRELOAD_PUSH_VALUE(uint32_t, strlen("elf kernel") + 1); strcpy((char*)(preload_ptr + size), "elf kernel"); size += strlen("elf kernel") + 1; size = roundup(size, sizeof(u_long)); - *(uint32_t*)(preload_ptr + size) = MODINFO_ADDR; - size += sizeof(uint32_t); - *(uint32_t*)(preload_ptr + size) = sizeof(vm_offset_t); - size += sizeof(uint32_t); - *(vm_offset_t*)(preload_ptr + size) = KERNLOADADDR; - size += sizeof(vm_offset_t); + PRELOAD_PUSH_VALUE(uint32_t, MODINFO_ADDR); + PRELOAD_PUSH_VALUE(uint32_t, sizeof(vm_offset_t)); + PRELOAD_PUSH_VALUE(vm_offset_t, KERNLOADADDR); size = roundup(size, sizeof(u_long)); - *(uint32_t*)(preload_ptr + size) = MODINFO_SIZE; - size += sizeof(uint32_t); - *(uint32_t*)(preload_ptr + size) = sizeof(size_t); - size += sizeof(uint32_t); - *(vm_offset_t*)(preload_ptr + size) = (size_t)&end - KERNLOADADDR; + PRELOAD_PUSH_VALUE(uint32_t, MODINFO_SIZE); + PRELOAD_PUSH_VALUE(uint32_t, sizeof(size_t)); + PRELOAD_PUSH_VALUE(size_t, (size_t)&end - KERNLOADADDR); size = roundup(size, sizeof(u_long)); - size += sizeof(size_t); /* End marker */ - *(uint32_t*)(preload_ptr + size) = 0; - size += sizeof(uint32_t); - *(uint32_t*)(preload_ptr + size) = 0; - size += sizeof(uint32_t); + PRELOAD_PUSH_VALUE(uint32_t, 0); + PRELOAD_PUSH_VALUE(uint32_t, 0); + +#undef PRELOAD_PUSH_VALUE KASSERT((size < sizeof(fake_preload)), ("fake preload size is more thenallocated")); |