Diff for /np2/i386c/ia32/segments.c between versions 1.20 and 1.26

version 1.20, 2011/01/15 17:17:23 version 1.26, 2012/02/05 06:16:08
Line 27 Line 27
 #include "cpu.h"  #include "cpu.h"
 #include "ia32.mcr"  #include "ia32.mcr"
   
   static void CPUCALL segdesc_set_default(int, UINT16, descriptor_t *);
   
 void  void CPUCALL
 load_segreg(int idx, UINT16 selector, UINT16 *sregp, descriptor_t *sdp, int exc)  load_segreg(int idx, UINT16 selector, UINT16 *sregp, descriptor_t *sdp, int exc)
 {  {
         selector_t sel;          selector_t sel;
Line 42  load_segreg(int idx, UINT16 selector, UI Line 43  load_segreg(int idx, UINT16 selector, UI
                 /* real-mode or vm86 mode */                  /* real-mode or vm86 mode */
                 *sregp = selector;                  *sregp = selector;
                 segdesc_clear(&sel.desc);                  segdesc_clear(&sel.desc);
                 sel.desc.u.seg.limit = CPU_STAT_SREGLIMIT(idx);  
                 segdesc_set_default(idx, selector, &sel.desc);                  segdesc_set_default(idx, selector, &sel.desc);
                 *sdp = sel.desc;                  *sdp = sel.desc;
                 return;                  return;
Line 122  load_segreg(int idx, UINT16 selector, UI Line 122  load_segreg(int idx, UINT16 selector, UI
 /*  /*
  * load SS register   * load SS register
  */   */
 void  void CPUCALL
 load_ss(UINT16 selector, const descriptor_t *sdp, int cpl)  load_ss(UINT16 selector, const descriptor_t *sdp, int cpl)
 {  {
   
Line 134  load_ss(UINT16 selector, const descripto Line 134  load_ss(UINT16 selector, const descripto
 /*  /*
  * load CS register   * load CS register
  */   */
 void  void CPUCALL
 load_cs(UINT16 selector, const descriptor_t *sdp, int new_cpl)  load_cs(UINT16 selector, const descriptor_t *sdp, int new_cpl)
 {  {
         int cpl = new_cpl & 3;          int cpl = new_cpl & 3;
Line 150  load_cs(UINT16 selector, const descripto Line 150  load_cs(UINT16 selector, const descripto
 /*  /*
  * load LDT register   * load LDT register
  */   */
 void  void CPUCALL
 load_ldtr(UINT16 selector, int exc)  load_ldtr(UINT16 selector, int exc)
 {  {
         selector_t sel;          selector_t sel;
Line 162  load_ldtr(UINT16 selector, int exc) Line 162  load_ldtr(UINT16 selector, int exc)
         if (rv < 0 || sel.ldt) {          if (rv < 0 || sel.ldt) {
                 if (rv == -2) {                  if (rv == -2) {
                         /* null segment */                          /* null segment */
                           VERBOSE(("load_ldtr: null segment"));
                         CPU_LDTR = 0;                          CPU_LDTR = 0;
                         memset(&CPU_LDTR_DESC, 0, sizeof(CPU_LDTR_DESC));                          memset(&CPU_LDTR_DESC, 0, sizeof(CPU_LDTR_DESC));
                         return;                          return;
Line 189  load_ldtr(UINT16 selector, int exc) Line 190  load_ldtr(UINT16 selector, int exc)
         CPU_LDTR_DESC = sel.desc;          CPU_LDTR_DESC = sel.desc;
 }  }
   
 void  void CPUCALL
 load_descriptor(descriptor_t *sdp, UINT32 addr)  load_descriptor(descriptor_t *sdp, UINT32 addr)
 {  {
         UINT32 l, h;          UINT32 l, h;
Line 303  load_descriptor(descriptor_t *sdp, UINT3 Line 304  load_descriptor(descriptor_t *sdp, UINT3
 #endif  #endif
 }  }
   
 int  int CPUCALL
 parse_selector(selector_t *ssp, UINT16 selector)  parse_selector(selector_t *ssp, UINT16 selector)
 {  {
         UINT32 base;          UINT32 base;
Line 337  parse_selector(selector_t *ssp, UINT16 s Line 338  parse_selector(selector_t *ssp, UINT16 s
                 limit = CPU_GDTR_LIMIT;                  limit = CPU_GDTR_LIMIT;
         }          }
         if (idx + 7 > 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;                  return -3;
         }          }
   
Line 352  parse_selector(selector_t *ssp, UINT16 s Line 353  parse_selector(selector_t *ssp, UINT16 s
         return 0;          return 0;
 }  }
   
 int  int CPUCALL
 selector_is_not_present(const selector_t *ssp)  selector_is_not_present(const selector_t *ssp)
 {  {
         UINT32 h;          UINT32 h;
Line 375  selector_is_not_present(const selector_t Line 376  selector_is_not_present(const selector_t
         return 0;          return 0;
 }  }
   
 void  void CPUCALL
 segdesc_init(int idx, UINT16 sreg, descriptor_t *sdp)  segdesc_init(int idx, UINT16 sreg, descriptor_t *sdp)
 {  {
   
Line 384  segdesc_init(int idx, UINT16 sreg, descr Line 385  segdesc_init(int idx, UINT16 sreg, descr
   
         CPU_REGS_SREG(idx) = sreg;          CPU_REGS_SREG(idx) = sreg;
         segdesc_clear(sdp);          segdesc_clear(sdp);
         sdp->u.seg.limit = 0xffff;  
         segdesc_set_default(idx, sreg, sdp);          segdesc_set_default(idx, sreg, sdp);
 }  }
   
 void  static void CPUCALL
 segdesc_set_default(int idx, UINT16 selector, descriptor_t *sdp)  segdesc_set_default(int idx, UINT16 selector, descriptor_t *sdp)
 {  {
   
Line 396  segdesc_set_default(int idx, UINT16 sele Line 396  segdesc_set_default(int idx, UINT16 sele
         __ASSERT((sdp != NULL));          __ASSERT((sdp != NULL));
   
         sdp->u.seg.segbase = (UINT32)selector << 4;          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.c = (idx == CPU_CS_INDEX) ? 1 : 0;   /* code or data */
         sdp->u.seg.g = 0;       /* non 4k factor scale */          sdp->u.seg.g = 0;       /* non 4k factor scale */
         sdp->u.seg.wr = 1;      /* execute/read(CS) or read/write(others) */          sdp->u.seg.wr = 1;      /* execute/read(CS) or read/write(others) */

Removed from v.1.20  
changed lines
  Added in v.1.26


RetroPC.NET-CVS <cvs@retropc.net>