Diff for /np2/i386c/ia32/paging.c between versions 1.30 and 1.35

version 1.30, 2008/03/22 04:03:07 version 1.35, 2011/12/29 13:32:12
Line 1 Line 1
 /*      $Id$    */  
   
 /*  /*
  * Copyright (c) 2003-2004 NONAKA Kimihiro   * Copyright (c) 2003-2004 NONAKA Kimihiro
  * All rights reserved.   * All rights reserved.
Line 30 Line 28
 #include "ia32.mcr"  #include "ia32.mcr"
   
 /*  /*
  * ¡¦¥ì¡£¥·¡¦¥¯¡¦¥æ¡¦¥¥¡¦ö§¥Í¥Û浡¼   * åãÔ妾å⥯åãÊ夫å㥩åã°æ¥»¶ç¡¢  *
  * 4-31: ͽÌóºÑ¤ß   * 4-31: 人Ѥß
  *    3: RSVD: 0 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤ÏͽÌó¥Ó¥Ã¥È°ãÈ¿¤Ç¤Ï¤Ê¤«¤Ã¤¿¡¥   *    3: RSVD: 0 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤ÏͽÌó¥Ó¥Ã¥È°ãÈ¿¤Ç¤Ï¤Ê¤«¤Ã¤¿¡¥
  *             1 = ¥Ú¡¼¥¸¡¦¥Õ¥©¥ë¥È¤Î¸¶°ø¤Ï¡¤°ãÈ¿¤È¥Þ¡¼¥¯¤µ¤ì¤¿ PTE ¤Þ¤¿¤Ï   *             1 = ¥Ú¡¼¥¸¡¦¥Õ¥©¥ë¥È¤Î¸¶°ø¤Ï¡¤°ãÈ¿¤È¥Þ¡¼¥¯¤µ¤ì¤¿ PTE ¤Þ¤¿¤Ï
  *                 PDE ¤ÎͽÌó¥Ó¥Ã¥È°ÌÃ֤Τ¦¤Á°ì¤Ä¤Ç¡¤1 ¤¬¸¡½Ð¤µ¤ì¤¿¤³¤È¤Ç¤¢¤ë¡¥   *                 PDE ¤ÎͽÌó¥Ó¥Ã¥È°ÌÃ֤Τ¦¤Á°ì¤Ä¤Ç¡¤1 ¤¬¸¡½Ð¤µ¤ì¤¿¤³¤È¤Ç¤¢¤ë¡¥
  *    2: U/S:  0 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥¢¥¯¥»¥¹¤Ï¥×¥í¥»¥Ã¥µ¤¬¥¹¡¼¥Ñ¥Ð¥¤¥¶¡¦   *    2: U/S:  0 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥¢¥¯¥»¥¹¤Ï¥×¥í¥»¥Ã¥µ¤¬¥¹¡¼¥Ñ¥Ð¥¤¥¶¡¦
  *                 ¥â¡¼¥É¤Ç¼Â¹ÔÃæ¤Ë¹Ô¤ï¤ì¤¿¡¥   *                 ¥â¡¼¥É¤Ç¼Â¹ÔÃæ¤Ë¹Ô¤ï¤ì¤¿¡¥
  *             1 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥¢¥¯¥»¥¹¤Ï¥×¥í¥»¥Ã¥µ¤¬¥æ¡¼¥¶¡¦¥â¡¼¥É¤Ç   *             1 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥¢¥¯¥»¥¹¤Ï¥×¥í¥»¥Ã¥µ¤¬¥æ¡¼¥¶¡¦¥â¡¼¥É¤Ç
  *                 ¼Â¹ÔÃæ¤Ë¹Ô¤ï¤ì¤¿¡¥   *                 ¼Â¹ÔÃæ¤Ë¹Ô¤ï¤ì¤¿¡¥
  *    1: W/R:  0 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥¢¥¯¥»¥¹¤¬ÆÉ¤ß¼è¤ê¤Ç¤¢¤Ã¤¿¡¥   *    1: W/R:  0 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥¢¥¯¥»¥¹¤¬ÆÉ¤ß¼è¤ê¤Ç¤¢¤Ã¤¿¡¥
  *             1 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥¢¥¯¥»¥¹¤¬½ñ¤­¹þ¤ß¤Ç¤¢¤Ã¤¿¡¥   *             1 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤È¤Ê¤Ã¤¿¥¢¥¯¥»¥¹¤¬½ñ¤­¹þ¤ß¤Ç¤¢¤Ã¤¿¡¥
  *    0: P:    0 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤¬ÉԺߥڡ¼¥¸¤Ç¤¢¤Ã¤¿¡¥   *    0: P:    0 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤¬ÉԺߥڡ¼¥¸¤Ç¤¢¤Ã¤¿¡¥
  *             1 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤¬¥Ú¡¼¥¸¡¦¥ì¥Ù¥ëÊݸî°ãÈ¿¤Ç¤¢¤Ã¤¿¡¥   *             1 = ¥Õ¥©¥ë¥È¤Î¸¶°ø¤¬¥Ú¡¼¥¸¡¦¥ì¥Ù¥ëÊݸî°ãÈ¿¤Ç¤¢¤Ã¤¿¡¥
  */   */
   
 /*  /*
  * ²¼´¬ 4.12. ¥Ú¡¼¥¸Êݸî¤È¥»¥°¥á¥ó¥ÈÊݸî¤ÎÁȤ߹ç¤ï¤»   * ä¸ 4.12. ¥Ú¡¼¥¸Êݸî¤È¥»¥°¥á¥ó¥ÈÊݸî¤ÎÁȤ߹ç¤ï¤»
  * ¡Öɽ 4-2. ¥Ú¡¼¥¸¡¦¥Ç¥£¥ì¥¯¥È¥ê¤È¥Ú¡¼¥¸¡¦¥Æ¡¼¥Ö¥ë¤ÎÊݸî¤ÎÁȤ߹ç¤ï¤»¡×   * ¡Öɽ 4-2. ¥Ú¡¼¥¸¡¦¥Ç¥£¥ì¥¯¥È¥ê¤È¥Ú¡¼¥¸¡¦¥Æ¡¼¥Ö¥ë¤ÎÊݸî¤ÎÁȤ߹ç¤ï¤»¡×
  *   *
  * +------------+------------+------------+   * +------------+------------+------------+
  * |    PDE     |    PTE     |   merge    |   * |    PDE     |    PTE     |   merge    |
Line 73 Line 71
  * |  s  |  rw  |  s  |  rw  |  s  |  rw  |   * |  s  |  rw  |  s  |  rw  |  s  |  rw  |
  * +-----+------+-----+------+-----+------+   * +-----+------+-----+------+-----+------+
  *   *
  * ¡Ö¥£ rw/p : CR0 ¡¢¥Û WP ¡¦¥â¡¦¥Æ¡¦¥Í¡¢¥ã ON ¡¢¥Û¥»ø»î¦¥Ò¡¢¥Þ ro   * ãॵ rw/p : CR0 åá¥ç WP åãÆå¥ãåã°å¡ì ON åá¥çꢥ¨éð°å¢­åá¥Ã ro
  */   */
   
 /*  /*
  * ¡¦â§ä§ô§¡Ö¡¦¥Ã¡¦¥µ¡¦¥±/PxE(¥»ê·¥å¥µ¥¤¥»¥Í)/CPL/CR0 ¡¢¥Í¡¦¥ì¡£¥·¡¦¥¯¡¦¡Ö¡¦¥Ã¡¦¥µ¡¦¥±¥¯¡Ö¡¢¥Û¥¨¥ê¥­¥¯   * åã¡£åã¡Öå㥧åâ¡Öåâ¥Ãå⥵å⥱/PxE(躴ꥣÐç½âí奡)/CPL/CR0 åᥣåãÔ妾å⥯åâ¡Öåâ¥Ãå⥵å⥱쪥¥åá¥çñö¡ÖèÁ  *
  * +-----+-----+-----+-----+-----+---+   * +-----+-----+-----+-----+-----+---+
  * | CR0 | CPL | PxE | PxE | ope |   |   * | CR0 | CPL | PxE | PxE | ope |   |
Line 157  static const UINT8 page_access_bit[32] = Line 155  static const UINT8 page_access_bit[32] =
   
 /*  /*
  *--   *--
  * 32bit ʪÍý¥¢¥É¥ì¥¹ 4k ¥Ú¡¼¥¸   * 32bit í饥íð¬å¤¤åã²å¦®å⥱ 4k åãÔ妾å⥯
  *   *
  * ¡¦ô§¥Ò¡¦¡Ö¡£¥ò¡¦¡Ö¡¦¥Î¡¦ø§¥±   * å㥧åã¶å¤¤å㥵åâ¡Öåã²å¦®å⥱
  *  31                    22 21                  12 11                       0   *  31                    22 21                  12 11                       0
  * +------------------------+----------------------+--------------------------+   * +------------------------+----------------------+--------------------------+
  * |  ¡¦¥ì¡£¥·¡¦¥¯¡£¥ò¡¦¥Ì¡¦¡×¡¦ø§¥Ã¡¦¥Í¡¦ |   ¥Ú¡¼¥¸¡¦¥Æ¡¼¥Ö¥ë   |        ¥ª¥Õ¥»¥Ã¥È        |   * |  åãÔ妾å⥯å㥵åã®å¤¥åã¥ãåâ¥Ãåã°å¦¬  |   åãÔ妾å⥯å㥵åã¬å¦¾åãÌ妭   |        å⥧åãÊ夽åã¦å¥è        |
  * +------------------------+----------------------+--------------------------+   * +------------------------+----------------------+--------------------------+
  *             |                        |                       |   *             |                        |                       |
  * +-----------+            +-----------+                       +----------+   * +-----------+            +-----------+                       +----------+
  * |                        |                                              |   * |                        |                                              |
  * |  ¡¦¥ì¡£¥·¡¦¥¯¡£¥ò¡¦¥Ì¡¦¡×¡¦ø§¥Ã¡¦¥Í¡¦ |   ¥Ú¡¼¥¸¡¦¥Æ¡¼¥Ö¥ë            ¥Ú¡¼¥¸         |   * |  ¥Ú¡¼¥¸¡¦¥Ç¥£¥ì¥¯¥È¥ê  |   ¥Ú¡¼¥¸¡¦¥Æ¡¼¥Ö¥ë            ¥Ú¡¼¥¸         |
  * | +--------------------+ | +-------------------+   +------------------+ |   * | +--------------------+ | +-------------------+   +------------------+ |
  * | |                    | | |                   |   |                  | |   * | |                    | | |                   |   |                  | |
  * | |                    | | +-------------------+   |                  | |   * | |                    | | +-------------------+   |                  | |
Line 179  static const UINT8 page_access_bit[32] = Line 177  static const UINT8 page_access_bit[32] =
  *   |                    | | |                   | | |                  |   *   |                    | | |                   | | |                  |
  * +>+--------------------+ +>+-------------------+ +>+------------------+   * +>+--------------------+ +>+-------------------+ +>+------------------+
  * |   * |
  * +- CR3()   * +- CR3(ʪÍý¥¢¥É¥ì¥¹)
  */   */
   
 static UINT32 MEMCALL paging(const UINT32 laddr, const int ucrw);  static UINT32 MEMCALL paging(const UINT32 laddr, const int ucrw);
 #if defined(IA32_SUPPORT_TLB)  
 static void MEMCALL tlb_update(const UINT32 laddr, const UINT entry, const int ucrw);  static void MEMCALL tlb_update(const UINT32 laddr, const UINT entry, const int ucrw);
 #endif  
   
 #define PAGE_SIZE       0x1000  #define PAGE_SIZE       0x1000
 #define PAGE_MASK       (PAGE_SIZE - 1)  #define PAGE_MASK       (PAGE_SIZE - 1)
   
 UINT8 MEMCALL  UINT8 MEMCALL
 cpu_memory_access_la_RMW_b(UINT32 laddr, UINT32 (*func)(UINT32, void *), void *arg)  cpu_memory_access_la_RMW_b(UINT32 laddr, UINT32 (CPUCALL *func)(UINT32, void *), void *arg)
 {  {
         const int ucrw = CPU_PAGE_WRITE_DATA|CPU_STAT_USER_MODE;          const int ucrw = CPU_PAGE_WRITE_DATA|CPU_STAT_USER_MODE;
         UINT32 result, value;          UINT32 result, value;
Line 206  cpu_memory_access_la_RMW_b(UINT32 laddr, Line 202  cpu_memory_access_la_RMW_b(UINT32 laddr,
 }  }
   
 UINT16 MEMCALL  UINT16 MEMCALL
 cpu_memory_access_la_RMW_w(UINT32 laddr, UINT32 (*func)(UINT32, void *), void *arg)  cpu_memory_access_la_RMW_w(UINT32 laddr, UINT32 (CPUCALL *func)(UINT32, void *), void *arg)
 {  {
         const int ucrw = CPU_PAGE_WRITE_DATA|CPU_STAT_USER_MODE;          const int ucrw = CPU_PAGE_WRITE_DATA|CPU_STAT_USER_MODE;
         UINT32 result, value;          UINT32 result, value;
Line 229  cpu_memory_access_la_RMW_w(UINT32 laddr, Line 225  cpu_memory_access_la_RMW_w(UINT32 laddr,
 }  }
   
 UINT32 MEMCALL  UINT32 MEMCALL
 cpu_memory_access_la_RMW_d(UINT32 laddr, UINT32 (*func)(UINT32, void *), void *arg)  cpu_memory_access_la_RMW_d(UINT32 laddr, UINT32 (CPUCALL *func)(UINT32, void *), void *arg)
 {  {
         const int ucrw = CPU_PAGE_WRITE_DATA|CPU_STAT_USER_MODE;          const int ucrw = CPU_PAGE_WRITE_DATA|CPU_STAT_USER_MODE;
         UINT32 result, value;          UINT32 result, value;
Line 641  paging(const UINT32 laddr, const int ucr Line 637  paging(const UINT32 laddr, const int ucr
         UINT32 pte;             /* page table entry */          UINT32 pte;             /* page table entry */
         UINT bit;          UINT bit;
         UINT err;          UINT err;
 #if defined(IA32_SUPPORT_TLB)  
         TLB_ENTRY_T *ep;          TLB_ENTRY_T *ep;
   
         ep = tlb_lookup(laddr, ucrw);          ep = tlb_lookup(laddr, ucrw);
         if (ep != NULL)          if (ep != NULL)
                 return ep->paddr + (laddr & PAGE_MASK);                  return ep->paddr + (laddr & PAGE_MASK);
 #endif  
   
         pde_addr = CPU_STAT_PDE_BASE + ((laddr >> 20) & 0xffc);          pde_addr = CPU_STAT_PDE_BASE + ((laddr >> 20) & 0xffc);
         pde = cpu_memoryread_d(pde_addr);          pde = cpu_memoryread_d(pde_addr);
Line 703  paging(const UINT32 laddr, const int ucr Line 697  paging(const UINT32 laddr, const int ucr
                 cpu_memorywrite_d(pte_addr, pte);                  cpu_memorywrite_d(pte_addr, pte);
         }          }
   
 #if defined(IA32_SUPPORT_TLB)  
         tlb_update(laddr, pte, (bit & (CPU_PTE_WRITABLE|CPU_PTE_USER_MODE)) + ((ucrw & CPU_PAGE_CODE) >> 1));          tlb_update(laddr, pte, (bit & (CPU_PTE_WRITABLE|CPU_PTE_USER_MODE)) + ((ucrw & CPU_PAGE_CODE) >> 1));
 #endif  
         return paddr;          return paddr;
   
 pf_exception:  pf_exception:
Line 716  pf_exception: Line 709  pf_exception:
         return 0;       /* compiler happy */          return 0;       /* compiler happy */
 }  }
   
   
 #if defined(IA32_SUPPORT_TLB)  
 /*   /* 
  * TLB   * TLB
  */   */
Line 789  tlb_init(void) Line 780  tlb_init(void)
   
         memset(tlb, 0, sizeof(tlb));          memset(tlb, 0, sizeof(tlb));
 #if defined(IA32_PROFILE_TLB)  #if defined(IA32_PROFILE_TLB)
         memset(tlb_profile, 0, sizeof(tlb_profile));          memset(&tlb_profile, 0, sizeof(tlb_profile));
 #endif  /* IA32_PROFILE_TLB */  #endif  /* IA32_PROFILE_TLB */
 }  }
   
Line 906  tlb_update(const UINT32 laddr, const UIN Line 897  tlb_update(const UINT32 laddr, const UIN
         }          }
         ep->memp = NULL;          ep->memp = NULL;
 }  }
 #endif  /* IA32_SUPPORT_TLB */  

Removed from v.1.30  
changed lines
  Added in v.1.35


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