summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Tymoshenko <gonzo@FreeBSD.org>2012-03-15 23:53:24 +0000
committerOleksandr Tymoshenko <gonzo@FreeBSD.org>2012-03-15 23:53:24 +0000
commit66134c7e5932fc6373b4df843d056b5ed640b376 (patch)
tree7a1852d96154dbcb357b63eb360c52dc9d2b617a
parent0d8d9edaaaca133545e9c50bbc51a19ea2bd6006 (diff)
Notes
-rw-r--r--sys/mips/mips/machdep.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/sys/mips/mips/machdep.c b/sys/mips/mips/machdep.c
index 21b85c571d9a3..99d6a8f172b8e 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"));