]> git.wh0rd.org - ICEs.git/blame - bfin-asm-math/memory.i
initial import
[ICEs.git] / bfin-asm-math / memory.i
CommitLineData
45516216 1struct _subtable_data {
2 int usecount;
3};
4struct _table_data {
5 unsigned char *table;
6 struct _subtable_data subtable[64];
7};
8void reallocate_subtable(struct _table_data *tabledata, unsigned char subentry)
9{
10 unsigned char subindex = subentry - (256 - 64);
11 if (tabledata->subtable[subindex].usecount <= 0)
12 osd_die();
13}
14void release_subtable(struct _table_data *tabledata, unsigned char subentry)
15{
16 unsigned char subindex = subentry - (256 - 64);
17 if (tabledata->subtable[subindex].usecount <= 0)
18 osd_die();
19}
20void install_mem_handler(int end, char *handler_name)
21{
22 int lmirrorbits;
23 int hmirrorbits;
24 int lmirrorcount;
25 int hmirrorcount;
26 struct _table_data *tabledata;
27 char prev_entry;
28 int cur_index;
29 int prev_index;
30 for (; hmirrorcount < (1 << hmirrorbits); hmirrorcount++) {
31 int hmirrorbase = 0;
32 if (cur_index == ((end + hmirrorbase) >> (32 - 18))) {
33 if (hmirrorcount != 0
34 && prev_entry == tabledata->table[cur_index]) {
35 if (tabledata->table[cur_index] >= (256 - 64))
36 release_subtable(tabledata,
37 tabledata->
38 table[cur_index]);
39 if (tabledata->table[prev_index] >= (256 - 64))
40 reallocate_subtable(tabledata,
41 tabledata->
42 table[prev_index]);
43 }
44 }
45 for (lmirrorcount = 0;
46 lmirrorcount < (1 << lmirrorbits); lmirrorcount++) ;
47 }
48}