25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: memory_x86.c,v 1.1 2005/08/29 14:36:42 debug Exp $ |
* $Id: memory_x86.c,v 1.2 2006/03/30 19:41:51 debug Exp $ |
29 |
* |
* |
30 |
* Included from cpu_x86.c. |
* Included from cpu_x86.c. |
31 |
* |
* |
72 |
writable = 1; |
writable = 1; |
73 |
} else { |
} else { |
74 |
if (PROTECTED_MODE && vaddr > dc->limit) { |
if (PROTECTED_MODE && vaddr > dc->limit) { |
75 |
fatal("TODO: vaddr=0x%llx > limit (0x%llx)\n", |
fatal("TODO: vaddr=0x%"PRIx64" > limit (0x%"PRIx64")\n", |
76 |
(long long)vaddr, (long long)dc->limit); |
(uint64_t) vaddr, (uint64_t) dc->limit); |
77 |
/* goto fail; */ |
/* goto fail; */ |
78 |
} |
} |
79 |
|
|
80 |
/* TODO: Check the Privilege Level */ |
/* TODO: Check the Privilege Level */ |
90 |
/* TODO: This should be cached somewhere, in some |
/* TODO: This should be cached somewhere, in some |
91 |
kind of simulated TLB. */ |
kind of simulated TLB. */ |
92 |
if (cpu->cd.x86.cr[3] & 0xfff) { |
if (cpu->cd.x86.cr[3] & 0xfff) { |
93 |
fatal("TODO: cr3=%016llx (lowest bits non-zero)\n", |
fatal("TODO: cr3=%016"PRIx64" (lowest bits non-zero)\n", |
94 |
(long long)cpu->cd.x86.cr[3]); |
(uint64_t) cpu->cd.x86.cr[3]); |
95 |
goto fail; |
goto fail; |
96 |
} |
} |
97 |
|
|
107 |
res = cpu->memory_rw(cpu, cpu->mem, table_addr + 4*a, pded, |
res = cpu->memory_rw(cpu, cpu->mem, table_addr + 4*a, pded, |
108 |
sizeof(pded), MEM_READ, PHYSICAL); |
sizeof(pded), MEM_READ, PHYSICAL); |
109 |
if (!res) { |
if (!res) { |
110 |
fatal("TODO: could not read pde (table = 0x%llx)\n", |
fatal("TODO: could not read pde (table = 0x%"PRIx64 |
111 |
(long long)table_addr); |
")\n", (uint64_t) table_addr); |
112 |
goto fail; |
goto fail; |
113 |
} |
} |
114 |
if ((pded[0] & 0x01) && !(pded[0] & 0x20)) { |
if ((pded[0] & 0x01) && !(pded[0] & 0x20)) { |
129 |
if (!(pde & 0x01)) { |
if (!(pde & 0x01)) { |
130 |
fatal("PAGE FAULT: pde not present: vaddr=0x%08x, " |
fatal("PAGE FAULT: pde not present: vaddr=0x%08x, " |
131 |
"usermode=%i\n", (int)vaddr, usermode); |
"usermode=%i\n", (int)vaddr, usermode); |
132 |
fatal(" CS:EIP = 0x%04x:0x%016llx\n", |
fatal(" CS:EIP = 0x%04x:0x%016"PRIx64"\n", |
133 |
(int)cpu->cd.x86.s[X86_S_CS], |
(int) cpu->cd.x86.s[X86_S_CS], (uint64_t) cpu->pc); |
|
(long long)cpu->pc); |
|
134 |
if (!no_exceptions) { |
if (!no_exceptions) { |
135 |
cpu->cd.x86.cr[2] = vaddr; |
cpu->cd.x86.cr[2] = vaddr; |
136 |
x86_interrupt(cpu, 14, (writeflag? 2 : 0) + |
x86_interrupt(cpu, 14, (writeflag? 2 : 0) + |
144 |
res = cpu->memory_rw(cpu, cpu->mem, table_addr + 4*b, pted, |
res = cpu->memory_rw(cpu, cpu->mem, table_addr + 4*b, pted, |
145 |
sizeof(pted), MEM_READ, PHYSICAL); |
sizeof(pted), MEM_READ, PHYSICAL); |
146 |
if (!res) { |
if (!res) { |
147 |
fatal("TODO: could not read pte (pt = 0x%llx)\n", |
fatal("TODO: could not read pte (pt = 0x%"PRIx64")\n", |
148 |
(long long)table_addr); |
(uint64_t) table_addr); |
149 |
goto fail; |
goto fail; |
150 |
} |
} |
151 |
pte = pted[0] + (pted[1] << 8) + (pted[2] << 16) + |
pte = pted[0] + (pted[1] << 8) + (pted[2] << 16) + |