Subversion Repositories Kolibri OS

Rev

Rev 808 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #include "pci.h"
  2. #include "rhd_regs.h"
  3.  
  4. enum RHD_CHIPSETS {
  5.     RHD_UNKNOWN = 0,
  6.     /* R500 */
  7.     RHD_RV505,
  8.     RHD_RV515,
  9.     RHD_RV516,
  10.     RHD_R520,
  11.     RHD_RV530,
  12.     RHD_RV535,
  13.     RHD_RV550,
  14.     RHD_RV560,
  15.     RHD_RV570,
  16.     RHD_R580,
  17.     /* R500 Mobility */
  18.     RHD_M52,
  19.     RHD_M54,
  20.     RHD_M56,
  21.     RHD_M58,
  22.     RHD_M62,
  23.     RHD_M64,
  24.     RHD_M66,
  25.     RHD_M68,
  26.     RHD_M71,
  27.     /* R500 integrated */
  28.     RHD_RS600,
  29.     RHD_RS690,
  30.     RHD_RS740,
  31.     /* R600 */
  32.     RHD_R600,
  33.     RHD_RV610,
  34.     RHD_RV630,
  35.     /* R600 Mobility */
  36.     RHD_M72,
  37.     RHD_M74,
  38.     RHD_M76,
  39.     /* RV670 came into existence after RV6x0 and M7x */
  40.     RHD_RV670,
  41.     RHD_R680,
  42.     RHD_RV620,
  43.     RHD_M82,
  44.     RHD_RV635,
  45.     RHD_M86,
  46.     RHD_CHIP_END
  47. };
  48.  
  49. enum RHD_FAMILIES {
  50.     RHD_FAMILY_UNKNOWN = 0,
  51.     RHD_FAMILY_RV515,
  52.     RHD_FAMILY_R520,
  53.     RHD_FAMILY_RV530,
  54.     RHD_FAMILY_RV560,
  55.     RHD_FAMILY_RV570,
  56.     RHD_FAMILY_R580,
  57.     RHD_FAMILY_RS690,
  58.     RHD_FAMILY_R600,
  59.     RHD_FAMILY_RV610,
  60.     RHD_FAMILY_RV630,
  61.     RHD_FAMILY_RV670,
  62.     RHD_FAMILY_RV620,
  63.     RHD_FAMILY_RV635
  64. };
  65.  
  66. #define RHD_FB_BAR         0
  67. #define RHD_MMIO_BAR       2
  68.  
  69. #define RHD_MEM_GART       1
  70. #define RHD_MEM_FB         2
  71.  
  72. typedef struct RHDRec
  73. {
  74.   CARD32            MMIOBase;
  75.   CARD32            MMIOMapSize;
  76.   CARD32            videoRam;
  77.  
  78.   CARD32            FbBase;            /* map base of fb   */
  79.   CARD32            PhisBase;
  80.   CARD32            FbIntAddress;      /* card internal address of FB */
  81.   CARD32            FbMapSize;
  82.  
  83.   CARD32            FbFreeStart;
  84.   CARD32            FbFreeSize;
  85.  
  86.   /* visible part of the framebuffer */
  87.   unsigned int      FbScanoutStart;
  88.   unsigned int      FbScanoutSize;
  89.  
  90.   enum RHD_CHIPSETS ChipSet;
  91.   char              *ChipName;
  92.  
  93.   Bool              IsIGP;
  94.  
  95.   CARD32            bus;
  96.   CARD32            devfn;
  97.  
  98.   PCITAG            PciTag;
  99.   CARD16            PciDeviceID;
  100.  
  101.   CARD16            subvendor_id;
  102.   CARD16            subdevice_id;
  103.  
  104.   CARD32            memBase[6];
  105.   CARD32            ioBase[6];
  106.   CARD32            memtype[6];
  107.   CARD32            memsize[6];
  108.  
  109.   struct mem_block  *fb_heap;
  110.   struct mem_block  *gart_heap;
  111.  
  112.   CARD32            displayWidth;
  113.   CARD32            displayHeight;
  114.  
  115.   CARD32            __xmin;
  116.   CARD32            __ymin;
  117.   CARD32            __xmax;
  118.   CARD32            __ymax;
  119.  
  120.   CARD32            gui_control;
  121.   CARD32            dst_pitch_offset;
  122.   CARD32            surface_cntl;
  123.  
  124.   u32               *ring_base;
  125.   u32               ring_rp;
  126.   u32               ring_wp;
  127.  
  128.   int               num_gb_pipes;
  129.   Bool              has_tcl;
  130. }RHD_t, *RHDPtr;
  131.  
  132. extern RHD_t rhd;
  133.  
  134. typedef struct
  135. {
  136.   int xmin;
  137.   int ymin;
  138.   int xmax;
  139.   int ymax;
  140. }clip_t, *PTRclip;
  141.  
  142. typedef struct {
  143.     int                 token;          /* id of the token */
  144.     const char *        name;           /* token name */
  145. } SymTabRec, *SymTabPtr;
  146.  
  147. extern inline CARD32 INREG(CARD16 offset)
  148. {
  149.   return *(volatile CARD32 *)((CARD8*)(rhd.MMIOBase + offset));
  150. }
  151.  
  152. //#define INREG(offset) *(volatile CARD32 *)((CARD8*)(rhd.MMIOBase + (offset)))
  153.  
  154. extern inline void
  155. OUTREG(CARD16 offset, CARD32 value)
  156. {
  157.   *(volatile CARD32 *)((CARD8 *)(rhd.MMIOBase + offset)) = value;
  158. }
  159.  
  160. extern inline CARD32 _RHDRegRead(RHDPtr rhdPtr, CARD16 offset)
  161. {
  162.   return *(volatile CARD32 *)((CARD8*)(rhdPtr->MMIOBase + offset));
  163. }
  164.  
  165. extern inline void
  166. MASKREG(CARD16 offset, CARD32 value, CARD32 mask)
  167. {
  168.   CARD32 tmp;
  169.  
  170.   tmp = INREG(offset);
  171.   tmp &= ~mask;
  172.   tmp |= (value & mask);
  173.   OUTREG(offset, tmp);
  174. };
  175.  
  176. extern inline void
  177. _RHDRegWrite(RHDPtr rhdPtr, CARD16 offset, CARD32 value)
  178. {
  179.   *(volatile CARD32 *)((CARD8 *)(rhdPtr->MMIOBase + offset)) = value;
  180. }
  181.  
  182. extern inline void
  183. _RHDRegMask(RHDPtr rhdPtr, CARD16 offset, CARD32 value, CARD32 mask)
  184. {
  185.   CARD32 tmp;
  186.  
  187.   tmp = _RHDRegRead(rhdPtr, offset);
  188.   tmp &= ~mask;
  189.   tmp |= (value & mask);
  190.   _RHDRegWrite(rhdPtr, offset, tmp);
  191. };
  192.  
  193. enum RHD_FAMILIES RHDFamily(enum RHD_CHIPSETS chipset);
  194.  
  195. #define RHDRegRead(ptr, offset) _RHDRegRead((ptr)->rhdPtr, (offset))
  196. #define RHDRegWrite(ptr, offset, value) _RHDRegWrite((ptr)->rhdPtr, (offset), (value))
  197. #define RHDRegMask(ptr, offset, value, mask) _RHDRegMask((ptr)->rhdPtr, (offset), (value), (mask))
  198.  
  199.  
  200. RHDPtr FindPciDevice();
  201.  
  202. Bool RHDPreInit();
  203. int rhdInitHeap(RHDPtr rhdPtr);
  204.  
  205. #define RHDFUNC(ptr)
  206.  
  207. #define DBG(x) x
  208. //  #define DBG(x)
  209.  
  210. #pragma pack (push,1)
  211. typedef struct s_cursor
  212. {
  213.    u32   magic;                           // 'CURS'
  214.    void  (*destroy)(struct s_cursor*);    // destructor
  215.    u32   fd;                              // next object in list
  216.    u32   bk;                              // prev object in list
  217.    u32   pid;                             // owner id
  218.  
  219.    void *base;                            // allocated memory
  220.    u32   hot_x;                           // hotspot coords
  221.    u32   hot_y;
  222. }cursor_t;
  223. #pragma pack (pop)
  224.  
  225. #define LOAD_FROM_FILE   0
  226. #define LOAD_FROM_MEM    1
  227. #define LOAD_INDIRECT    2
  228.  
  229. cursor_t *create_cursor(u32 pid, void *src, u32 flags);
  230. void __stdcall copy_cursor(void *img, void *src);
  231. void destroy_cursor(cursor_t *cursor);
  232. void __destroy_cursor(cursor_t *cursor);                // wrap
  233.  
  234. void __stdcall r500_SelectCursor(cursor_t *cursor);
  235. void __stdcall r500_SetCursor(cursor_t *cursor, int x, int y);
  236. void __stdcall r500_CursorRestore(int x, int y);
  237.  
  238. void  R5xx2DInit();
  239.