struct _subtable_data { unsigned int usecount; }; struct _table_data { unsigned char *table; struct _subtable_data subtable[64]; }; struct _addrspace_data { struct _table_data read; struct _table_data write; }; void reallocate_subtable(struct _table_data *tabledata, unsigned char subentry); void release_subtable(struct _table_data *tabledata, unsigned char subentry); void install_mem_handler(struct _addrspace_data *space, int iswrite, int databits, int ismatchmask, unsigned int start, unsigned int end, unsigned int mask, unsigned int mirror, void **handler, int isfixed, const char *handler_name) { unsigned int lmirrorbits; unsigned int hmirrorbits; unsigned int lmirrorcount; unsigned int hmirrorcount; struct _table_data *tabledata = iswrite ? &space->write : &space->read; unsigned char prev_entry = 0; int cur_index; int prev_index = 0; int i; for (i = (32 - 18); hmirrorcount < (1 << hmirrorbits); hmirrorcount++) { unsigned int hmirrorbase = 0; if (cur_index == ((end + hmirrorbase) >> (32 - 18))) { if (hmirrorcount != 0 && prev_entry == tabledata->table[cur_index]) { if (tabledata->table[cur_index] >= (256 - 64)) release_subtable(tabledata, tabledata-> table[cur_index]); if (tabledata->table[prev_index] >= (256 - 64)) reallocate_subtable(tabledata, tabledata-> table[prev_index]); } prev_entry = tabledata->table[cur_index]; } for (lmirrorcount = 0; lmirrorcount < (1 << lmirrorbits); lmirrorcount++) { } } } void reallocate_subtable(struct _table_data *tabledata, unsigned char subentry) { unsigned char subindex = subentry - (256 - 64); if (tabledata->subtable[subindex].usecount <= 0) osd_die(); } void release_subtable(struct _table_data *tabledata, unsigned char subentry) { unsigned char subindex = subentry - (256 - 64); if (tabledata->subtable[subindex].usecount <= 0) osd_die(); }