struct intrinfo_entry * add_interrupt(const struct startup_intrinfo *startup_intr) { struct intrinfo_entry *intr; unsigned i; if(intr_prev_output_rtn == NULL) { //Hook into the sizing/writing list intr_prev_output_rtn = callout_output_rtn; callout_output_rtn = (output_callout_t *)callout_output_intr; } intr = grow_syspage_section(&lsp.intrinfo, sizeof(*intr)); //Point at newly allocated entry intr = (void *)((uint8_t *)intr + lsp.intrinfo.size - sizeof(*intr)); *intr = *(struct intrinfo_entry *)startup_intr; if(startup_intr->id.rtn != NULL) { intr->id.size = startup_intr->id.rtn->rtn_size; } if(startup_intr->eoi.rtn != NULL) { intr->eoi.size = startup_intr->eoi.rtn->rtn_size; } for(i = 0; i < NUM_ELTS(offsets); ++i) { void (**rtn)(void) = (void (**)(void))((uintptr_t)intr + offsets[i]); callout_register_data(rtn, startup_intr->patch_data); } return(intr); }
int add_cache_ways(int next, unsigned flags, unsigned line_size, unsigned num_lines, unsigned ways, const struct callout_rtn *rtn) { struct cacheattr_entry *cache = lsp.cacheattr.p; int num = lsp.cacheattr.size / sizeof(*cache); int i; if(cache_prev_output_rtn == NULL) { //Hook into the sizing/writing list cache_prev_output_rtn = callout_output_rtn; callout_output_rtn = (output_callout_t *)callout_output_cache; } //Look for an already existing entry that matches for(i = 0; i < num; ++i, ++cache) { if( cache->next == next && cache->flags == flags && cache->line_size == line_size && cache->num_lines == num_lines && cache->control == (cache_rtn *)rtn) return(i); } //Have to add a new entry cache = grow_syspage_section(&lsp.cacheattr, sizeof(*cache)); cache += i; cache->next = next; cache->flags = flags; cache->line_size = line_size; cache->num_lines = num_lines; cache->ways = ways; cache->control = (cache_rtn *)rtn; return(i); }
unsigned add_typed_string(int type_index, const char *name) { char *p = lsp.typed_strings.p->data; unsigned i; unsigned len; unsigned spare; unsigned need; del_typed_string(type_index); i = find_typed_string(_CS_NONE); len = strlen(name) + 1; len = ROUND(len, sizeof(uint32_t)); need = len + 2*sizeof(uint32_t); spare = lsp.typed_strings.size - i; if(spare < need) { grow_syspage_section(&lsp.typed_strings, need - spare); } *(uint32_t *)&p[i] = type_index; strcpy(&p[i+sizeof(uint32_t)], name); return(i); }
unsigned add_string(const char *name) { char *p = lsp.strings.p->data; char *str; unsigned i; unsigned len; unsigned spare; i = 0; for( ;; ) { str = &p[i]; if(*str == '\0') break; if(strcmp(name, str) == 0) return(i); i += strlen(str)+1; } len = strlen(name) + 2; spare = lsp.strings.size - i; if(len > spare) { grow_syspage_section(&lsp.strings, len - (lsp.strings.size-i)); } strcpy(str, name); return(i); }