Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / hidds / nouveau / pci-device-mock / NVG86.c
blob972806677ae21017c5e5011c215bc7e86321098d
1 /*
2 Copyright 2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <proto/oop.h>
9 #include "pcimockhardware.h"
10 #include "pcimockhardware_intern.h"
11 #include "pcimock_intern.h"
13 OOP_Object * METHOD(NVG86MockHardware, Root, New)
15 o = (OOP_Object *)OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
17 GET_PCIMOCKHWDATA
18 DEF_NEXTCAPADDR
20 /* Allocate address space regions */
21 ALLOC_ASR(hwdata, PCI_CONFIG_SPACE, 256);
22 ALLOC_ASR(hwdata, PCI_BAR0, 0x1000000);
23 ALLOC_ASR(hwdata, PCI_BAR1, 0x10000000);
24 ALLOC_ASR(hwdata, PCI_BAR3, 0x2000000);
25 ALLOC_ASR(hwdata, PCI_ROM, 0x20000);
27 /* Fill in pci config space */
28 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x00, 0x042410de); /* PCICS_PRODUCT, PCICS_VENDOR */
29 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x04, 0x00300006); /* PCICS_STATUS, PCICS_COMMAND */
30 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x08, 0x030000a1); /* PCICS_CLASS, PCICS_SUBCLASS, PCICS_PROGIF, PCICS_REVISION */
31 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x0c, 0x00000000); /* PCICS_BIST, PCICS_HEADERTYPE, PCICS_LATENCY, PCICS_CACHELS */
32 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x10, hwdata->Regions[PCI_BAR0].Address); /* PCICS_BAR0 */
33 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x14, hwdata->Regions[PCI_BAR1].Address); /* PCICS_BAR1 */
34 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x1c, hwdata->Regions[PCI_BAR3].Address); /* PCICS_BAR3 */
35 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x2c, 0x81c71043); /* PCICS_SUBSYSTEM, PCICS_SUBVENDOR */
36 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x30, hwdata->Regions[PCI_ROM].Address); /* PCICS_EXPROM_BASE */
37 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x34, 0x00000080); /* PCICS_CAP_PTR */
38 SET_ASR_DWORD(hwdata, PCI_CONFIG_SPACE, 0x3c, 0x0000010b); /* PCICS_INT_PIN, PCICS_INT_LINE */
40 /* Capabilities */
41 ADD_PCI_CAP(hwdata, 0x10); /* CAPABILITY: PCICAP_PCIE */
42 ADD_PCI_CAP(hwdata, 0xff); /* CAPABILITY: END */
44 /* Fill in BAR 0 */
45 SET_ASR_DWORD(hwdata, PCI_BAR0, 0x00000000, 0x086000a1); /* NV03_PMC_BOOT_0 */
46 SET_ASR_DWORD(hwdata, PCI_BAR0, 0x0010020c, 0x10000000); /* NV04_PFB_FIFO_DATA */
47 SET_ASR_DWORD(hwdata, PCI_BAR0, 0x00100200, 0x00000000); /* r0 */
48 SET_ASR_DWORD(hwdata, PCI_BAR0, 0x00100204, 0x01086000); /* r4 */
49 SET_ASR_DWORD(hwdata, PCI_BAR0, 0x00100250, 0x00000000); /* rt */
50 SET_ASR_DWORD(hwdata, PCI_BAR0, 0x00001540, 0x01010001); /* ru, NV40_PMC_GRAPH_UNITS */
52 return o;
55 VOID METHOD(NVG86MockHardware, Hidd_PCIMockHardware, MemoryReadAtAddress)
57 GET_PCIMOCKHWDATA
59 /* Detect in which address space the address is located and get relative offset */
60 struct RegionAndOffset rao = HIDDPCIMockHardwareDetectRegionAndOffset(hwdata, msg->memoryaddress);
62 if (rao.Region == -1)
63 return;
65 if (rao.Region == PCI_CONFIG_SPACE)
67 switch(rao.Offset)
69 case(0x00000000):
70 case(0x00000004):
71 case(0x00000008):
72 case(0x0000000c):
73 case(0x00000010):
74 case(0x00000014):
75 case(0x00000018):
76 case(0x0000001c):
77 case(0x00000020):
78 case(0x00000024):
79 case(0x0000002c):
80 case(0x00000030):
81 case(0x00000034):
82 case(0x0000003c):
83 case(0x00000080):
84 case(0x00000084):
85 return;
89 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);
92 VOID METHOD(NVG86MockHardware, Hidd_PCIMockHardware, MemoryChangedAtAddress)
94 GET_PCIMOCKHWDATA
96 /* Detect in which address space the address is located and get relative offset */
97 struct RegionAndOffset rao = HIDDPCIMockHardwareDetectRegionAndOffset(hwdata, msg->memoryaddress);
99 if (rao.Region == -1)
100 return;
102 if (rao.Region == PCI_CONFIG_SPACE)
104 switch(rao.Offset)
106 case(0x00000004):
107 return;
111 OOP_DoSuperMethod(cl, o, (OOP_Msg)msg);