--- np2/i386c/ia32/segments.c 2008/03/22 04:03:08 1.19 +++ np2/i386c/ia32/segments.c 2012/02/05 02:22:49 1.25 @@ -1,5 +1,3 @@ -/* $Id: segments.c,v 1.19 2008/03/22 04:03:08 monaka Exp $ */ - /* * Copyright (c) 2003 NONAKA Kimihiro * All rights reserved. @@ -30,7 +28,7 @@ #include "ia32.mcr" -void +void CPUCALL load_segreg(int idx, UINT16 selector, UINT16 *sregp, descriptor_t *sdp, int exc) { selector_t sel; @@ -44,7 +42,6 @@ load_segreg(int idx, UINT16 selector, UI /* real-mode or vm86 mode */ *sregp = selector; segdesc_clear(&sel.desc); - sel.desc.u.seg.limit = CPU_STAT_SREGLIMIT(idx); segdesc_set_default(idx, selector, &sel.desc); *sdp = sel.desc; return; @@ -124,7 +121,7 @@ load_segreg(int idx, UINT16 selector, UI /* * load SS register */ -void +void CPUCALL load_ss(UINT16 selector, const descriptor_t *sdp, int cpl) { @@ -136,7 +133,7 @@ load_ss(UINT16 selector, const descripto /* * load CS register */ -void +void CPUCALL load_cs(UINT16 selector, const descriptor_t *sdp, int new_cpl) { int cpl = new_cpl & 3; @@ -152,7 +149,7 @@ load_cs(UINT16 selector, const descripto /* * load LDT register */ -void +void CPUCALL load_ldtr(UINT16 selector, int exc) { selector_t sel; @@ -164,6 +161,7 @@ load_ldtr(UINT16 selector, int exc) if (rv < 0 || sel.ldt) { if (rv == -2) { /* null segment */ + VERBOSE(("load_ldtr: null segment")); CPU_LDTR = 0; memset(&CPU_LDTR_DESC, 0, sizeof(CPU_LDTR_DESC)); return; @@ -191,7 +189,7 @@ load_ldtr(UINT16 selector, int exc) CPU_LDTR_DESC = sel.desc; } -void +void CPUCALL load_descriptor(descriptor_t *sdp, UINT32 addr) { UINT32 l, h; @@ -305,7 +303,7 @@ load_descriptor(descriptor_t *sdp, UINT3 #endif } -int +int CPUCALL parse_selector(selector_t *ssp, UINT16 selector) { UINT32 base; @@ -339,7 +337,7 @@ parse_selector(selector_t *ssp, UINT16 s limit = CPU_GDTR_LIMIT; } if (idx + 7 > limit) { - VERBOSE(("parse_selector: segment limit check failed")); + VERBOSE(("parse_selector: segment limit check failed: 0x%08x > 0x%08x", idx + 7, limit)); return -3; } @@ -354,7 +352,7 @@ parse_selector(selector_t *ssp, UINT16 s return 0; } -int +int CPUCALL selector_is_not_present(const selector_t *ssp) { UINT32 h; @@ -377,7 +375,7 @@ selector_is_not_present(const selector_t return 0; } -void +void CPUCALL segdesc_init(int idx, UINT16 sreg, descriptor_t *sdp) { @@ -386,11 +384,10 @@ segdesc_init(int idx, UINT16 sreg, descr CPU_REGS_SREG(idx) = sreg; segdesc_clear(sdp); - sdp->u.seg.limit = 0xffff; segdesc_set_default(idx, sreg, sdp); } -void +void CPUCALL segdesc_set_default(int idx, UINT16 selector, descriptor_t *sdp) { @@ -398,7 +395,7 @@ segdesc_set_default(int idx, UINT16 sele __ASSERT((sdp != NULL)); sdp->u.seg.segbase = (UINT32)selector << 4; - /* sdp->u.seg.limit */ + sdp->u.seg.limit = 0xffff; sdp->u.seg.c = (idx == CPU_CS_INDEX) ? 1 : 0; /* code or data */ sdp->u.seg.g = 0; /* non 4k factor scale */ sdp->u.seg.wr = 1; /* execute/read(CS) or read/write(others) */