25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_x86.c,v 1.5 2005/11/13 00:14:07 debug Exp $ |
* $Id: cpu_x86.c,v 1.7 2006/02/17 18:38:30 debug Exp $ |
29 |
* |
* |
30 |
* x86 (and amd64) CPU emulation. |
* x86 (and amd64) CPU emulation. |
31 |
* |
* |
168 |
while (models[i].model_number != 0) { |
while (models[i].model_number != 0) { |
169 |
debug("%s", models[i].name); |
debug("%s", models[i].name); |
170 |
|
|
171 |
for (j=0; j<10-strlen(models[i].name); j++) |
for (j=0; j<10-(int)strlen(models[i].name); j++) |
172 |
debug(" "); |
debug(" "); |
173 |
i++; |
i++; |
174 |
if ((i % 6) == 0 || models[i].name == NULL) |
if ((i % 6) == 0 || models[i].name == NULL) |
508 |
} |
} |
509 |
|
|
510 |
|
|
511 |
static uint32_t read_imm(unsigned char **instrp, uint64_t *newpcp, |
uint32_t read_imm(unsigned char **instrp, uint64_t *newpcp, |
512 |
int mode) |
int mode) |
513 |
{ |
{ |
514 |
return read_imm_common(instrp, newpcp, mode, 0); |
return read_imm_common(instrp, newpcp, mode, 0); |
515 |
} |
} |
516 |
|
|
517 |
|
|
518 |
static void print_csip(struct cpu *cpu) |
void print_csip(struct cpu *cpu) |
519 |
{ |
{ |
520 |
fatal("0x%04x:", cpu->cd.x86.s[X86_S_CS]); |
fatal("0x%04x:", cpu->cd.x86.s[X86_S_CS]); |
521 |
if (PROTECTED_MODE) |
if (PROTECTED_MODE) |
713 |
int segment = 1, rpl, orig_selector = selector; |
int segment = 1, rpl, orig_selector = selector; |
714 |
unsigned char descr[8]; |
unsigned char descr[8]; |
715 |
char *table_name = "GDT"; |
char *table_name = "GDT"; |
716 |
uint64_t base, limit, table_base, table_limit; |
uint64_t base, limit, table_base; |
717 |
|
int64_t table_limit; |
718 |
|
|
719 |
if (segnr > 0x100) /* arbitrary, larger than N_X86_SEGS */ |
if (segnr > 0x100) /* arbitrary, larger than N_X86_SEGS */ |
720 |
segment = 0; |
segment = 0; |
2429 |
* |
* |
2430 |
* TODO: Level 1 and 2 info. |
* TODO: Level 1 and 2 info. |
2431 |
*/ |
*/ |
2432 |
static void x86_cpuid(struct cpu *cpu) |
void x86_cpuid(struct cpu *cpu) |
2433 |
{ |
{ |
2434 |
switch (cpu->cd.x86.r[X86_R_AX]) { |
switch (cpu->cd.x86.r[X86_R_AX]) { |
2435 |
/* Normal CPU id: */ |
/* Normal CPU id: */ |
2597 |
if (PROTECTED_MODE) { |
if (PROTECTED_MODE) { |
2598 |
int i, int_type = 0; |
int i, int_type = 0; |
2599 |
|
|
2600 |
if (nr * 8 > cpu->cd.x86.idtr_limit) { |
if (nr * 8 > (int)cpu->cd.x86.idtr_limit) { |
2601 |
fatal("TODO: protected mode int 0x%02x outside idtr" |
fatal("TODO: protected mode int 0x%02x outside idtr" |
2602 |
" limit (%i)?\n", nr, (int)cpu->cd.x86.idtr_limit); |
" limit (%i)?\n", nr, (int)cpu->cd.x86.idtr_limit); |
2603 |
cpu->running = 0; |
cpu->running = 0; |
2739 |
/* |
/* |
2740 |
* Real mode: |
* Real mode: |
2741 |
*/ |
*/ |
2742 |
if (nr * 4 > cpu->cd.x86.idtr_limit) { |
if (nr * 4 > (int)cpu->cd.x86.idtr_limit) { |
2743 |
fatal("TODO: real mode int 0x%02x outside idtr limit (" |
fatal("TODO: real mode int 0x%02x outside idtr limit (" |
2744 |
"%i)?\n", nr, (int)cpu->cd.x86.idtr_limit); |
"%i)?\n", nr, (int)cpu->cd.x86.idtr_limit); |
2745 |
cpu->running = 0; |
cpu->running = 0; |