/* Round start to nearest page boundary below and set len so that the resulting address range ends at the lowest * possible page boundary where the original address range is still entirely contained. It returns the * difference between the rounded start address and the original start address. */ static uintptr_t round_to_page_boundaries(uintptr_t *start, size_t *len) { uintptr_t page_size = getpagesize(); uintptr_t page_mask = ~(page_size-1); uintptr_t end = *start + *len; uintptr_t old_start = *start; msg_gspew("page_size=%" PRIxPTR "\n", page_size); msg_gspew("pre-rounding: start=0x%0*" PRIxPTR ", len=0x%zx, end=0x%0*" PRIxPTR "\n", PRIxPTR_WIDTH, *start, *len, PRIxPTR_WIDTH, end); *start = *start & page_mask; end = (end + page_size - 1) & page_mask; *len = end - *start; msg_gspew("post-rounding: start=0x%0*" PRIxPTR ", len=0x%zx, end=0x%0*" PRIxPTR "\n", PRIxPTR_WIDTH, *start, *len, PRIxPTR_WIDTH, *start + *len); return old_start - *start; }
/* returns the index of the entry (or a negative value if it is not found) */ static int find_romentry(char *name) { int i; if (num_rom_entries == 0) return -1; msg_gspew("Looking for region \"%s\"... ", name); for (i = 0; i < num_rom_entries; i++) { if (!strcmp(rom_entries[i].name, name)) { rom_entries[i].included = 1; msg_gspew("found.\n"); return i; } } msg_gspew("not found.\n"); return -1; }