diff --git a/DMAtest/dmatest.c b/DMAtest/dmatest.c old mode 100755 new mode 100644 index 3f69c48..9ff75d2 --- a/DMAtest/dmatest.c +++ b/DMAtest/dmatest.c @@ -2,8 +2,8 @@ #define __NOLIBBASE__ -#include #include +#include #include extern struct Library *SysBase, *DOSBase; @@ -12,101 +12,102 @@ struct Library *PrometheusBase, *CardBase; const UBYTE VString[] = "$VER: dmalist 1.2 (6.10.2002) © by Matay 2002"; - /* private structures */ struct DMAMemChunk - { - struct MinNode dmc_Node; /* for linking into list */ - APTR dmc_Address; /* logical (CPU) address */ - struct Task *dmc_Owner; /* memory owner (NULL if none) */ - ULONG dmc_Size; /* chunk size in bytes */ - }; +{ + struct MinNode dmc_Node; /* for linking into list */ + APTR dmc_Address; /* logical (CPU) address */ + struct Task * dmc_Owner; /* memory owner (NULL if none) */ + ULONG dmc_Size; /* chunk size in bytes */ +}; struct CardBase - { - struct Library cb_Library; - UBYTE cb_Flags; - UBYTE cb_Pad; - struct Library *cb_SysBase; - struct Library *cb_ExpansionBase; - APTR cb_SegList; - STRPTR cb_Name; +{ + struct Library cb_Library; + UBYTE cb_Flags; + UBYTE cb_Pad; + struct Library *cb_SysBase; + struct Library *cb_ExpansionBase; + APTR cb_SegList; + STRPTR cb_Name; /* standard fields ends here */ - struct Library *cb_PrometheusBase; + struct Library * cb_PrometheusBase; BOOL cb_DMAMemGranted; APTR cb_LegacyIOBase; - APTR cb_MemPool; /* for DMA memory management lists */ + APTR cb_MemPool; /* for DMA memory management lists */ struct MinList cb_MemList; struct SignalSemaphore *cb_MemSem; - }; - +}; BOOL try_memory(void) - { +{ APTR pointer; if (pointer = Prm_AllocDMABuffer(4)) - { + { Prm_FreeDMABuffer(pointer, 4); return TRUE; - } + } return FALSE; - } - +} void dump_list(struct CardBase *cb) - { +{ struct DMAMemChunk *dmc; - PutStr("\nStart End Size\tOwner\n" - "---------------------------------------------------------------\n"); + PutStr( + "\nStart End Size\tOwner\n" + "---------------------------------------------------------------\n"); ObtainSemaphoreShared(cb->cb_MemSem); - for (dmc = (struct DMAMemChunk*)cb->cb_MemList.mlh_Head; - dmc->dmc_Node.mln_Succ; - dmc = (struct DMAMemChunk*)dmc->dmc_Node.mln_Succ) - { + for (dmc = (struct DMAMemChunk *)cb->cb_MemList.mlh_Head; dmc->dmc_Node.mln_Succ; + dmc = (struct DMAMemChunk *)dmc->dmc_Node.mln_Succ) + { STRPTR owner; - if (dmc->dmc_Owner) owner = dmc->dmc_Owner->tc_Node.ln_Name; - else owner = "FREE"; + if (dmc->dmc_Owner) + owner = dmc->dmc_Owner->tc_Node.ln_Name; + else + owner = "FREE"; - Printf("$%08lx $%08lx %ld\t%s\n", (ULONG)dmc->dmc_Address, (ULONG)dmc->dmc_Address + dmc->dmc_Size - 1, - dmc->dmc_Size, (LONG)owner); - } + Printf("$%08lx $%08lx %ld\t%s\n", + (ULONG)dmc->dmc_Address, + (ULONG)dmc->dmc_Address + dmc->dmc_Size - 1, + dmc->dmc_Size, + (LONG)owner); + } ReleaseSemaphore(cb->cb_MemSem); PutStr("---------------------------------------------------------------\n\n"); return; - } +} - -int main (void) - { +int main(void) +{ APTR b; Printf("Prometheus DMA memory lister v 1.2\n"); if (PrometheusBase = OpenLibrary("prometheus.library", 2)) - { + { if (CardBase = OpenLibrary("Prometheus.card", 7)) - { + { if (try_memory()) - { + { Printf("DMA memory detected, block listing...\n"); - dump_list((struct CardBase*)CardBase); - } - else Printf("No free DMA memory found.\n"); + dump_list((struct CardBase *)CardBase); + } + else + Printf("No free DMA memory found.\n"); CloseLibrary(CardBase); - } - else Printf("Prometheus is not upgraded yet.\n"); + } + else + Printf("Prometheus is not upgraded yet.\n"); CloseLibrary(PrometheusBase); - } - else Printf("Can't open prometheus.library v2+\n"); - } - - - + } + else + Printf("Can't open prometheus.library v2+\n"); +} diff --git a/DMAtest/rtl8139.c b/DMAtest/rtl8139.c old mode 100755 new mode 100644 index 316a969..d37f623 --- a/DMAtest/rtl8139.c +++ b/DMAtest/rtl8139.c @@ -2,13 +2,12 @@ #define __NOLIBBASE__ -#include #include +#include #include -#define PCI_COMMAND 0x04 -#define PCI_STATUS 0x06 - +#define PCI_COMMAND 0x04 +#define PCI_STATUS 0x06 extern struct Library *SysBase, *DOSBase; @@ -16,20 +15,17 @@ struct Library *PrometheusBase; const UBYTE VString[] = "$VER: RTL8139test 1.0 (13.9.2002) © by Matay 2002"; -int main (void) - { +int main(void) +{ PCIBoard *b; - UWORD s; + UWORD s; Printf("RTL8139 test.\n"); if (PrometheusBase = OpenLibrary("prometheus.library", 2)) - { + { Printf("prometheus.library v2 base at $%08lx\n", (LONG)PrometheusBase); - if (b = Prm_FindBoardTags(NULL, - PRM_Vendor, 0x10EC, - PRM_Device, 0x8139, - TAG_END)) - { + if (b = Prm_FindBoardTags(NULL, PRM_Vendor, 0x10EC, PRM_Device, 0x8139, TAG_END)) + { Printf("RTL8139 board at $%08lx.\n", (ULONG)b); s = Prm_ReadConfigWord(b, PCI_COMMAND); Printf("conf: %04lx\n", s); @@ -41,12 +37,11 @@ int main (void) Printf("devc: %04lx\n", s); s = Prm_ReadConfigByte(b, 62); Printf("intr: %02lx\n", s); - } - else Printf("No RTL8139 board found.\n"); + } + else + Printf("No RTL8139 board found.\n"); CloseLibrary(PrometheusBase); - } - else Printf("Can't open prometheus.library v2+\n"); - } - - - + } + else + Printf("Can't open prometheus.library v2+\n"); +} diff --git a/PromLib/driver_2.c b/PromLib/driver_2.c index 63dc271..43574f3 100644 --- a/PromLib/driver_2.c +++ b/PromLib/driver_2.c @@ -1,4 +1,4 @@ -/* +/* $VER: driver.c 4.5 (14.01.2024) by Dennis Boon - Made a fix to the bus numbering of bridges and the setting of bridge memory limits $VER: driver.c 4.4 (08.05.2023) by Dennis Boon with fixes from Mathias Heyer @@ -23,187 +23,188 @@ - Fixed bug in Prm_WriteConfXXXX ULONG data reg and UBYTE offset reg register was reversed. - Fixed Prm_ReadConfXXXX & Prm_WriteConfXXXX removed offset rounded down now it use REAL offset. - Added function GetVirtualAddress() -$VER: driver.c 2.5 (19.12.2002) by Grzegorz Kraszewski +$VER: driver.c 2.5 (19.12.2002) by Grzegorz Kraszewski */ //#define TESTEXE //#define DEBUG -//void illegal(void)="\tillegal\n"; +// void illegal(void)="\tillegal\n"; #define __NOLIBBASE__ -#include -#include -#include -#include +#include +#include +#include #include -#include #include -#include #include -#include -#include +#include #include +#include +#include +#include +#include +#include #include -#include /* from private include directory */ #define PCIBOARD_TYPEDEF typedef struct { - struct MinNode pn_Node; - volatile struct PciConfig *pn_ConfigBase; /* v2 */ - struct TagItem pn_TagList[30]; /* increased from 25 (27 different tags in total in V4) */ + struct MinNode pn_Node; + volatile struct PciConfig *pn_ConfigBase; /* v2 */ + struct TagItem pn_TagList[30]; /* increased from 25 (27 different tags in total in V4) */ } PCIBoard; - #ifdef __VBCC__ -#include //private include + #include //private include #else -#include + #include #endif -#include "prometheus.h" #include "endian.h" #include "lists.h" +#include "prometheus.h" -#define FS_PCI_ADDR_CONFIG0 0x1fc00000 -#define FS_PCI_ADDR_CONFIG1 0x1fd00000 -#define FS_PCI_ADDR_IO 0x1fe00000 - -#define PCI_MEMSIZE_4KB 0xfffff000 -#define PCI_MEMSIZE_64KB 0xffff0000 -#define PCI_MEMSIZE_256KB 0xfffc0000 -#define PCI_MEMSIZE_4MB 0xffc00000 -#define PCI_MEMSIZE_16MB 0xff000000 -#define PCI_MEMSIZE_64MB 0xfc000000 -#define PCI_MEMSIZE_128MB 0xf8000000 - -#define VID_FREESCALE 0x1957 -#define VID_3DFX 0x121a -#define VID_MOTOROLA 0x1057 -#define VID_TI 0x104c -#define VID_ATI 0x1002 -#define VID_S3 0x5333 - -#define DEVID_MPC107 0x0004 -#define DEVID_MPC834X 0x0086 -#define DEVID_MPC831X 0x00b6 -#define DEVID_POWERPLUSIII 0x480b -#define DEVID_PERMEDIA2 0x3d07 -#define DEVID_VIRGE3D 0x5631 -#define DEVID_VIRGEDX 0x8A01 -#define DEVID_VIRGEGX2 0x8A02 -#define DEVID_TRIO64 0x8811 +#define FS_PCI_ADDR_CONFIG0 0x1fc00000 +#define FS_PCI_ADDR_CONFIG1 0x1fd00000 +#define FS_PCI_ADDR_IO 0x1fe00000 + +#define PCI_MEMSIZE_4KB 0xfffff000 +#define PCI_MEMSIZE_64KB 0xffff0000 +#define PCI_MEMSIZE_256KB 0xfffc0000 +#define PCI_MEMSIZE_4MB 0xffc00000 +#define PCI_MEMSIZE_16MB 0xff000000 +#define PCI_MEMSIZE_64MB 0xfc000000 +#define PCI_MEMSIZE_128MB 0xf8000000 + +#define VID_FREESCALE 0x1957 +#define VID_3DFX 0x121a +#define VID_MOTOROLA 0x1057 +#define VID_TI 0x104c +#define VID_ATI 0x1002 +#define VID_S3 0x5333 + +#define DEVID_MPC107 0x0004 +#define DEVID_MPC834X 0x0086 +#define DEVID_MPC831X 0x00b6 +#define DEVID_POWERPLUSIII 0x480b +#define DEVID_PERMEDIA2 0x3d07 +#define DEVID_VIRGE3D 0x5631 +#define DEVID_VIRGEDX 0x8A01 +#define DEVID_VIRGEGX2 0x8A02 +#define DEVID_TRIO64 0x8811 struct PrometheusBase { - struct Library pb_Lib; - struct Library *pb_SysBase; - struct Library *pb_UtilityBase; - struct Library *pb_DMASuppBase; /* base of the library supporting DMA functions */ - APTR pb_SegList; - APTR pb_MemPool; - APTR pb_BaseAddr; - struct MinList pb_Cards; - struct List pb_Busses; /* this list is private used only at startup time */ - BOOL pb_FireStorm; - UBYTE pb_BridgeCnt; + struct Library pb_Lib; + struct Library *pb_SysBase; + struct Library *pb_UtilityBase; + struct Library *pb_DMASuppBase; /* base of the library supporting DMA functions */ + APTR pb_SegList; + APTR pb_MemPool; + APTR pb_BaseAddr; + struct MinList pb_Cards; + struct List pb_Busses; /* this list is private used only at startup time */ + BOOL pb_FireStorm; + UBYTE pb_BridgeCnt; }; struct PCIBus { - struct Node br_Node; - UBYTE br_BusNr; - UBYTE br_pBusNr; - BOOL br_hasGraphics; - BOOL br_hasUpperIO; - struct PciConfig volatile *br_ConfigBase; - struct List br_CardRequests; + struct Node br_Node; + UBYTE br_BusNr; + UBYTE br_pBusNr; + BOOL br_hasGraphics; + BOOL br_hasUpperIO; + struct PciConfig volatile *br_ConfigBase; + struct List br_CardRequests; }; struct SpaceReq { - struct Node sr_Node; - ULONG sr_Size; - ULONG sr_Type; - ULONG sr_Flag; - struct TagItem *sr_Tag; - ULONG volatile *sr_CfgAddr; /* ptr to base register */ + struct Node sr_Node; + ULONG sr_Size; + ULONG sr_Type; + ULONG sr_Flag; + struct TagItem *sr_Tag; + ULONG volatile *sr_CfgAddr; /* ptr to base register */ }; struct PciConfig - { - UWORD pc_Vendor; /* these two words swapped! */ - UWORD pc_Device; - - UWORD pc_Command; /* these two words swapped! */ - UWORD pc_Status; - - UBYTE pc_Revision; /* these four bytes swapped! */ - UBYTE pc_Interface; - UBYTE pc_SubClass; - UBYTE pc_Class; - - UBYTE pc_CacheLineSize; /* these four bytes swapped! */ - UBYTE pc_LatencyTimer; - UBYTE pc_HeaderType; - UBYTE pc_BIST; - - union hts { - struct ht0 { - ULONG pc_BaseRegs[6]; - ULONG pc_Cardbus; /* currently unused */ - UWORD pc_SybsystemVID; - UWORD pc_SubsystemID; - ULONG pc_ROM; - - ULONG pc_Reserved[2]; - - UBYTE pc_IntLine; - UBYTE pc_IntPin; - UBYTE pc_MinGnt; - UBYTE pc_MaxLat; - } t0; - - struct ht1 { - ULONG pc_BaseRegs[2]; - UBYTE pc_PrimaryBus; - UBYTE pc_SecondaryBus; - UBYTE pc_SubordinateBus; - UBYTE pc_SecondaryLat; - - UBYTE pc_IOBase; - UBYTE pc_IOLimit; - UWORD pc_SecondaryStatus; - UWORD pc_MemoryBase; - UWORD pc_MemoryLimit; - UWORD pc_PrefetchMemBase; - UWORD pc_PrefetchMemLimit; - - ULONG pc_PrefetchBaseUp; - ULONG pc_PrefetchLimitUp; - - UWORD pc_IOBaseUp; - UWORD pc_IOLimitUp; - - ULONG pc_Reserved; - ULONG pc_ROM; - - UBYTE pc_IntLine; - UBYTE pc_IntPin; - UWORD pc_BridgeControl; - } t1; - UBYTE pc_Unused[192]; - } types; +{ + UWORD pc_Vendor; /* these two words swapped! */ + UWORD pc_Device; + + UWORD pc_Command; /* these two words swapped! */ + UWORD pc_Status; + + UBYTE pc_Revision; /* these four bytes swapped! */ + UBYTE pc_Interface; + UBYTE pc_SubClass; + UBYTE pc_Class; + + UBYTE pc_CacheLineSize; /* these four bytes swapped! */ + UBYTE pc_LatencyTimer; + UBYTE pc_HeaderType; + UBYTE pc_BIST; + + union hts { + struct ht0 + { + ULONG pc_BaseRegs[6]; + ULONG pc_Cardbus; /* currently unused */ + UWORD pc_SybsystemVID; + UWORD pc_SubsystemID; + ULONG pc_ROM; + + ULONG pc_Reserved[2]; + + UBYTE pc_IntLine; + UBYTE pc_IntPin; + UBYTE pc_MinGnt; + UBYTE pc_MaxLat; + } t0; + + struct ht1 + { + ULONG pc_BaseRegs[2]; + UBYTE pc_PrimaryBus; + UBYTE pc_SecondaryBus; + UBYTE pc_SubordinateBus; + UBYTE pc_SecondaryLat; + + UBYTE pc_IOBase; + UBYTE pc_IOLimit; + UWORD pc_SecondaryStatus; + UWORD pc_MemoryBase; + UWORD pc_MemoryLimit; + UWORD pc_PrefetchMemBase; + UWORD pc_PrefetchMemLimit; + + ULONG pc_PrefetchBaseUp; + ULONG pc_PrefetchLimitUp; + + UWORD pc_IOBaseUp; + UWORD pc_IOLimitUp; + + ULONG pc_Reserved; + ULONG pc_ROM; + + UBYTE pc_IntLine; + UBYTE pc_IntPin; + UWORD pc_BridgeControl; + } t1; + UBYTE pc_Unused[192]; + } types; }; -#define BLOCK_MEMORY 0 -#define BLOCK_INOUT 1 -#define BLOCK_GFXMEM 2 -#define BLOCK_USRMEM 3 -#define BLOCK_CFGMEM 4 +#define BLOCK_MEMORY 0 +#define BLOCK_INOUT 1 +#define BLOCK_GFXMEM 2 +#define BLOCK_USRMEM 3 +#define BLOCK_CFGMEM 4 #define VERSION 4 #define REVISION 5 @@ -211,9 +212,9 @@ struct PciConfig #define CARD_NAME "Picasso96/Prometheus.card" #ifdef DEBUG -#define __DBG__ "debug " + #define __DBG__ "debug " #else -#define __DBG__ + #define __DBG__ #endif char libid[] = "\0$VER: prometheus.library 4.5 " __DBG__ "(14.01.2024)\r\n"; @@ -226,113 +227,146 @@ char libname[] = "prometheus.library\0"; /*--- Functions prototypes -------------------------------------------------*/ -struct PrometheusBase *LibInit (__reg("d0") struct PrometheusBase *pb, __reg("a0") void *seglist, __reg("a6") struct Library *sysb); -struct PrometheusBase *LibOpen (__reg("a6") struct PrometheusBase *pb); -LONG LibClose (__reg("a6") struct PrometheusBase *pb); -APTR LibExpunge (__reg("a6") struct PrometheusBase *pb); -long LibReserved (void); -PCIBoard* FindBoardTagList (__reg("a6") struct PrometheusBase *pb , __reg("a0") PCIBoard *node, __reg("a1") struct TagItem *taglist); -ULONG GetBoardAttrsTagList (__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("a1") struct TagItem *taglist); +struct PrometheusBase *LibInit(__reg("d0") struct PrometheusBase *pb, + __reg("a0") void * seglist, + __reg("a6") struct Library * sysb); +struct PrometheusBase *LibOpen(__reg("a6") struct PrometheusBase *pb); +LONG LibClose(__reg("a6") struct PrometheusBase *pb); +APTR LibExpunge(__reg("a6") struct PrometheusBase *pb); +long LibReserved(void); +PCIBoard * FindBoardTagList(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * node, + __reg("a1") struct TagItem * taglist); +ULONG GetBoardAttrsTagList(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("a1") struct TagItem * taglist); ULONG ReadConfigLong(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE offset); UWORD ReadConfigWord(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE offset); UBYTE ReadConfigByte(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE offset); -void WriteConfigLong(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") ULONG data, __reg("d1") UBYTE offset); -void WriteConfigWord(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UWORD data, __reg("d1") UBYTE offset); -void WriteConfigByte(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE data, __reg("d1") UBYTE offset); -LONG SetBoardAttrsTagList(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("a1") struct TagItem *taglist); -BOOL AddIntServer_(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("a1") struct Interrupt *intr); -void RemIntServer_(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("a1") struct Interrupt *intr); -APTR AllocDMABuffer(__reg("a6") struct PrometheusBase *pb, __reg("d0") ULONG size); -void FreeDMABuffer(__reg("a6") struct PrometheusBase *pb, __reg("a0") APTR buffer, __reg("d0") ULONG size); -APTR GetPhysicalAddress(__reg("a6") struct PrometheusBase *pb, __reg("d0") APTR addr); -APTR GetVirtualAddress(__reg("a6") struct PrometheusBase *pb, __reg("d0") APTR addr); -APTR AllocPCIAddressSpace(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") ULONG size, __reg("d1") ULONG bar); -void FreePCIAddressSpace(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") ULONG bar); - -void *FuncTable[] = - { - (APTR)LibOpen, - (APTR)LibClose, - (APTR)LibExpunge, - (APTR)LibReserved, - (APTR)FindBoardTagList, - (APTR)GetBoardAttrsTagList, - (APTR)ReadConfigLong, - (APTR)ReadConfigWord, - (APTR)ReadConfigByte, - (APTR)WriteConfigLong, - (APTR)WriteConfigWord, - (APTR)WriteConfigByte, - (APTR)SetBoardAttrsTagList, - (APTR)AddIntServer_, - (APTR)RemIntServer_, - (APTR)AllocDMABuffer, - (APTR)FreeDMABuffer, - (APTR)GetPhysicalAddress, - (APTR)GetVirtualAddress, - (APTR)AllocPCIAddressSpace, - (APTR)FreePCIAddressSpace, - (APTR)-1 - }; - -struct MyDataInit /* do not change */ +void WriteConfigLong(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("d0") ULONG data, + __reg("d1") UBYTE offset); +void WriteConfigWord(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("d0") UWORD data, + __reg("d1") UBYTE offset); +void WriteConfigByte(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("d0") UBYTE data, + __reg("d1") UBYTE offset); +LONG SetBoardAttrsTagList(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("a1") struct TagItem * taglist); +BOOL AddIntServer_(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("a1") struct Interrupt * intr); +void RemIntServer_(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("a1") struct Interrupt * intr); +APTR AllocDMABuffer(__reg("a6") struct PrometheusBase *pb, __reg("d0") ULONG size); +void FreeDMABuffer(__reg("a6") struct PrometheusBase *pb, __reg("a0") APTR buffer, __reg("d0") ULONG size); +APTR GetPhysicalAddress(__reg("a6") struct PrometheusBase *pb, __reg("d0") APTR addr); +APTR GetVirtualAddress(__reg("a6") struct PrometheusBase *pb, __reg("d0") APTR addr); +APTR AllocPCIAddressSpace(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("d0") ULONG size, + __reg("d1") ULONG bar); +void FreePCIAddressSpace(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") ULONG bar); + +void *FuncTable[] = {(APTR)LibOpen, + (APTR)LibClose, + (APTR)LibExpunge, + (APTR)LibReserved, + (APTR)FindBoardTagList, + (APTR)GetBoardAttrsTagList, + (APTR)ReadConfigLong, + (APTR)ReadConfigWord, + (APTR)ReadConfigByte, + (APTR)WriteConfigLong, + (APTR)WriteConfigWord, + (APTR)WriteConfigByte, + (APTR)SetBoardAttrsTagList, + (APTR)AddIntServer_, + (APTR)RemIntServer_, + (APTR)AllocDMABuffer, + (APTR)FreeDMABuffer, + (APTR)GetPhysicalAddress, + (APTR)GetVirtualAddress, + (APTR)AllocPCIAddressSpace, + (APTR)FreePCIAddressSpace, + (APTR)-1}; + +struct MyDataInit /* do not change */ { - UWORD ln_Type_Init; UWORD ln_Type_Offset; UWORD ln_Type_Content; - UBYTE ln_Name_Init; UBYTE ln_Name_Offset; ULONG ln_Name_Content; - UWORD lib_Flags_Init; UWORD lib_Flags_Offset; UWORD lib_Flags_Content; - UWORD lib_Version_Init; UWORD lib_Version_Offset; UWORD lib_Version_Content; - UWORD lib_Revision_Init; UWORD lib_Revision_Offset; UWORD lib_Revision_Content; - UBYTE lib_IdString_Init; UBYTE lib_IdString_Offset; ULONG lib_IdString_Content; - ULONG ENDMARK; -} DataTab = + UWORD ln_Type_Init; + UWORD ln_Type_Offset; + UWORD ln_Type_Content; + UBYTE ln_Name_Init; + UBYTE ln_Name_Offset; + ULONG ln_Name_Content; + UWORD lib_Flags_Init; + UWORD lib_Flags_Offset; + UWORD lib_Flags_Content; + UWORD lib_Version_Init; + UWORD lib_Version_Offset; + UWORD lib_Version_Content; + UWORD lib_Revision_Init; + UWORD lib_Revision_Offset; + UWORD lib_Revision_Content; + UBYTE lib_IdString_Init; + UBYTE lib_IdString_Offset; + ULONG lib_IdString_Content; + ULONG ENDMARK; +} DataTab = {0xe000, + 8, + NT_LIBRARY, + 0x0080, + 10, + (ULONG)&libname[0], + 0xe000, + 14, + LIBF_SUMUSED | LIBF_CHANGED, + 0xd000, + 20, + VERSION, + 0xd000, + 22, + REVISION, + 0x80, + 24, + (ULONG)&libid[0], + (ULONG)0}; + +struct InitTable /* do not change */ { - 0xe000,8,NT_LIBRARY, - 0x0080,10,(ULONG) &libname[0], - 0xe000,14,LIBF_SUMUSED|LIBF_CHANGED, - 0xd000,20,VERSION, - 0xd000,22,REVISION, - 0x80,24,(ULONG) &libid[0], - (ULONG) 0 -}; - -struct InitTable /* do not change */ -{ - ULONG LibBaseSize; - APTR *FunctionTable; - struct MyDataInit *DataTable; - APTR InitLibTable; -} InitTab = -{ - (ULONG) sizeof(struct PrometheusBase), - (APTR *) &FuncTable[0], - (struct MyDataInit *) &DataTab, - (APTR) LibInit -}; - + ULONG LibBaseSize; + APTR * FunctionTable; + struct MyDataInit *DataTable; + APTR InitLibTable; +} InitTab = {(ULONG)sizeof(struct PrometheusBase), (APTR *)&FuncTable[0], (struct MyDataInit *)&DataTab, (APTR)LibInit}; /*--------------------------------------------------------------------------*/ /* Our Resident struct. */ /*--------------------------------------------------------------------------*/ -const struct Resident ROMTag = /* do not change */ -{ - RTC_MATCHWORD, - (APTR)&ROMTag, - &ROMTag.rt_Init + 1, - RTF_AUTOINIT, - VERSION, - NT_LIBRARY, - 0, - &libname[0], - &libid[0], - &InitTab -}; +const struct Resident ROMTag = /* do not change */ + {RTC_MATCHWORD, + (APTR)&ROMTag, + &ROMTag.rt_Init + 1, + RTF_AUTOINIT, + VERSION, + NT_LIBRARY, + 0, + &libname[0], + &libid[0], + &InitTab}; /*--------------------------------------------------------------------------*/ /* Fake entry. */ /*--------------------------------------------------------------------------*/ -int main (void) +int main(void) { return -1; } @@ -345,21 +379,21 @@ int main (void) #ifdef TESTEXE extern struct Library *SysBase; -#define D(x) x -#define kprintf printf -#define CARDDELAY 100000 + #define D(x) x + #define kprintf printf + #define CARDDELAY 100000 #else -#ifdef DEBUG -#define D(x) x -#define CARDDELAY 100000 + #ifdef DEBUG + #define D(x) x + #define CARDDELAY 100000 -APTR __DRawPutChar(__reg("a6") void *, __reg("d0") UBYTE MyChar)="\tjsr\t-516(a6)"; +APTR __DRawPutChar(__reg("a6") void *, __reg("d0") UBYTE MyChar) = "\tjsr\t-516(a6)"; -#define DRawPutChar(MyChar) __DRawPutChar(SysBase, (MyChar)) + #define DRawPutChar(MyChar) __DRawPutChar(SysBase, (MyChar)) void DPutChProc(__reg("d0") UBYTE mychar, __reg("a3") APTR PutChData) { - struct ExecBase* SysBase = (struct ExecBase*)PutChData; + struct ExecBase *SysBase = (struct ExecBase *)PutChData; DRawPutChar(mychar); return; } @@ -368,55 +402,55 @@ void kprintf(STRPTR format, ...) { if (format) { - struct ExecBase* SysBase = *(struct ExecBase **)4L; - va_list args; + struct ExecBase *SysBase = *(struct ExecBase **)4L; + va_list args; va_start(args, format); RawDoFmt(format, (APTR)args, &DPutChProc, (APTR)SysBase); va_end(args); } return; } -#else -void kprintf(const char *,...); -#define D(x) -#define CARDDELAY 10000 /* 10ms enough? */ -#endif + #else +void kprintf(const char *, ...); + #define D(x) + #define CARDDELAY 10000 /* 10ms enough? */ + #endif #endif /***************************************************************************** NAME */ -void arosEnqueue(struct List * list, struct Node * node) +void arosEnqueue(struct List *list, struct Node *node) /* FUNCTION - Sort a node into a list. The sort-key is the field node->ln_Pri. - The node will be inserted into the list before the first node - with lower priority. This creates a FIFO queue for nodes with - the same priority. + Sort a node into a list. The sort-key is the field node->ln_Pri. + The node will be inserted into the list before the first node + with lower priority. This creates a FIFO queue for nodes with + the same priority. INPUTS - list - Insert into this list. The list has to be in descending - order in respect to the field ln_Pri of all nodes. - node - This node is to be inserted. Note that this has to - be a complete node and not a MinNode ! + list - Insert into this list. The list has to be in descending + order in respect to the field ln_Pri of all nodes. + node - This node is to be inserted. Note that this has to + be a complete node and not a MinNode ! RESULT - The new node will be inserted before nodes with lower - priority. + The new node will be inserted before nodes with lower + priority. NOTES - The list has to be in descending order in respect to the field - ln_Pri of all nodes. + The list has to be in descending order in respect to the field + ln_Pri of all nodes. EXAMPLE - struct List * list; - struct Node * node; + struct List * list; + struct Node * node; - node->ln_Pri = 5; + node->ln_Pri = 5; - // Sort the node at the correct place into the list - Enqueue (list, node); + // Sort the node at the correct place into the list + Enqueue (list, node); BUGS @@ -426,42 +460,40 @@ void arosEnqueue(struct List * list, struct Node * node) ******************************************************************************/ { - struct Node * next; + struct Node *next; /* Look through the list */ - ForeachNode (list, next) + ForeachNode(list, next) { - /* - Look for the first node with a lower pri as the node - we have to insert into the list. - */ - if (node->ln_Pri > next->ln_Pri) - break; + /* + Look for the first node with a lower pri as the node + we have to insert into the list. + */ + if (node->ln_Pri > next->ln_Pri) break; } - - //D(kprintf("nodepri %ld\n", node->ln_Pri)); + + // D(kprintf("nodepri %ld\n", node->ln_Pri)); /* Insert the node before(!) next. The situation looks like this: - A<->next<->B *<-node->* + A<->next<->B *<-node->* - ie. next->ln_Pred points to A, A->ln_Succ points to next, - next->ln_Succ points to B, B->ln_Pred points to next. - ln_Succ and ln_Pred of node contain illegal pointers. + ie. next->ln_Pred points to A, A->ln_Succ points to next, + next->ln_Succ points to B, B->ln_Pred points to next. + ln_Succ and ln_Pred of node contain illegal pointers. */ - /* Let node point to A: A<-node */ - node->ln_Pred = next->ln_Pred; + node->ln_Pred = next->ln_Pred; /* Make node point to next: A<->node->next<->B */ - node->ln_Succ = next; + node->ln_Succ = next; /* Let A point to node: A->node */ next->ln_Pred->ln_Succ = node; /* Make next point to node: A<->node<-next<->B */ - next->ln_Pred = node; + next->ln_Pred = node; } /* Enqueue */ @@ -471,43 +503,44 @@ void arosEnqueue(struct List * list, struct Node * node) BOOL PrmTimeDelay(struct PrometheusBase *pb, LONG unit, ULONG secs, ULONG microsecs) { - struct PortIO { - struct MsgPort port; - struct timerequest treq; - } *portio; + struct PortIO + { + struct MsgPort port; + struct timerequest treq; + } * portio; - LONG ret = TRUE; + LONG ret = TRUE; - struct Library *SysBase = pb->pb_SysBase; + struct Library *SysBase = pb->pb_SysBase; - if ((portio = (struct PortIO*)AllocMem(sizeof(*portio), MEMF_CLEAR | MEMF_PUBLIC))) - { - if ((BYTE)(portio->port.mp_SigBit = AllocSignal(-1)) >= 0) + if ((portio = (struct PortIO *)AllocMem(sizeof(*portio), MEMF_CLEAR | MEMF_PUBLIC))) { - portio->port.mp_Node.ln_Type = NT_MSGPORT; - portio->port.mp_SigTask = FindTask(NULL); - NewList(&portio->port.mp_MsgList); - portio->treq.tr_node.io_Message.mn_Node.ln_Type = NT_REPLYMSG; - portio->treq.tr_node.io_Message.mn_ReplyPort = &portio->port; - - if (!(OpenDevice("timer.device", unit, &portio->treq.tr_node, 0))) - { - portio->treq.tr_node.io_Command = TR_ADDREQUEST; - portio->treq.tr_time.tv_secs = secs; - portio->treq.tr_time.tv_micro = microsecs; - - if (!(DoIO(&portio->treq.tr_node))) + if ((BYTE)(portio->port.mp_SigBit = AllocSignal(-1)) >= 0) { - ret = FALSE; - } + portio->port.mp_Node.ln_Type = NT_MSGPORT; + portio->port.mp_SigTask = FindTask(NULL); + NewList(&portio->port.mp_MsgList); + portio->treq.tr_node.io_Message.mn_Node.ln_Type = NT_REPLYMSG; + portio->treq.tr_node.io_Message.mn_ReplyPort = &portio->port; + + if (!(OpenDevice("timer.device", unit, &portio->treq.tr_node, 0))) + { + portio->treq.tr_node.io_Command = TR_ADDREQUEST; + portio->treq.tr_time.tv_secs = secs; + portio->treq.tr_time.tv_micro = microsecs; - CloseDevice(&portio->treq.tr_node); - } - FreeSignal(portio->port.mp_SigBit); + if (!(DoIO(&portio->treq.tr_node))) + { + ret = FALSE; + } + + CloseDevice(&portio->treq.tr_node); + } + FreeSignal(portio->port.mp_SigBit); + } + FreeMem(portio, sizeof(*portio)); } - FreeMem(portio, sizeof(*portio)); - } - return ret; + return ret; } /*--------------------------------------------------------------------------*/ @@ -515,335 +548,353 @@ BOOL PrmTimeDelay(struct PrometheusBase *pb, LONG unit, ULONG secs, ULONG micros /*--------------------------------------------------------------------------*/ BYTE SizeToPri(ULONG size) - { - BYTE pri; +{ + BYTE pri; - for (pri = 0; !(size & 0x00000001); size >>= 1) pri++; - return pri; - } + for (pri = 0; !(size & 0x00000001); size >>= 1) pri++; + return pri; +} /*--------------------------------------------------------------------------*/ /* AddRequest() adds memory or I/O space request to pb_Requests list. */ /*--------------------------------------------------------------------------*/ -void AddRequest(struct PrometheusBase *pb, struct PCIBus *pcibus, ULONG size, ULONG type, struct TagItem *tag, ULONG volatile *cfgreg, ULONG flag) - { - struct Library *SysBase = pb->pb_SysBase; - struct SpaceReq *srq; - BYTE Pri = SizeToPri(size); - - //D(kprintf("[AddRequest] pb 0x%lx, pbus 0x%lx, size 0x%lx, pri %ld, type %ld, tag 0x%lx, reg 0x%lx\n", pb, pcibus, size, SizeToPri(size), type, tag, cfgreg)); - - switch (type) - { - case BLOCK_MEMORY: +void AddRequest(struct PrometheusBase *pb, + struct PCIBus * pcibus, + ULONG size, + ULONG type, + struct TagItem * tag, + ULONG volatile * cfgreg, + ULONG flag) +{ + struct Library * SysBase = pb->pb_SysBase; + struct SpaceReq *srq; + BYTE Pri = SizeToPri(size); + + // D(kprintf("[AddRequest] pb 0x%lx, pbus 0x%lx, size 0x%lx, pri %ld, type %ld, tag 0x%lx, reg 0x%lx\n", pb, pcibus, + // size, SizeToPri(size), type, tag, cfgreg)); + + switch (type) { + case BLOCK_MEMORY: { Pri = -Pri; break; } - case BLOCK_GFXMEM: - { + case BLOCK_GFXMEM: { Pri = 127; break; } - case BLOCK_CFGMEM: - { - Pri = 126; + case BLOCK_CFGMEM: { + Pri = 126; type = BLOCK_MEMORY; break; } - } - - if (srq = AllocPooled(pb->pb_MemPool, sizeof(struct SpaceReq))) - { - srq->sr_Size = size; - srq->sr_Type = type; - srq->sr_Flag = flag; - srq->sr_Tag = tag; - srq->sr_CfgAddr = cfgreg; - srq->sr_Node.ln_Type = 0xFE; - srq->sr_Node.ln_Name = "PCICard"; - srq->sr_Node.ln_Pri = Pri; - - - arosEnqueue(&pcibus->br_CardRequests, &srq->sr_Node); - //D(kprintf("Jo AR 0x%lx\n", &pcibus->br_CardRequests)); - - } - //D(kprintf("AddRequest end\n")); - - return; - } + } + + if (srq = AllocPooled(pb->pb_MemPool, sizeof(struct SpaceReq))) + { + srq->sr_Size = size; + srq->sr_Type = type; + srq->sr_Flag = flag; + srq->sr_Tag = tag; + srq->sr_CfgAddr = cfgreg; + srq->sr_Node.ln_Type = 0xFE; + srq->sr_Node.ln_Name = "PCICard"; + srq->sr_Node.ln_Pri = Pri; + + arosEnqueue(&pcibus->br_CardRequests, &srq->sr_Node); + // D(kprintf("Jo AR 0x%lx\n", &pcibus->br_CardRequests)); + } + // D(kprintf("AddRequest end\n")); + + return; +} /*--------------------------------------------------------------------------*/ /* AddBus() adds PCIBusses to pb_Busses list. */ /*--------------------------------------------------------------------------*/ -struct PCIBus* AddBus(struct PrometheusBase *pb, UBYTE busnr, UBYTE pbusnr) - { - struct Library *SysBase = pb->pb_SysBase; - struct PCIBus *brq; - - D(kprintf("[AddBus] busnr: %ld, parentbusnr: %ld\n", busnr, pbusnr)); - - if (brq = AllocPooled(pb->pb_MemPool, sizeof(struct PCIBus))) - { - brq->br_BusNr = busnr; - brq->br_pBusNr = pbusnr; - brq->br_hasGraphics = FALSE; - brq->br_hasUpperIO = FALSE; - brq->br_Node.ln_Type = NT_USER; - brq->br_Node.ln_Pri = 0; - brq->br_Node.ln_Name = "PCIBus"; - NewList(&brq->br_CardRequests); - - AddTail((struct List*)&pb->pb_Busses, (struct Node*)&brq->br_Node); - } - pb->pb_BridgeCnt += 1; - - //D(kprintf("AddBus end %ld\n", pb->pb_BridgeCnt)); - - return brq; - } +struct PCIBus *AddBus(struct PrometheusBase *pb, UBYTE busnr, UBYTE pbusnr) +{ + struct Library *SysBase = pb->pb_SysBase; + struct PCIBus * brq; + + D(kprintf("[AddBus] busnr: %ld, parentbusnr: %ld\n", busnr, pbusnr)); + + if (brq = AllocPooled(pb->pb_MemPool, sizeof(struct PCIBus))) + { + brq->br_BusNr = busnr; + brq->br_pBusNr = pbusnr; + brq->br_hasGraphics = FALSE; + brq->br_hasUpperIO = FALSE; + brq->br_Node.ln_Type = NT_USER; + brq->br_Node.ln_Pri = 0; + brq->br_Node.ln_Name = "PCIBus"; + NewList(&brq->br_CardRequests); + + AddTail((struct List *)&pb->pb_Busses, (struct Node *)&brq->br_Node); + } + pb->pb_BridgeCnt += 1; + + // D(kprintf("AddBus end %ld\n", pb->pb_BridgeCnt)); + + return brq; +} /*--------------------------------------------------------------------------*/ /* QueryCard() asks card about memory requests and adds them to pb_Requests */ /* list. It also generates card's taglist. */ /*--------------------------------------------------------------------------*/ -void QueryCard (struct PrometheusBase *pb, struct PCIBus *pcibus, volatile struct PciConfig *conf, struct ConfigDev *cdev) +void QueryCard(struct PrometheusBase * pb, + struct PCIBus * pcibus, + volatile struct PciConfig *conf, + struct ConfigDev * cdev) { - struct Library *SysBase = pb->pb_SysBase; - UWORD basereg, vendor, device; - ULONG memsize, memtype, flag; - UBYTE Class, SubClass; - ULONG bus = 0, slot = 0; - WORD tagindex = 0; - PCIBoard *pcinode; - BOOL Bridge = FALSE; - - D(kprintf("[QueryCard] 0x%lx\n", conf)); - - PrmTimeDelay(pb, 0, 0, CARDDELAY); //Seems like bridges give trouble without this. - - if (conf->pc_Vendor != 0xFFFF) - { - if (pcinode = AllocPooled (pb->pb_MemPool, sizeof (PCIBoard))) + struct Library *SysBase = pb->pb_SysBase; + UWORD basereg, vendor, device; + ULONG memsize, memtype, flag; + UBYTE Class, SubClass; + ULONG bus = 0, slot = 0; + WORD tagindex = 0; + PCIBoard * pcinode; + BOOL Bridge = FALSE; + + D(kprintf("[QueryCard] 0x%lx\n", conf)); + + PrmTimeDelay(pb, 0, 0, CARDDELAY); // Seems like bridges give trouble without this. + + if (conf->pc_Vendor != 0xFFFF) { - AddTail((struct List*)&pb->pb_Cards, (struct Node*)pcinode); - - /* v2: save pointer to PCI config space for ReadConfigXxxx() and */ - /* WriteConfigXxxx(). */ - - pcinode->pn_ConfigBase = conf; - - /* NOTE: do not depend on tag order in taglist in custom code! */ - /* It WILL change. Use utility.library taglist interface. */ - - pcinode->pn_TagList[tagindex].ti_Tag = PRM_Vendor; - CacheClearU(); - pcinode->pn_TagList[tagindex++].ti_Data = vendor = swapw(conf->pc_Vendor) & 0xFFFF; - pcinode->pn_TagList[tagindex].ti_Tag = PRM_Device; - CacheClearU(); - pcinode->pn_TagList[tagindex++].ti_Data = device = swapw(conf->pc_Device) & 0xFFFF; - pcinode->pn_TagList[tagindex].ti_Tag = PRM_Revision; - CacheClearU(); - pcinode->pn_TagList[tagindex++].ti_Data = conf->pc_Revision; - pcinode->pn_TagList[tagindex].ti_Tag = PRM_Class; - CacheClearU(); - pcinode->pn_TagList[tagindex++].ti_Data = Class = conf->pc_Class; - pcinode->pn_TagList[tagindex].ti_Tag = PRM_SubClass; - CacheClearU(); - pcinode->pn_TagList[tagindex++].ti_Data = SubClass = conf->pc_SubClass; - pcinode->pn_TagList[tagindex].ti_Tag = PRM_Interface; - CacheClearU(); - pcinode->pn_TagList[tagindex++].ti_Data = conf->pc_Interface; - pcinode->pn_TagList[tagindex].ti_Tag = PRM_HeaderType; - CacheClearU(); - pcinode->pn_TagList[tagindex++].ti_Data = conf->pc_HeaderType; - - /* up to six base registers */ - - if(Class == 0x6 && SubClass == 0x4) - { - Bridge = TRUE; - CacheClearU(); - conf->types.t1.pc_ROM = 0xFEFFFFFF; - CacheClearU(); - memsize = swapl(conf->types.t1.pc_ROM); - } - else - { - pcinode->pn_TagList[tagindex].ti_Tag = PRM_SubsysVendor; - CacheClearU(); - pcinode->pn_TagList[tagindex++].ti_Data = swapw(conf->types.t0.pc_SybsystemVID); - pcinode->pn_TagList[tagindex].ti_Tag = PRM_SubsysID; - CacheClearU(); - pcinode->pn_TagList[tagindex++].ti_Data = swapw(conf->types.t0.pc_SubsystemID); - - for (basereg = 0; basereg < 6; basereg++) + if (pcinode = AllocPooled(pb->pb_MemPool, sizeof(PCIBoard))) { - flag = 0; - CacheClearU(); - conf->types.t0.pc_BaseRegs[basereg] = 0xFFFFFFFF; - CacheClearU(); - memsize = swapl(conf->types.t0.pc_BaseRegs[basereg]); - - if (vendor == VID_FREESCALE) //only do BAR0/1 for K1/M1 and BAR0/2 for - { - if (basereg == 1) + AddTail((struct List *)&pb->pb_Cards, (struct Node *)pcinode); + + /* v2: save pointer to PCI config space for ReadConfigXxxx() and */ + /* WriteConfigXxxx(). */ + + pcinode->pn_ConfigBase = conf; + + /* NOTE: do not depend on tag order in taglist in custom code! */ + /* It WILL change. Use utility.library taglist interface. */ + + pcinode->pn_TagList[tagindex].ti_Tag = PRM_Vendor; + CacheClearU(); + pcinode->pn_TagList[tagindex++].ti_Data = vendor = swapw(conf->pc_Vendor) & 0xFFFF; + pcinode->pn_TagList[tagindex].ti_Tag = PRM_Device; + CacheClearU(); + pcinode->pn_TagList[tagindex++].ti_Data = device = swapw(conf->pc_Device) & 0xFFFF; + pcinode->pn_TagList[tagindex].ti_Tag = PRM_Revision; + CacheClearU(); + pcinode->pn_TagList[tagindex++].ti_Data = conf->pc_Revision; + pcinode->pn_TagList[tagindex].ti_Tag = PRM_Class; + CacheClearU(); + pcinode->pn_TagList[tagindex++].ti_Data = Class = conf->pc_Class; + pcinode->pn_TagList[tagindex].ti_Tag = PRM_SubClass; + CacheClearU(); + pcinode->pn_TagList[tagindex++].ti_Data = SubClass = conf->pc_SubClass; + pcinode->pn_TagList[tagindex].ti_Tag = PRM_Interface; + CacheClearU(); + pcinode->pn_TagList[tagindex++].ti_Data = conf->pc_Interface; + pcinode->pn_TagList[tagindex].ti_Tag = PRM_HeaderType; + CacheClearU(); + pcinode->pn_TagList[tagindex++].ti_Data = conf->pc_HeaderType; + + /* up to six base registers */ + + if (Class == 0x6 && SubClass == 0x4) { - if (device == DEVID_MPC834X) - { - memsize = PCI_MEMSIZE_64MB; - } - else - { - memsize = PCI_MEMSIZE_128MB; /* Flash ? */ - } + Bridge = TRUE; + CacheClearU(); + conf->types.t1.pc_ROM = 0xFEFFFFFF; + CacheClearU(); + memsize = swapl(conf->types.t1.pc_ROM); } + else + { + pcinode->pn_TagList[tagindex].ti_Tag = PRM_SubsysVendor; + CacheClearU(); + pcinode->pn_TagList[tagindex++].ti_Data = swapw(conf->types.t0.pc_SybsystemVID); + pcinode->pn_TagList[tagindex].ti_Tag = PRM_SubsysID; + CacheClearU(); + pcinode->pn_TagList[tagindex++].ti_Data = swapw(conf->types.t0.pc_SubsystemID); + + for (basereg = 0; basereg < 6; basereg++) + { + flag = 0; + CacheClearU(); + conf->types.t0.pc_BaseRegs[basereg] = 0xFFFFFFFF; + CacheClearU(); + memsize = swapl(conf->types.t0.pc_BaseRegs[basereg]); + + if (vendor == VID_FREESCALE) // only do BAR0/1 for K1/M1 and BAR0/2 for + { + if (basereg == 1) + { + if (device == DEVID_MPC834X) + { + memsize = PCI_MEMSIZE_64MB; + } + else + { + memsize = PCI_MEMSIZE_128MB; /* Flash ? */ + } + } #if 0 else if ((basereg == 2) && (device == DEVID_MPC831X)) { memsize = PCI_MEMSIZE_16MB; /* Boot ROM? */ flag = 1; } -#endif //debugdebug - else if (basereg != 0) +#endif // debugdebug + else if (basereg != 0) + { + memsize = -1; + } + } + + else if ((vendor == VID_MOTOROLA) && (device == DEVID_POWERPLUSIII)) + { + if (basereg == 0) + memsize = PCI_MEMSIZE_4KB; + else if (basereg == 1) + memsize = PCI_MEMSIZE_4KB; + else if (basereg == 3) + memsize = PCI_MEMSIZE_256KB; + } + else if ((vendor == VID_MOTOROLA) && (device == DEVID_MPC107)) + { + if (basereg == 0) memsize = -1; + } + if (memsize == 0xFFFFFFFF) memsize = 0; /* board doesn't respond */ + + if (memsize) + { + if (memsize & 0x00000001) + { + memtype = BLOCK_INOUT; + memsize = (-(memsize & 0xFFFFFFFC)) & 0x0000FFFF; + D(kprintf("[QueryCard] io size: 0x%08lx\n", memsize)); + } + else + { + // 3dfx cards have their memory at basereg 1 so map this first for dma access + if ((vendor == VID_3DFX || (vendor == VID_TI && device == DEVID_PERMEDIA2)) && + Class == 0x3 && basereg == 1) + memtype = BLOCK_GFXMEM; + else if (vendor == VID_ATI && Class == 0x3 && basereg == 0) + memtype = BLOCK_GFXMEM; + else if ((vendor == VID_TI && device == DEVID_PERMEDIA2) && Class == 0x3 && basereg == 2) + memtype = BLOCK_GFXMEM; + else if ((vendor == VID_3DFX) && (basereg == 0)) + memtype = BLOCK_CFGMEM; + else if ((vendor == VID_S3) && (basereg == 0) && + (device == DEVID_VIRGE3D || device == DEVID_VIRGEDX || device == DEVID_VIRGEGX2 || + device == DEVID_TRIO64)) + memtype = BLOCK_GFXMEM; + else + memtype = BLOCK_MEMORY; + memsize = -(memsize & 0xFFFFFFF0); + D(kprintf("[QueryCard] mem size: 0x%08lx\n", memsize)); + } + pcinode->pn_TagList[tagindex].ti_Tag = PRM_MemorySize0 + basereg; + pcinode->pn_TagList[tagindex++].ti_Data = memsize; + pcinode->pn_TagList[tagindex].ti_Tag = PRM_MemoryAddr0 + basereg; + CacheClearU(); + AddRequest(pb, + pcibus, + memsize, + memtype, + &pcinode->pn_TagList[tagindex++], + &conf->types.t0.pc_BaseRegs[basereg], + flag); + } + else + { + pcinode->pn_TagList[tagindex++].ti_Tag = PRM_MemorySize0 + basereg; + pcinode->pn_TagList[tagindex++].ti_Tag = PRM_MemoryAddr0 + basereg; + CacheClearU(); + } + } + + /* query board ROM size */ + CacheClearU(); + conf->types.t0.pc_ROM = 0xFEFFFFFF; + CacheClearU(); + memsize = swapl(conf->types.t0.pc_ROM); + } + if (memsize == 0xFFFFFFFF) memsize = 0; /* board doesn't respond */ + + /* add board rom space request */ + if (memsize) { - memsize = -1; + memtype = BLOCK_MEMORY; + memsize = -(memsize & 0xFFFFF800); + pcinode->pn_TagList[tagindex].ti_Tag = PRM_ROM_Size; + pcinode->pn_TagList[tagindex++].ti_Data = memsize; + pcinode->pn_TagList[tagindex].ti_Tag = PRM_ROM_Address; + AddRequest(pb, + pcibus, + memsize, + memtype, + &pcinode->pn_TagList[tagindex++], + Bridge ? &conf->types.t1.pc_ROM : &conf->types.t0.pc_ROM, + 0); } - } - - else if ((vendor == VID_MOTOROLA) && (device == DEVID_POWERPLUSIII)) - { - if (basereg == 0) - memsize = PCI_MEMSIZE_4KB; - else if (basereg == 1) - memsize = PCI_MEMSIZE_4KB; - else if (basereg == 3) - memsize = PCI_MEMSIZE_256KB; - } - else if ((vendor == VID_MOTOROLA) && (device == DEVID_MPC107)) - { - if (basereg == 0) - memsize = -1; - } - if (memsize == 0xFFFFFFFF) memsize = 0; /* board doesn't respond */ - - if (memsize) - { - if (memsize & 0x00000001) + } + + /* V2: set up PRM_BoardOwner tag (initialized to NULL) */ + + pcinode->pn_TagList[tagindex].ti_Tag = PRM_BoardOwner; + if (!(Bridge)) + { + pcinode->pn_TagList[tagindex++].ti_Data = NULL; + } + else + { + pcinode->pn_TagList[tagindex++].ti_Data = (ULONG)pb; + } + + /* V2: set up PRM_SlotNumber tag */ + + bus = pcibus->br_BusNr; + + if (pb->pb_FireStorm == TRUE) + { + if (bus > 0) { - memtype = BLOCK_INOUT; - memsize = (-(memsize & 0xFFFFFFFC)) & 0x0000FFFF; - D(kprintf("[QueryCard] io size: 0x%08lx\n", memsize)); + slot = (((ULONG)conf & 0x0000F800) >> 11); } else { - // 3dfx cards have their memory at basereg 1 so map this first for dma access - if((vendor == VID_3DFX || (vendor == VID_TI && device == DEVID_PERMEDIA2)) && Class == 0x3 && basereg == 1) - memtype = BLOCK_GFXMEM; - else if(vendor == VID_ATI && Class == 0x3 && basereg == 0) - memtype = BLOCK_GFXMEM; - else if((vendor == VID_TI && device == DEVID_PERMEDIA2) && Class == 0x3 && basereg == 2) - memtype = BLOCK_GFXMEM; - else if((vendor == VID_3DFX) && (basereg == 0)) - memtype = BLOCK_CFGMEM; - else if((vendor == VID_S3) && (basereg == 0) && (device == DEVID_VIRGE3D || device == DEVID_VIRGEDX || device == DEVID_VIRGEGX2 || device == DEVID_TRIO64)) - memtype = BLOCK_GFXMEM; - else - memtype = BLOCK_MEMORY; - memsize = -(memsize & 0xFFFFFFF0); - D(kprintf("[QueryCard] mem size: 0x%08lx\n", memsize)); - } - pcinode->pn_TagList[tagindex].ti_Tag = PRM_MemorySize0 + basereg; - pcinode->pn_TagList[tagindex++].ti_Data = memsize; - pcinode->pn_TagList[tagindex].ti_Tag = PRM_MemoryAddr0 + basereg; - CacheClearU(); - AddRequest (pb, pcibus, memsize, memtype, &pcinode->pn_TagList[tagindex++], &conf->types.t0.pc_BaseRegs[basereg], flag); - } - else - { - pcinode->pn_TagList[tagindex++].ti_Tag = PRM_MemorySize0 + basereg; - pcinode->pn_TagList[tagindex++].ti_Tag = PRM_MemoryAddr0 + basereg; - CacheClearU(); - } + slot = ((ULONG)conf & 0xF0000) >> 17; + if (slot == 4) slot = 3; + } + } + else + { + slot = ((ULONG)conf & 0xFFFF) >> 13; } - /* query board ROM size */ - CacheClearU(); - conf->types.t0.pc_ROM = 0xFEFFFFFF; - CacheClearU(); - memsize = swapl(conf->types.t0.pc_ROM); - - } - if (memsize == 0xFFFFFFFF) memsize = 0; /* board doesn't respond */ - - /* add board rom space request */ - if (memsize) - { - memtype = BLOCK_MEMORY; - memsize = -(memsize & 0xFFFFF800); - pcinode->pn_TagList[tagindex].ti_Tag = PRM_ROM_Size; - pcinode->pn_TagList[tagindex++].ti_Data = memsize; - pcinode->pn_TagList[tagindex].ti_Tag = PRM_ROM_Address; - AddRequest (pb, pcibus, memsize, memtype, &pcinode->pn_TagList[tagindex++], Bridge ? &conf->types.t1.pc_ROM : &conf->types.t0.pc_ROM, 0 ); - } - } + D(kprintf("[QueryCard] conf: 0x%08lx bus: %lx, slot: %lx\n", (ULONG)conf, bus, slot)); - /* V2: set up PRM_BoardOwner tag (initialized to NULL) */ + pcinode->pn_TagList[tagindex].ti_Tag = PRM_SlotNumber; + pcinode->pn_TagList[tagindex++].ti_Data = (ULONG)slot; - pcinode->pn_TagList[tagindex].ti_Tag = PRM_BoardOwner; - if (!(Bridge)) - { - pcinode->pn_TagList[tagindex++].ti_Data = NULL; - } - else - { - pcinode->pn_TagList[tagindex++].ti_Data = (ULONG)pb; - } + /* V2: set up PRM_FunctionNumber tag - currently multifunction devices */ + /* are not supported. New for V2.4 - function number is supported and */ + /* derived from config area address. */ + + pcinode->pn_TagList[tagindex].ti_Tag = PRM_FunctionNumber; + pcinode->pn_TagList[tagindex++].ti_Data = ((ULONG)conf & 0x00000700) >> 8; + pcinode->pn_TagList[tagindex].ti_Tag = PRM_BusNumber; + pcinode->pn_TagList[tagindex++].ti_Data = (ULONG)bus; + pcinode->pn_TagList[tagindex].ti_Tag = TAG_DONE; + + // D(kprintf("QueryCard end\n")); - /* V2: set up PRM_SlotNumber tag */ - - bus = pcibus->br_BusNr; - - if(pb->pb_FireStorm == TRUE) - { - if(bus > 0) - { - slot = (((ULONG)conf & 0x0000F800) >> 11); - } - else - { - slot = ((ULONG)conf & 0xF0000) >> 17; - if(slot == 4) slot = 3; - } - } - else - { - slot = ((ULONG)conf & 0xFFFF) >> 13; - } - - D(kprintf("[QueryCard] conf: 0x%08lx bus: %lx, slot: %lx\n", (ULONG)conf, bus, slot)); - - pcinode->pn_TagList[tagindex].ti_Tag = PRM_SlotNumber; - pcinode->pn_TagList[tagindex++].ti_Data = (ULONG)slot; - - /* V2: set up PRM_FunctionNumber tag - currently multifunction devices */ - /* are not supported. New for V2.4 - function number is supported and */ - /* derived from config area address. */ - - pcinode->pn_TagList[tagindex].ti_Tag = PRM_FunctionNumber; - pcinode->pn_TagList[tagindex++].ti_Data = ((ULONG)conf & 0x00000700) >> 8; - pcinode->pn_TagList[tagindex].ti_Tag = PRM_BusNumber; - pcinode->pn_TagList[tagindex++].ti_Data = (ULONG)bus; - pcinode->pn_TagList[tagindex].ti_Tag = TAG_DONE; - - //D(kprintf("QueryCard end\n")); - - //D(kprintf("tagindex: %lx\n", tagindex)); - } + // D(kprintf("tagindex: %lx\n", tagindex)); + } } /*--------------------------------------------------------------------------*/ @@ -853,253 +904,283 @@ void QueryCard (struct PrometheusBase *pb, struct PCIBus *pcibus, volatile struc void WriteAddresses(struct PrometheusBase *pb, struct ConfigDev *cdev) { - struct Library *SysBase = pb->pb_SysBase; - struct SpaceReq *srq, *srqn; - struct PCIBus *pbus; - ULONG io_highaddr = 0; - ULONG mem_highaddr = 0; //0x100000; - ULONG mask = ~(-cdev->cd_BoardSize); - ULONG fs_size_mask = 0; - UBYTE count; - UBYTE busnr = 0; - ULONG memlimit, iolimit; - - //D(kprintf("WriteAddresses\n")); - - if (pb->pb_FireStorm == FALSE) - { - mem_highaddr = (ULONG)cdev->cd_BoardAddr + cdev->cd_BoardSize; - io_highaddr = (ULONG)cdev->cd_BoardAddr + 0xF0000; - } - else io_highaddr = 0x1000; /* leave some space for hardcoded ISA io addresses */ - - ForeachNode(&pb->pb_Busses, pbus) /* find the graphic card first for dma mem */ - { - if(pbus->br_hasGraphics == TRUE && (struct PCIBus *)pb->pb_Busses.lh_Head != pbus) - { - Remove((struct Node *)pbus); /* move the bus with graphics card to list head */ - AddHead(&pb->pb_Busses, (struct Node *)pbus); - break; - } - } - - /* walk through the found PCI Busses for bridge address window alignment reasons */ - - ForeachNode(&pb->pb_Busses, pbus) - { - ListLength(&pbus->br_CardRequests, count); - D(kprintf("[WriteAddresses] Bus %ld count %ld\n", pbus->br_BusNr, count)); - - if(pbus->br_BusNr > 0) - { - /* we need to align the first used address for PCI Bridge windows here */ - if(mem_highaddr & 0x000FFFFF) - { - mem_highaddr &= 0xFFF00000; // only upper three digits - mem_highaddr += 0x100000; // align on next 1MB window - } - if(io_highaddr & 0x0fff) - { - io_highaddr = (io_highaddr & 0xf000) + 0x1000; - } - - pbus->br_ConfigBase->types.t1.pc_MemoryBase = swapw((mem_highaddr & 0xFFF00000) >> 16); - pbus->br_ConfigBase->types.t1.pc_PrefetchMemBase = swapw((mem_highaddr & 0xFFF00000) >> 16); - D(kprintf("[WriteAddresses] bus: %lx, Bus MemBase: 0x%08lx\n", pbus->br_BusNr, pbus->br_ConfigBase->types.t1.pc_MemoryBase)); - - pbus->br_ConfigBase->types.t1.pc_IOBase = (io_highaddr >> 12); - D(kprintf("[WriteAddresses] bus: %lx, Bus IOBase: 0x%08lx\n", pbus->br_BusNr, pbus->br_ConfigBase->types.t1.pc_IOBase)); - - CacheClearU(); - } + struct Library * SysBase = pb->pb_SysBase; + struct SpaceReq *srq, *srqn; + struct PCIBus * pbus; + ULONG io_highaddr = 0; + ULONG mem_highaddr = 0; // 0x100000; + ULONG mask = ~(-cdev->cd_BoardSize); + ULONG fs_size_mask = 0; + UBYTE count; + UBYTE busnr = 0; + ULONG memlimit, iolimit; + + // D(kprintf("WriteAddresses\n")); + + if (pb->pb_FireStorm == FALSE) + { + mem_highaddr = (ULONG)cdev->cd_BoardAddr + cdev->cd_BoardSize; + io_highaddr = (ULONG)cdev->cd_BoardAddr + 0xF0000; + } + else + io_highaddr = 0x1000; /* leave some space for hardcoded ISA io addresses */ + + ForeachNode(&pb->pb_Busses, pbus) /* find the graphic card first for dma mem */ + { + if (pbus->br_hasGraphics == TRUE && (struct PCIBus *)pb->pb_Busses.lh_Head != pbus) + { + Remove((struct Node *)pbus); /* move the bus with graphics card to list head */ + AddHead(&pb->pb_Busses, (struct Node *)pbus); + break; + } + } + + /* walk through the found PCI Busses for bridge address window alignment reasons */ + + ForeachNode(&pb->pb_Busses, pbus) + { + ListLength(&pbus->br_CardRequests, count); + D(kprintf("[WriteAddresses] Bus %ld count %ld\n", pbus->br_BusNr, count)); + + if (pbus->br_BusNr > 0) + { + /* we need to align the first used address for PCI Bridge windows here */ + if (mem_highaddr & 0x000FFFFF) + { + mem_highaddr &= 0xFFF00000; // only upper three digits + mem_highaddr += 0x100000; // align on next 1MB window + } + if (io_highaddr & 0x0fff) + { + io_highaddr = (io_highaddr & 0xf000) + 0x1000; + } + + pbus->br_ConfigBase->types.t1.pc_MemoryBase = swapw((mem_highaddr & 0xFFF00000) >> 16); + pbus->br_ConfigBase->types.t1.pc_PrefetchMemBase = swapw((mem_highaddr & 0xFFF00000) >> 16); + D(kprintf("[WriteAddresses] bus: %lx, Bus MemBase: 0x%08lx\n", + pbus->br_BusNr, + pbus->br_ConfigBase->types.t1.pc_MemoryBase)); + + pbus->br_ConfigBase->types.t1.pc_IOBase = (io_highaddr >> 12); + D(kprintf("[WriteAddresses] bus: %lx, Bus IOBase: 0x%08lx\n", + pbus->br_BusNr, + pbus->br_ConfigBase->types.t1.pc_IOBase)); + + CacheClearU(); + } #if 0 for (srq = (struct SpaceReq*)pbus->br_CardRequests.lh_Head; srq->sr_Node.ln_Succ; srq = (struct SpaceReq*)srq->sr_Node.ln_Succ); #endif - ForeachNodeSafe(&pbus->br_CardRequests, srq, srqn) - { - if (pb->pb_FireStorm == TRUE) - { - /* check if free space is not exhausted */ - if (mem_highaddr >= 0x1FC00000) break; /* 508 MB */ - if (io_highaddr >= 0x1fffff) break; - - fs_size_mask = ~(-srq->sr_Size); - - switch (srq->sr_Type) - { - case BLOCK_GFXMEM: - case BLOCK_MEMORY: - if(( mem_highaddr & fs_size_mask) != 0) mem_highaddr = (mem_highaddr | fs_size_mask) + 1; - - *srq->sr_CfgAddr = swapl((mem_highaddr | 1) & mask); - srq->sr_Tag->ti_Data = (ULONG)cdev->cd_BoardAddr + mem_highaddr; - - if (srq->sr_Flag == 1) *(srq->sr_CfgAddr + 1) = 0; /* Clear BigFoot Upper (64 bit) Boot ROM address */ - D(kprintf("[WriteAddresses] mem Pri: %03ld, addr: 0x%08lx, bus: %ld\n", srq->sr_Node.ln_Pri, mem_highaddr, pbus->br_BusNr)); - mem_highaddr += srq->sr_Size; - break; - - case BLOCK_INOUT: - if(( io_highaddr & fs_size_mask) != 0) io_highaddr = (io_highaddr | fs_size_mask) + 1; - - *srq->sr_CfgAddr = swapl(io_highaddr & mask); - srq->sr_Tag->ti_Data = (ULONG)cdev->cd_BoardAddr + FS_PCI_ADDR_IO + io_highaddr; - D(kprintf("[WriteAddresses] io Pri: %03ld, addr: 0x%08lx, bus: %ld\n", srq->sr_Node.ln_Pri, io_highaddr, pbus->br_BusNr)); - io_highaddr += srq->sr_Size; - break; - } - - } - else - { - switch (srq->sr_Type) - { - case BLOCK_GFXMEM: - case BLOCK_MEMORY: mem_highaddr -= srq->sr_Size; break; - case BLOCK_INOUT: io_highaddr -= srq->sr_Size; break; - } - - if (mem_highaddr <= (ULONG)cdev->cd_BoardAddr + 0x00100000) break; - if (io_highaddr <= (ULONG)cdev->cd_BoardAddr + 0x00010000) break; - - /* write assigned address to the card ('1' in memory registers enables */ - /* ROM decoding and has no meaning in ordinary base registers. Write */ - /* the address to the taglist also. */ - - switch (srq->sr_Type) - { - case BLOCK_GFXMEM: - case BLOCK_MEMORY: - *srq->sr_CfgAddr = swapl((mem_highaddr | 1) & mask); - srq->sr_Tag->ti_Data = mem_highaddr; - D(kprintf("[WriteAddresses] Pri: %03ld, addr: 0x%08lx, bus: %ld\n", srq->sr_Node.ln_Pri, mem_highaddr, pbus->br_BusNr)); - break; - - case BLOCK_INOUT: - *srq->sr_CfgAddr = swapl(io_highaddr & mask); - srq->sr_Tag->ti_Data = io_highaddr; - D(kprintf("[WriteAddresses] Pri: %03ld, addr: 0x%08lx, bus: %ld\n", srq->sr_Node.ln_Pri, io_highaddr, pbus->br_BusNr)); - break; - } - } - CacheClearU(); - } - busnr = pbus->br_BusNr; - } - - /* calculate new address space top address */ - - - if (busnr > 0) - { - -#if 0 //We be cheating... + ForeachNodeSafe(&pbus->br_CardRequests, srq, srqn) + { + if (pb->pb_FireStorm == TRUE) + { + /* check if free space is not exhausted */ + if (mem_highaddr >= 0x1FC00000) break; /* 508 MB */ + if (io_highaddr >= 0x1fffff) break; + + fs_size_mask = ~(-srq->sr_Size); + + switch (srq->sr_Type) + { + case BLOCK_GFXMEM: + case BLOCK_MEMORY: + if ((mem_highaddr & fs_size_mask) != 0) mem_highaddr = (mem_highaddr | fs_size_mask) + 1; + + *srq->sr_CfgAddr = swapl((mem_highaddr | 1) & mask); + srq->sr_Tag->ti_Data = (ULONG)cdev->cd_BoardAddr + mem_highaddr; + + if (srq->sr_Flag == 1) + *(srq->sr_CfgAddr + 1) = 0; /* Clear BigFoot Upper (64 bit) Boot ROM address */ + D(kprintf("[WriteAddresses] mem Pri: %03ld, addr: 0x%08lx, bus: %ld\n", + srq->sr_Node.ln_Pri, + mem_highaddr, + pbus->br_BusNr)); + mem_highaddr += srq->sr_Size; + break; + + case BLOCK_INOUT: + if ((io_highaddr & fs_size_mask) != 0) io_highaddr = (io_highaddr | fs_size_mask) + 1; + + *srq->sr_CfgAddr = swapl(io_highaddr & mask); + srq->sr_Tag->ti_Data = (ULONG)cdev->cd_BoardAddr + FS_PCI_ADDR_IO + io_highaddr; + D(kprintf("[WriteAddresses] io Pri: %03ld, addr: 0x%08lx, bus: %ld\n", + srq->sr_Node.ln_Pri, + io_highaddr, + pbus->br_BusNr)); + io_highaddr += srq->sr_Size; + break; + } + } + else + { + switch (srq->sr_Type) + { + case BLOCK_GFXMEM: + case BLOCK_MEMORY: + mem_highaddr -= srq->sr_Size; + break; + case BLOCK_INOUT: + io_highaddr -= srq->sr_Size; + break; + } + + if (mem_highaddr <= (ULONG)cdev->cd_BoardAddr + 0x00100000) break; + if (io_highaddr <= (ULONG)cdev->cd_BoardAddr + 0x00010000) break; + + /* write assigned address to the card ('1' in memory registers enables */ + /* ROM decoding and has no meaning in ordinary base registers. Write */ + /* the address to the taglist also. */ + + switch (srq->sr_Type) + { + case BLOCK_GFXMEM: + case BLOCK_MEMORY: + *srq->sr_CfgAddr = swapl((mem_highaddr | 1) & mask); + srq->sr_Tag->ti_Data = mem_highaddr; + D(kprintf("[WriteAddresses] Pri: %03ld, addr: 0x%08lx, bus: %ld\n", + srq->sr_Node.ln_Pri, + mem_highaddr, + pbus->br_BusNr)); + break; + + case BLOCK_INOUT: + *srq->sr_CfgAddr = swapl(io_highaddr & mask); + srq->sr_Tag->ti_Data = io_highaddr; + D(kprintf("[WriteAddresses] Pri: %03ld, addr: 0x%08lx, bus: %ld\n", + srq->sr_Node.ln_Pri, + io_highaddr, + pbus->br_BusNr)); + break; + } + } + CacheClearU(); + } + busnr = pbus->br_BusNr; + } + + /* calculate new address space top address */ + + if (busnr > 0) + { +#if 0 // We be cheating... memlimit = (mem_highaddr + 0x000FFFFF) & 0xFFF00000; #else - memlimit = 0x1FC00000; + memlimit = 0x1FC00000; #endif - iolimit = (io_highaddr + 0x0FFF) & 0xF000; + iolimit = (io_highaddr + 0x0FFF) & 0xF000; - ForeachNode(&pb->pb_Busses, pbus) - { - if ((pbus->br_BusNr > 0) && (pbus->br_BusNr <= busnr)) /* This suffices for now */ - { - pbus->br_ConfigBase->types.t1.pc_MemoryLimit = swapw((memlimit >> 16) - 1); - pbus->br_ConfigBase->types.t1.pc_PrefetchMemLimit = swapw((memlimit >> 16) - 1); - pbus->br_ConfigBase->types.t1.pc_IOLimit = ((iolimit >> 12) - 1); - - D(kprintf("[WriteAddresses] bus: %lx, Adjusted Bus MemLimit: 0x%08lx\n", pbus->br_BusNr, pbus->br_ConfigBase->types.t1.pc_MemoryLimit)); - D(kprintf("[WriteAddresses] bus: %lx, Adjusted Bus IOLimit: 0x%08lx\n", pbus->br_BusNr, pbus->br_ConfigBase->types.t1.pc_IOLimit)); - } - CacheClearU(); + ForeachNode(&pb->pb_Busses, pbus) + { + if ((pbus->br_BusNr > 0) && (pbus->br_BusNr <= busnr)) /* This suffices for now */ + { + pbus->br_ConfigBase->types.t1.pc_MemoryLimit = swapw((memlimit >> 16) - 1); + pbus->br_ConfigBase->types.t1.pc_PrefetchMemLimit = swapw((memlimit >> 16) - 1); + pbus->br_ConfigBase->types.t1.pc_IOLimit = ((iolimit >> 12) - 1); + + D(kprintf("[WriteAddresses] bus: %lx, Adjusted Bus MemLimit: 0x%08lx\n", + pbus->br_BusNr, + pbus->br_ConfigBase->types.t1.pc_MemoryLimit)); + D(kprintf("[WriteAddresses] bus: %lx, Adjusted Bus IOLimit: 0x%08lx\n", + pbus->br_BusNr, + pbus->br_ConfigBase->types.t1.pc_IOLimit)); + } + CacheClearU(); + } } - } - return; + return; } UBYTE ScanBus(struct PrometheusBase *pb, struct PCIBus *pBus, struct ConfigDev *cdev) { - struct Library *SysBase = pb->pb_SysBase; - volatile struct PciConfig *pci; - WORD function, funmax; /* introduced in V2.4 */ - WORD headertype, slot; - - APTR cfspace = (APTR)((ULONG)cdev->cd_BoardAddr + FS_PCI_ADDR_CONFIG1 + ((ULONG)(pBus->br_BusNr) << 16)); - UBYTE busdepth = pBus->br_BusNr; - - for (slot = 0; slot <= 0x1f; slot++) - { - pci = cfspace; - headertype = pci->pc_HeaderType; - - D(kprintf("[ScanBus] scanning bus slot: %02ld, cfspace: 0x%08lx ht: 0x%02lx v: 0x%04lx d: 0x%04lx\n" - ,slot, cfspace, headertype, pci->pc_Vendor, pci->pc_Device)); - - /* What todo if we got a PCI-PCI Bridge */ - if((headertype & 0x7f) == 0x01) - { - struct PCIBus *pbusnew; - - D(kprintf("[ScanBus] Found a PCI-PCI Bridge.\n")); - - pci->types.t1.pc_PrimaryBus = pBus->br_BusNr; /* we are given the new bus data */ - pci->types.t1.pc_SecondaryBus = pBus->br_BusNr+1; - pci->types.t1.pc_SubordinateBus = 0xFF; - pbusnew = AddBus(pb, pBus->br_BusNr+1, pBus->br_BusNr); - pbusnew->br_ConfigBase = cfspace; /* save for WriteAddresses access */ - - if((pci->types.t1.pc_IOBase & 0xf) == 0x01) - { - pbusnew->br_hasUpperIO = TRUE; - D(kprintf("[ScanBus] Bridge has upper IO support!\n")); - } - - busdepth = ScanBus(pb, pbusnew, cdev); - pci->types.t1.pc_SubordinateBus = busdepth; - CacheClearU(); - } - - if(pci->pc_Class == 0x3) - { - D(kprintf("[ScanBus] Found a graphic card!\n")); - pBus->br_hasGraphics = TRUE; - } - - if(pci->pc_Vendor != 0xFFFF && pci->pc_Device != 0xFFFF) - { - /* determine if a device is multifunction (bit 7 in pc_HeaderType). */ - /* 'function' loop counts from 0 to 7 if it is, is performed only once if */ - /* not. */ - - if((headertype & 0x80) && (pci->pc_Vendor != swapw(VID_ATI))) /* save 128MB of second aperture */ - funmax = 8; else funmax = 1; - - for (function = 0; function < funmax; function++) - { - QueryCard(pb, pBus, &pci[function<<8], cdev); - pci[function<<8].pc_LatencyTimer = 0x80; /* no latency because of Zorro III design (v 2.5) */ - if(((pci->pc_Vendor == swapw(VID_MOTOROLA)) && (pci->pc_Device == swapw(DEVID_MPC107)) && (pci->pc_Revision == 0x13))) - { - pci[function<<8].pc_Command = swapw(0x003); /* do not enable busmaster for MPC107 rev 19*/ - } - else if(pci->pc_Vendor == swapw(VID_ATI)) - { - pci[function<<8].pc_LatencyTimer = 0x80; - pci[function<<8].pc_Command = swapw(0x207); - } - else - { - pci[function<<8].pc_Command = swapw(0x007); /* enable I/O, memory space and busmaster */ - } - } - CacheClearU(); - } - cfspace = (APTR)(((ULONG)cfspace + 0x800)); - } - - return busdepth; + struct Library * SysBase = pb->pb_SysBase; + volatile struct PciConfig *pci; + WORD function, funmax; /* introduced in V2.4 */ + WORD headertype, slot; + + APTR cfspace = (APTR)((ULONG)cdev->cd_BoardAddr + FS_PCI_ADDR_CONFIG1 + ((ULONG)(pBus->br_BusNr) << 16)); + UBYTE busdepth = pBus->br_BusNr; + + for (slot = 0; slot <= 0x1f; slot++) + { + pci = cfspace; + headertype = pci->pc_HeaderType; + + D(kprintf("[ScanBus] scanning bus slot: %02ld, cfspace: 0x%08lx ht: 0x%02lx v: 0x%04lx d: 0x%04lx\n", + slot, + cfspace, + headertype, + pci->pc_Vendor, + pci->pc_Device)); + + /* What todo if we got a PCI-PCI Bridge */ + if ((headertype & 0x7f) == 0x01) + { + struct PCIBus *pbusnew; + + D(kprintf("[ScanBus] Found a PCI-PCI Bridge.\n")); + + pci->types.t1.pc_PrimaryBus = pBus->br_BusNr; /* we are given the new bus data */ + pci->types.t1.pc_SecondaryBus = pBus->br_BusNr + 1; + pci->types.t1.pc_SubordinateBus = 0xFF; + pbusnew = AddBus(pb, pBus->br_BusNr + 1, pBus->br_BusNr); + pbusnew->br_ConfigBase = cfspace; /* save for WriteAddresses access */ + + if ((pci->types.t1.pc_IOBase & 0xf) == 0x01) + { + pbusnew->br_hasUpperIO = TRUE; + D(kprintf("[ScanBus] Bridge has upper IO support!\n")); + } + + busdepth = ScanBus(pb, pbusnew, cdev); + pci->types.t1.pc_SubordinateBus = busdepth; + CacheClearU(); + } + + if (pci->pc_Class == 0x3) + { + D(kprintf("[ScanBus] Found a graphic card!\n")); + pBus->br_hasGraphics = TRUE; + } + + if (pci->pc_Vendor != 0xFFFF && pci->pc_Device != 0xFFFF) + { + /* determine if a device is multifunction (bit 7 in pc_HeaderType). */ + /* 'function' loop counts from 0 to 7 if it is, is performed only once if */ + /* not. */ + + if ((headertype & 0x80) && (pci->pc_Vendor != swapw(VID_ATI))) /* save 128MB of second aperture */ + funmax = 8; + else + funmax = 1; + + for (function = 0; function < funmax; function++) + { + QueryCard(pb, pBus, &pci[function << 8], cdev); + pci[function << 8].pc_LatencyTimer = 0x80; /* no latency because of Zorro III design (v 2.5) */ + if (((pci->pc_Vendor == swapw(VID_MOTOROLA)) && (pci->pc_Device == swapw(DEVID_MPC107)) && + (pci->pc_Revision == 0x13))) + { + pci[function << 8].pc_Command = swapw(0x003); /* do not enable busmaster for MPC107 rev 19*/ + } + else if (pci->pc_Vendor == swapw(VID_ATI)) + { + pci[function << 8].pc_LatencyTimer = 0x80; + pci[function << 8].pc_Command = swapw(0x207); + } + else + { + pci[function << 8].pc_Command = swapw(0x007); /* enable I/O, memory space and busmaster */ + } + } + CacheClearU(); + } + cfspace = (APTR)(((ULONG)cfspace + 0x800)); + } + + return busdepth; } /*--------------------------------------------------------------------------*/ /* ConfigurePrometheus() configures all cards inserted in Prometheus slots. */ @@ -1107,180 +1188,187 @@ UBYTE ScanBus(struct PrometheusBase *pb, struct PCIBus *pBus, struct ConfigDev * void ConfigurePrometheus(struct PrometheusBase *pb, struct ConfigDev *cdev) { - struct Library *SysBase = pb->pb_SysBase; - WORD headertype, slot; - WORD function, funmax; /* introduced in V2.4 */ - ULONG fs_csreg = 0x10000; /* slot configspace offset */ - volatile APTR cfspace; /* ptr to cards config space */ - volatile ULONG *fs_cfreg; /* ptr to configreg */ - volatile struct PciConfig *pci; - volatile APTR mfptr; - struct PCIBus *pbus; - UBYTE busdepth; - - /* initialize pb_Busses list */ - - NewList(&pb->pb_Busses); - pb->pb_BaseAddr = cdev->cd_BoardAddr; - - pbus = AddBus(pb, 0, 0); /* add 'RootBus' to busses list */ - - if (pb->pb_FireStorm == TRUE) - { - cfspace = (APTR)((ULONG)cdev->cd_BoardAddr + FS_PCI_ADDR_CONFIG0); - fs_cfreg = (ULONG*)((ULONG)cfspace + 0x8000); - *fs_cfreg |= 0x80000000; /* disable reset */ - PrmTimeDelay(pb, 0, 0, 5000); - *fs_cfreg &= 0x7fffffff; /* reset */ - PrmTimeDelay(pb, 0, 0, 5000); - *fs_cfreg |= 0xc0000000; /* disable reset, enable ints */ - PrmTimeDelay(pb, 0, 0, 5000); - cfspace = (APTR)((ULONG)cfspace + fs_csreg); - } - else - { - cfspace = (APTR)((ULONG)cdev->cd_BoardAddr + 0x000F0000); - } - - for (slot = 0; slot < 4; slot++) - { - busdepth = 0; - pci = cfspace; - headertype = pci->pc_HeaderType; - - D(kprintf("[ConfigurePrometheus] scanning bus slot: %ld, cfspace: 0x%08lx ht: 0x%02lx v: 0x%04lx d: 0x%04lx\n" - , slot, cfspace, headertype, pci->pc_Vendor, pci->pc_Device)); - - /* What todo if we got a PCI-PCI Bridge */ - /* bridges only work with e3b upgraded hardware */ - - if(((headertype & 0x7f) == 0x01) && (pb->pb_FireStorm == TRUE)) { - struct PCIBus *pbusnew; - D(kprintf("[ConfigurePrometheus] Found a PCI-PCI Bridge. BusNr: %ld\n", pb->pb_BridgeCnt)); - pci->types.t1.pc_PrimaryBus = 0x00; - pci->types.t1.pc_SecondaryBus = pb->pb_BridgeCnt; - pci->types.t1.pc_SubordinateBus = 0xFF; - pbusnew = AddBus(pb, pb->pb_BridgeCnt, 0); /* add first secondary bus */ - pbusnew->br_ConfigBase = cfspace; /* save for WriteAddresses access */ - - D(kprintf("[ConfigurePrometheus] pbusnr: %ld, busnr: %ld\n", pbusnew->br_pBusNr, pbusnew->br_BusNr)); - if((pci->types.t1.pc_IOBase & 0xf) == 0x01) - pbusnew->br_hasUpperIO = TRUE; - - busdepth = ScanBus(pb, pbusnew, cdev); - - pci->types.t1.pc_SubordinateBus = busdepth; - CacheClearU(); - } - - //D(kprintf("[ConfigurePrometheus] pb_BridgeCnt: %ld\n", pb->pb_BridgeCnt)); - - if(pci->pc_Class == 0x3) - { - D(kprintf("We found a graphic card!\n")); - pbus->br_hasGraphics = TRUE; - } - - if(pci->pc_Vendor != 0xFFFF && pci->pc_Device != 0xFFFF) { - - /* determine if a device is multifunction (bit 7 in pc_HeaderType). */ - /* 'function' loop counts from 0 to 7 if it is, is performed only once if */ - /* not. */ - - if ((headertype & 0x80) && (pci->pc_Vendor != swapw(VID_ATI))) /* save 128MB of second aperture */ - funmax = 8; else funmax = 1; - - for (function = 0; function < funmax; function++) - { - if (pb->pb_FireStorm == TRUE) - { - mfptr = (APTR)(((ULONG)cfspace) + (function<<8)); - pci = mfptr; - QueryCard(pb, pbus, pci, cdev); - pci->pc_LatencyTimer = 0x00; /* no latency because of Zorro III design (v 2.5) */ - - if(((pci->pc_Vendor == swapw(VID_MOTOROLA)) && (pci->pc_Device == swapw(DEVID_MPC107)) && (pci->pc_Revision == 0x13))) - { - pci->pc_Command = swapw(0x003); /* do not enable busmaster for MPC107 rev 19*/ - } - else if(pci->pc_Vendor == swapw(VID_ATI)) - { - pci->pc_LatencyTimer = 0x80; - pci->pc_Command = swapw(0x207); - } - else - { - pci->pc_Command = swapw(0x007); /* enable I/O, memory space and busmaster */ - } - } - else - { - QueryCard(pb, pbus, &pci[function], cdev); - pci[function].pc_Command = 0x0700; /* enable I/O, memory space and busmaster */ - pci[function].pc_LatencyTimer = 0x00; /* no latency because of Zorro III design (v 2.5) */ - } - } - } + struct Library * SysBase = pb->pb_SysBase; + WORD headertype, slot; + WORD function, funmax; /* introduced in V2.4 */ + ULONG fs_csreg = 0x10000; /* slot configspace offset */ + volatile APTR cfspace; /* ptr to cards config space */ + volatile ULONG * fs_cfreg; /* ptr to configreg */ + volatile struct PciConfig *pci; + volatile APTR mfptr; + struct PCIBus * pbus; + UBYTE busdepth; + + /* initialize pb_Busses list */ + + NewList(&pb->pb_Busses); + pb->pb_BaseAddr = cdev->cd_BoardAddr; + + pbus = AddBus(pb, 0, 0); /* add 'RootBus' to busses list */ + if (pb->pb_FireStorm == TRUE) { - fs_csreg <<= 1; // 0x20000, 0x40000, 0x80000 - cfspace = (APTR)(((ULONG)cfspace & 0xfff0ffff) + fs_csreg); + cfspace = (APTR)((ULONG)cdev->cd_BoardAddr + FS_PCI_ADDR_CONFIG0); + fs_cfreg = (ULONG *)((ULONG)cfspace + 0x8000); + *fs_cfreg |= 0x80000000; /* disable reset */ + PrmTimeDelay(pb, 0, 0, 5000); + *fs_cfreg &= 0x7fffffff; /* reset */ + PrmTimeDelay(pb, 0, 0, 5000); + *fs_cfreg |= 0xc0000000; /* disable reset, enable ints */ + PrmTimeDelay(pb, 0, 0, 5000); + cfspace = (APTR)((ULONG)cfspace + fs_csreg); } else { - cfspace = (APTR)((ULONG)cfspace + 0x2000); + cfspace = (APTR)((ULONG)cdev->cd_BoardAddr + 0x000F0000); } - } - WriteAddresses(pb, cdev); + for (slot = 0; slot < 4; slot++) + { + busdepth = 0; + pci = cfspace; + headertype = pci->pc_HeaderType; + + D(kprintf("[ConfigurePrometheus] scanning bus slot: %ld, cfspace: 0x%08lx ht: 0x%02lx v: 0x%04lx d: 0x%04lx\n", + slot, + cfspace, + headertype, + pci->pc_Vendor, + pci->pc_Device)); - cdev->cd_Driver = pb; - cdev->cd_Flags &= ~CDF_CONFIGME; - return; + /* What todo if we got a PCI-PCI Bridge */ + /* bridges only work with e3b upgraded hardware */ + + if (((headertype & 0x7f) == 0x01) && (pb->pb_FireStorm == TRUE)) + { + struct PCIBus *pbusnew; + D(kprintf("[ConfigurePrometheus] Found a PCI-PCI Bridge. BusNr: %ld\n", pb->pb_BridgeCnt)); + pci->types.t1.pc_PrimaryBus = 0x00; + pci->types.t1.pc_SecondaryBus = pb->pb_BridgeCnt; + pci->types.t1.pc_SubordinateBus = 0xFF; + pbusnew = AddBus(pb, pb->pb_BridgeCnt, 0); /* add first secondary bus */ + pbusnew->br_ConfigBase = cfspace; /* save for WriteAddresses access */ + + D(kprintf("[ConfigurePrometheus] pbusnr: %ld, busnr: %ld\n", pbusnew->br_pBusNr, pbusnew->br_BusNr)); + if ((pci->types.t1.pc_IOBase & 0xf) == 0x01) pbusnew->br_hasUpperIO = TRUE; + + busdepth = ScanBus(pb, pbusnew, cdev); + + pci->types.t1.pc_SubordinateBus = busdepth; + CacheClearU(); + } + + // D(kprintf("[ConfigurePrometheus] pb_BridgeCnt: %ld\n", pb->pb_BridgeCnt)); + + if (pci->pc_Class == 0x3) + { + D(kprintf("We found a graphic card!\n")); + pbus->br_hasGraphics = TRUE; + } + + if (pci->pc_Vendor != 0xFFFF && pci->pc_Device != 0xFFFF) + { + /* determine if a device is multifunction (bit 7 in pc_HeaderType). */ + /* 'function' loop counts from 0 to 7 if it is, is performed only once if */ + /* not. */ + + if ((headertype & 0x80) && (pci->pc_Vendor != swapw(VID_ATI))) /* save 128MB of second aperture */ + funmax = 8; + else + funmax = 1; + + for (function = 0; function < funmax; function++) + { + if (pb->pb_FireStorm == TRUE) + { + mfptr = (APTR)(((ULONG)cfspace) + (function << 8)); + pci = mfptr; + QueryCard(pb, pbus, pci, cdev); + pci->pc_LatencyTimer = 0x00; /* no latency because of Zorro III design (v 2.5) */ + + if (((pci->pc_Vendor == swapw(VID_MOTOROLA)) && (pci->pc_Device == swapw(DEVID_MPC107)) && + (pci->pc_Revision == 0x13))) + { + pci->pc_Command = swapw(0x003); /* do not enable busmaster for MPC107 rev 19*/ + } + else if (pci->pc_Vendor == swapw(VID_ATI)) + { + pci->pc_LatencyTimer = 0x80; + pci->pc_Command = swapw(0x207); + } + else + { + pci->pc_Command = swapw(0x007); /* enable I/O, memory space and busmaster */ + } + } + else + { + QueryCard(pb, pbus, &pci[function], cdev); + pci[function].pc_Command = 0x0700; /* enable I/O, memory space and busmaster */ + pci[function].pc_LatencyTimer = 0x00; /* no latency because of Zorro III design (v 2.5) */ + } + } + } + if (pb->pb_FireStorm == TRUE) + { + fs_csreg <<= 1; // 0x20000, 0x40000, 0x80000 + cfspace = (APTR)(((ULONG)cfspace & 0xfff0ffff) + fs_csreg); + } + else + { + cfspace = (APTR)((ULONG)cfspace + 0x2000); + } + } + + WriteAddresses(pb, cdev); + + cdev->cd_Driver = pb; + cdev->cd_Flags &= ~CDF_CONFIGME; + return; } #ifdef TESTEXE int main(void) { - struct PrometheusBase *pb; - struct Library *UtilityBase, *ExpansionBase; - struct ConfigDev *driver = NULL; - UBYTE cards = 0; - - if (pb = (struct PrometheusBase*)AllocVec(sizeof (struct PrometheusBase), MEMF_ANY | MEMF_CLEAR)) - { - pb->pb_SysBase = SysBase; - pb->pb_Cards.mlh_Head = (struct MinNode*)&pb->pb_Cards.mlh_Tail; - pb->pb_Cards.mlh_Tail = NULL; - pb->pb_Cards.mlh_TailPred = (struct MinNode*)&pb->pb_Cards.mlh_Head; - pb->pb_BridgeCnt = 0; - printf("TestExe\n"); - - if (pb->pb_MemPool = CreatePool(MEMF_ANY | MEMF_CLEAR, 4 * sizeof(PCIBoard), 4 * sizeof(PCIBoard))) - { - if (UtilityBase = OpenLibrary ("utility.library", 36)) - { - printf("TestExe\n"); - pb->pb_UtilityBase = UtilityBase; - if (ExpansionBase = OpenLibrary ("expansion.library", 36)) - { - printf("TestExe\n"); - - while (driver = FindConfigDev(driver, 0xAD47, 1)) // find Matay board - { - pb->pb_FireStorm = FALSE; - ConfigurePrometheus (pb, driver); - } - while (driver = FindConfigDev(driver, 0x0e3b, 0xc8)) // find e3b Firestorm board - { - pb->pb_FireStorm = TRUE; - ConfigurePrometheus (pb, driver); - } - CloseLibrary (ExpansionBase); - } - } - } - } + struct PrometheusBase *pb; + struct Library * UtilityBase, *ExpansionBase; + struct ConfigDev * driver = NULL; + UBYTE cards = 0; + + if (pb = (struct PrometheusBase *)AllocVec(sizeof(struct PrometheusBase), MEMF_ANY | MEMF_CLEAR)) + { + pb->pb_SysBase = SysBase; + pb->pb_Cards.mlh_Head = (struct MinNode *)&pb->pb_Cards.mlh_Tail; + pb->pb_Cards.mlh_Tail = NULL; + pb->pb_Cards.mlh_TailPred = (struct MinNode *)&pb->pb_Cards.mlh_Head; + pb->pb_BridgeCnt = 0; + printf("TestExe\n"); + + if (pb->pb_MemPool = CreatePool(MEMF_ANY | MEMF_CLEAR, 4 * sizeof(PCIBoard), 4 * sizeof(PCIBoard))) + { + if (UtilityBase = OpenLibrary("utility.library", 36)) + { + printf("TestExe\n"); + pb->pb_UtilityBase = UtilityBase; + if (ExpansionBase = OpenLibrary("expansion.library", 36)) + { + printf("TestExe\n"); + + while (driver = FindConfigDev(driver, 0xAD47, 1)) // find Matay board + { + pb->pb_FireStorm = FALSE; + ConfigurePrometheus(pb, driver); + } + while (driver = FindConfigDev(driver, 0x0e3b, 0xc8)) // find e3b Firestorm board + { + pb->pb_FireStorm = TRUE; + ConfigurePrometheus(pb, driver); + } + CloseLibrary(ExpansionBase); + } + } + } + } } #else @@ -1288,543 +1376,552 @@ int main(void) /* INIT */ /*-------------------------------------------------------------------------*/ -struct PrometheusBase *LibInit(__reg("d0") struct PrometheusBase *pb, __reg("a0") APTR seglist, __reg("a6") struct Library *sysb) +struct PrometheusBase *LibInit(__reg("d0") struct PrometheusBase *pb, + __reg("a0") APTR seglist, + __reg("a6") struct Library * sysb) { - struct PrometheusBase *rval = NULL; - struct ExecBase *SysBase = (struct ExecBase*)sysb; - struct Library *UtilityBase, *ExpansionBase; - struct ConfigDev *driver = NULL; - UBYTE cards = 0; - - if (!(SysBase->AttnFlags & AFF_68020)) - { - FreeMem ((APTR)((ULONG)pb - (ULONG)pb->pb_Lib.lib_NegSize), - (LONG)pb->pb_Lib.lib_PosSize + (LONG)pb->pb_Lib.lib_NegSize); + struct PrometheusBase *rval = NULL; + struct ExecBase * SysBase = (struct ExecBase *)sysb; + struct Library * UtilityBase, *ExpansionBase; + struct ConfigDev * driver = NULL; + UBYTE cards = 0; + + if (!(SysBase->AttnFlags & AFF_68020)) + { + FreeMem((APTR)((ULONG)pb - (ULONG)pb->pb_Lib.lib_NegSize), + (LONG)pb->pb_Lib.lib_PosSize + (LONG)pb->pb_Lib.lib_NegSize); return FALSE; - } - - pb->pb_Lib.lib_OpenCnt = 1; - pb->pb_SegList = seglist; - pb->pb_SysBase = sysb; - pb->pb_DMASuppBase = NULL; - pb->pb_Cards.mlh_Head = (struct MinNode*)&pb->pb_Cards.mlh_Tail; - pb->pb_Cards.mlh_Tail = NULL; - pb->pb_Cards.mlh_TailPred = (struct MinNode*)&pb->pb_Cards.mlh_Head; - pb->pb_BridgeCnt = 0; - - if (pb->pb_MemPool = CreatePool(MEMF_ANY | MEMF_CLEAR, 4 * sizeof(PCIBoard), 4 * sizeof(PCIBoard))) - { - if (UtilityBase = OpenLibrary ("utility.library", 36)) - { - pb->pb_UtilityBase = UtilityBase; - if (ExpansionBase = OpenLibrary ("expansion.library", 36)) - { - while (driver = FindConfigDev(driver, 0xAD47, 1)) // find Matay board - { - pb->pb_FireStorm = FALSE; - ConfigurePrometheus (pb, driver); - } - while (driver = FindConfigDev(driver, 0x0e3b, 0xc8)) // find e3b Firestorm board - { - pb->pb_FireStorm = TRUE; - ConfigurePrometheus (pb, driver); - } - rval = pb; - CloseLibrary (ExpansionBase); - } - if (!rval) - { - CloseLibrary (UtilityBase); - pb->pb_UtilityBase = NULL; - } - } - } - return rval; -} + } + pb->pb_Lib.lib_OpenCnt = 1; + pb->pb_SegList = seglist; + pb->pb_SysBase = sysb; + pb->pb_DMASuppBase = NULL; + pb->pb_Cards.mlh_Head = (struct MinNode *)&pb->pb_Cards.mlh_Tail; + pb->pb_Cards.mlh_Tail = NULL; + pb->pb_Cards.mlh_TailPred = (struct MinNode *)&pb->pb_Cards.mlh_Head; + pb->pb_BridgeCnt = 0; + + if (pb->pb_MemPool = CreatePool(MEMF_ANY | MEMF_CLEAR, 4 * sizeof(PCIBoard), 4 * sizeof(PCIBoard))) + { + if (UtilityBase = OpenLibrary("utility.library", 36)) + { + pb->pb_UtilityBase = UtilityBase; + if (ExpansionBase = OpenLibrary("expansion.library", 36)) + { + while (driver = FindConfigDev(driver, 0xAD47, 1)) // find Matay board + { + pb->pb_FireStorm = FALSE; + ConfigurePrometheus(pb, driver); + } + while (driver = FindConfigDev(driver, 0x0e3b, 0xc8)) // find e3b Firestorm board + { + pb->pb_FireStorm = TRUE; + ConfigurePrometheus(pb, driver); + } + rval = pb; + CloseLibrary(ExpansionBase); + } + if (!rval) + { + CloseLibrary(UtilityBase); + pb->pb_UtilityBase = NULL; + } + } + } + return rval; +} /*-------------------------------------------------------------------------*/ /* OPEN */ /*-------------------------------------------------------------------------*/ -struct PrometheusBase *LibOpen ( __reg("a6") struct PrometheusBase *pb) +struct PrometheusBase *LibOpen(__reg("a6") struct PrometheusBase *pb) { - struct PrometheusBase *ret = pb; - - pb->pb_Lib.lib_OpenCnt++; - pb->pb_Lib.lib_Flags &= ~LIBF_DELEXP; - return ret; + struct PrometheusBase *ret = pb; + + pb->pb_Lib.lib_OpenCnt++; + pb->pb_Lib.lib_Flags &= ~LIBF_DELEXP; + return ret; } /*-------------------------------------------------------------------------*/ /* CLOSE */ /*-------------------------------------------------------------------------*/ -long LibClose ( __reg("a6") struct PrometheusBase *pb) +long LibClose(__reg("a6") struct PrometheusBase *pb) { - if (!(--pb->pb_Lib.lib_OpenCnt)) - { - if (pb->pb_Lib.lib_Flags & LIBF_DELEXP) return ((long)LibExpunge (pb)); - } - return 0; + if (!(--pb->pb_Lib.lib_OpenCnt)) + { + if (pb->pb_Lib.lib_Flags & LIBF_DELEXP) return ((long)LibExpunge(pb)); + } + return 0; } /*-------------------------------------------------------------------------*/ /* EXPUNGE */ /*-------------------------------------------------------------------------*/ -void *LibExpunge ( __reg("a6") struct PrometheusBase *pb) +void *LibExpunge(__reg("a6") struct PrometheusBase *pb) { - APTR seglist; - struct Library *SysBase = pb->pb_SysBase; + APTR seglist; + struct Library *SysBase = pb->pb_SysBase; - if (pb->pb_Lib.lib_OpenCnt) - { - pb->pb_Lib.lib_Flags |= LIBF_DELEXP; - return 0; - } - Remove ((struct Node*)pb); - if (pb->pb_MemPool) DeletePool (pb->pb_MemPool); - if (pb->pb_UtilityBase) CloseLibrary (pb->pb_UtilityBase); - if (pb->pb_DMASuppBase) CloseLibrary (pb->pb_DMASuppBase); - seglist = pb->pb_SegList; - FreeMem ((APTR)((ULONG)pb - pb->pb_Lib.lib_NegSize), (LONG)pb->pb_Lib.lib_PosSize + (LONG)pb->pb_Lib.lib_NegSize); - return seglist; + if (pb->pb_Lib.lib_OpenCnt) + { + pb->pb_Lib.lib_Flags |= LIBF_DELEXP; + return 0; + } + Remove((struct Node *)pb); + if (pb->pb_MemPool) DeletePool(pb->pb_MemPool); + if (pb->pb_UtilityBase) CloseLibrary(pb->pb_UtilityBase); + if (pb->pb_DMASuppBase) CloseLibrary(pb->pb_DMASuppBase); + seglist = pb->pb_SegList; + FreeMem((APTR)((ULONG)pb - pb->pb_Lib.lib_NegSize), (LONG)pb->pb_Lib.lib_PosSize + (LONG)pb->pb_Lib.lib_NegSize); + return seglist; } /*-------------------------------------------------------------------------*/ /* RESERVED */ /*-------------------------------------------------------------------------*/ -long LibReserved (void) +long LibReserved(void) { - return 0; + return 0; } /****** prometheus.library/Prm_FindBoardTagList ***************************** -* -* NAME -* Prm_FindBoardTagList -- Finds PCI board with attributes given in the -* taglist. -* Prm_FindBoardTags -- Varargs stub for Prm_FindBoardTagList. -* -* SYNOPSIS -* Board = Prm_FindBoardTagList (Previous, TagList) -* A0 A1 -* -* PCIBoard *Prm_FindBoardTagList (PCIBoard*, struct TagItem*); -* -* Board = Prm_FindBoardTags (Previous, Tag1, ...) -* -* PCIBoard *Prm_FindBoardTags (PCIBoard*, Tag, ...); -* -* FUNCTION -* Finds all PCI boards connected to any Prometheus PCI bridge in the -* system, matching the tags in the TagList. First call returns first -* matching board found. To find all the matching boards call the -* function in loop until it returns NULL. -* -* INPUTS -* Previous - pointer to a "blackbox" PCI board structure. The function -* will search board list from the *next* board after -* Previous. NULL value means "start search from the -* beginning of internal list". -* TagList - list of tags all boards will be checked against. -* Empty taglist (TagList points to LONG 0), or NULL -* here means all the boards will be returned in turn. -* -* RESULT -* Board - a pointer to a "blackbox" PCI board structure. Don't try -* to peeking and pokeing it, use only as a parameter in -* prometheus.library calls. Function can return NULL if no -* [more] matching boards can be found. -* -* EXAMPLE -* Let's check if any Voodoo3 2000 board is plugged in: -* -* PCIBoard *board = NULL; -* -* while (board = Prm_FindBoardTags (board, PRM_Vendor, -* 0x121A, PRM_Device, 5, TAG_END)) -* { -* \* do something with 'board' *\ -* } -* -* NOTES -* Don't give random values as Previous board. It should be only pointer -* returned by Prm_FindBoardTagList() call or NULL. -* -* BUGS -* -* SEE ALSO -* Prm_GetBoardAttrsTagList() -* -***************************************************************************** -* -*/ - -PCIBoard *FindBoardTagList ( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *node, __reg("a1") struct TagItem *taglist) + * + * NAME + * Prm_FindBoardTagList -- Finds PCI board with attributes given in the + * taglist. + * Prm_FindBoardTags -- Varargs stub for Prm_FindBoardTagList. + * + * SYNOPSIS + * Board = Prm_FindBoardTagList (Previous, TagList) + * A0 A1 + * + * PCIBoard *Prm_FindBoardTagList (PCIBoard*, struct TagItem*); + * + * Board = Prm_FindBoardTags (Previous, Tag1, ...) + * + * PCIBoard *Prm_FindBoardTags (PCIBoard*, Tag, ...); + * + * FUNCTION + * Finds all PCI boards connected to any Prometheus PCI bridge in the + * system, matching the tags in the TagList. First call returns first + * matching board found. To find all the matching boards call the + * function in loop until it returns NULL. + * + * INPUTS + * Previous - pointer to a "blackbox" PCI board structure. The function + * will search board list from the *next* board after + * Previous. NULL value means "start search from the + * beginning of internal list". + * TagList - list of tags all boards will be checked against. + * Empty taglist (TagList points to LONG 0), or NULL + * here means all the boards will be returned in turn. + * + * RESULT + * Board - a pointer to a "blackbox" PCI board structure. Don't try + * to peeking and pokeing it, use only as a parameter in + * prometheus.library calls. Function can return NULL if no + * [more] matching boards can be found. + * + * EXAMPLE + * Let's check if any Voodoo3 2000 board is plugged in: + * + * PCIBoard *board = NULL; + * + * while (board = Prm_FindBoardTags (board, PRM_Vendor, + * 0x121A, PRM_Device, 5, TAG_END)) + * { + * \* do something with 'board' *\ + * } + * + * NOTES + * Don't give random values as Previous board. It should be only pointer + * returned by Prm_FindBoardTagList() call or NULL. + * + * BUGS + * + * SEE ALSO + * Prm_GetBoardAttrsTagList() + * + ***************************************************************************** + * + */ + +PCIBoard *FindBoardTagList(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * node, + __reg("a1") struct TagItem * taglist) { - struct TagItem *tag, *tagbase, *tagptr; - struct Library *UtilityBase = pb->pb_UtilityBase; + struct TagItem *tag, *tagbase, *tagptr; + struct Library *UtilityBase = pb->pb_UtilityBase; - if (!node) node = (PCIBoard*)pb->pb_Cards.mlh_Head; - else node = (PCIBoard*)node->pn_Node.mln_Succ; + if (!node) + node = (PCIBoard *)pb->pb_Cards.mlh_Head; + else + node = (PCIBoard *)node->pn_Node.mln_Succ; - while (node->pn_Node.mln_Succ) + while (node->pn_Node.mln_Succ) { - /* NULL taglist? No filtering, just return next card. */ + /* NULL taglist? No filtering, just return next card. */ - if (!(tagptr = taglist)) return node; + if (!(tagptr = taglist)) return node; - while (tag = NextTagItem(&tagptr)) - { - if (tagbase = FindTagItem (tag->ti_Tag, node->pn_TagList)) - if (tagbase->ti_Data != tag->ti_Data) break; - } - if (!tag) return node; - node = (PCIBoard*)node->pn_Node.mln_Succ; + while (tag = NextTagItem(&tagptr)) + { + if (tagbase = FindTagItem(tag->ti_Tag, node->pn_TagList)) + if (tagbase->ti_Data != tag->ti_Data) break; + } + if (!tag) return node; + node = (PCIBoard *)node->pn_Node.mln_Succ; } - return NULL; + return NULL; } - /****** prometheus.library/Prm_GetBoardAttrsTagList ************************* -* -* NAME -* Prm_GetBoardAttrsTagList -- reads information about PCI board. -* Prm_GetBoardAttrsTags -- Varargs stub for Prm_GetBoardAttrsTagList. -* -* SYNOPSIS -* TagsRead = Prm_GetBoardAttrsTagList (Board, TagList) -* A0 A1 -* -* ULONG Prm_GetBoardAttrsTagList (PCIBoard*, struct TagItem*); -* -* TagsRead = Prm_GetBoardAttrsTags (Board, Tag1, ...) -* -* ULONG Prm_GetBoardAttrsTags (PCIBoard*, Tag, ...); -* -* FUNCTION -* Reads information from board internal structure and writes it -* according to given taglist. Function looks for every passed tag value -* in database and if found writes its value at address given in ti_Data -* in passed TagList. -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). It can be NULL, function returns -* immediately in the case, no data is written. Don't pass -* random values here. -* TagList - Function will search in internal database for every ti_Tag -* in the TagList. If tag is found, ti_Data field is used as a -* pointer to ULONG and the information is written at the -* address. Unrecognized tags are skipped and 0 is written to -* the given ti_Data location. TagList can be NULL, -* function returns immediately at the case, no data are -* written. If ti_Data field of any tag is NULL, no data is -* written for this tag. Following tags are recognized: -* -* PRM_Vendor - Board vendor number assigned by PCISIG. -* PRM_Device - Device number assigned by manufacturer. -* PRM_Revision - Device revision number assigned by manufacturer. -* PRM_Class - Device class as defined in PCI specification. -* PRM_SubClass - Device subclass as defined in PCI specification. -* PRM_MemoryAddrX - (where X can be from '0' to '5'), PCI board can -* have up to six memory blocks allocated. These tags contains base -* adresses of blocks assigned by prometheus.library in init code. -* NULL value means a block is not used. You can depend on fact -* that the last nybble of PRM_MemoryAddrX is equal to X. It is -* guarranted in future releases. So the code below is valid: -* -* \* read all possible base adresses *\ -* -* ULONG baseaddr; -* -* for (i = 0; i < 6; i++) -* { -* Prm_GetBoardAttrsTags (any_board, PRM_MemoryAddr0 + i, -* (ULONG)&baseaddr, TAG_END); -* } -* -* PRM_MemorySizeX - (where X can be from '0' to '5'), PCI board can -* have up to six memory blocks allocated. These tags contains sizes -* of blocks assigned by prometheus.library in init code. NULL value -* means a block is not used. You can depend on fact that the last -* nybble of PRM_MemorySizeX is equal to X. It is guarranted in -* future releases (see code above). -* PRM_ROM_Address - Address of PCI on-board ROM (if found). -* PRM_ROM_Size - Size of PCI on-board ROM (if found). -* PRM_BoardOwner (V2) - an address of driver which claimed the board. -* Typically it points to struct Node, and driver name can be read -* from ln_Name field. -* PRM_SlotNumber (V2) - number of the physical PCI slot the board is -* inserted in. Range from 0 to 3 for primary PCI bus. -* PRM_FunctionNumber (V2) - number of device function. For single- -* -function devices always 0, for multifunction from 0 to 7. Every -* function of a multifunction board is reported by prometheus.library -* as a separate "board". -* -* RESULT -* TagsRead - Number of succesfully read tags. -* -* EXAMPLE -* Get first base address and block size of the card: -* -* APTR baseaddress = NULL; -* ULONG blocksize = 0; -* -* Prm_GetBoardAttrsTags (any_board, -* PRM_MemoryAddr0, (ULONG)&baseaddress, -* PRM_MemorySize0, (ULONG)&blocksize, -* TAG_END); -* -* NOTES -* -* BUGS -* -* SEE ALSO -* Prm_SetBoardAttrsTagList() -* -***************************************************************************** -* -*/ + * + * NAME + * Prm_GetBoardAttrsTagList -- reads information about PCI board. + * Prm_GetBoardAttrsTags -- Varargs stub for Prm_GetBoardAttrsTagList. + * + * SYNOPSIS + * TagsRead = Prm_GetBoardAttrsTagList (Board, TagList) + * A0 A1 + * + * ULONG Prm_GetBoardAttrsTagList (PCIBoard*, struct TagItem*); + * + * TagsRead = Prm_GetBoardAttrsTags (Board, Tag1, ...) + * + * ULONG Prm_GetBoardAttrsTags (PCIBoard*, Tag, ...); + * + * FUNCTION + * Reads information from board internal structure and writes it + * according to given taglist. Function looks for every passed tag value + * in database and if found writes its value at address given in ti_Data + * in passed TagList. + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). It can be NULL, function returns + * immediately in the case, no data is written. Don't pass + * random values here. + * TagList - Function will search in internal database for every ti_Tag + * in the TagList. If tag is found, ti_Data field is used as a + * pointer to ULONG and the information is written at the + * address. Unrecognized tags are skipped and 0 is written to + * the given ti_Data location. TagList can be NULL, + * function returns immediately at the case, no data are + * written. If ti_Data field of any tag is NULL, no data is + * written for this tag. Following tags are recognized: + * + * PRM_Vendor - Board vendor number assigned by PCISIG. + * PRM_Device - Device number assigned by manufacturer. + * PRM_Revision - Device revision number assigned by manufacturer. + * PRM_Class - Device class as defined in PCI specification. + * PRM_SubClass - Device subclass as defined in PCI specification. + * PRM_MemoryAddrX - (where X can be from '0' to '5'), PCI board can + * have up to six memory blocks allocated. These tags contains base + * adresses of blocks assigned by prometheus.library in init code. + * NULL value means a block is not used. You can depend on fact + * that the last nybble of PRM_MemoryAddrX is equal to X. It is + * guarranted in future releases. So the code below is valid: + * + * \* read all possible base adresses *\ + * + * ULONG baseaddr; + * + * for (i = 0; i < 6; i++) + * { + * Prm_GetBoardAttrsTags (any_board, PRM_MemoryAddr0 + i, + * (ULONG)&baseaddr, TAG_END); + * } + * + * PRM_MemorySizeX - (where X can be from '0' to '5'), PCI board can + * have up to six memory blocks allocated. These tags contains sizes + * of blocks assigned by prometheus.library in init code. NULL value + * means a block is not used. You can depend on fact that the last + * nybble of PRM_MemorySizeX is equal to X. It is guarranted in + * future releases (see code above). + * PRM_ROM_Address - Address of PCI on-board ROM (if found). + * PRM_ROM_Size - Size of PCI on-board ROM (if found). + * PRM_BoardOwner (V2) - an address of driver which claimed the board. + * Typically it points to struct Node, and driver name can be read + * from ln_Name field. + * PRM_SlotNumber (V2) - number of the physical PCI slot the board is + * inserted in. Range from 0 to 3 for primary PCI bus. + * PRM_FunctionNumber (V2) - number of device function. For single- + * -function devices always 0, for multifunction from 0 to 7. Every + * function of a multifunction board is reported by prometheus.library + * as a separate "board". + * + * RESULT + * TagsRead - Number of succesfully read tags. + * + * EXAMPLE + * Get first base address and block size of the card: + * + * APTR baseaddress = NULL; + * ULONG blocksize = 0; + * + * Prm_GetBoardAttrsTags (any_board, + * PRM_MemoryAddr0, (ULONG)&baseaddress, + * PRM_MemorySize0, (ULONG)&blocksize, + * TAG_END); + * + * NOTES + * + * BUGS + * + * SEE ALSO + * Prm_SetBoardAttrsTagList() + * + ***************************************************************************** + * + */ + +ULONG GetBoardAttrsTagList(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("a1") struct TagItem * taglist) +{ + struct TagItem *tagptr, *tag, *tagbase; + struct Library *UtilityBase = pb->pb_UtilityBase; + ULONG cnt = 0; -ULONG GetBoardAttrsTagList ( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("a1") struct TagItem *taglist) - { - struct TagItem *tagptr, *tag, *tagbase; - struct Library *UtilityBase = pb->pb_UtilityBase; - ULONG cnt = 0; - - if (board && taglist) - { - tagptr = taglist; - while (tag = NextTagItem (&tagptr)) - { - if (tag->ti_Data) - { - if (tagbase = FindTagItem (tag->ti_Tag, board->pn_TagList)) - { - *(ULONG*)tag->ti_Data = tagbase->ti_Data; - cnt++; - } - else *(ULONG*)tag->ti_Data = 0; - } - } - } - return cnt; - } + if (board && taglist) + { + tagptr = taglist; + while (tag = NextTagItem(&tagptr)) + { + if (tag->ti_Data) + { + if (tagbase = FindTagItem(tag->ti_Tag, board->pn_TagList)) + { + *(ULONG *)tag->ti_Data = tagbase->ti_Data; + cnt++; + } + else + *(ULONG *)tag->ti_Data = 0; + } + } + } + return cnt; +} /****** prometheus.library/Prm_ReadConfigLong ******************************* -* -* NAME -* Prm_ReadConfigLong -- reads a longword (32 bits) from config -* space of given PCI board. (V2) -* -* SYNOPSIS -* Value = Prm_ReadConfigLong (Board, Offset) -* A0 D0:8 -* -* ULONG Prm_ReadConfigLong (PCIBoard*, UBYTE); -* -* FUNCTION -* This function allows for direct reading of PCI board config space. -* Takes care of data endianness, data are always returned as big -* endian. -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). -* Offset - Config space offset in bytes to read from. Offset will be -* rounded down to 4 bytes boundary. -* -* RESULT -* Value - Longword read from PCI board. -* -* NOTES -* -* BUGS -* -* SEE ALSO -* Prm_ReadConfigWord(), Prm_ReadConfigByte(), Prm_WriteConfigLong() -* -***************************************************************************** -* -*/ - -ULONG ReadConfigLong( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE offset) + * + * NAME + * Prm_ReadConfigLong -- reads a longword (32 bits) from config + * space of given PCI board. (V2) + * + * SYNOPSIS + * Value = Prm_ReadConfigLong (Board, Offset) + * A0 D0:8 + * + * ULONG Prm_ReadConfigLong (PCIBoard*, UBYTE); + * + * FUNCTION + * This function allows for direct reading of PCI board config space. + * Takes care of data endianness, data are always returned as big + * endian. + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). + * Offset - Config space offset in bytes to read from. Offset will be + * rounded down to 4 bytes boundary. + * + * RESULT + * Value - Longword read from PCI board. + * + * NOTES + * + * BUGS + * + * SEE ALSO + * Prm_ReadConfigWord(), Prm_ReadConfigByte(), Prm_WriteConfigLong() + * + ***************************************************************************** + * + */ + +ULONG ReadConfigLong(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE offset) { - ULONG cfgl = (ULONG)board->pn_ConfigBase; + ULONG cfgl = (ULONG)board->pn_ConfigBase; struct Library *SysBase = pb->pb_SysBase; - ULONG tmp; + ULONG tmp; CacheClearU(); - - tmp = swapl( *(ULONG*)(cfgl+(ULONG)offset)); - + + tmp = swapl(*(ULONG *)(cfgl + (ULONG)offset)); + D(kprintf("Prm_ReadConfigLong offset 0x%lx result 0x%08lx\n", offset, tmp)); - + return tmp; } /****** prometheus.library/Prm_ReadConfigWord ******************************* -* -* NAME -* Prm_ReadConfigWord -- reads a word (16 bits) from config space of -* given PCI board. (V2) -* -* SYNOPSIS -* Value = Prm_ReadConfigWord (Board, Offset) -* A0 D0:8 -* -* UWORD Prm_ReadConfigWord (PCIBoard*, UBYTE); -* -* FUNCTION -* This function allows for direct reading of PCI board config space. -* Takes care of data endianness, data are always returned as big -* endian. For example if VendorID is $5678 and DeviceID is $1234 then: -* Prm_ReadConfigWord(board, 0) returns $1234, -* Prm_ReadConfigWord(board, 2) returns $5678, -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). -* Offset - Config space offset in bytes to read from. Offset will be -* rounded down to 2 bytes boundary. -* -* RESULT -* Value - Word read from PCI board. -* -* NOTES -* -* BUGS -* -* SEE ALSO -* Prm_ReadConfigLong(), Prm_ReadConfigByte(), Prm_WriteConfigWord() -* -***************************************************************************** -* -*/ - -UWORD ReadConfigWord( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE offset) + * + * NAME + * Prm_ReadConfigWord -- reads a word (16 bits) from config space of + * given PCI board. (V2) + * + * SYNOPSIS + * Value = Prm_ReadConfigWord (Board, Offset) + * A0 D0:8 + * + * UWORD Prm_ReadConfigWord (PCIBoard*, UBYTE); + * + * FUNCTION + * This function allows for direct reading of PCI board config space. + * Takes care of data endianness, data are always returned as big + * endian. For example if VendorID is $5678 and DeviceID is $1234 then: + * Prm_ReadConfigWord(board, 0) returns $1234, + * Prm_ReadConfigWord(board, 2) returns $5678, + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). + * Offset - Config space offset in bytes to read from. Offset will be + * rounded down to 2 bytes boundary. + * + * RESULT + * Value - Word read from PCI board. + * + * NOTES + * + * BUGS + * + * SEE ALSO + * Prm_ReadConfigLong(), Prm_ReadConfigByte(), Prm_WriteConfigWord() + * + ***************************************************************************** + * + */ + +UWORD ReadConfigWord(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE offset) { - - ULONG cfgw = (ULONG)board->pn_ConfigBase; + ULONG cfgw = (ULONG)board->pn_ConfigBase; struct Library *SysBase = pb->pb_SysBase; - UWORD tmp; - + UWORD tmp; + CacheClearU(); - tmp = swapw( *(UWORD*)(cfgw+(ULONG)offset)); - + tmp = swapw(*(UWORD *)(cfgw + (ULONG)offset)); + D(kprintf("Prm_ReadConfigWord offset 0x%lx result 0x%04lx\n", offset, tmp)); - + return tmp; } /****** prometheus.library/Prm_ReadConfigByte ******************************* -* -* NAME -* Prm_ReadConfigByte -- reads a byte (8 bits) from config space of -* given PCI board. (V2) -* -* SYNOPSIS -* Value = Prm_ReadConfigByte (Board, Offset) -* A0 D0:8 -* -* UBYTE Prm_ReadConfigByte (PCIBoard*, UBYTE); -* -* FUNCTION -* This function allows for direct reading of PCI board config space. -* Takes care of data endianness. Data are always returned as big -* endian. For example if VendorID is $5678 and DeviceID is $1234 then: -* Prm_ReadConfigByte(board, 0) returns $12, -* Prm_ReadConfigByte(board, 1) returns $34, -* Prm_ReadConfigByte(board, 2) returns $56, -* Prm_ReadConfigByte(board, 3) returns $78, -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). -* Offset - Config space offset in bytes to read from. -* -* RESULT -* Value - Value read from PCI board. -* -* NOTES -* -* BUGS -* -* SEE ALSO -* Prm_ReadConfigLong(), Prm_ReadConfigWord(), Prm_WriteConfigByte() -* -***************************************************************************** -* -*/ - -UBYTE ReadConfigByte( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE offset) + * + * NAME + * Prm_ReadConfigByte -- reads a byte (8 bits) from config space of + * given PCI board. (V2) + * + * SYNOPSIS + * Value = Prm_ReadConfigByte (Board, Offset) + * A0 D0:8 + * + * UBYTE Prm_ReadConfigByte (PCIBoard*, UBYTE); + * + * FUNCTION + * This function allows for direct reading of PCI board config space. + * Takes care of data endianness. Data are always returned as big + * endian. For example if VendorID is $5678 and DeviceID is $1234 then: + * Prm_ReadConfigByte(board, 0) returns $12, + * Prm_ReadConfigByte(board, 1) returns $34, + * Prm_ReadConfigByte(board, 2) returns $56, + * Prm_ReadConfigByte(board, 3) returns $78, + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). + * Offset - Config space offset in bytes to read from. + * + * RESULT + * Value - Value read from PCI board. + * + * NOTES + * + * BUGS + * + * SEE ALSO + * Prm_ReadConfigLong(), Prm_ReadConfigWord(), Prm_WriteConfigByte() + * + ***************************************************************************** + * + */ + +UBYTE ReadConfigByte(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE offset) { - volatile UBYTE *cfgb = (UBYTE*)board->pn_ConfigBase; + volatile UBYTE *cfgb = (UBYTE *)board->pn_ConfigBase; struct Library *SysBase = pb->pb_SysBase; - UBYTE tmp; + UBYTE tmp; CacheClearU(); tmp = cfgb[offset]; - + D(kprintf("Prm_ReadConfigByte offset 0x%lx result 0x%02lx\n", offset, tmp)); - + return tmp; } /****** prometheus.library/Prm_WriteConfigLong ****************************** -* -* NAME -* Prm_WriteConfigLong -- writes a longword (32 bits) to config space of -* given PCI board. (V2) -* -* SYNOPSIS -* Prm_WriteConfigLong (Board, Data, Offset) -* A0 D0 D1:8 -* -* VOID Prm_WriteConfigLong (PCIBoard*, ULONG, UBYTE); -* -* FUNCTION -* This function allows for direct writing to PCI board config space. -* Takes care of data endianness, you should specify data in big-endian -* mode. -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). -* Data - Data to be written to PCI board. -* Offset - Config space offset in bytes to write to. Offset will be -* rounded down to nearest 4 byte boundary. -* -* RESULT -* None. -* -* NOTES -* Offsets from 0 to $40 are configured at boot time and must not be -* changed by any application. -* -* BUGS -* -* SEE ALSO -* Prm_WriteConfigWord(), Prm_WriteConfigByte(), Prm_ReadConfigLong() -* -***************************************************************************** -* -*/ - -void WriteConfigLong( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") ULONG data, __reg("d1") UBYTE offset) + * + * NAME + * Prm_WriteConfigLong -- writes a longword (32 bits) to config space of + * given PCI board. (V2) + * + * SYNOPSIS + * Prm_WriteConfigLong (Board, Data, Offset) + * A0 D0 D1:8 + * + * VOID Prm_WriteConfigLong (PCIBoard*, ULONG, UBYTE); + * + * FUNCTION + * This function allows for direct writing to PCI board config space. + * Takes care of data endianness, you should specify data in big-endian + * mode. + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). + * Data - Data to be written to PCI board. + * Offset - Config space offset in bytes to write to. Offset will be + * rounded down to nearest 4 byte boundary. + * + * RESULT + * None. + * + * NOTES + * Offsets from 0 to $40 are configured at boot time and must not be + * changed by any application. + * + * BUGS + * + * SEE ALSO + * Prm_WriteConfigWord(), Prm_WriteConfigByte(), Prm_ReadConfigLong() + * + ***************************************************************************** + * + */ + +void WriteConfigLong(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("d0") ULONG data, + __reg("d1") UBYTE offset) { - ULONG cfgl = (ULONG)board->pn_ConfigBase; + ULONG cfgl = (ULONG)board->pn_ConfigBase; struct Library *SysBase = pb->pb_SysBase; D(kprintf("Prm_WriteConfigLong offset 0x%lx data 0x%08lx\n", offset, data)); - *(ULONG*)(cfgl+(ULONG)offset) = swapl(data); + *(ULONG *)(cfgl + (ULONG)offset) = swapl(data); CacheClearU(); @@ -1832,61 +1929,64 @@ void WriteConfigLong( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoar } /****** prometheus.library/Prm_WriteConfigWord ****************************** -* -* NAME -* Prm_WriteConfigWord -- writes a word (16 bits) to config space of -* given PCI board. (V2) -* -* SYNOPSIS -* Prm_WriteConfigWord (Board, Data, Offset) -* A0 D0:16 D1:8 -* -* VOID Prm_WriteConfigWord (PCIBoard*, UWORD, UBYTE); -* -* FUNCTION -* This function allows for direct writing to PCI board config space. -* Takes care of data endianness, you should specify data in big-endian -* mode. Words will be writen as follows: -* -* offset 0 offset 2 -* -* bits 15-8 bits 7-0 bits 15-8 bits 7-0 -* -* configuration longword -* -* bits 31-24 bits 23-16 bits 15-8 bits 7-0 -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). -* Data - Data to be written to PCI board. -* Offset - Config space offset in bytes to write to. Offset will be -* rounded down to nearest 2 byte boundary. -* -* RESULT -* None. -* -* NOTES -* Offsets from 0 to $40 are configured at boot time and must not be -* changed by any application. -* -* BUGS -* -* SEE ALSO -* Prm_WriteConfigLong(), Prm_WriteConfigByte(), Prm_ReadConfigWord() -* -***************************************************************************** -* -*/ - -void WriteConfigWord(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UWORD data, __reg("d1") UBYTE offset) + * + * NAME + * Prm_WriteConfigWord -- writes a word (16 bits) to config space of + * given PCI board. (V2) + * + * SYNOPSIS + * Prm_WriteConfigWord (Board, Data, Offset) + * A0 D0:16 D1:8 + * + * VOID Prm_WriteConfigWord (PCIBoard*, UWORD, UBYTE); + * + * FUNCTION + * This function allows for direct writing to PCI board config space. + * Takes care of data endianness, you should specify data in big-endian + * mode. Words will be writen as follows: + * + * offset 0 offset 2 + * + * bits 15-8 bits 7-0 bits 15-8 bits 7-0 + * + * configuration longword + * + * bits 31-24 bits 23-16 bits 15-8 bits 7-0 + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). + * Data - Data to be written to PCI board. + * Offset - Config space offset in bytes to write to. Offset will be + * rounded down to nearest 2 byte boundary. + * + * RESULT + * None. + * + * NOTES + * Offsets from 0 to $40 are configured at boot time and must not be + * changed by any application. + * + * BUGS + * + * SEE ALSO + * Prm_WriteConfigLong(), Prm_WriteConfigByte(), Prm_ReadConfigWord() + * + ***************************************************************************** + * + */ + +void WriteConfigWord(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("d0") UWORD data, + __reg("d1") UBYTE offset) { - ULONG cfgw = (ULONG)board->pn_ConfigBase; + ULONG cfgw = (ULONG)board->pn_ConfigBase; struct Library *SysBase = pb->pb_SysBase; D(kprintf("Prm_WriteConfigWord offset 0x%lx data 0x%04lx\n", offset, data)); - *(UWORD*)(cfgw+(ULONG)offset) = swapw(data); + *(UWORD *)(cfgw + (ULONG)offset) = swapw(data); CacheClearU(); @@ -1894,55 +1994,58 @@ void WriteConfigWord(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard } /****** prometheus.library/Prm_WriteConfigByte ************************** -* -* NAME -* Prm_WriteConfigByte -- writes a byte (8 bits) to config space of -* given PCI board. (V2) -* -* SYNOPSIS -* Prm_WriteConfigByte (Board, Data, Offset) -* A0 D0:8 D1:8 -* -* VOID Prm_WriteConfigWord (PCIBoard*, UBYTE, UBYTE); -* -* FUNCTION -* This function allows for direct writing to PCI board config space. -* Takes care of data endianness, you should specify data in big-endian -* mode. Words will be writen as follows: -* -* offset 0 offset 1 offset 2 offset 3 -* -* bits 7-0 bits 7-0 bits 7-0 bits 7-0 -* -* configuration longword -* -* bits 31-24 bits 23-16 bits 15-8 bits 7-0 -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). -* Data - Data to be written to PCI board. -* Offset - Config space offset in bytes to write to. -* -* RESULT -* None. -* -* NOTES -* Offsets from 0 to $40 are configured at boot time and must not be -* changed by any application. -* -* BUGS -* -* SEE ALSO -* Prm_WriteConfigWord(), Prm_WriteConfigLong(), Prm_ReadConfigByte() -* -***************************************************************************** -* -*/ - -void WriteConfigByte( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") UBYTE data, __reg("d1") UBYTE offset) + * + * NAME + * Prm_WriteConfigByte -- writes a byte (8 bits) to config space of + * given PCI board. (V2) + * + * SYNOPSIS + * Prm_WriteConfigByte (Board, Data, Offset) + * A0 D0:8 D1:8 + * + * VOID Prm_WriteConfigWord (PCIBoard*, UBYTE, UBYTE); + * + * FUNCTION + * This function allows for direct writing to PCI board config space. + * Takes care of data endianness, you should specify data in big-endian + * mode. Words will be writen as follows: + * + * offset 0 offset 1 offset 2 offset 3 + * + * bits 7-0 bits 7-0 bits 7-0 bits 7-0 + * + * configuration longword + * + * bits 31-24 bits 23-16 bits 15-8 bits 7-0 + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). + * Data - Data to be written to PCI board. + * Offset - Config space offset in bytes to write to. + * + * RESULT + * None. + * + * NOTES + * Offsets from 0 to $40 are configured at boot time and must not be + * changed by any application. + * + * BUGS + * + * SEE ALSO + * Prm_WriteConfigWord(), Prm_WriteConfigLong(), Prm_ReadConfigByte() + * + ***************************************************************************** + * + */ + +void WriteConfigByte(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("d0") UBYTE data, + __reg("d1") UBYTE offset) { - volatile UBYTE *cfgb = (UBYTE*)board->pn_ConfigBase; + volatile UBYTE *cfgb = (UBYTE *)board->pn_ConfigBase; struct Library *SysBase = pb->pb_SysBase; D(kprintf("Prm_WriteConfigByte offset 0x%lx data 0x%02lx\n", offset, data)); @@ -1955,244 +2058,250 @@ void WriteConfigByte( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoar } /****** prometheus.library/Prm_SetBoardAttrsTagList ************************* -* -* NAME -* Prm_SetBoardAttrsTagList -- Sets a PCI board attributes. (V2) -* Prm_SetBoardAttrsTags -- Varargs stub for Prm_SetBoardAttrsTagList. -* -* SYNOPSIS -* Attrs = Prm_SetBoardAttrsTagList (Board, TagList) -* A0 A1 -* -* ULONG Prm_SetBoardAttrsTagList (PCIBoard*, struct TagItem*); -* -* Attrs = Prm_SetBoardAttrsTags (Board, Tag1, ...) -* -* ULONG Prm_SetBoardAttrsTags (PCIBoard*, Tag, ...); -* -* FUNCTION -* Sets an attribute of a PCI board. Note that not all attributes are -* settable (this is defined in 'libraries/prometheus.h' include file). -* Function looks for every passed tag value in TagList and if found in -* the data base and writing the attribute is permitted new value is -* recorded in the database. -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). It can be NULL, function returns -* immediately in the case, no data is written, function -* returns 0. Don't pass random values here. -* TagList - Function will search in internal database for every ti_Tag -* in the TagList. If tag is found, ti_Data field is used as a -* new value in the database if setting the attibute is -* permitted. Unrecognized tags are skipped. TagList can be -* NULL, function returns immediately at the case, no data are -* changed, function returns FALSE. Following tags are -* recognized and allowed for setting: -* -* PRM_BoardOwner - Contains an address of driver which claimed the -* board. Only device drivers should set it. If this attribute -* was NULL before setting, it will be set succesfully and the -* function returns TRUE. If the attribute was set already to -* non NULL value by someone else and the new value is non -* NULL (setting the attribute to NULL means "unlocking" -* hardware) the function fails, it means old value stays -* unchanged and the function returns FALSE. This way a driver -* can "lock" its hardware. You can always set this attribute -* to an address of your Library or Device structure. If your -* driver is neither library nor device (which is strongly -* discouraged) set the attribute to a Node structure with -* valid ln_Name field. -* -* EXAMPLE -* Try to acquire hardware inside the driver: -* -* if (Prm_SetBoardAttrsTags(board, -* PRM_BoardOwner, (LONG)MyDeviceBase, -* TAG_END)) -* { -* \* proceed with the hardware *\ -* } -* else -* { -* \* somebody already claimed the hadrware *\ -* \* inform the user and quit *\ -* } -* -* RESULT -* Number of attributes succesfully set. In current (V2) library it can -* be 0 or 1 (for PRM_BoardOwner). -* -* NOTES -* -* BUGS -* -* SEE ALSO -* Prm_GetBoardAttrsTagList() -* -***************************************************************************** -* -*/ + * + * NAME + * Prm_SetBoardAttrsTagList -- Sets a PCI board attributes. (V2) + * Prm_SetBoardAttrsTags -- Varargs stub for Prm_SetBoardAttrsTagList. + * + * SYNOPSIS + * Attrs = Prm_SetBoardAttrsTagList (Board, TagList) + * A0 A1 + * + * ULONG Prm_SetBoardAttrsTagList (PCIBoard*, struct TagItem*); + * + * Attrs = Prm_SetBoardAttrsTags (Board, Tag1, ...) + * + * ULONG Prm_SetBoardAttrsTags (PCIBoard*, Tag, ...); + * + * FUNCTION + * Sets an attribute of a PCI board. Note that not all attributes are + * settable (this is defined in 'libraries/prometheus.h' include file). + * Function looks for every passed tag value in TagList and if found in + * the data base and writing the attribute is permitted new value is + * recorded in the database. + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). It can be NULL, function returns + * immediately in the case, no data is written, function + * returns 0. Don't pass random values here. + * TagList - Function will search in internal database for every ti_Tag + * in the TagList. If tag is found, ti_Data field is used as a + * new value in the database if setting the attibute is + * permitted. Unrecognized tags are skipped. TagList can be + * NULL, function returns immediately at the case, no data are + * changed, function returns FALSE. Following tags are + * recognized and allowed for setting: + * + * PRM_BoardOwner - Contains an address of driver which claimed the + * board. Only device drivers should set it. If this attribute + * was NULL before setting, it will be set succesfully and the + * function returns TRUE. If the attribute was set already to + * non NULL value by someone else and the new value is non + * NULL (setting the attribute to NULL means "unlocking" + * hardware) the function fails, it means old value stays + * unchanged and the function returns FALSE. This way a driver + * can "lock" its hardware. You can always set this attribute + * to an address of your Library or Device structure. If your + * driver is neither library nor device (which is strongly + * discouraged) set the attribute to a Node structure with + * valid ln_Name field. + * + * EXAMPLE + * Try to acquire hardware inside the driver: + * + * if (Prm_SetBoardAttrsTags(board, + * PRM_BoardOwner, (LONG)MyDeviceBase, + * TAG_END)) + * { + * \* proceed with the hardware *\ + * } + * else + * { + * \* somebody already claimed the hadrware *\ + * \* inform the user and quit *\ + * } + * + * RESULT + * Number of attributes succesfully set. In current (V2) library it can + * be 0 or 1 (for PRM_BoardOwner). + * + * NOTES + * + * BUGS + * + * SEE ALSO + * Prm_GetBoardAttrsTagList() + * + ***************************************************************************** + * + */ const LONG SettableTags[] = {PRM_BoardOwner, TAG_END}; -LONG SetBoardAttrsTagList ( __reg("a6") struct PrometheusBase *pb, PCIBoard __reg("a0") *board, __reg("a1") struct TagItem *taglist) - { - LONG attr_count = 0; +LONG SetBoardAttrsTagList(__reg("a6") struct PrometheusBase *pb, + PCIBoard __reg("a0") * board, + __reg("a1") struct TagItem * taglist) +{ + LONG attr_count = 0; struct TagItem *item, *dbasetag, *tagptr = taglist; struct Library *UtilityBase = pb->pb_UtilityBase; if (board) - { + { if (taglist) - { + { while (item = NextTagItem(&tagptr)) - { - if (TagInArray(item->ti_Tag, (Tag*)SettableTags)) - { + { + if (TagInArray(item->ti_Tag, (Tag *)SettableTags)) + { if (dbasetag = FindTagItem(PRM_BoardOwner, board->pn_TagList)) - { + { switch (item->ti_Tag) - { - case PRM_BoardOwner: - if ((dbasetag->ti_Data == NULL) || (item->ti_Data == NULL)) - { - dbasetag->ti_Data = item->ti_Data; - attr_count++; - } + { + case PRM_BoardOwner: + if ((dbasetag->ti_Data == NULL) || (item->ti_Data == NULL)) + { + dbasetag->ti_Data = item->ti_Data; + attr_count++; + } break; - } - } - } - } - } - } + } + } + } + } + } + } return attr_count; - } +} /****** prometheus.library/Prm_AddIntServer ********************************* -* -* NAME -* Prm_AddIntServer -- Adds PCI interrupt service routine to the -* system. (V2) -* -* SYNOPSIS -* Success = Prm_AddIntServer (Board, Interrupt) -* A0 A1 -* -* BOOL Prm_AddIntServer (PCIBoard*, struct Interrupt*); -* -* FUNCTION -* Adds an interrupt server to a system interrupt server chain -* responsible for interrupts generated by PCI boards in Prometheus. -* With current hardware all these interrupt servers will be added -* to INTB_PORTS chain, but this will change with G4 board. -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). It can be NULL, function returns -* immediately in the case with FALSE value. Don't pass -* random values here. -* Interrupt- Properly initialized Interrupt structure, exactly like -* for exec AddIntServer() call. Interrupt code have to take -* into account that PCI interrupts are shared, that means -* every interrupt server should check if interrupt was -* generated by 'its' board or another one. If int server -* claims the interrupt it returns 1, zero otherwise. -* -* RESULT -* TRUE if interrupt was successfully installed, FALSE otherwise. -* -* NOTES -* Current exec.library requires that interrupt server claiming an -* interrupt exits with zero CPU flag cleared. Server should set -* the flag if this interrupt was not handled by it. You have to ensure -* CPU flags are set properly at server routine exit. It can be done -* using __interrupt attribute for server routine, which cause setting -* processor flags according to return value: -* -* __interrupt IntCode(userdata reg(a1)) -* { -* if (check_int()) -* { -* \* handle the interrupt *\ -* return (1); -* } -* else return (0); -* } -* -* If your compiler does not support __interrupt attribute you have to -* use assembler stub: -* -* _IntStub: LEA _IntCode,a0 -* JSR (a0) -* TST.L d0 ;sets CPU flags according to return value -* RTS -* -* and put IntStub() into is_Code field of struct Interrupt. -* -* BUGS -* -* SEE ALSO -* Prm_RemIntServer(), exec.library/AddIntServer() -* -***************************************************************************** -* -*/ - -BOOL AddIntServer_( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("a1") struct Interrupt *intr) - { + * + * NAME + * Prm_AddIntServer -- Adds PCI interrupt service routine to the + * system. (V2) + * + * SYNOPSIS + * Success = Prm_AddIntServer (Board, Interrupt) + * A0 A1 + * + * BOOL Prm_AddIntServer (PCIBoard*, struct Interrupt*); + * + * FUNCTION + * Adds an interrupt server to a system interrupt server chain + * responsible for interrupts generated by PCI boards in Prometheus. + * With current hardware all these interrupt servers will be added + * to INTB_PORTS chain, but this will change with G4 board. + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). It can be NULL, function returns + * immediately in the case with FALSE value. Don't pass + * random values here. + * Interrupt- Properly initialized Interrupt structure, exactly like + * for exec AddIntServer() call. Interrupt code have to take + * into account that PCI interrupts are shared, that means + * every interrupt server should check if interrupt was + * generated by 'its' board or another one. If int server + * claims the interrupt it returns 1, zero otherwise. + * + * RESULT + * TRUE if interrupt was successfully installed, FALSE otherwise. + * + * NOTES + * Current exec.library requires that interrupt server claiming an + * interrupt exits with zero CPU flag cleared. Server should set + * the flag if this interrupt was not handled by it. You have to ensure + * CPU flags are set properly at server routine exit. It can be done + * using __interrupt attribute for server routine, which cause setting + * processor flags according to return value: + * + * __interrupt IntCode(userdata reg(a1)) + * { + * if (check_int()) + * { + * \* handle the interrupt *\ + * return (1); + * } + * else return (0); + * } + * + * If your compiler does not support __interrupt attribute you have to + * use assembler stub: + * + * _IntStub: LEA _IntCode,a0 + * JSR (a0) + * TST.L d0 ;sets CPU flags according to return value + * RTS + * + * and put IntStub() into is_Code field of struct Interrupt. + * + * BUGS + * + * SEE ALSO + * Prm_RemIntServer(), exec.library/AddIntServer() + * + ***************************************************************************** + * + */ + +BOOL AddIntServer_(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("a1") struct Interrupt * intr) +{ struct Library *UtilityBase = pb->pb_UtilityBase; - struct Library *SysBase = pb->pb_SysBase; + struct Library *SysBase = pb->pb_SysBase; D(kprintf("Prm_AddIntServer\n")); if (!board) return FALSE; AddIntServer(INTB_PORTS, intr); - + return TRUE; - } +} /****** prometheus.library/Prm_RemIntServer ********************************* -* -* NAME -* Prm_RemIntServer -- Removes PCI interrupt service routine from the -* system. (V2) -* -* SYNOPSIS -* Prm_RemIntServer (Board, Interrupt) -* A0 A1 -* -* VOID Prm_RemIntServer (PCIBoard*, struct Interrupt*); -* -* FUNCTION -* Removes a PCI interrupt service routine previously added by -* Prm_AddIntServer() call. -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). It can be NULL, function returns -* immediately in the case. Don't pass random values here. -* Interrupt - Interrupt structure given as a parameter for -* Prm_AddIntServer(). -* -* RESULT -* None. -* -* NOTES -* -* BUGS -* -* SEE ALSO -* Prm_AddIntServer() -* -***************************************************************************** -* -*/ - -void RemIntServer_(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("a1") struct Interrupt *intr) - { + * + * NAME + * Prm_RemIntServer -- Removes PCI interrupt service routine from the + * system. (V2) + * + * SYNOPSIS + * Prm_RemIntServer (Board, Interrupt) + * A0 A1 + * + * VOID Prm_RemIntServer (PCIBoard*, struct Interrupt*); + * + * FUNCTION + * Removes a PCI interrupt service routine previously added by + * Prm_AddIntServer() call. + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). It can be NULL, function returns + * immediately in the case. Don't pass random values here. + * Interrupt - Interrupt structure given as a parameter for + * Prm_AddIntServer(). + * + * RESULT + * None. + * + * NOTES + * + * BUGS + * + * SEE ALSO + * Prm_AddIntServer() + * + ***************************************************************************** + * + */ + +void RemIntServer_(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("a1") struct Interrupt * intr) +{ struct Library *SysBase = pb->pb_SysBase; D(kprintf("Prm_RemIntServer\n")); @@ -2200,323 +2309,338 @@ void RemIntServer_(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard * if (!board) return; if (intr) RemIntServer(INTB_PORTS, intr); return; - } +} /****** prometheus.library/Prm_AllocDMABuffer ******************************* -* -* NAME -* Prm_AllocDMABuffer -- Allocates memory buffer DMA-able on PCI bus. -* (V2) -* -* SYNOPSIS -* Buffer = Prm_AllocDMABuffer (Size) -* D0 -* -* APTR Prm_AllocDMABuffer (ULONG); -* -* FUNCTION -* Allocates a memory buffer accessible for PCI boards using DMA in -* busmaster mode to fetch and store data. -* -* INPUTS -* Size - Size of requested memory block in bytes. It will be -* rounded up to nearest longword boundary. Returned block -* is always longword aligned. Zero size is an no-op with -* NULL pointer returned. -* RESULT -* Buffer - Address of memory block allocated or NULL if there is no -* more free DMA-able memory. Note well - this is logical -* address as seen by CPU. To obtain physical PCI bus address -* (used e.g. when programming board's DMA controllers) use -* Prm_GetPhysicalAddress() function. -* -* NOTES -* Function must not be called from an interrupt. -* -* BUGS -* -* SEE ALSO -* Prm_FreeDMABuffer(), Prm_GetPhysicalAddress() -* -***************************************************************************** -* -*/ + * + * NAME + * Prm_AllocDMABuffer -- Allocates memory buffer DMA-able on PCI bus. + * (V2) + * + * SYNOPSIS + * Buffer = Prm_AllocDMABuffer (Size) + * D0 + * + * APTR Prm_AllocDMABuffer (ULONG); + * + * FUNCTION + * Allocates a memory buffer accessible for PCI boards using DMA in + * busmaster mode to fetch and store data. + * + * INPUTS + * Size - Size of requested memory block in bytes. It will be + * rounded up to nearest longword boundary. Returned block + * is always longword aligned. Zero size is an no-op with + * NULL pointer returned. + * RESULT + * Buffer - Address of memory block allocated or NULL if there is no + * more free DMA-able memory. Note well - this is logical + * address as seen by CPU. To obtain physical PCI bus address + * (used e.g. when programming board's DMA controllers) use + * Prm_GetPhysicalAddress() function. + * + * NOTES + * Function must not be called from an interrupt. + * + * BUGS + * + * SEE ALSO + * Prm_FreeDMABuffer(), Prm_GetPhysicalAddress() + * + ***************************************************************************** + * + */ APTR AllocDMABuffer(__reg("a6") struct PrometheusBase *pb, __reg("d0") ULONG size) - { +{ struct Library *SysBase = pb->pb_SysBase; struct Library *CardBase; - APTR mem; + APTR mem; D(kprintf("Prm_AllocDMABuffer size 0x%08lx\n", size)); if (!pb->pb_DMASuppBase) { - pb->pb_DMASuppBase = OpenLibrary(CARD_NAME, 7); + pb->pb_DMASuppBase = OpenLibrary(CARD_NAME, 7); } if (CardBase = pb->pb_DMASuppBase) { - mem = (APTR)AllocDMAMem(size); - D(kprintf("Prm_AllocDMABuffer ptr 0x%08lx\n", mem)); - return mem; + mem = (APTR)AllocDMAMem(size); + D(kprintf("Prm_AllocDMABuffer ptr 0x%08lx\n", mem)); + return mem; } return NULL; - } +} /****** prometheus.library/Prm_FreeDMABuffer ******************************** -* -* NAME -* Prm_FreeDMABuffer -- Frees DMA-able memory buffer. (V2) -* -* SYNOPSIS -* Prm_FreeDMABuffer (Buffer, Size) -* A0 D0 -* -* VOID Prm_FreeDMABuffer (APTR, ULONG); -* -* FUNCTION -* Frees a memory buffer allocated by Prm_AllocDMABuffer() call. -* -* INPUTS -* Buffer - Address of allocated memory block as returned by -* Prm_AllocDMABuffer(). NULL address is a no-op. -* Size - Size of allocated block. Must match size given for -* Prm_AllocDMABuffer(). Zero size is a no-op. -* RESULT -* None. -* -* NOTES -* Function must not be called from an interrupt. -* -* BUGS -* -* SEE ALSO -* Prm_AllocDMABuffer(), Prm_GetPhysicalAddress() -* -***************************************************************************** -* -*/ - -void FreeDMABuffer( __reg("a6") struct PrometheusBase *pb, __reg("a0") APTR buffer, __reg("d0") ULONG size) - { + * + * NAME + * Prm_FreeDMABuffer -- Frees DMA-able memory buffer. (V2) + * + * SYNOPSIS + * Prm_FreeDMABuffer (Buffer, Size) + * A0 D0 + * + * VOID Prm_FreeDMABuffer (APTR, ULONG); + * + * FUNCTION + * Frees a memory buffer allocated by Prm_AllocDMABuffer() call. + * + * INPUTS + * Buffer - Address of allocated memory block as returned by + * Prm_AllocDMABuffer(). NULL address is a no-op. + * Size - Size of allocated block. Must match size given for + * Prm_AllocDMABuffer(). Zero size is a no-op. + * RESULT + * None. + * + * NOTES + * Function must not be called from an interrupt. + * + * BUGS + * + * SEE ALSO + * Prm_AllocDMABuffer(), Prm_GetPhysicalAddress() + * + ***************************************************************************** + * + */ + +void FreeDMABuffer(__reg("a6") struct PrometheusBase *pb, __reg("a0") APTR buffer, __reg("d0") ULONG size) +{ struct Library *SysBase = pb->pb_SysBase; struct Library *CardBase; D(kprintf("Prm_FreeDMABuffer 0x%08lx 0x%08lx\n", buffer, size)); { - if (!pb->pb_DMASuppBase) - { - pb->pb_DMASuppBase = OpenLibrary(CARD_NAME, 7); - } + if (!pb->pb_DMASuppBase) + { + pb->pb_DMASuppBase = OpenLibrary(CARD_NAME, 7); + } - if (CardBase = pb->pb_DMASuppBase) - { - FreeDMAMem(buffer, size); - } + if (CardBase = pb->pb_DMASuppBase) + { + FreeDMAMem(buffer, size); + } } return; - } +} /****** prometheus.library/Prm_GetPhysicalAddress *************************** -* -* NAME -* Prm_GetPhysicalAddress -- Converts logical address in Prometheus -* address space to physical address on PCI bus. (V2) -* -* SYNOPSIS -* PhyAddr = Prm_GetPhysicalAddress (Address) -* D0 -* -* APTR Prm_GetPhysicalAddress (APTR); -* -* FUNCTION -* Calculates physical PCI bus address of any address in Prometheus -* address space. This physical address is especially useful for -* programming DMA buffer address in PCI boards' DMA controllers. -* -* INPUTS -* Address - Logical address as seen by CPU. Address is checked if it -* belongs to Prometheus PCI Memory space. -* RESULT -* PhyAddr - The same address as seen by PCI boards. If given parameter -* is not a valid logical PCI address in Memory space -* function returns NULL. -* -* NOTES -* -* BUGS -* -* SEE ALSO -* Prm_AllocDMABuffer() -* -***************************************************************************** -* -*/ - -APTR GetPhysicalAddress( __reg("a6") struct PrometheusBase *pb, __reg("d0") APTR addr) + * + * NAME + * Prm_GetPhysicalAddress -- Converts logical address in Prometheus + * address space to physical address on PCI bus. (V2) + * + * SYNOPSIS + * PhyAddr = Prm_GetPhysicalAddress (Address) + * D0 + * + * APTR Prm_GetPhysicalAddress (APTR); + * + * FUNCTION + * Calculates physical PCI bus address of any address in Prometheus + * address space. This physical address is especially useful for + * programming DMA buffer address in PCI boards' DMA controllers. + * + * INPUTS + * Address - Logical address as seen by CPU. Address is checked if it + * belongs to Prometheus PCI Memory space. + * RESULT + * PhyAddr - The same address as seen by PCI boards. If given parameter + * is not a valid logical PCI address in Memory space + * function returns NULL. + * + * NOTES + * + * BUGS + * + * SEE ALSO + * Prm_AllocDMABuffer() + * + ***************************************************************************** + * + */ + +APTR GetPhysicalAddress(__reg("a6") struct PrometheusBase *pb, __reg("d0") APTR addr) { D(kprintf("Prm_GetPhysicalAddress 0x%08lx\n", addr)); - - if(pb->pb_FireStorm == TRUE) { - if (((ULONG)addr < (ULONG)pb->pb_BaseAddr) || - ((ULONG)addr >= (ULONG)pb->pb_BaseAddr + FS_PCI_ADDR_CONFIG0)) return NULL; - else return (APTR)((ULONG)addr & 0x1FFFFFFF); - } + + if (pb->pb_FireStorm == TRUE) + { + if (((ULONG)addr < (ULONG)pb->pb_BaseAddr) || ((ULONG)addr >= (ULONG)pb->pb_BaseAddr + FS_PCI_ADDR_CONFIG0)) + return NULL; else - { - if (((ULONG)addr < (ULONG)pb->pb_BaseAddr + 0x00100000) || - ((ULONG)addr > (ULONG)pb->pb_BaseAddr + 0x1FFFFFFF)) return NULL; - else return (APTR)((ULONG)addr & 0x1FFFFFFF); - } + return (APTR)((ULONG)addr & 0x1FFFFFFF); + } + else + { + if (((ULONG)addr < (ULONG)pb->pb_BaseAddr + 0x00100000) || ((ULONG)addr > (ULONG)pb->pb_BaseAddr + 0x1FFFFFFF)) + return NULL; + else + return (APTR)((ULONG)addr & 0x1FFFFFFF); + } } /****** prometheus.library/Prm_GetVirtualAddress *************************** -* -* NAME -* Prm_GetPhysicalAddress -- Converts physical address on PCI bus -* to logical address in Prometheus address space (V3) -* -* SYNOPSIS -* PhyAddr = Prm_GetVirtualAddress (Address) -* D0 -* -* APTR Prm_GetVirtualAddress (APTR); -* -* FUNCTION -* Calculates physical address of any logical address in Prometheus -* PCI bus address space. -* -* INPUTS -* Address - physical address as seen by PCI bus. Address is checked if it -* belongs to Prometheus PCI Memory space. -* RESULT -* PhyAddr - The same address as seen by the CPU. If given parameter -* is not a valid physikal PCI address in Memory space -* function returns NULL. -* -* NOTES -* -* BUGS -* -* SEE ALSO -* Prm_AllocDMABuffer() -* -***************************************************************************** -* -*/ - -APTR GetVirtualAddress( __reg("a6") struct PrometheusBase *pb, __reg("d0") APTR addr) + * + * NAME + * Prm_GetPhysicalAddress -- Converts physical address on PCI bus + * to logical address in Prometheus address space (V3) + * + * SYNOPSIS + * PhyAddr = Prm_GetVirtualAddress (Address) + * D0 + * + * APTR Prm_GetVirtualAddress (APTR); + * + * FUNCTION + * Calculates physical address of any logical address in Prometheus + * PCI bus address space. + * + * INPUTS + * Address - physical address as seen by PCI bus. Address is checked if it + * belongs to Prometheus PCI Memory space. + * RESULT + * PhyAddr - The same address as seen by the CPU. If given parameter + * is not a valid physikal PCI address in Memory space + * function returns NULL. + * + * NOTES + * + * BUGS + * + * SEE ALSO + * Prm_AllocDMABuffer() + * + ***************************************************************************** + * + */ + +APTR GetVirtualAddress(__reg("a6") struct PrometheusBase *pb, __reg("d0") APTR addr) { D(kprintf("Prm_GetVirtualAddress 0x%08lx\n", addr)); - if(pb->pb_FireStorm == TRUE) { - if ( (ULONG)addr >= FS_PCI_ADDR_CONFIG0 ) return NULL; - else return (APTR)((ULONG)addr + (ULONG)pb->pb_BaseAddr); - } else { - if ( ((ULONG)addr < 0x00100000) || ((ULONG)addr > 0x1FFFFFFF) ) return NULL; - else return (APTR)((ULONG)addr + (ULONG)pb->pb_BaseAddr); + if (pb->pb_FireStorm == TRUE) + { + if ((ULONG)addr >= FS_PCI_ADDR_CONFIG0) + return NULL; + else + return (APTR)((ULONG)addr + (ULONG)pb->pb_BaseAddr); + } + else + { + if (((ULONG)addr < 0x00100000) || ((ULONG)addr > 0x1FFFFFFF)) + return NULL; + else + return (APTR)((ULONG)addr + (ULONG)pb->pb_BaseAddr); } } /****** prometheus.library/Prm_AllocPCIAddressSpace ****************************** -* -* NAME -* Prm_AllocPCIAddressSpace -- Allocates an address range in PCI memory space -* for the indicated PCI BAR. (V4) -* -* SYNOPSIS -* PciAddr = Prm_AllocPCIAddressSpace (Board, Size, Bar) -* A0 D0 D1 -* -* APTR Prm_AllocPCIAddressSpace (PCIBoard*, ULONG, ULONG); -* -* FUNCTION -* This function allows for pci address space to be reserved for certain devices -* especially PPC cards. -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). -* Data - Size of the PCI address space you want to reserve -* Bar - The P{I BAR for which this reservation is intended -* -* RESULT -* PciAddr - Logical address as seen by the CPU in Prometheus PCI bus -* address space. -* -* NOTES -* This only reserves the address in the PCI address space. The user needs -* to write the address to the intended configuration register himself. -* -* BUGS -* -* SEE ALSO -* Prm_FreePCIAddressSpace() -* -***************************************************************************** -* -*/ - -APTR AllocPCIAddressSpace( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") ULONG size, __reg("d1") ULONG bar) + * + * NAME + * Prm_AllocPCIAddressSpace -- Allocates an address range in PCI memory space + * for the indicated PCI BAR. (V4) + * + * SYNOPSIS + * PciAddr = Prm_AllocPCIAddressSpace (Board, Size, Bar) + * A0 D0 D1 + * + * APTR Prm_AllocPCIAddressSpace (PCIBoard*, ULONG, ULONG); + * + * FUNCTION + * This function allows for pci address space to be reserved for certain devices + * especially PPC cards. + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). + * Data - Size of the PCI address space you want to reserve + * Bar - The P{I BAR for which this reservation is intended + * + * RESULT + * PciAddr - Logical address as seen by the CPU in Prometheus PCI bus + * address space. + * + * NOTES + * This only reserves the address in the PCI address space. The user needs + * to write the address to the intended configuration register himself. + * + * BUGS + * + * SEE ALSO + * Prm_FreePCIAddressSpace() + * + ***************************************************************************** + * + */ + +APTR AllocPCIAddressSpace(__reg("a6") struct PrometheusBase *pb, + __reg("a0") PCIBoard * board, + __reg("d0") ULONG size, + __reg("d1") ULONG bar) { - ULONG memsizeTag, memaddrTag, memLower; - struct Library *UtilityBase; - struct TagItem* memsizetagPtr; - struct TagItem* memaddrtagPtr; - struct TagItem* pcibustagPtr; - struct PCIBus* curpciBus; - struct PCIBus* nxtpciBus; - struct SpaceReq* cursrq; - struct SpaceReq* nxtsrq; + ULONG memsizeTag, memaddrTag, memLower; + struct Library * UtilityBase; + struct TagItem * memsizetagPtr; + struct TagItem * memaddrtagPtr; + struct TagItem * pcibustagPtr; + struct PCIBus * curpciBus; + struct PCIBus * nxtpciBus; + struct SpaceReq *cursrq; + struct SpaceReq *nxtsrq; UtilityBase = pb->pb_UtilityBase; D(kprintf("Prm_AllocPCIAddressSpace bar %ld size 0x%08lx\n", bar, size)); - memLower = 0; + memLower = 0; memsizeTag = PRM_MemorySize0 + bar; memaddrTag = PRM_MemoryAddr0 + bar; memsizetagPtr = FindTagItem(memsizeTag, board->pn_TagList); memaddrtagPtr = FindTagItem(memaddrTag, board->pn_TagList); - pcibustagPtr = FindTagItem(PRM_BusNumber, board->pn_TagList); + pcibustagPtr = FindTagItem(PRM_BusNumber, board->pn_TagList); if ((!(memsizetagPtr->ti_Data)) && (!(memaddrtagPtr->ti_Data))) { - memLower = (ULONG)pb->pb_BaseAddr; - curpciBus = (struct PCIBus*)pb->pb_Busses.lh_Head; + memLower = (ULONG)pb->pb_BaseAddr; + curpciBus = (struct PCIBus *)pb->pb_Busses.lh_Head; - while (nxtpciBus = (struct PCIBus*)curpciBus->br_Node.ln_Succ) + while (nxtpciBus = (struct PCIBus *)curpciBus->br_Node.ln_Succ) { if (curpciBus->br_BusNr == pcibustagPtr->ti_Data) break; curpciBus = nxtpciBus; } - cursrq = (struct SpaceReq*)curpciBus->br_CardRequests.lh_Head; + cursrq = (struct SpaceReq *)curpciBus->br_CardRequests.lh_Head; - while (nxtsrq = (struct SpaceReq*)cursrq->sr_Node.ln_Succ) + while (nxtsrq = (struct SpaceReq *)cursrq->sr_Node.ln_Succ) { if (cursrq->sr_Type == BLOCK_INOUT) { cursrq = nxtsrq; } else if (((memLower <= cursrq->sr_Tag->ti_Data) && (cursrq->sr_Tag->ti_Data < (memLower + size))) || - ((cursrq->sr_Tag->ti_Data <= memLower) && (memLower < (cursrq->sr_Tag->ti_Data + cursrq->sr_Size)))) + ((cursrq->sr_Tag->ti_Data <= memLower) && + (memLower < (cursrq->sr_Tag->ti_Data + cursrq->sr_Size)))) { memLower = memLower + cursrq->sr_Size; if (memLower & ~(-size)) { memLower = ((memLower + size) & (-size)); } - cursrq = (struct SpaceReq*)curpciBus->br_CardRequests.lh_Head; + cursrq = (struct SpaceReq *)curpciBus->br_CardRequests.lh_Head; } else { cursrq = nxtsrq; } - if ((memLower > ((ULONG)pb->pb_BaseAddr) + FS_PCI_ADDR_CONFIG0) || (memLower + size > ((ULONG)pb->pb_BaseAddr) + 0x20000000)) + if ((memLower > ((ULONG)pb->pb_BaseAddr) + FS_PCI_ADDR_CONFIG0) || + (memLower + size > ((ULONG)pb->pb_BaseAddr) + 0x20000000)) { memLower = 0; break; @@ -2533,56 +2657,56 @@ APTR AllocPCIAddressSpace( __reg("a6") struct PrometheusBase *pb, __reg("a0") PC } /****** prometheus.library/Prm_FreePCIAddressSpace ****************************** -* -* NAME -* Prm_FreePCIAddressSpace -- Frees an address range in PCI memory space -* for the indicated PCI BAR previously reserved -* by Prm_AllocPCIAddressSpace(). (V4) -* -* SYNOPSIS -* Prm_FreePCIAddressSpace (Board, Bar) -* A0 D0 -* -* VOID Prm_FreePCIAddressSpace (PCIBoard*, ULONG); -* -* FUNCTION -* This function frees up reserved PCI address space previously allocated -* by AllocPCIAddressSpace(). PCI address space reserved during initialization -* of the prometheus.library cannot be freed. -* -* INPUTS -* Board - "Blackbox" structure pointer returned by -* Prm_FindBoardTagList(). -* Bar - The P{I BAR for which this reservation is intended -* -* RESULT -* None. -* -* NOTES -* -* BUGS -* -* SEE ALSO -* Prm_AllocPCIAddressSpace() -* -***************************************************************************** -* -*/ - -void FreePCIAddressSpace( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") ULONG bar) + * + * NAME + * Prm_FreePCIAddressSpace -- Frees an address range in PCI memory space + * for the indicated PCI BAR previously reserved + * by Prm_AllocPCIAddressSpace(). (V4) + * + * SYNOPSIS + * Prm_FreePCIAddressSpace (Board, Bar) + * A0 D0 + * + * VOID Prm_FreePCIAddressSpace (PCIBoard*, ULONG); + * + * FUNCTION + * This function frees up reserved PCI address space previously allocated + * by AllocPCIAddressSpace(). PCI address space reserved during initialization + * of the prometheus.library cannot be freed. + * + * INPUTS + * Board - "Blackbox" structure pointer returned by + * Prm_FindBoardTagList(). + * Bar - The P{I BAR for which this reservation is intended + * + * RESULT + * None. + * + * NOTES + * + * BUGS + * + * SEE ALSO + * Prm_AllocPCIAddressSpace() + * + ***************************************************************************** + * + */ + +void FreePCIAddressSpace(__reg("a6") struct PrometheusBase *pb, __reg("a0") PCIBoard *board, __reg("d0") ULONG bar) { - ULONG memsizeTag, memaddrTag; - struct Library *UtilityBase; - struct Library *SysBase; - struct TagItem* memsizetagPtr; - struct TagItem* memaddrtagPtr; - struct TagItem* pcibustagPtr; - struct PCIBus* curpciBus; - struct PCIBus* nxtpciBus; - struct SpaceReq* cursrq; - struct SpaceReq* nxtsrq; - - SysBase = pb->pb_SysBase; + ULONG memsizeTag, memaddrTag; + struct Library * UtilityBase; + struct Library * SysBase; + struct TagItem * memsizetagPtr; + struct TagItem * memaddrtagPtr; + struct TagItem * pcibustagPtr; + struct PCIBus * curpciBus; + struct PCIBus * nxtpciBus; + struct SpaceReq *cursrq; + struct SpaceReq *nxtsrq; + + SysBase = pb->pb_SysBase; UtilityBase = pb->pb_UtilityBase; D(kprintf("Prm_FreePCIAddressSpace bar %ld\n", bar)); @@ -2592,24 +2716,24 @@ void FreePCIAddressSpace( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCI memsizetagPtr = FindTagItem(memsizeTag, board->pn_TagList); memaddrtagPtr = FindTagItem(memaddrTag, board->pn_TagList); - pcibustagPtr = FindTagItem(PRM_BusNumber, board->pn_TagList); + pcibustagPtr = FindTagItem(PRM_BusNumber, board->pn_TagList); if ((memsizetagPtr->ti_Data) && (memaddrtagPtr->ti_Data)) { - curpciBus = (struct PCIBus*)pb->pb_Busses.lh_Head; + curpciBus = (struct PCIBus *)pb->pb_Busses.lh_Head; - while (nxtpciBus = (struct PCIBus*)curpciBus->br_Node.ln_Succ) + while (nxtpciBus = (struct PCIBus *)curpciBus->br_Node.ln_Succ) { if (curpciBus->br_BusNr == pcibustagPtr->ti_Data) break; curpciBus = nxtpciBus; } - cursrq = (struct SpaceReq*)curpciBus->br_CardRequests.lh_Head; + cursrq = (struct SpaceReq *)curpciBus->br_CardRequests.lh_Head; - while (nxtsrq = (struct SpaceReq*)cursrq->sr_Node.ln_Succ) + while (nxtsrq = (struct SpaceReq *)cursrq->sr_Node.ln_Succ) { if ((cursrq->sr_Type == BLOCK_USRMEM) && (cursrq->sr_Tag->ti_Data == memaddrtagPtr->ti_Data)) { - Remove((struct Node*)cursrq); + Remove((struct Node *)cursrq); FreePooled(pb->pb_MemPool, (APTR)cursrq, sizeof(struct SpaceReq)); memsizetagPtr->ti_Data = 0; memaddrtagPtr->ti_Data = NULL; @@ -2621,5 +2745,4 @@ void FreePCIAddressSpace( __reg("a6") struct PrometheusBase *pb, __reg("a0") PCI return; } - #endif diff --git a/PromLib/endian.h b/PromLib/endian.h index 895e0d1..7eeb3ab 100644 --- a/PromLib/endian.h +++ b/PromLib/endian.h @@ -2,33 +2,31 @@ /* swap word */ - #ifdef __VBCC__ - -ULONG swapl(__reg("d0")ULONG) = "\trol.w\t#8,d0\n\tswap\td0\n\trol.w\t#8,d0\n"; -ULONG swapw(__reg("d0")ULONG) = "\trol.w\t#8,d0\n"; +ULONG swapl(__reg("d0") ULONG) = "\trol.w\t#8,d0\n\tswap\td0\n\trol.w\t#8,d0\n"; +ULONG swapw(__reg("d0") ULONG) = "\trol.w\t#8,d0\n"; #else - -#define swapw(arg)\ - ({short __arg = (arg);\ - asm ("ROL.W #8,%0"\ - :"=d" (__arg)\ - :"0" (__arg)\ - :"cc");\ - __arg;}) + #define swapw(arg) \ + ({ \ + short __arg = (arg); \ + asm("ROL.W #8,%0" : "=d"(__arg) : "0"(__arg) : "cc"); \ + __arg; \ + }) /* swap long */ -#define swapl(arg)\ - ({long __arg = (arg);\ - asm ("ROL.W #8,%0;\ + #define swapl(arg) \ + ({ \ + long __arg = (arg); \ + asm("ROL.W #8,%0;\ SWAP %0;\ - ROL.W #8,%0"\ - :"=d" (__arg)\ - :"0" (__arg)\ - :"cc");\ - __arg;}) + ROL.W #8,%0" \ + : "=d"(__arg) \ + : "0"(__arg) \ + : "cc"); \ + __arg; \ + }) #endif diff --git a/PromLib/include/.clang-format b/PromLib/include/.clang-format new file mode 100644 index 0000000..57af94e --- /dev/null +++ b/PromLib/include/.clang-format @@ -0,0 +1,4 @@ +{ + "DisableFormat": "true", + "SortIncludes": "false" +} diff --git a/PromLib/prometheus.h b/PromLib/prometheus.h index 4bfa309..c95d611 100644 --- a/PromLib/prometheus.h +++ b/PromLib/prometheus.h @@ -3,13 +3,13 @@ /* $VER: prometheus.h 2.6 (01.03.2010) © e3b. */ -#define PROMETHEUSNAME "prometheus.library" -#define PROMETHEUSVERSION 2 -#define PROMETHEUSMINVERSION 6 +#define PROMETHEUSNAME "prometheus.library" +#define PROMETHEUSVERSION 2 +#define PROMETHEUSMINVERSION 6 #define PROMETHEUSVERSIONSTRING "\0$VER: prometheus.library 2.6 (01.03.2010)\r\n" #ifndef PCIBOARD_TYPEDEF -#define PCIBOARD_TYPEDEF + #define PCIBOARD_TYPEDEF typedef VOID PCIBoard; #endif /* PCIBOARD_TYPEDEF */ @@ -18,45 +18,43 @@ typedef VOID PCIBoard; /* 'S' - the attribute is settable. */ /* 'G' - the attribute is gettable. */ -#define PRM_Vendor 0x6EDA0000 /* [.G] */ -#define PRM_Device 0x6EDA0001 /* [.G] */ -#define PRM_Revision 0x6EDA0002 /* [.G] */ -#define PRM_Class 0x6EDA0003 /* [.G] */ -#define PRM_SubClass 0x6EDA0004 /* [.G] */ +#define PRM_Vendor 0x6EDA0000 /* [.G] */ +#define PRM_Device 0x6EDA0001 /* [.G] */ +#define PRM_Revision 0x6EDA0002 /* [.G] */ +#define PRM_Class 0x6EDA0003 /* [.G] */ +#define PRM_SubClass 0x6EDA0004 /* [.G] */ /* You can depend on fact that the last nybble of PRM_MemoryAddrX and */ /* PRM_MemorySizeX is equal to X. It is guarranted in future releases. */ -#define PRM_MemoryAddr0 0x6EDA0010 /* [.G] */ -#define PRM_MemoryAddr1 0x6EDA0011 /* [.G] */ -#define PRM_MemoryAddr2 0x6EDA0012 /* [.G] */ -#define PRM_MemoryAddr3 0x6EDA0013 /* [.G] */ -#define PRM_MemoryAddr4 0x6EDA0014 /* [.G] */ -#define PRM_MemoryAddr5 0x6EDA0015 /* [.G] */ -#define PRM_ROM_Address 0x6EDA0016 /* [.G] */ - -#define PRM_MemorySize0 0x6EDA0020 /* [.G] */ -#define PRM_MemorySize1 0x6EDA0021 /* [.G] */ -#define PRM_MemorySize2 0x6EDA0022 /* [.G] */ -#define PRM_MemorySize3 0x6EDA0023 /* [.G] */ -#define PRM_MemorySize4 0x6EDA0024 /* [.G] */ -#define PRM_MemorySize5 0x6EDA0025 /* [.G] */ -#define PRM_ROM_Size 0x6EDA0026 /* [.G] */ +#define PRM_MemoryAddr0 0x6EDA0010 /* [.G] */ +#define PRM_MemoryAddr1 0x6EDA0011 /* [.G] */ +#define PRM_MemoryAddr2 0x6EDA0012 /* [.G] */ +#define PRM_MemoryAddr3 0x6EDA0013 /* [.G] */ +#define PRM_MemoryAddr4 0x6EDA0014 /* [.G] */ +#define PRM_MemoryAddr5 0x6EDA0015 /* [.G] */ +#define PRM_ROM_Address 0x6EDA0016 /* [.G] */ + +#define PRM_MemorySize0 0x6EDA0020 /* [.G] */ +#define PRM_MemorySize1 0x6EDA0021 /* [.G] */ +#define PRM_MemorySize2 0x6EDA0022 /* [.G] */ +#define PRM_MemorySize3 0x6EDA0023 /* [.G] */ +#define PRM_MemorySize4 0x6EDA0024 /* [.G] */ +#define PRM_MemorySize5 0x6EDA0025 /* [.G] */ +#define PRM_ROM_Size 0x6EDA0026 /* [.G] */ /* Tags added in V2 of library */ -#define PRM_BoardOwner 0x6EDA0005 /* [SG] */ -#define PRM_SlotNumber 0x6EDA0006 /* [.G] */ -#define PRM_FunctionNumber 0x6EDA0007 /* [.G] */ -#define PRM_BusNumber 0x6EDA0008 /* [.G] */ +#define PRM_BoardOwner 0x6EDA0005 /* [SG] */ +#define PRM_SlotNumber 0x6EDA0006 /* [.G] */ +#define PRM_FunctionNumber 0x6EDA0007 /* [.G] */ +#define PRM_BusNumber 0x6EDA0008 /* [.G] */ /* unknown tags */ -#define PRM_HeaderType 0x6EDA0009 -#define PRM_SubsysVendor 0x6EDA000A -#define PRM_SubsysID 0x6EDA000B -#define PRM_Interface 0x6EDA000C +#define PRM_HeaderType 0x6EDA0009 +#define PRM_SubsysVendor 0x6EDA000A +#define PRM_SubsysID 0x6EDA000B +#define PRM_Interface 0x6EDA000C #endif /* LIBRARIES_PROMETHEUS_H */ - - diff --git a/PrometheusCard/boardinfo.h b/PrometheusCard/boardinfo.h old mode 100755 new mode 100644 index 28ba335..d8187bf --- a/PrometheusCard/boardinfo.h +++ b/PrometheusCard/boardinfo.h @@ -1,86 +1,85 @@ #ifndef boardinfo_H #define boardinfo_H -#ifndef LIBRARIES_PICASSO96_H -#include "picasso96.h" +#ifndef LIBRARIES_PICASSO96_H + #include "picasso96.h" #endif -#ifndef EXEC_INTERRUPTS_H -#include +#ifndef EXEC_INTERRUPTS_H + #include #endif -#ifndef EXEC_LIBRARIES_H -#include +#ifndef EXEC_LIBRARIES_H + #include #endif -#ifndef EXEC_SEMAPHORES_H -#include +#ifndef EXEC_SEMAPHORES_H + #include #endif -#ifndef GRAPHICS_GFX_H -#include +#ifndef GRAPHICS_GFX_H + #include #endif -#ifndef GRAPHICS_VIEW_H -#include +#ifndef GRAPHICS_VIEW_H + #include #endif #ifndef DEVICES_TIMER_H -#include + #include #endif #ifndef settings_H -#include "settings.h" + #include "settings.h" #endif /* registerized parameters */ #ifdef __STORMGCC__ - #define ASM -#else - #ifdef __GNUC__ - #define ASM - #define __REGD0(x) x __asm("d0") - #define __REGD1(x) x __asm("d1") - #define __REGD2(x) x __asm("d2") - #define __REGD3(x) x __asm("d3") - #define __REGD4(x) x __asm("d4") - #define __REGD5(x) x __asm("d5") - #define __REGD6(x) x __asm("d6") - #define __REGD7(x) x __asm("d7") - #define __REGA0(x) x __asm("a0") - #define __REGA1(x) x __asm("a1") - #define __REGA2(x) x __asm("a2") - #define __REGA3(x) x __asm("a3") - #define __REGA4(x) x __asm("a4") - #define __REGA5(x) x __asm("a5") - #define __REGA6(x) x __asm("a6") - #define __REGA7(x) x __asm("a7") - #else #define ASM - #define __REGD0(x) __reg("d0") x - #define __REGD1(x) __reg("d1") x - #define __REGD2(x) __reg("d2") x - #define __REGD3(x) __reg("d3") x - #define __REGD4(x) __reg("d4") x - #define __REGD5(x) __reg("d5") x - #define __REGD6(x) __reg("d6") x - #define __REGD7(x) __reg("d7") x - #define __REGA0(x) __reg("a0") x - #define __REGA1(x) __reg("a1") x - #define __REGA2(x) __reg("a2") x - #define __REGA3(x) __reg("a3") x - #define __REGA4(x) __reg("a4") x - #define __REGA5(x) __reg("a5") x - #define __REGA6(x) __reg("a6") x - #define __REGA7(x) __reg("a7") x - #endif +#else + #ifdef __GNUC__ + #define ASM + #define __REGD0(x) x __asm("d0") + #define __REGD1(x) x __asm("d1") + #define __REGD2(x) x __asm("d2") + #define __REGD3(x) x __asm("d3") + #define __REGD4(x) x __asm("d4") + #define __REGD5(x) x __asm("d5") + #define __REGD6(x) x __asm("d6") + #define __REGD7(x) x __asm("d7") + #define __REGA0(x) x __asm("a0") + #define __REGA1(x) x __asm("a1") + #define __REGA2(x) x __asm("a2") + #define __REGA3(x) x __asm("a3") + #define __REGA4(x) x __asm("a4") + #define __REGA5(x) x __asm("a5") + #define __REGA6(x) x __asm("a6") + #define __REGA7(x) x __asm("a7") + #else + #define ASM + #define __REGD0(x) __reg("d0") x + #define __REGD1(x) __reg("d1") x + #define __REGD2(x) __reg("d2") x + #define __REGD3(x) __reg("d3") x + #define __REGD4(x) __reg("d4") x + #define __REGD5(x) __reg("d5") x + #define __REGD6(x) __reg("d6") x + #define __REGD7(x) __reg("d7") x + #define __REGA0(x) __reg("a0") x + #define __REGA1(x) __reg("a1") x + #define __REGA2(x) __reg("a2") x + #define __REGA3(x) __reg("a3") x + #define __REGA4(x) __reg("a4") x + #define __REGA5(x) __reg("a5") x + #define __REGA6(x) __reg("a6") x + #define __REGA7(x) __reg("a7") x + #endif #endif - /************************************************************************/ -#define MAXSPRITEWIDTH 32 +#define MAXSPRITEWIDTH 32 #define MAXSPRITEHEIGHT 48 /************************************************************************/ @@ -91,524 +90,765 @@ /************************************************************************/ /* Types for BoardType Identification */ -typedef enum { - BT_NoBoard, - BT_oMniBus, - BT_Graffity, - BT_CyberVision, - BT_Domino, - BT_Merlin, - BT_PicassoII, - BT_Piccolo, - BT_RetinaBLT, - BT_Spectrum, - BT_PicassoIV, - BT_PiccoloSD64, - BT_A2410, - BT_Pixel64, - BT_uaegfx, // 14 - BT_CVision3D, - BT_Altais, - BT_Prometheus, - BT_Mediator, - BT_powerfb, - BT_powerpci, - BT_CVisionPPC, - BT_GREX, - BT_Prototype7, - BT_MaxBoardTypes +typedef enum +{ + BT_NoBoard, + BT_oMniBus, + BT_Graffity, + BT_CyberVision, + BT_Domino, + BT_Merlin, + BT_PicassoII, + BT_Piccolo, + BT_RetinaBLT, + BT_Spectrum, + BT_PicassoIV, + BT_PiccoloSD64, + BT_A2410, + BT_Pixel64, + BT_uaegfx, // 14 + BT_CVision3D, + BT_Altais, + BT_Prometheus, + BT_Mediator, + BT_powerfb, + BT_powerpci, + BT_CVisionPPC, + BT_GREX, + BT_Prototype7, + BT_MaxBoardTypes } BTYPE; /************************************************************************/ /* Types for PaletteChipType Identification */ -typedef enum { - PCT_Unknown, - PCT_S11483, // Sierra S11483: HiColor 15 bit, oMniBus, Domino - PCT_S15025, // Sierra S15025: TrueColor 32 bit, oMniBus - PCT_CirrusGD542x, // Cirrus GD542x internal: TrueColor 24 bit - PCT_Domino, // is in fact a Sierra S11483 - PCT_BT482, // BrookTree BT482: TrueColor 32 bit, Merlin - PCT_Music, // Music MU9C4910: TrueColor 24 bit, oMniBus - PCT_ICS5300, // ICS 5300: ...., Retina BLT Z3 - PCT_CirrusGD5446, // Cirrus GD5446 internal: TrueColor 24 bit - PCT_CirrusGD5434, // Cirrus GD5434 internal: TrueColor 32 bit - PCT_S3Trio64, // S3 Trio64 internal: TrueColor 32 bit - PCT_A2410_xxx, // A2410 DAC, *type unknown* - PCT_S3ViRGE, // S3 ViRGE internal: TrueColor 32 bit - PCT_3dfxVoodoo, // 3dfx Voodoo internal - PCT_TIPermedia2, // TexasInstruments TVP4020 Permedia2 internal - PCT_MaxPaletteChipTypes +typedef enum +{ + PCT_Unknown, + PCT_S11483, // Sierra S11483: HiColor 15 bit, oMniBus, Domino + PCT_S15025, // Sierra S15025: TrueColor 32 bit, oMniBus + PCT_CirrusGD542x, // Cirrus GD542x internal: TrueColor 24 bit + PCT_Domino, // is in fact a Sierra S11483 + PCT_BT482, // BrookTree BT482: TrueColor 32 bit, Merlin + PCT_Music, // Music MU9C4910: TrueColor 24 bit, oMniBus + PCT_ICS5300, // ICS 5300: ...., Retina BLT Z3 + PCT_CirrusGD5446, // Cirrus GD5446 internal: TrueColor 24 bit + PCT_CirrusGD5434, // Cirrus GD5434 internal: TrueColor 32 bit + PCT_S3Trio64, // S3 Trio64 internal: TrueColor 32 bit + PCT_A2410_xxx, // A2410 DAC, *type unknown* + PCT_S3ViRGE, // S3 ViRGE internal: TrueColor 32 bit + PCT_3dfxVoodoo, // 3dfx Voodoo internal + PCT_TIPermedia2, // TexasInstruments TVP4020 Permedia2 internal + PCT_MaxPaletteChipTypes } PCTYPE; /************************************************************************/ /* Types for GraphicsControllerType Identification */ -typedef enum { - GCT_Unknown, - GCT_ET4000, - GCT_ETW32, - GCT_CirrusGD542x, - GCT_NCR77C32BLT, - GCT_CirrusGD5446, - GCT_CirrusGD5434, - GCT_S3Trio64, - GCT_TI34010, - GCT_S3ViRGE, - GCT_3dfxVoodoo, - GCT_TIPermedia2, - GCT_MaxGraphicsControllerTypes +typedef enum +{ + GCT_Unknown, + GCT_ET4000, + GCT_ETW32, + GCT_CirrusGD542x, + GCT_NCR77C32BLT, + GCT_CirrusGD5446, + GCT_CirrusGD5434, + GCT_S3Trio64, + GCT_TI34010, + GCT_S3ViRGE, + GCT_3dfxVoodoo, + GCT_TIPermedia2, + GCT_MaxGraphicsControllerTypes } GCTYPE; /************************************************************************/ -#define RGBFF_PLANAR RGBFF_NONE -#define RGBFF_CHUNKY RGBFF_CLUT +#define RGBFF_PLANAR RGBFF_NONE +#define RGBFF_CHUNKY RGBFF_CLUT -#define RGBFB_PLANAR RGBFB_NONE -#define RGBFB_CHUNKY RGBFB_CLUT +#define RGBFB_PLANAR RGBFB_NONE +#define RGBFB_CHUNKY RGBFB_CLUT /************************************************************************/ -enum{ - DPMS_ON, /* Full operation */ - DPMS_STANDBY, /* Optional state of minimal power reduction */ - DPMS_SUSPEND, /* Significant reduction of power consumption */ - DPMS_OFF /* Lowest level of power consumption */ +enum +{ + DPMS_ON, /* Full operation */ + DPMS_STANDBY, /* Optional state of minimal power reduction */ + DPMS_SUSPEND, /* Significant reduction of power consumption */ + DPMS_OFF /* Lowest level of power consumption */ }; /************************************************************************/ -struct CLUTEntry { - UBYTE Red; - UBYTE Green; - UBYTE Blue; +struct CLUTEntry +{ + UBYTE Red; + UBYTE Green; + UBYTE Blue; }; -struct ColorIndexMapping { - ULONG ColorMask; - ULONG Colors[256]; +struct ColorIndexMapping +{ + ULONG ColorMask; + ULONG Colors[256]; }; /************************************************************************/ -struct GfxMemChunk { - struct MinNode Node; - char *Ptr; - ULONG Size; - BOOL Used; +struct GfxMemChunk +{ + struct MinNode Node; + char * Ptr; + ULONG Size; + BOOL Used; }; /* if we should ever need more space... */ -struct GMNExtensions { - ULONG Dummy; +struct GMNExtensions +{ + ULONG Dummy; }; -struct GfxMemoryNode { - struct MinNode Node; - BYTE *Ptr; - ULONG Size; - struct BitMapExtra *bme; - BOOL Used; - WORD Priority; - struct GMNExtensions *Extra; +struct GfxMemoryNode +{ + struct MinNode Node; + BYTE * Ptr; + ULONG Size; + struct BitMapExtra * bme; + BOOL Used; + WORD Priority; + struct GMNExtensions *Extra; }; /************************************************************************/ -struct Template { - APTR Memory; - WORD BytesPerRow; - UBYTE XOffset; // 0 <= XOffset <= 15 - UBYTE DrawMode; - ULONG FgPen; - ULONG BgPen; +struct Template +{ + APTR Memory; + WORD BytesPerRow; + UBYTE XOffset; // 0 <= XOffset <= 15 + UBYTE DrawMode; + ULONG FgPen; + ULONG BgPen; }; /************************************************************************/ -struct Pattern { - APTR Memory; - UWORD XOffset, YOffset; - ULONG FgPen, BgPen; - UBYTE Size; // Width: 16, Height: (1<AllocBitMap() */ -#define ABMA_Friend (TAG_USER+0) -#define ABMA_Depth (TAG_USER+1) -#define ABMA_RGBFormat (TAG_USER+2) -#define ABMA_Clear (TAG_USER+3) -#define ABMA_Displayable (TAG_USER+4) -#define ABMA_Visible (TAG_USER+5) -#define ABMA_NoMemory (TAG_USER+6) -#define ABMA_NoSprite (TAG_USER+7) -#define ABMA_Colors (TAG_USER+8) -#define ABMA_Colors32 (TAG_USER+9) -#define ABMA_ModeWidth (TAG_USER+10) -#define ABMA_ModeHeight (TAG_USER+11) -#define ABMA_RenderFunc (TAG_USER+12) -#define ABMA_SaveFunc (TAG_USER+13) -#define ABMA_UserData (TAG_USER+14) -#define ABMA_Alignment (TAG_USER+15) -#define ABMA_ConstantBytesPerRow (TAG_USER+16) -#define ABMA_UserPrivate (TAG_USER+17) -#define ABMA_ConstantByteSwapping (TAG_USER+18) +#define ABMA_Friend (TAG_USER + 0) +#define ABMA_Depth (TAG_USER + 1) +#define ABMA_RGBFormat (TAG_USER + 2) +#define ABMA_Clear (TAG_USER + 3) +#define ABMA_Displayable (TAG_USER + 4) +#define ABMA_Visible (TAG_USER + 5) +#define ABMA_NoMemory (TAG_USER + 6) +#define ABMA_NoSprite (TAG_USER + 7) +#define ABMA_Colors (TAG_USER + 8) +#define ABMA_Colors32 (TAG_USER + 9) +#define ABMA_ModeWidth (TAG_USER + 10) +#define ABMA_ModeHeight (TAG_USER + 11) +#define ABMA_RenderFunc (TAG_USER + 12) +#define ABMA_SaveFunc (TAG_USER + 13) +#define ABMA_UserData (TAG_USER + 14) +#define ABMA_Alignment (TAG_USER + 15) +#define ABMA_ConstantBytesPerRow (TAG_USER + 16) +#define ABMA_UserPrivate (TAG_USER + 17) +#define ABMA_ConstantByteSwapping (TAG_USER + 18) /************************************************************************/ /* Tags for bi->GetBitMapAttr() */ -#define GBMA_MEMORY (TAG_USER+0) -#define GBMA_BASEMEMORY (TAG_USER+1) -#define GBMA_BYTESPERROW (TAG_USER+2) -#define GBMA_BYTESPERPIXEL (TAG_USER+3) -#define GBMA_BITSPERPIXEL (TAG_USER+4) -#define GBMA_RGBFORMAT (TAG_USER+6) -#define GBMA_WIDTH (TAG_USER+7) -#define GBMA_HEIGHT (TAG_USER+8) -#define GBMA_DEPTH (TAG_USER+9) +#define GBMA_MEMORY (TAG_USER + 0) +#define GBMA_BASEMEMORY (TAG_USER + 1) +#define GBMA_BYTESPERROW (TAG_USER + 2) +#define GBMA_BYTESPERPIXEL (TAG_USER + 3) +#define GBMA_BITSPERPIXEL (TAG_USER + 4) +#define GBMA_RGBFORMAT (TAG_USER + 6) +#define GBMA_WIDTH (TAG_USER + 7) +#define GBMA_HEIGHT (TAG_USER + 8) +#define GBMA_DEPTH (TAG_USER + 9) /************************************************************************/ -struct BoardInfo{ - UBYTE *RegisterBase, *MemoryBase, *MemoryIOBase; - ULONG MemorySize; - char *BoardName,VBIName[32]; - struct CardBase *CardBase; - struct ChipBase *ChipBase; - struct ExecBase *ExecBase; - struct Library *UtilBase; - struct Interrupt HardInterrupt; - struct Interrupt SoftInterrupt; - struct SignalSemaphore BoardLock; - struct MinList ResolutionsList; - BTYPE BoardType; - PCTYPE PaletteChipType; - GCTYPE GraphicsControllerType; - UWORD MoniSwitch; - UWORD BitsPerCannon; - ULONG Flags; - UWORD SoftSpriteFlags; - UWORD ChipFlags; // private, chip specific, not touched by RTG - ULONG CardFlags; // private, card specific, not touched by RTG - - UWORD BoardNum; // set by rtg.library - UWORD RGBFormats; - - UWORD MaxHorValue[MAXMODES]; - UWORD MaxVerValue[MAXMODES]; - UWORD MaxHorResolution[MAXMODES]; - UWORD MaxVerResolution[MAXMODES]; - ULONG MaxMemorySize, MaxChunkSize; - - ULONG MemoryClock; - - ULONG PixelClockCount[MAXMODES]; - - APTR ASM (*AllocCardMem)(__REGA0(struct BoardInfo *bi), __REGD0(ULONG size), __REGD1(BOOL force), __REGD2(BOOL system)); - BOOL ASM (*FreeCardMem)(__REGA0(struct BoardInfo *bi), __REGA1(APTR membase)); - - BOOL ASM (*SetSwitch)(__REGA0(struct BoardInfo *), __REGD0(BOOL)); - - void ASM (*SetColorArray)(__REGA0(struct BoardInfo *), __REGD0(UWORD), __REGD1(UWORD)); - - void ASM (*SetDAC)(__REGA0(struct BoardInfo *), __REGD7(RGBFTYPE)); - void ASM (*SetGC)(__REGA0(struct BoardInfo *), __REGA1(struct ModeInfo *), __REGD0(BOOL)); - void ASM (*SetPanning)(__REGA0(struct BoardInfo *), __REGA1(UBYTE *), __REGD0(UWORD), __REGD1(WORD), __REGD2(WORD), __REGD7(RGBFTYPE)); - UWORD ASM (*CalculateBytesPerRow)(__REGA0(struct BoardInfo *), __REGD0(UWORD), __REGD7(RGBFTYPE)); - APTR ASM (*CalculateMemory)(__REGA0(struct BoardInfo *), __REGA1(APTR), __REGD7(RGBFTYPE)); - ULONG ASM (*GetCompatibleFormats)(__REGA0(struct BoardInfo *), __REGD7(RGBFTYPE)); - BOOL ASM (*SetDisplay)(__REGA0(struct BoardInfo *), __REGD0(BOOL)); - - LONG ASM (*ResolvePixelClock)(__REGA0(struct BoardInfo *), __REGA1(struct ModeInfo *), __REGD0(ULONG), __REGD7(RGBFTYPE)); - ULONG ASM (*GetPixelClock)(__REGA0(struct BoardInfo *bi), __REGA1(struct ModeInfo *), __REGD0(ULONG), __REGD7(RGBFTYPE)); - void ASM (*SetClock)(__REGA0(struct BoardInfo *)); - - void ASM (*SetMemoryMode)(__REGA0(struct BoardInfo *), __REGD7(RGBFTYPE)); - void ASM (*SetWriteMask)(__REGA0(struct BoardInfo *), __REGD0(UBYTE)); - void ASM (*SetClearMask)(__REGA0(struct BoardInfo *), __REGD0(UBYTE)); - void ASM (*SetReadPlane)(__REGA0(struct BoardInfo *), __REGD0(UBYTE)); - - void ASM (*WaitVerticalSync)(__REGA0(struct BoardInfo *), __REGD0(BOOL)); - BOOL ASM (*SetInterrupt)(__REGA0(struct BoardInfo *), __REGD0(BOOL)); - - void ASM (*WaitBlitter)(__REGA0(struct BoardInfo *)); - - void ASM (*ScrollPlanar)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGD0(UWORD), __REGD1(UWORD), __REGD2(UWORD), __REGD3(UWORD), __REGD4(UWORD), __REGD5(UWORD), __REGD6(UBYTE)); - void ASM (*ScrollPlanarDefault)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGD0(UWORD), __REGD1(UWORD), __REGD2(UWORD), __REGD3(UWORD), __REGD4(UWORD), __REGD5(UWORD), __REGD6(UBYTE)); - void ASM (*UpdatePlanar)(__REGA0(struct BoardInfo *), __REGA1(struct BitMap *), __REGA2(struct RenderInfo *), __REGD0(SHORT), __REGD1(SHORT), __REGD2(SHORT), __REGD3(SHORT), __REGD4(UBYTE)); - void ASM (*UpdatePlanarDefault)(__REGA0(struct BoardInfo *), __REGA1(struct BitMap *), __REGA2(struct RenderInfo *), __REGD0(SHORT), __REGD1(SHORT), __REGD2(SHORT), __REGD3(SHORT), __REGD4(UBYTE)); - void ASM (*BlitPlanar2Chunky)(__REGA0(struct BoardInfo *), __REGA1(struct BitMap *), __REGA2(struct RenderInfo *), __REGD0(SHORT), __REGD1(SHORT), __REGD2(SHORT), __REGD3(SHORT), __REGD4(SHORT), __REGD5(SHORT), __REGD6(UBYTE), __REGD7(UBYTE)); - void ASM (*BlitPlanar2ChunkyDefault)(__REGA0(struct BoardInfo *), __REGA1(struct BitMap *), __REGA2(struct RenderInfo *), __REGD0(SHORT), __REGD1(SHORT), __REGD2(SHORT), __REGD3(SHORT), __REGD4(SHORT), __REGD5(SHORT), __REGD6(UBYTE), __REGD7(UBYTE)); - - void ASM (*FillRect)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(ULONG), __REGD5(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*FillRectDefault)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(ULONG), __REGD5(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*InvertRect)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*InvertRectDefault)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*BlitRect)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(WORD), __REGD5(WORD), __REGD6(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*BlitRectDefault)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(WORD), __REGD5(WORD), __REGD6(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*BlitTemplate)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGA2(struct Template *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*BlitTemplateDefault)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGA2(struct Template *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*BlitPattern)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGA2(struct Pattern *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*BlitPatternDefault)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGA2(struct Pattern *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*DrawLine)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGA2(struct Line *), __REGD0(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*DrawLineDefault)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGA2(struct Line *), __REGD0(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*BlitRectNoMaskComplete)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGA2(struct RenderInfo *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(WORD), __REGD5(WORD), __REGD6(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*BlitRectNoMaskCompleteDefault)(__REGA0(struct BoardInfo *), __REGA1(struct RenderInfo *), __REGA2(struct RenderInfo *), __REGD0(WORD), __REGD1(WORD), __REGD2(WORD), __REGD3(WORD), __REGD4(WORD), __REGD5(WORD), __REGD6(UBYTE), __REGD7(RGBFTYPE)); - void ASM (*BlitPlanar2Direct)(__REGA0(struct BoardInfo *), __REGA1(struct BitMap *), __REGA2(struct RenderInfo *), __REGA3(struct ColorIndexMapping *), __REGD0(SHORT), __REGD1(SHORT), __REGD2(SHORT), __REGD3(SHORT), __REGD4(SHORT), __REGD5(SHORT), __REGD6(UBYTE), __REGD7(UBYTE)); - void ASM (*BlitPlanar2DirectDefault)(__REGA0(struct BoardInfo *), __REGA1(struct BitMap *), __REGA2(struct RenderInfo *), __REGA3(struct ColorIndexMapping *), __REGD0(SHORT), __REGD1(SHORT), __REGD2(SHORT), __REGD3(SHORT), __REGD4(SHORT), __REGD5(SHORT), __REGD6(UBYTE), __REGD7(UBYTE)); - void ASM (*Reserved0)(__REGA0(struct BoardInfo *)); - void ASM (*Reserved0Default)(__REGA0(struct BoardInfo *)); - void ASM (*Reserved1)(__REGA0(struct BoardInfo *)); - void ASM (*Reserved1Default)(__REGA0(struct BoardInfo *)); - void ASM (*Reserved2)(__REGA0(struct BoardInfo *)); - void ASM (*Reserved2Default)(__REGA0(struct BoardInfo *)); - void ASM (*Reserved3)(__REGA0(struct BoardInfo *)); - void ASM (*Reserved3Default)(__REGA0(struct BoardInfo *)); - - int ASM (*WriteYUVRect)(__REGA0(struct BoardInfo *), __REGA1(APTR), __REGD0(SHORT), __REGD1(SHORT), __REGA2(struct RenderInfo *), __REGD2(SHORT), __REGD3(SHORT), __REGD4(SHORT), __REGD5(SHORT), __REGA3(struct TagItem *)); - int ASM (*WriteYUVRectDefault)(__REGA0(struct BoardInfo *), __REGA1(APTR), __REGD0(SHORT), __REGD1(SHORT), __REGA2(struct RenderInfo *), __REGD2(SHORT), __REGD3(SHORT), __REGD4(SHORT), __REGD5(SHORT), __REGA3(struct TagItem *)); - - BOOL ASM (*GetVSyncState)(__REGA0(struct BoardInfo *), __REGD0(BOOL)); - ULONG ASM (*GetVBeamPos)(__REGA0(struct BoardInfo *)); - void ASM (*SetDPMSLevel)(__REGA0(struct BoardInfo *), __REGD0(ULONG)); - void ASM (*ResetChip)(__REGA0(struct BoardInfo *)); - ULONG ASM (*GetFeatureAttrs)(__REGA0(struct BoardInfo *), __REGA1(APTR), __REGD0(ULONG), __REGA2(struct TagItem *)); - - struct BitMap * ASM (*AllocBitMap)(__REGA0(struct BoardInfo *), __REGD0(ULONG), __REGD1(ULONG), __REGA1(struct TagItem *)); - BOOL ASM (*FreeBitMap)(__REGA0(struct BoardInfo *), __REGA1(struct BitMap *), __REGA2(struct TagItem *)); - ULONG ASM (*GetBitMapAttr)(__REGA0(struct BoardInfo *), __REGA1(struct BitMap *), __REGD0(ULONG)); - - BOOL ASM (*SetSprite)(__REGA0(struct BoardInfo *), __REGD0(BOOL), __REGD7(RGBFTYPE)); - void ASM (*SetSpritePosition)(__REGA0(struct BoardInfo *), __REGD0(WORD), __REGD1(WORD), __REGD7(RGBFTYPE)); - void ASM (*SetSpriteImage)(__REGA0(struct BoardInfo *), __REGD7(RGBFTYPE)); - void ASM (*SetSpriteColor)(__REGA0(struct BoardInfo *), __REGD0(UBYTE), __REGD1(UBYTE), __REGD2(UBYTE), __REGD3(UBYTE), __REGD7(RGBFTYPE)); - - APTR ASM (*CreateFeature)(__REGA0(struct BoardInfo *), __REGD0(ULONG), __REGA1(struct TagItem *)); - ULONG ASM (*SetFeatureAttrs)(__REGA0(struct BoardInfo *), __REGA1(APTR), __REGD0(ULONG), __REGA2(struct TagItem *)); - BOOL ASM (*DeleteFeature)(__REGA0(struct BoardInfo *), __REGA1(APTR), __REGD0(ULONG)); - struct MinList SpecialFeatures; - - struct ModeInfo *ModeInfo; /* Chip Settings Stuff */ - RGBFTYPE RGBFormat; - WORD XOffset; - WORD YOffset; - UBYTE Depth; - UBYTE ClearMask; - BOOL Border; - ULONG Mask; - struct CLUTEntry CLUT[256]; - - struct ViewPort *ViewPort; /* ViewPort Stuff */ - struct BitMap *VisibleBitMap; - struct BitMapExtra *BitMapExtra; - struct MinList BitMapList; - struct MinList MemList; - - WORD MouseX; - WORD MouseY; /* Sprite Stuff */ - UBYTE MouseWidth; - UBYTE MouseHeight; - UBYTE MouseXOffset; - UBYTE MouseYOffset; - UWORD *MouseImage; - UBYTE MousePens[4]; - struct Rectangle MouseRect; - UBYTE *MouseChunky; - UWORD *MouseRendered; - UBYTE *MouseSaveBuffer; - - ULONG ChipData[16]; /* for chip driver needs */ - ULONG CardData[16]; /* for card driver needs */ - - APTR MemorySpaceBase; /* the base address of the board memory address space */ - ULONG MemorySpaceSize; /* size of that area */ - - APTR DoubleBufferList; /* chain of dbinfos being notified on vblanks */ - - struct timeval SyncTime; /* system time when screen was set up, used for pseudo vblanks */ - ULONG SyncPeriod; /* length of one frame in micros */ - struct MsgPort SoftVBlankPort; /* MsgPort for software emulation of board interrupt */ - - struct MinList WaitQ; /* for WaitTOF and WaitBOVP, all elements will be signaled on VBlank */ - - LONG EssentialFormats; /* these RGBFormats will be used when user does not choose "all" - will be filled by InitBoard() */ - UBYTE *MouseImageBuffer; /* rendered to the destination color format */ +struct BoardInfo +{ + UBYTE * RegisterBase, *MemoryBase, *MemoryIOBase; + ULONG MemorySize; + char * BoardName, VBIName[32]; + struct CardBase * CardBase; + struct ChipBase * ChipBase; + struct ExecBase * ExecBase; + struct Library * UtilBase; + struct Interrupt HardInterrupt; + struct Interrupt SoftInterrupt; + struct SignalSemaphore BoardLock; + struct MinList ResolutionsList; + BTYPE BoardType; + PCTYPE PaletteChipType; + GCTYPE GraphicsControllerType; + UWORD MoniSwitch; + UWORD BitsPerCannon; + ULONG Flags; + UWORD SoftSpriteFlags; + UWORD ChipFlags; // private, chip specific, not touched by RTG + ULONG CardFlags; // private, card specific, not touched by RTG + + UWORD BoardNum; // set by rtg.library + UWORD RGBFormats; + + UWORD MaxHorValue[MAXMODES]; + UWORD MaxVerValue[MAXMODES]; + UWORD MaxHorResolution[MAXMODES]; + UWORD MaxVerResolution[MAXMODES]; + ULONG MaxMemorySize, MaxChunkSize; + + ULONG MemoryClock; + + ULONG PixelClockCount[MAXMODES]; + + APTR ASM (*AllocCardMem)(__REGA0(struct BoardInfo *bi), + __REGD0(ULONG size), + __REGD1(BOOL force), + __REGD2(BOOL system)); + BOOL ASM (*FreeCardMem)(__REGA0(struct BoardInfo *bi), __REGA1(APTR membase)); + + BOOL ASM (*SetSwitch)(__REGA0(struct BoardInfo *), __REGD0(BOOL)); + + void ASM (*SetColorArray)(__REGA0(struct BoardInfo *), __REGD0(UWORD), __REGD1(UWORD)); + + void ASM (*SetDAC)(__REGA0(struct BoardInfo *), __REGD7(RGBFTYPE)); + void ASM (*SetGC)(__REGA0(struct BoardInfo *), __REGA1(struct ModeInfo *), __REGD0(BOOL)); + void ASM (*SetPanning)(__REGA0(struct BoardInfo *), + __REGA1(UBYTE *), + __REGD0(UWORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD7(RGBFTYPE)); + UWORD ASM (*CalculateBytesPerRow)(__REGA0(struct BoardInfo *), __REGD0(UWORD), __REGD7(RGBFTYPE)); + APTR ASM (*CalculateMemory)(__REGA0(struct BoardInfo *), __REGA1(APTR), __REGD7(RGBFTYPE)); + ULONG ASM (*GetCompatibleFormats)(__REGA0(struct BoardInfo *), __REGD7(RGBFTYPE)); + BOOL ASM (*SetDisplay)(__REGA0(struct BoardInfo *), __REGD0(BOOL)); + + LONG ASM (*ResolvePixelClock)(__REGA0(struct BoardInfo *), + __REGA1(struct ModeInfo *), + __REGD0(ULONG), + __REGD7(RGBFTYPE)); + ULONG ASM (*GetPixelClock)(__REGA0(struct BoardInfo *bi), + __REGA1(struct ModeInfo *), + __REGD0(ULONG), + __REGD7(RGBFTYPE)); + void ASM (*SetClock)(__REGA0(struct BoardInfo *)); + + void ASM (*SetMemoryMode)(__REGA0(struct BoardInfo *), __REGD7(RGBFTYPE)); + void ASM (*SetWriteMask)(__REGA0(struct BoardInfo *), __REGD0(UBYTE)); + void ASM (*SetClearMask)(__REGA0(struct BoardInfo *), __REGD0(UBYTE)); + void ASM (*SetReadPlane)(__REGA0(struct BoardInfo *), __REGD0(UBYTE)); + + void ASM (*WaitVerticalSync)(__REGA0(struct BoardInfo *), __REGD0(BOOL)); + BOOL ASM (*SetInterrupt)(__REGA0(struct BoardInfo *), __REGD0(BOOL)); + + void ASM (*WaitBlitter)(__REGA0(struct BoardInfo *)); + + void ASM (*ScrollPlanar)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGD0(UWORD), + __REGD1(UWORD), + __REGD2(UWORD), + __REGD3(UWORD), + __REGD4(UWORD), + __REGD5(UWORD), + __REGD6(UBYTE)); + void ASM (*ScrollPlanarDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGD0(UWORD), + __REGD1(UWORD), + __REGD2(UWORD), + __REGD3(UWORD), + __REGD4(UWORD), + __REGD5(UWORD), + __REGD6(UBYTE)); + void ASM (*UpdatePlanar)(__REGA0(struct BoardInfo *), + __REGA1(struct BitMap *), + __REGA2(struct RenderInfo *), + __REGD0(SHORT), + __REGD1(SHORT), + __REGD2(SHORT), + __REGD3(SHORT), + __REGD4(UBYTE)); + void ASM (*UpdatePlanarDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct BitMap *), + __REGA2(struct RenderInfo *), + __REGD0(SHORT), + __REGD1(SHORT), + __REGD2(SHORT), + __REGD3(SHORT), + __REGD4(UBYTE)); + void ASM (*BlitPlanar2Chunky)(__REGA0(struct BoardInfo *), + __REGA1(struct BitMap *), + __REGA2(struct RenderInfo *), + __REGD0(SHORT), + __REGD1(SHORT), + __REGD2(SHORT), + __REGD3(SHORT), + __REGD4(SHORT), + __REGD5(SHORT), + __REGD6(UBYTE), + __REGD7(UBYTE)); + void ASM (*BlitPlanar2ChunkyDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct BitMap *), + __REGA2(struct RenderInfo *), + __REGD0(SHORT), + __REGD1(SHORT), + __REGD2(SHORT), + __REGD3(SHORT), + __REGD4(SHORT), + __REGD5(SHORT), + __REGD6(UBYTE), + __REGD7(UBYTE)); + + void ASM (*FillRect)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(ULONG), + __REGD5(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*FillRectDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(ULONG), + __REGD5(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*InvertRect)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*InvertRectDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*BlitRect)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(WORD), + __REGD5(WORD), + __REGD6(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*BlitRectDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(WORD), + __REGD5(WORD), + __REGD6(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*BlitTemplate)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGA2(struct Template *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*BlitTemplateDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGA2(struct Template *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*BlitPattern)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGA2(struct Pattern *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*BlitPatternDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGA2(struct Pattern *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*DrawLine)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGA2(struct Line *), + __REGD0(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*DrawLineDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGA2(struct Line *), + __REGD0(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*BlitRectNoMaskComplete)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGA2(struct RenderInfo *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(WORD), + __REGD5(WORD), + __REGD6(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*BlitRectNoMaskCompleteDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct RenderInfo *), + __REGA2(struct RenderInfo *), + __REGD0(WORD), + __REGD1(WORD), + __REGD2(WORD), + __REGD3(WORD), + __REGD4(WORD), + __REGD5(WORD), + __REGD6(UBYTE), + __REGD7(RGBFTYPE)); + void ASM (*BlitPlanar2Direct)(__REGA0(struct BoardInfo *), + __REGA1(struct BitMap *), + __REGA2(struct RenderInfo *), + __REGA3(struct ColorIndexMapping *), + __REGD0(SHORT), + __REGD1(SHORT), + __REGD2(SHORT), + __REGD3(SHORT), + __REGD4(SHORT), + __REGD5(SHORT), + __REGD6(UBYTE), + __REGD7(UBYTE)); + void ASM (*BlitPlanar2DirectDefault)(__REGA0(struct BoardInfo *), + __REGA1(struct BitMap *), + __REGA2(struct RenderInfo *), + __REGA3(struct ColorIndexMapping *), + __REGD0(SHORT), + __REGD1(SHORT), + __REGD2(SHORT), + __REGD3(SHORT), + __REGD4(SHORT), + __REGD5(SHORT), + __REGD6(UBYTE), + __REGD7(UBYTE)); + void ASM (*Reserved0)(__REGA0(struct BoardInfo *)); + void ASM (*Reserved0Default)(__REGA0(struct BoardInfo *)); + void ASM (*Reserved1)(__REGA0(struct BoardInfo *)); + void ASM (*Reserved1Default)(__REGA0(struct BoardInfo *)); + void ASM (*Reserved2)(__REGA0(struct BoardInfo *)); + void ASM (*Reserved2Default)(__REGA0(struct BoardInfo *)); + void ASM (*Reserved3)(__REGA0(struct BoardInfo *)); + void ASM (*Reserved3Default)(__REGA0(struct BoardInfo *)); + + int ASM (*WriteYUVRect)(__REGA0(struct BoardInfo *), + __REGA1(APTR), + __REGD0(SHORT), + __REGD1(SHORT), + __REGA2(struct RenderInfo *), + __REGD2(SHORT), + __REGD3(SHORT), + __REGD4(SHORT), + __REGD5(SHORT), + __REGA3(struct TagItem *)); + int ASM (*WriteYUVRectDefault)(__REGA0(struct BoardInfo *), + __REGA1(APTR), + __REGD0(SHORT), + __REGD1(SHORT), + __REGA2(struct RenderInfo *), + __REGD2(SHORT), + __REGD3(SHORT), + __REGD4(SHORT), + __REGD5(SHORT), + __REGA3(struct TagItem *)); + + BOOL ASM (*GetVSyncState)(__REGA0(struct BoardInfo *), __REGD0(BOOL)); + ULONG ASM (*GetVBeamPos)(__REGA0(struct BoardInfo *)); + void ASM (*SetDPMSLevel)(__REGA0(struct BoardInfo *), __REGD0(ULONG)); + void ASM (*ResetChip)(__REGA0(struct BoardInfo *)); + ULONG ASM (*GetFeatureAttrs)(__REGA0(struct BoardInfo *), __REGA1(APTR), __REGD0(ULONG), __REGA2(struct TagItem *)); + + struct BitMap *ASM (*AllocBitMap)(__REGA0(struct BoardInfo *), + __REGD0(ULONG), + __REGD1(ULONG), + __REGA1(struct TagItem *)); + BOOL ASM (*FreeBitMap)(__REGA0(struct BoardInfo *), __REGA1(struct BitMap *), __REGA2(struct TagItem *)); + ULONG ASM (*GetBitMapAttr)(__REGA0(struct BoardInfo *), __REGA1(struct BitMap *), __REGD0(ULONG)); + + BOOL ASM (*SetSprite)(__REGA0(struct BoardInfo *), __REGD0(BOOL), __REGD7(RGBFTYPE)); + void ASM (*SetSpritePosition)(__REGA0(struct BoardInfo *), __REGD0(WORD), __REGD1(WORD), __REGD7(RGBFTYPE)); + void ASM (*SetSpriteImage)(__REGA0(struct BoardInfo *), __REGD7(RGBFTYPE)); + void ASM (*SetSpriteColor)(__REGA0(struct BoardInfo *), + __REGD0(UBYTE), + __REGD1(UBYTE), + __REGD2(UBYTE), + __REGD3(UBYTE), + __REGD7(RGBFTYPE)); + + APTR ASM (*CreateFeature)(__REGA0(struct BoardInfo *), __REGD0(ULONG), __REGA1(struct TagItem *)); + ULONG ASM (*SetFeatureAttrs)(__REGA0(struct BoardInfo *), __REGA1(APTR), __REGD0(ULONG), __REGA2(struct TagItem *)); + BOOL ASM (*DeleteFeature)(__REGA0(struct BoardInfo *), __REGA1(APTR), __REGD0(ULONG)); + struct MinList SpecialFeatures; + + struct ModeInfo *ModeInfo; /* Chip Settings Stuff */ + RGBFTYPE RGBFormat; + WORD XOffset; + WORD YOffset; + UBYTE Depth; + UBYTE ClearMask; + BOOL Border; + ULONG Mask; + struct CLUTEntry CLUT[256]; + + struct ViewPort * ViewPort; /* ViewPort Stuff */ + struct BitMap * VisibleBitMap; + struct BitMapExtra *BitMapExtra; + struct MinList BitMapList; + struct MinList MemList; + + WORD MouseX; + WORD MouseY; /* Sprite Stuff */ + UBYTE MouseWidth; + UBYTE MouseHeight; + UBYTE MouseXOffset; + UBYTE MouseYOffset; + UWORD * MouseImage; + UBYTE MousePens[4]; + struct Rectangle MouseRect; + UBYTE * MouseChunky; + UWORD * MouseRendered; + UBYTE * MouseSaveBuffer; + + ULONG ChipData[16]; /* for chip driver needs */ + ULONG CardData[16]; /* for card driver needs */ + + APTR MemorySpaceBase; /* the base address of the board memory address space */ + ULONG MemorySpaceSize; /* size of that area */ + + APTR DoubleBufferList; /* chain of dbinfos being notified on vblanks */ + + struct timeval SyncTime; /* system time when screen was set up, used for pseudo vblanks */ + ULONG SyncPeriod; /* length of one frame in micros */ + struct MsgPort SoftVBlankPort; /* MsgPort for software emulation of board interrupt */ + + struct MinList WaitQ; /* for WaitTOF and WaitBOVP, all elements will be signaled on VBlank */ + + LONG EssentialFormats; /* these RGBFormats will be used when user does not choose "all" + will be filled by InitBoard() */ + UBYTE *MouseImageBuffer; /* rendered to the destination color format */ }; /* BoardInfo flags */ /* 0-15: hardware flags */ /* 16-31: user flags */ -#define BIB_HARDWARESPRITE 0 /* board has hardware sprite */ -#define BIB_NOMEMORYMODEMIX 1 /* board does not support modifying planar bitmaps while displaying chunky and vice versa */ -#define BIB_NEEDSALIGNMENT 2 /* bitmaps have to be aligned (not yet supported!) */ -#define BIB_CACHEMODECHANGE 3 /* board memory may be set to Imprecise (060) or Nonserialised (040) */ -#define BIB_VBLANKINTERRUPT 4 /* board can cause a hardware interrupt on a vertical retrace */ -#define BIB_HASSPRITEBUFFER 5 /* board has allocated memory for software sprite image and save buffer */ - -#define BIB_DBLSCANDBLSPRITEY 8 /* hardware sprite y position is doubled on doublescan display modes */ -#define BIB_ILACEHALFSPRITEY 9 /* hardware sprite y position is halved on interlace display modes */ -#define BIB_ILACEDBLROWOFFSET 10 /* doubled row offset in interlaced display modes needs additional horizontal bit */ -#define BIB_INTERNALMODESONLY 11 /* board creates its resolutions and modes automatically and does not support user setting files (UAE) */ -#define BIB_FLICKERFIXER 12 /* board can flicker fix Amiga RGB signal */ -#define BIB_VIDEOCAPTURE 13 /* board can capture video data to a memory area */ -#define BIB_VIDEOWINDOW 14 /* board can display a second mem area as a pip */ -#define BIB_BLITTER 15 /* board has blitter */ - -#define BIB_HIRESSPRITE 16 /* mouse sprite has double resolution */ -#define BIB_BIGSPRITE 17 /* user wants big mouse sprite */ -#define BIB_BORDEROVERRIDE 18 /* user wants to override system overscan border prefs */ -#define BIB_BORDERBLANK 19 /* user wants border blanking */ -#define BIB_INDISPLAYCHAIN 20 /* board switches Amiga signal */ -#define BIB_QUIET 21 /* not yet implemented */ -#define BIB_NOMASKBLITS 22 /* perform blits without taking care of mask */ -#define BIB_NOP2CBLITS 23 /* use CPU for planar to chunky conversions */ -#define BIB_NOBLITTER 24 /* disable all blitter functions */ -#define BIB_SYSTEM2SCREENBLITS 25 /* allow data to be written to screen memory for cpu as blitter source */ -#define BIB_GRANTDIRECTACCESS 26 /* all data on the board can be accessed at any time without bi->SetMemoryMode() */ - -#define BIB_OVERCLOCK 31 /* enable overclocking for some boards */ - -#define BIB_IGNOREMASK BIB_NOMASKBLITS - -#define BIF_HARDWARESPRITE (1<SetMemoryMode() */ + +#define BIB_OVERCLOCK 31 /* enable overclocking for some boards */ + +#define BIB_IGNOREMASK BIB_NOMASKBLITS + +#define BIF_HARDWARESPRITE (1 << BIB_HARDWARESPRITE) +#define BIF_NOMEMORYMODEMIX (1 << BIB_NOMEMORYMODEMIX) +#define BIF_NEEDSALIGNMENT (1 << BIB_NEEDSALIGNMENT) +#define BIF_CACHEMODECHANGE (1 << BIB_CACHEMODECHANGE) +#define BIF_VBLANKINTERRUPT (1 << BIB_VBLANKINTERRUPT) +#define BIF_HASSPRITEBUFFER (1 << BIB_HASSPRITEBUFFER) +#define BIF_DBLSCANDBLSPRITEY (1 << BIB_DBLSCANDBLSPRITEY) +#define BIF_ILACEHALFSPRITEY (1 << BIB_ILACEHALFSPRITEY) +#define BIF_ILACEDBLROWOFFSET (1 << BIB_ILACEDBLROWOFFSET) +#define BIF_INTERNALMODESONLY (1 << BIB_INTERNALMODESONLY) +#define BIF_FLICKERFIXER (1 << BIB_FLICKERFIXER) +#define BIF_VIDEOCAPTURE (1 << BIB_VIDEOCAPTURE) +#define BIF_VIDEOWINDOW (1 << BIB_VIDEOWINDOW) +#define BIF_BLITTER (1 << BIB_BLITTER) +#define BIF_HIRESSPRITE (1 << BIB_HIRESSPRITE) +#define BIF_BIGSPRITE (1 << BIB_BIGSPRITE) +#define BIF_BORDEROVERRIDE (1 << BIB_BORDEROVERRIDE) +#define BIF_BORDERBLANK (1 << BIB_BORDERBLANK) +#define BIF_INDISPLAYCHAIN (1 << BIB_INDISPLAYCHAIN) +#define BIF_QUIET (1 << BIB_QUIET) +#define BIF_NOMASKBLITS (1 << BIB_NOMASKBLITS) +#define BIF_NOP2CBLITS (1 << BIB_NOP2CBLITS) +#define BIF_NOBLITTER (1 << BIB_NOBLITTER) +#define BIF_SYSTEM2SCREENBLITS (1 << BIB_SYSTEM2SCREENBLITS) +#define BIF_GRANTDIRECTACCESS (1 << BIB_GRANTDIRECTACCESS) +#define BIF_OVERCLOCK (1 << BIB_OVERCLOCK) + +#define BIF_IGNOREMASK BIF_NOMASKBLITS /* write errors, continued for historical reasons... :-) */ -#define BIB_NOC2PBLITS BIB_NOP2CBLITS -#define BIF_NOC2PBLITS BIF_NOP2CBLITS +#define BIB_NOC2PBLITS BIB_NOP2CBLITS +#define BIF_NOC2PBLITS BIF_NOP2CBLITS /************************************************************************/ -//struct CardBase { +// struct CardBase { // struct Library LibBase; // UBYTE Flags; // UBYTE pad; @@ -620,22 +860,23 @@ struct BoardInfo{ // char *Name; //}; -struct ChipBase { - struct Library LibBase; - UBYTE Flags; - UBYTE pad; +struct ChipBase +{ + struct Library LibBase; + UBYTE Flags; + UBYTE pad; - struct ExecBase *ExecBase; + struct ExecBase *ExecBase; - APTR SegList; + APTR SegList; }; /************************************************************************/ /* private Tags */ -#define P96BD_BoardType (P96BD_Dummy+0x101) -#define P96BD_ChipType (P96BD_Dummy+0x102) -#define P96BD_DACType (P96BD_Dummy+0x103) -#define P96BD_CurrentScreenBitMap (P96BD_Dummy+0x104) +#define P96BD_BoardType (P96BD_Dummy + 0x101) +#define P96BD_ChipType (P96BD_Dummy + 0x102) +#define P96BD_DACType (P96BD_Dummy + 0x103) +#define P96BD_CurrentScreenBitMap (P96BD_Dummy + 0x104) /************************************************************************/ #endif diff --git a/PrometheusCard/card.c b/PrometheusCard/card.c old mode 100755 new mode 100644 index 7969c3c..f903b21 --- a/PrometheusCard/card.c +++ b/PrometheusCard/card.c @@ -1,11 +1,11 @@ +#include #include +#include +#include #include -#include #include #include -#include -#include -#include +#include #include "boardinfo.h" #include "card.h" @@ -19,293 +19,293 @@ typedef void (*dpmsFunc)(__REGA0(struct BoardInfo *bi), __REGD0(ULONG level)); typedef void (*intFunc)(void); /****************************************************************************************** -* * -* This function registers the interrupt server for the board * -* * -******************************************************************************************/ + * * + * This function registers the interrupt server for the board * + * * + ******************************************************************************************/ void RegisterIntServer(struct CardBase *cb, void *board, struct Interrupt *interrupt) - { - struct Library* PrometheusBase = cb->cb_PrometheusBase; - struct Library* SysBase = cb->cb_SysBase; +{ + struct Library *PrometheusBase = cb->cb_PrometheusBase; + struct Library *SysBase = cb->cb_SysBase; - if(PrometheusBase->lib_Version >= 2) - { + if (PrometheusBase->lib_Version >= 2) + { Prm_AddIntServer(board, interrupt); - } + } else - { + { AddIntServer(INTB_PORTS, interrupt); - } - } + } +} /****************************************************************************************** -* * -* This function registers the owner for the board to prevent it from being used twice * -* * -******************************************************************************************/ + * * + * This function registers the owner for the board to prevent it from being used twice * + * * + ******************************************************************************************/ void RegisterOwner(struct CardBase *cb, void *board, struct Node *driver) - { - struct Library* PrometheusBase = cb->cb_PrometheusBase; +{ + struct Library *PrometheusBase = cb->cb_PrometheusBase; if (PrometheusBase->lib_Version >= 2) - { - Prm_SetBoardAttrsTags(board, PRM_BoardOwner, (ULONG)driver); - } - } + { + Prm_SetBoardAttrsTags(board, PRM_BoardOwner, (ULONG)driver); + } +} /****************************************************************************************** -* * -* This function should set a board switch to let the Amiga signal pass through when * -* supplied with a 0 in d0 and to show the board signal if a 1 is passed in d0. You should * -* remember the current state of the switch to avoid unneeded switching. You may use the * -* MoniSwitch field of the BoardInfo structure for buffering the current state. * -* * -* For PCI bridges we have no integrated monitor switch solution, but there is an external * -* display switch from JAVOSOFT that shows the secondary video input if the primary video * -* signal is configure for DPMS_OFF. * -* * -******************************************************************************************/ + * * + * This function should set a board switch to let the Amiga signal pass through when * + * supplied with a 0 in d0 and to show the board signal if a 1 is passed in d0. You should * + * remember the current state of the switch to avoid unneeded switching. You may use the * + * MoniSwitch field of the BoardInfo structure for buffering the current state. * + * * + * For PCI bridges we have no integrated monitor switch solution, but there is an external * + * display switch from JAVOSOFT that shows the secondary video input if the primary video * + * signal is configure for DPMS_OFF. * + * * + ******************************************************************************************/ BOOL SetSwitch(__REGA0(struct BoardInfo *bi), __REGD0(BOOL state)) - { +{ BOOL oldState = (bi->MoniSwitch & 1) ? TRUE : FALSE; - + bi->MoniSwitch = (bi->MoniSwitch & ~1) | (state ? 1 : 0); if (oldState != (state ? TRUE : FALSE)) - { + { /* when anything changed shut primary video off */ /* or restore current DPMS level logged by our */ /* SetDPMSLevel replacement below */ ((dpmsFunc)bi->JSetOldDPMSLevel)(bi, state ? bi->JDPMSLevel : DPMS_OFF); - } + } return oldState; - } +} /******************************************************************************************** -* This function sets the DPMS level supplied. Valid values are (see boardinfo.h): * -* DPMS_ON (normal operation) * -* DPMS_STANDBY (Optional state of minimal power reduction) * -* DPMS_SUSPEND (Significant reduction of power consumption) * -* DPMS_OFF (Monitor off, lowest level of power consumption) * -* * -********************************************************************************************/ + * This function sets the DPMS level supplied. Valid values are (see boardinfo.h): * + * DPMS_ON (normal operation) * + * DPMS_STANDBY (Optional state of minimal power reduction) * + * DPMS_SUSPEND (Significant reduction of power consumption) * + * DPMS_OFF (Monitor off, lowest level of power consumption) * + * * + ********************************************************************************************/ void SetDPMSLevel(__REGA0(struct BoardInfo *bi), __REGD0(ULONG level)) - { +{ if (level <= DPMS_OFF) - { + { /* log new level in any case */ bi->JDPMSLevel = level; /* but only do real DPMS if the primary video is visible */ - if(bi->MoniSwitch & 1) ((dpmsFunc)bi->JSetOldDPMSLevel)(bi, level); - } - } + if (bi->MoniSwitch & 1) ((dpmsFunc)bi->JSetOldDPMSLevel)(bi, level); + } +} /******************************************************************************************** -* * -* FindCard is called in the first stage of the board initialisation and configuration and * -* is used to look if there is a free and unconfigured board of the type the driver is * -* capable of managing. If it finds one, it immediately reserves it for use by Picasso96, * -* usually by clearing the CDB_CONFIGME bit in the flags field of the ConfigDev struct of * -* this expansion card. But this is only a common example, a driver can do whatever it wants * -* to mark this card as used by the driver. This mechanism is intended to ensure that a * -* board is only configured and used by one driver. FindBoard also usually fills some fields * -* of the BoardInfo struct supplied by the caller, the rtg.library, for example the * -* MemoryBase, MemorySize and RegisterBase fields. * -* * -* For PCI bridges we abuse this concept to some degree - we just make sure the bridge is * -* available. To find a board with supported chipset and to enumerate multiple boards we use * -* the InitCard function * -* * -********************************************************************************************/ + * * + * FindCard is called in the first stage of the board initialisation and configuration and * + * is used to look if there is a free and unconfigured board of the type the driver is * + * capable of managing. If it finds one, it immediately reserves it for use by Picasso96, * + * usually by clearing the CDB_CONFIGME bit in the flags field of the ConfigDev struct of * + * this expansion card. But this is only a common example, a driver can do whatever it wants * + * to mark this card as used by the driver. This mechanism is intended to ensure that a * + * board is only configured and used by one driver. FindBoard also usually fills some fields * + * of the BoardInfo struct supplied by the caller, the rtg.library, for example the * + * MemoryBase, MemorySize and RegisterBase fields. * + * * + * For PCI bridges we abuse this concept to some degree - we just make sure the bridge is * + * available. To find a board with supported chipset and to enumerate multiple boards we use * + * the InitCard function * + * * + ********************************************************************************************/ BOOL FindCard(__REGA0(struct BoardInfo *bi), __REGA6(struct CardBase *base)) - { +{ /* we can't do very much here as bridge is already initialized */ return TRUE; - } +} /******************************************************************************************** -* * -* This function gets a long work representing all RGBFormats that can coexist * -* simultaneously on the board with a bitmap of the supplied RGBFormat. This is used when a * -* bitmap is put to the board in order to check all bitmaps currently on board if they have * -* to leave. This is for example the case with Cirrus based boards where all chunky and * -* Hi/TrueColor bitmaps must leave whenever a planar bitmap needs to be put to the board, * -* because the formats cannot share the board due to restrictions by that VGA chips. * -* * -********************************************************************************************/ + * * + * This function gets a long work representing all RGBFormats that can coexist * + * simultaneously on the board with a bitmap of the supplied RGBFormat. This is used when a * + * bitmap is put to the board in order to check all bitmaps currently on board if they have * + * to leave. This is for example the case with Cirrus based boards where all chunky and * + * Hi/TrueColor bitmaps must leave whenever a planar bitmap needs to be put to the board, * + * because the formats cannot share the board due to restrictions by that VGA chips. * + * * + ********************************************************************************************/ ULONG GetCompatibleFormats(__REGA0(struct BoardInfo *bi), __REGD7(RGBFTYPE format)) - { - return (ULONG)~RGBFF_PLANAR | RGBFF_A8R8G8B8 | RGBFF_R8G8B8A8 | RGBFF_R5G6B5 | - RGBFF_R5G5B5 | RGBFF_YUV422 | RGBFF_YUV422PA; - } +{ + return (ULONG)~RGBFF_PLANAR | RGBFF_A8R8G8B8 | RGBFF_R8G8B8A8 | RGBFF_R5G6B5 | RGBFF_R5G5B5 | RGBFF_YUV422 | + RGBFF_YUV422PA; +} /******************************************************************************************** -* * -* Dummy interrupt handler that will be used in case an interrupt is caused before the real * -* handler is registered by the chip driver. * -* * -********************************************************************************************/ + * * + * Dummy interrupt handler that will be used in case an interrupt is caused before the real * + * handler is registered by the chip driver. * + * * + ********************************************************************************************/ LONG HardInterruptCode(__REGA1(struct BoardInfo *bi)) - { +{ return 0; - } +} /******************************************************************************************** -* * -* InitCard is called in a second stage after the rtg.library allocated other system * -* resources like memory. During this call, all fields of the BoardInfo structure that need * -* to be filled must be initialized. * -* A driver that consists of two separate parts like a card driver and a chip driver calls * -* the init function of the chip driver at that time. * -* * -* That's exactly what we do: find any supported board and use the specific chip driver to * -* initialize the hardware. This way we make the chip driver re-usable for any other PCI or * -* a ZORRO bridge. * -* * -********************************************************************************************/ + * * + * InitCard is called in a second stage after the rtg.library allocated other system * + * resources like memory. During this call, all fields of the BoardInfo structure that need * + * to be filled must be initialized. * + * A driver that consists of two separate parts like a card driver and a chip driver calls * + * the init function of the chip driver at that time. * + * * + * That's exactly what we do: find any supported board and use the specific chip driver to * + * initialize the hardware. This way we make the chip driver re-usable for any other PCI or * + * a ZORRO bridge. * + * * + ********************************************************************************************/ BOOL InitCard(__REGA0(struct BoardInfo *bi), __REGA1(char **ToolTypes), __REGA6(struct CardBase *cb)) - { - struct Library* PrometheusBase = cb->cb_PrometheusBase; - BOOL found = FALSE; - BOOL forbid_interrupts = FALSE; - BOOL special_switch = FALSE; - ULONG dma_size = 0; - struct Library* UtilityBase = bi->UtilBase; +{ + struct Library *PrometheusBase = cb->cb_PrometheusBase; + BOOL found = FALSE; + BOOL forbid_interrupts = FALSE; + BOOL special_switch = FALSE; + ULONG dma_size = 0; + struct Library *UtilityBase = bi->UtilBase; /* add dummy handler for safety reasons... */ bi->HardInterrupt.is_Code = (intFunc)HardInterruptCode; if (HAS_TOOLTYPES) - { + { /* new Picasso96 version (with tooltype support) */ char *ToolType; while (ToolType = *ToolTypes++) - { + { /* check if JAVOSOFT is specified as switch type */ /* this is only important if just one monitor is used */ - + if (bi->Flags & BIF_INDISPLAYCHAIN) - { + { if (Stricmp(ToolType, "SWITCHTYPE=JAVOSOFT") == 0) - { + { special_switch = TRUE; - } - } + } + } /* user likes to disable vertical blanking interrupt? */ if (Stricmp(ToolType, "NOINTERRUPT=Yes") == 0) - { + { forbid_interrupts = TRUE; - } + } /* user likes to reserve some memory for DMA? */ if (Strnicmp(ToolType, "DMASIZE=", 8) == 0) - { + { if (!cb->cb_DMAMemGranted) - { + { STRPTR cp = &ToolType[8]; - UBYTE c; - ULONG size = 0; + UBYTE c; + ULONG size = 0; while ((c = *cp++) != 0) - { + { if ((c >= '0') && (c <= '9')) - { - size = size*10 + (c - '0'); - } + { + size = size * 10 + (c - '0'); + } else - { - if ((c == 'k') || (c == 'K')) size = size << 10; - else if((c == 'm') || (c == 'M')) size = size << 20; - } - } + { + if ((c == 'k') || (c == 'K')) + size = size << 10; + else if ((c == 'm') || (c == 'M')) + size = size << 20; + } + } if (size > 0) - { + { dma_size = size; bi->Flags |= BIF_GRANTDIRECTACCESS; - } - } - } - } - } + } + } + } + } + } - /* check Banshee/Voodoo3/4/5 based cards */ + /* check Banshee/Voodoo3/4/5 based cards */ - if (!found) found = Init3dfxVoodoo(cb, bi); + if (!found) found = Init3dfxVoodoo(cb, bi); - /* check ViRGE based S3 cards */ + /* check ViRGE based S3 cards */ - if (!found) found = InitS3ViRGE(cb, bi); + if (!found) found = InitS3ViRGE(cb, bi); - /* check Permedia2 based cards (3DLabs/TI) */ + /* check Permedia2 based cards (3DLabs/TI) */ - if(!found) found = Init3DLabsPermedia2(cb, bi); + if (!found) found = Init3DLabsPermedia2(cb, bi); - if (found) + if (found) { - bi->BoardName = BOARD_NAME; - bi->BoardType = BOARD_TYPE; - if (!(bi->ExecBase->AttnFlags & AFF_68040) && (bi->ExecBase->AttnFlags & AFF_68030)) + bi->BoardName = BOARD_NAME; + bi->BoardType = BOARD_TYPE; + if (!(bi->ExecBase->AttnFlags & AFF_68040) && (bi->ExecBase->AttnFlags & AFF_68030)) { - /* an 030 Amiga - don't use cache modifications. */ + /* an 030 Amiga - don't use cache modifications. */ - bi->Flags &= ~BIF_CACHEMODECHANGE; + bi->Flags &= ~BIF_CACHEMODECHANGE; } - if (special_switch) + if (special_switch) { - /* plug in handler for external monitor switch */ + /* plug in handler for external monitor switch */ - bi->SetSwitch = SetSwitch; + bi->SetSwitch = SetSwitch; - /* save chip specific SetDPMSLevel function */ + /* save chip specific SetDPMSLevel function */ - bi->JSetOldDPMSLevel = (ULONG)bi->SetDPMSLevel; + bi->JSetOldDPMSLevel = (ULONG)bi->SetDPMSLevel; - /* and overwrite with enhanced implementation */ + /* and overwrite with enhanced implementation */ - bi->SetDPMSLevel = SetDPMSLevel; + bi->SetDPMSLevel = SetDPMSLevel; - /* set startup value */ + /* set startup value */ - bi->MoniSwitch = (UWORD)0xFFFF; + bi->MoniSwitch = (UWORD)0xFFFF; } - - if (forbid_interrupts) + if (forbid_interrupts) { - /* just make sure no interrupts are caused */ - - bi->Flags = bi->Flags & ~(ULONG)BIF_VBLANKINTERRUPT; + /* just make sure no interrupts are caused */ + + bi->Flags = bi->Flags & ~(ULONG)BIF_VBLANKINTERRUPT; } - if (PrometheusBase->lib_Version >= 2) + if (PrometheusBase->lib_Version >= 2) { - if ((dma_size > 0) && (dma_size <= bi->MemorySize)) + if ((dma_size > 0) && (dma_size <= bi->MemorySize)) { - cb->cb_DMAMemGranted = TRUE; - bi->MemorySize = bi->MemorySize - dma_size; - InitDMAMemory(cb, (APTR)((ULONG)bi->MemoryBase + bi->MemorySize), dma_size); + cb->cb_DMAMemGranted = TRUE; + bi->MemorySize = bi->MemorySize - dma_size; + InitDMAMemory(cb, (APTR)((ULONG)bi->MemoryBase + bi->MemorySize), dma_size); } } } return found; - } - +} diff --git a/PrometheusCard/card.h b/PrometheusCard/card.h old mode 100755 new mode 100644 index 515c46e..1123360 --- a/PrometheusCard/card.h +++ b/PrometheusCard/card.h @@ -1,60 +1,60 @@ #include "boardinfo.h" -#define JSetOldDPMSLevel CardData[14] -#define JDPMSLevel CardData[15] +#define JSetOldDPMSLevel CardData[14] +#define JDPMSLevel CardData[15] -#define VENDOR_E3B 3643 -#define VENDOR_MATAY 44359 -#define DEVICE_FIRESTORM 200 -#define DEVICE_PROMETHEUS 1 -#define BOARD_NAME "Prometheus" -#define BOARD_TYPE BT_Prometheus +#define VENDOR_E3B 3643 +#define VENDOR_MATAY 44359 +#define DEVICE_FIRESTORM 200 +#define DEVICE_PROMETHEUS 1 +#define BOARD_NAME "Prometheus" +#define BOARD_TYPE BT_Prometheus #define LIB(a) struct Library *##a = cb->cb_##a #ifdef DEBUG -#define D(x) x + #define D(x) x void kprintf(STRPTR format, ...); #else -#define D(x) + #define D(x) #endif /* DMAMemChunk structure describes single DMA memory chunk. */ struct DMAMemChunk - { - struct MinNode dmc_Node; /* for linking into list */ - APTR dmc_Address; /* logical (CPU) address */ - struct Task *dmc_Owner; /* memory owner (NULL if none) */ - ULONG dmc_Size; /* chunk size in bytes */ - APTR dmc_AlignedAddr; /* Aligned on 4K address */ - }; +{ + struct MinNode dmc_Node; /* for linking into list */ + APTR dmc_Address; /* logical (CPU) address */ + struct Task * dmc_Owner; /* memory owner (NULL if none) */ + ULONG dmc_Size; /* chunk size in bytes */ + APTR dmc_AlignedAddr; /* Aligned on 4K address */ +}; struct CardBase - { - struct Library cb_Library; - UBYTE cb_Flags; - UBYTE cb_Pad; - struct Library *cb_SysBase; - struct Library *cb_ExpansionBase; - APTR cb_SegList; - STRPTR cb_Name; +{ + struct Library cb_Library; + UBYTE cb_Flags; + UBYTE cb_Pad; + struct Library *cb_SysBase; + struct Library *cb_ExpansionBase; + APTR cb_SegList; + STRPTR cb_Name; /* standard fields ends here */ - struct Library *cb_PrometheusBase; - BOOL cb_DMAMemGranted; - APTR cb_LegacyIOBase; - APTR cb_MemPool; /* for DMA memory management lists */ - struct MinList cb_MemList; -// struct DMAMemChunk cb_MemRoot; + struct Library *cb_PrometheusBase; + BOOL cb_DMAMemGranted; + APTR cb_LegacyIOBase; + APTR cb_MemPool; /* for DMA memory management lists */ + struct MinList cb_MemList; + // struct DMAMemChunk cb_MemRoot; struct SignalSemaphore *cb_MemSem; - }; +}; -BOOL Init3dfxVoodoo(struct CardBase *cb, struct BoardInfo *bi); // check Banshee/Voodoo3/4/5 based cards -BOOL Init3DLabsPermedia2(struct CardBase *cb, struct BoardInfo *bi); // check Permedia2 based cards (3DLabs/TI) -BOOL InitCirrusGD5446(struct BoardInfo *bi); // check GD5446 based Cirrus cards -BOOL InitS3ViRGE(struct CardBase *cb, struct BoardInfo *bi); // check ViRGE based S3 cards +BOOL Init3dfxVoodoo(struct CardBase *cb, struct BoardInfo *bi); // check Banshee/Voodoo3/4/5 based cards +BOOL Init3DLabsPermedia2(struct CardBase *cb, struct BoardInfo *bi); // check Permedia2 based cards (3DLabs/TI) +BOOL InitCirrusGD5446(struct BoardInfo *bi); // check GD5446 based Cirrus cards +BOOL InitS3ViRGE(struct CardBase *cb, struct BoardInfo *bi); // check ViRGE based S3 cards VOID InitDMAMemory(struct CardBase *cb, APTR memory, ULONG size); void RegisterIntServer(struct CardBase *cb, void *board, struct Interrupt *interrupt); @@ -65,6 +65,7 @@ BOOL FindCard(__REGA0(struct BoardInfo *bi), __REGA6(struct CardBase *base)); APTR AllocDMAMemory(__REGD0(ULONG size), __REGA6(struct CardBase *cb)); void FreeDMAMemory(__REGA0(APTR membase), __REGD0(ULONG memsize), __REGA6(struct CardBase *cb)); -#define NewList(l) (((struct List*)l)->lh_TailPred = (struct Node*)(l), \ - ((struct List*)l)->lh_Tail = 0, \ - ((struct List*)l)->lh_Head = (struct Node*)&(((struct List*)l)->lh_Tail)) +#define NewList(l) \ + (((struct List *)l)->lh_TailPred = (struct Node *)(l), \ + ((struct List *)l)->lh_Tail = 0, \ + ((struct List *)l)->lh_Head = (struct Node *)&(((struct List *)l)->lh_Tail)) diff --git a/PrometheusCard/card_3dfxvoodoo.c b/PrometheusCard/card_3dfxvoodoo.c old mode 100755 new mode 100644 index 5020f82..3b3ee2d --- a/PrometheusCard/card_3dfxvoodoo.c +++ b/PrometheusCard/card_3dfxvoodoo.c @@ -1,97 +1,103 @@ -#include -#include #include +#include #include +#include #include "card.h" struct CardInfo - { - ULONG Device; +{ + ULONG Device; UBYTE *Memory0; UBYTE *Memory1; UBYTE *Memory2; - ULONG Memory1Size; + ULONG Memory1Size; UBYTE *ROM; - }; +}; static ULONG count = 0; -#define PCI_VENDOR 0x121A -#define CHIP_NAME "picasso96/3dfxVoodoo.chip" +#define PCI_VENDOR 0x121A +#define CHIP_NAME "picasso96/3dfxVoodoo.chip" -#define ROMBase ChipData[14] -#define DeviceID ChipData[15] +#define ROMBase ChipData[14] +#define DeviceID ChipData[15] BOOL Init3dfxVoodoo(struct CardBase *cb, struct BoardInfo *bi) - { - struct Library* PrometheusBase = cb->cb_PrometheusBase; - struct Library* SysBase = cb->cb_SysBase; +{ + struct Library *PrometheusBase = cb->cb_PrometheusBase; + struct Library *SysBase = cb->cb_SysBase; - APTR board = NULL; + APTR board = NULL; ULONG current = 0; - #ifdef DBG - KPrintf("prometheus.card: Init3dfxVoodoo()\n"); - #endif +#ifdef DBG + KPrintf("prometheus.card: Init3dfxVoodoo()\n"); +#endif while ((board = (APTR)Prm_FindBoardTags(board, PRM_Vendor, PCI_VENDOR, TAG_END)) != NULL) - { + { struct CardInfo ci; - BOOL found = FALSE; + BOOL found = FALSE; - #ifdef DBG - KPrintf(" Voodoo board found on PCI [$%08lx]\n", (ULONG)board); - #endif +#ifdef DBG + KPrintf(" Voodoo board found on PCI [$%08lx]\n", (ULONG)board); +#endif Prm_GetBoardAttrsTags(board, - PRM_Device, (ULONG)&ci.Device, - PRM_MemoryAddr0, (ULONG)&ci.Memory0, - PRM_MemoryAddr1, (ULONG)&ci.Memory1, - PRM_MemoryAddr2, (ULONG)&ci.Memory2, - PRM_MemorySize1, (ULONG)&ci.Memory1Size, - PRM_ROM_Address, (ULONG)&ci.ROM, - TAG_END); - - switch(ci.Device) - { - case 3: // Banshee - case 5: // Avenger - case 9: // Rampage - found = TRUE; - break; - default: - found = FALSE; - } - - if(found) - { + PRM_Device, + (ULONG)&ci.Device, + PRM_MemoryAddr0, + (ULONG)&ci.Memory0, + PRM_MemoryAddr1, + (ULONG)&ci.Memory1, + PRM_MemoryAddr2, + (ULONG)&ci.Memory2, + PRM_MemorySize1, + (ULONG)&ci.Memory1Size, + PRM_ROM_Address, + (ULONG)&ci.ROM, + TAG_END); + + switch (ci.Device) + { + case 3: // Banshee + case 5: // Avenger + case 9: // Rampage + found = TRUE; + break; + default: + found = FALSE; + } + + if (found) + { struct ChipBase *ChipBase; - #ifdef DBG - KPrintf(" card attrs read (device %ld)\n", (ULONG)ci.Device); - #endif +#ifdef DBG + KPrintf(" card attrs read (device %ld)\n", (ULONG)ci.Device); +#endif // check for multiple hits and skip the ones already used - if(current++ < count) continue; + if (current++ < count) continue; // we have found one - so mark it as used and // don't care about possible errors from here on count++; - if ((ChipBase = (struct ChipBase*)OpenLibrary(CHIP_NAME, 7)) != NULL) - { - #ifdef DBG - KPrintf(" chip driver opened [$%08lx]\n", (ULONG)ChipBase); - #endif + if ((ChipBase = (struct ChipBase *)OpenLibrary(CHIP_NAME, 7)) != NULL) + { +#ifdef DBG + KPrintf(" chip driver opened [$%08lx]\n", (ULONG)ChipBase); +#endif bi->ChipBase = ChipBase; - bi->DeviceID = ci.Device; - bi->MemoryIOBase = ci.Memory0; - bi->MemoryBase = ci.Memory1; - bi->RegisterBase = ci.Memory2; - bi->MemorySize = ci.Memory1Size; - bi->ROMBase = (ULONG)ci.ROM; + bi->DeviceID = ci.Device; + bi->MemoryIOBase = ci.Memory0; + bi->MemoryBase = ci.Memory1; + bi->RegisterBase = ci.Memory2; + bi->MemorySize = ci.Memory1Size; + bi->ROMBase = (ULONG)ci.ROM; // register interrupt server RegisterIntServer(cb, board, &bi->HardInterrupt); @@ -101,13 +107,11 @@ BOOL Init3dfxVoodoo(struct CardBase *cb, struct BoardInfo *bi) // enable vertical blanking interrupt bi->Flags |= BIF_VBLANKINTERRUPT; - Prm_SetBoardAttrsTags(board, - PRM_BoardOwner, (ULONG)ChipBase, - TAG_END); + Prm_SetBoardAttrsTags(board, PRM_BoardOwner, (ULONG)ChipBase, TAG_END); return TRUE; - } - } - } // while + } + } + } // while return FALSE; - } +} diff --git a/PrometheusCard/card_3dlabspermedia2.c b/PrometheusCard/card_3dlabspermedia2.c old mode 100755 new mode 100644 index d92a930..71812be --- a/PrometheusCard/card_3dlabspermedia2.c +++ b/PrometheusCard/card_3dlabspermedia2.c @@ -1,63 +1,69 @@ -#include -#include #include +#include #include +#include #include "card.h" struct CardInfo - { - ULONG Device; - UBYTE *Memory0; - UBYTE *Memory1; - UBYTE *Memory2; - ULONG Memory1Size; - ULONG Memory2Size; +{ + ULONG Device; + UBYTE *Memory0; + UBYTE *Memory1; + UBYTE *Memory2; + ULONG Memory1Size; + ULONG Memory2Size; }; static ULONG count = 0; -#define PCI_VENDOR 0x104C // TexasInstruments -#define CHIP_NAME "picasso96/3DLabsPermedia2.chip" +#define PCI_VENDOR 0x104C // TexasInstruments +#define CHIP_NAME "picasso96/3DLabsPermedia2.chip" BOOL Init3DLabsPermedia2(struct CardBase *cb, struct BoardInfo *bi) - { - struct Library* SysBase = cb->cb_SysBase; - struct Library* PrometheusBase = cb->cb_PrometheusBase; - APTR board = NULL; - ULONG current = 0; - - while((board = (APTR)Prm_FindBoardTags(board, PRM_Vendor, PCI_VENDOR, TAG_END)) != NULL) - { +{ + struct Library *SysBase = cb->cb_SysBase; + struct Library *PrometheusBase = cb->cb_PrometheusBase; + APTR board = NULL; + ULONG current = 0; + + while ((board = (APTR)Prm_FindBoardTags(board, PRM_Vendor, PCI_VENDOR, TAG_END)) != NULL) + { struct CardInfo ci; - BOOL found = FALSE; + BOOL found = FALSE; Prm_GetBoardAttrsTags(board, - PRM_Device, (ULONG)&ci.Device, - PRM_MemoryAddr0, (ULONG)&ci.Memory0, - PRM_MemoryAddr1, (ULONG)&ci.Memory1, - PRM_MemoryAddr2, (ULONG)&ci.Memory2, - PRM_MemorySize1, (ULONG)&ci.Memory1Size, - PRM_MemorySize2, (ULONG)&ci.Memory2Size, - TAG_END); - - switch(ci.Device) - { - case 0x3D07: // Permedia2 - found = TRUE; + PRM_Device, + (ULONG)&ci.Device, + PRM_MemoryAddr0, + (ULONG)&ci.Memory0, + PRM_MemoryAddr1, + (ULONG)&ci.Memory1, + PRM_MemoryAddr2, + (ULONG)&ci.Memory2, + PRM_MemorySize1, + (ULONG)&ci.Memory1Size, + PRM_MemorySize2, + (ULONG)&ci.Memory2Size, + TAG_END); + + switch (ci.Device) + { + case 0x3D07: // Permedia2 + found = TRUE; break; - default: - found = FALSE; - } + default: + found = FALSE; + } - if(found) - { + if (found) + { struct ChipBase *ChipBase; /* check for multiple hits and skip the ones already used */ - if(current++ < count) continue; + if (current++ < count) continue; /* we have found one - so mark it as used and */ /* don't care about possible errors from here on */ @@ -65,49 +71,45 @@ BOOL Init3DLabsPermedia2(struct CardBase *cb, struct BoardInfo *bi) count++; if ((ChipBase = (struct ChipBase *)OpenLibrary(CHIP_NAME, 1)) != NULL) - { + { bi->ChipBase = ChipBase; bi->MemoryBase = ci.Memory1; bi->RegisterBase = (UBYTE *)((ULONG)ci.Memory0 + 0x18000); bi->MemoryIOBase = ci.Memory2; bi->MemorySize = ci.Memory1Size; - // register interrupt server - RegisterIntServer(cb, board, &bi->HardInterrupt); - - InitChip(bi); - - // enable vertical blanking interrupt - bi->Flags |= BIF_VBLANKINTERRUPT; - - if (ci.Memory1 + ci.Memory1Size == ci.Memory2) - { - bi->MemorySpaceBase = ci.Memory1; - bi->MemorySpaceSize = ci.Memory1Size + ci.Memory2Size; - } - else if (ci.Memory2 + ci.Memory2Size == ci.Memory1) - { - bi->MemorySpaceBase = ci.Memory2; - bi->MemorySpaceSize = ci.Memory1Size + ci.Memory2Size; - } - else - { - bi->MemorySpaceBase = ci.Memory1; - bi->MemorySpaceSize = ci.Memory1Size; + // register interrupt server + RegisterIntServer(cb, board, &bi->HardInterrupt); + + InitChip(bi); + + // enable vertical blanking interrupt + bi->Flags |= BIF_VBLANKINTERRUPT; + + if (ci.Memory1 + ci.Memory1Size == ci.Memory2) + { + bi->MemorySpaceBase = ci.Memory1; + bi->MemorySpaceSize = ci.Memory1Size + ci.Memory2Size; + } + else if (ci.Memory2 + ci.Memory2Size == ci.Memory1) + { + bi->MemorySpaceBase = ci.Memory2; + bi->MemorySpaceSize = ci.Memory1Size + ci.Memory2Size; + } + else + { + bi->MemorySpaceBase = ci.Memory1; + bi->MemorySpaceSize = ci.Memory1Size; + } + + // enable special cache mode settings + bi->Flags |= BIF_CACHEMODECHANGE; + + Prm_SetBoardAttrsTags(board, PRM_BoardOwner, (ULONG)ChipBase, TAG_END); + + return TRUE; + } } - - // enable special cache mode settings - bi->Flags |= BIF_CACHEMODECHANGE; - - Prm_SetBoardAttrsTags(board, - PRM_BoardOwner, (ULONG)ChipBase, - TAG_END); - - - return TRUE; - } - } - } + } return FALSE; - } - +} diff --git a/PrometheusCard/card_s3virge.c b/PrometheusCard/card_s3virge.c old mode 100755 new mode 100644 index bc6254c..c5522b0 --- a/PrometheusCard/card_s3virge.c +++ b/PrometheusCard/card_s3virge.c @@ -1,112 +1,115 @@ -#include -#include #include +#include #include +#include #include "card.h" struct CardInfo { - ULONG Device; - UBYTE *Memory0; - ULONG Memory0Size; + ULONG Device; + UBYTE *Memory0; + ULONG Memory0Size; }; static ULONG count = 0; -#define PCI_VENDOR 0x5333 -#define CHIP_VIRGE "picasso96/S3ViRGE.chip" -#define CHIP_TRIO "picasso96/S3Trio64.chip" +#define PCI_VENDOR 0x5333 +#define CHIP_VIRGE "picasso96/S3ViRGE.chip" +#define CHIP_TRIO "picasso96/S3Trio64.chip" -#define SystemSourceAperture ChipData[0] -#define SpecialRegisterBase ChipData[1] -#define BusType ChipData[3] // 0: ZorroII - 1: ZorroIII - 2: PCI +#define SystemSourceAperture ChipData[0] +#define SpecialRegisterBase ChipData[1] +#define BusType ChipData[3] // 0: ZorroII - 1: ZorroIII - 2: PCI BOOL InitS3ViRGE(struct CardBase *cb, struct BoardInfo *bi) { - struct Library* SysBase = cb->cb_SysBase; - struct Library* PrometheusBase = cb->cb_PrometheusBase; - APTR board = NULL; - ULONG current = 0; - - while((board = (APTR)Prm_FindBoardTags(board, PRM_Vendor, PCI_VENDOR, TAG_END)) != NULL) - { - struct CardInfo ci; - BOOL found = FALSE; - BOOL trio = FALSE; - - Prm_GetBoardAttrsTags(board, - PRM_Device, (ULONG)&ci.Device, - PRM_MemoryAddr0, (ULONG)&ci.Memory0, - PRM_MemorySize0, (ULONG)&ci.Memory0Size, - TAG_END); - - switch(ci.Device) - { - case 0x8A01: // VirgeDX/GX - case 0x8A02: // VirgeGX2 - case 0x5631: // 86c325 [ViRGE] - found = TRUE; - break; - case 0x8811: // Trio64 - found = TRUE; - trio = TRUE; - break; - default: - found = FALSE; - } - - if(found) - { - struct ChipBase *ChipBase; - - // check for multiple hits and skip the ones already used - if(current++ < count) continue; - - // we have found one - so mark it as used and - // don't care about possible errors from here on - count++; - - if(trio) + struct Library *SysBase = cb->cb_SysBase; + struct Library *PrometheusBase = cb->cb_PrometheusBase; + APTR board = NULL; + ULONG current = 0; + + while ((board = (APTR)Prm_FindBoardTags(board, PRM_Vendor, PCI_VENDOR, TAG_END)) != NULL) + { + struct CardInfo ci; + BOOL found = FALSE; + BOOL trio = FALSE; + + Prm_GetBoardAttrsTags(board, + PRM_Device, + (ULONG)&ci.Device, + PRM_MemoryAddr0, + (ULONG)&ci.Memory0, + PRM_MemorySize0, + (ULONG)&ci.Memory0Size, + TAG_END); + + switch (ci.Device) + { + case 0x8A01: // VirgeDX/GX + case 0x8A02: // VirgeGX2 + case 0x5631: // 86c325 [ViRGE] + found = TRUE; + break; + case 0x8811: // Trio64 + found = TRUE; + trio = TRUE; + break; + default: + found = FALSE; + } + + if (found) + { + struct ChipBase *ChipBase; + + // check for multiple hits and skip the ones already used + if (current++ < count) continue; + + // we have found one - so mark it as used and + // don't care about possible errors from here on + count++; + + if (trio) { - ChipBase = (struct ChipBase *)OpenLibrary(CHIP_TRIO, 7); + ChipBase = (struct ChipBase *)OpenLibrary(CHIP_TRIO, 7); } else { ChipBase = (struct ChipBase *)OpenLibrary(CHIP_VIRGE, 7); } - if(ChipBase != NULL) - { - bi->ChipBase = ChipBase; + if (ChipBase != NULL) + { + bi->ChipBase = ChipBase; - bi->MemoryBase = (UBYTE *)((ULONG)ci.Memory0); // + 0x2000000); - bi->RegisterBase = (UBYTE *)((ULONG)ci.Memory0 + 0x3008000); - bi->SpecialRegisterBase = (ULONG)ci.Memory0 + 0x3008000; - bi->MemoryIOBase = (UBYTE *)((ULONG)ci.Memory0 + 0x3007FFC); - bi->SystemSourceAperture = (ULONG)ci.Memory0 + 0x3007FFC; - bi->MemorySize = 0x400000; - bi->BusType = 2; + bi->MemoryBase = (UBYTE *)((ULONG)ci.Memory0); // + 0x2000000); + bi->RegisterBase = (UBYTE *)((ULONG)ci.Memory0 + 0x3008000); + bi->SpecialRegisterBase = (ULONG)ci.Memory0 + 0x3008000; + bi->MemoryIOBase = (UBYTE *)((ULONG)ci.Memory0 + 0x3007FFC); + bi->SystemSourceAperture = (ULONG)ci.Memory0 + 0x3007FFC; + bi->MemorySize = 0x400000; + bi->BusType = 2; - ((UBYTE *)cb->cb_LegacyIOBase)[0x3C3] = 1; // wakeup will only work with legacy IO + ((UBYTE *)cb->cb_LegacyIOBase)[0x3C3] = 1; // wakeup will only work with legacy IO - // register interrupt server - RegisterIntServer(cb, board, &bi->HardInterrupt); + // register interrupt server + RegisterIntServer(cb, board, &bi->HardInterrupt); - InitChip(bi); + InitChip(bi); - // enable vertical blanking interrupt - bi->Flags |= BIF_VBLANKINTERRUPT; + // enable vertical blanking interrupt + bi->Flags |= BIF_VBLANKINTERRUPT; - bi->MemorySpaceBase = bi->MemoryBase; - bi->MemorySpaceSize = bi->MemorySize; + bi->MemorySpaceBase = bi->MemoryBase; + bi->MemorySpaceSize = bi->MemorySize; - // enable special cache mode settings - bi->Flags |= BIF_CACHEMODECHANGE; + // enable special cache mode settings + bi->Flags |= BIF_CACHEMODECHANGE; - RegisterOwner(cb, board, (struct Node *)ChipBase); - // no need to continue - we have found a match - return TRUE; - } - } - } // while - return FALSE; + RegisterOwner(cb, board, (struct Node *)ChipBase); + // no need to continue - we have found a match + return TRUE; + } + } + } // while + return FALSE; } diff --git a/PrometheusCard/clib/.clang-format b/PrometheusCard/clib/.clang-format new file mode 100644 index 0000000..57af94e --- /dev/null +++ b/PrometheusCard/clib/.clang-format @@ -0,0 +1,4 @@ +{ + "DisableFormat": "true", + "SortIncludes": "false" +} diff --git a/PrometheusCard/dma.c b/PrometheusCard/dma.c old mode 100755 new mode 100644 index cfdd438..ea19a7c --- a/PrometheusCard/dma.c +++ b/PrometheusCard/dma.c @@ -1,8 +1,8 @@ #include +#include +#include #include #include -#include -#include #include "boardinfo.h" #include "card.h" @@ -13,166 +13,160 @@ /* it is much faster than read it from $00000004. */ struct PrometheusBase - { - struct Library pb_Lib; - struct Library *pb_SysBase; +{ + struct Library pb_Lib; + struct Library *pb_SysBase; /* private not used fields here */ - - }; - +}; APTR AllocDMAMemory(__REGD0(ULONG size), __REGA6(struct CardBase *cb)) - { - struct Library* SysBase = cb->cb_SysBase; - ULONG bestsize = 0xFFFFFFFF; +{ + struct Library * SysBase = cb->cb_SysBase; + ULONG bestsize = 0xFFFFFFFF; struct DMAMemChunk *mem, *best = NULL; - APTR memaddr = NULL; + APTR memaddr = NULL; D(kprintf("prometheus.card: allocDMA(%ld)\n", size)); if (size == 0) - { + { D(kprintf("prometheus.card: allocDMA() zero size!\n")); return NULL; - } + } size = (size + ALIGNMENT + 3) & ~3; ObtainSemaphore(cb->cb_MemSem); - for (mem = (struct DMAMemChunk*)cb->cb_MemList.mlh_Head; - mem->dmc_Node.mln_Succ; - mem = (struct DMAMemChunk*)mem->dmc_Node.mln_Succ) - { + for (mem = (struct DMAMemChunk *)cb->cb_MemList.mlh_Head; mem->dmc_Node.mln_Succ; + mem = (struct DMAMemChunk *)mem->dmc_Node.mln_Succ) + { if ((!mem->dmc_Owner) && (mem->dmc_Size >= size) && (mem->dmc_Size < bestsize)) - { + { bestsize = mem->dmc_Size; - best = mem; + best = mem; if (mem->dmc_Size == size) break; - } - } + } + } if (best) - { + { if (best->dmc_Size == size) - { + { best->dmc_Owner = FindTask(NULL); - memaddr = best->dmc_Address; - } + memaddr = best->dmc_Address; + } else - { + { if (mem = AllocPooled(cb->cb_MemPool, sizeof(struct DMAMemChunk))) - { + { D(kprintf("prometheus.card: DMC allocated at $%08lx\n", (LONG)mem)); - mem->dmc_Size = best->dmc_Size - size; + mem->dmc_Size = best->dmc_Size - size; mem->dmc_Address = (APTR)((ULONG)best->dmc_Address + size); - mem->dmc_Owner = NULL; - best->dmc_Owner = FindTask(NULL); - best->dmc_Size = size; - Insert((struct List*)&cb->cb_MemList, (struct Node*)mem, (struct Node*)best); + mem->dmc_Owner = NULL; + best->dmc_Owner = FindTask(NULL); + best->dmc_Size = size; + Insert((struct List *)&cb->cb_MemList, (struct Node *)mem, (struct Node *)best); memaddr = best->dmc_Address; - } - } - memaddr = (APTR)(((ULONG)memaddr + (ALIGNMENT - 1)) & (-ALIGNMENT)); - best->dmc_AlignedAddr = memaddr; - } + } + } + memaddr = (APTR)(((ULONG)memaddr + (ALIGNMENT - 1)) & (-ALIGNMENT)); + best->dmc_AlignedAddr = memaddr; + } ReleaseSemaphore(cb->cb_MemSem); D(kprintf("prometheus.card: Allocated DMA at $%08lx with size %ld\n", (LONG)memaddr, size)); return memaddr; - } - +} void FreeDMAMemory(__REGA0(APTR membase), __REGD0(ULONG memsize), __REGA6(struct CardBase *cb)) - { - struct Library* SysBase = cb->cb_SysBase; +{ + struct Library * SysBase = cb->cb_SysBase; struct DMAMemChunk *mem, *tmem; D(kprintf("prometheus.card: freeDMA($%08lx, %ld)\n", (LONG)membase, memsize)); if (memsize == 0) - { + { D(kprintf("prometheus.card: freeDMA() zero size!\n")); return; - } + } if (!membase) - { + { D(kprintf("prometheus.card: freeDMA() NULL pointer!\n")); return; - } + } ObtainSemaphore(cb->cb_MemSem); - for (mem = (struct DMAMemChunk*)cb->cb_MemList.mlh_Head; - mem->dmc_Node.mln_Succ; - mem = (struct DMAMemChunk*)mem->dmc_Node.mln_Succ) - { - if(mem->dmc_AlignedAddr == membase) break; - } + for (mem = (struct DMAMemChunk *)cb->cb_MemList.mlh_Head; mem->dmc_Node.mln_Succ; + mem = (struct DMAMemChunk *)mem->dmc_Node.mln_Succ) + { + if (mem->dmc_AlignedAddr == membase) break; + } if (!mem->dmc_Node.mln_Succ) - { + { D(kprintf("prometheus.card: freeDMA() block not found!\n")); return; - } + } if (!mem->dmc_Owner) - { + { D(kprintf("prometheus.card: freeDMA() freed twice!\n")); return; - } + } mem->dmc_Owner = NULL; /* merge with predecessor */ - tmem = (struct DMAMemChunk*)mem->dmc_Node.mln_Pred; + tmem = (struct DMAMemChunk *)mem->dmc_Node.mln_Pred; if ((tmem->dmc_Node.mln_Pred) && (!tmem->dmc_Owner)) - { + { mem->dmc_Address = tmem->dmc_Address; mem->dmc_Size += tmem->dmc_Size; - Remove((struct Node*)tmem); + Remove((struct Node *)tmem); D(kprintf("prometheus.card: DMC at $%08lx will be freed\n", (LONG)tmem)); FreePooled(cb->cb_MemPool, tmem, sizeof(struct DMAMemChunk)); - } + } /* merge with successor */ - tmem = (struct DMAMemChunk*)mem->dmc_Node.mln_Succ; + tmem = (struct DMAMemChunk *)mem->dmc_Node.mln_Succ; if ((tmem->dmc_Node.mln_Succ) && (!tmem->dmc_Owner)) - { + { mem->dmc_Size += tmem->dmc_Size; - Remove((struct Node*)tmem); + Remove((struct Node *)tmem); D(kprintf("prometheus.card: DMC at $%08lx will be freed\n", (LONG)tmem)); FreePooled(cb->cb_MemPool, tmem, sizeof(struct DMAMemChunk)); - } + } ReleaseSemaphore(cb->cb_MemSem); return; - } - +} VOID InitDMAMemory(struct CardBase *cb, APTR memory, ULONG size) - { - struct Library* SysBase = cb->cb_SysBase; - struct Library* PrometheusBase = cb->cb_PrometheusBase; +{ + struct Library * SysBase = cb->cb_SysBase; + struct Library * PrometheusBase = cb->cb_PrometheusBase; struct DMAMemChunk *dmc; if ((size > 0) && (memory != NULL)) - { + { ObtainSemaphore(cb->cb_MemSem); - cb->cb_MemList.mlh_Head = (struct MinNode*)&cb->cb_MemList.mlh_Tail; - cb->cb_MemList.mlh_Tail = NULL; - cb->cb_MemList.mlh_TailPred = (struct MinNode*)&cb->cb_MemList.mlh_Head; + cb->cb_MemList.mlh_Head = (struct MinNode *)&cb->cb_MemList.mlh_Tail; + cb->cb_MemList.mlh_Tail = NULL; + cb->cb_MemList.mlh_TailPred = (struct MinNode *)&cb->cb_MemList.mlh_Head; if (dmc = AllocPooled(cb->cb_MemPool, sizeof(struct DMAMemChunk))) - { - dmc->dmc_Size = size; + { + dmc->dmc_Size = size; dmc->dmc_Address = memory; - dmc->dmc_Owner = NULL; - AddHead((struct List*)&cb->cb_MemList, (struct Node*)dmc); - } + dmc->dmc_Owner = NULL; + AddHead((struct List *)&cb->cb_MemList, (struct Node *)dmc); + } ReleaseSemaphore(cb->cb_MemSem); - } - } + } +} diff --git a/PrometheusCard/inline/.clang-format b/PrometheusCard/inline/.clang-format new file mode 100644 index 0000000..57af94e --- /dev/null +++ b/PrometheusCard/inline/.clang-format @@ -0,0 +1,4 @@ +{ + "DisableFormat": "true", + "SortIncludes": "false" +} diff --git a/PrometheusCard/picasso96.h b/PrometheusCard/picasso96.h old mode 100755 new mode 100644 index bc74872..d285550 --- a/PrometheusCard/picasso96.h +++ b/PrometheusCard/picasso96.h @@ -4,257 +4,262 @@ */ /************************************************************************/ #ifndef LIBRARIES_PICASSO96_H -#define LIBRARIES_PICASSO96_H -/************************************************************************/ -/* includes - */ -#ifndef EXEC_TYPES_H -#include -#endif - -#ifndef EXEC_NODES_H -#include -#endif - -#ifndef UTILITY_TAGITEM_H -#include -#endif - -/************************************************************************/ -/* This is the name of the library - */ -#define P96NAME "Picasso96API.library" + #define LIBRARIES_PICASSO96_H + /************************************************************************/ + /* includes + */ + #ifndef EXEC_TYPES_H + #include + #endif + + #ifndef EXEC_NODES_H + #include + #endif + + #ifndef UTILITY_TAGITEM_H + #include + #endif + + /************************************************************************/ + /* This is the name of the library + */ + #define P96NAME "Picasso96API.library" /************************************************************************/ /* Types for RGBFormat used */ -typedef enum { - RGBFB_NONE, /* no valid RGB format (should not happen) */ - RGBFB_CLUT, /* palette mode, set colors when opening screen using - tags or use SetRGB32/LoadRGB32(...) */ - RGBFB_R8G8B8, /* TrueColor RGB (8 bit each) */ - RGBFB_B8G8R8, /* TrueColor BGR (8 bit each) */ - RGBFB_R5G6B5PC, /* HiColor16 (5 bit R, 6 bit G, 5 bit B), - format: gggbbbbbrrrrrggg */ - RGBFB_R5G5B5PC, /* HiColor15 (5 bit each), format: gggbbbbb0rrrrrgg */ - RGBFB_A8R8G8B8, /* 4 Byte TrueColor ARGB (A unused alpha channel) */ - RGBFB_A8B8G8R8, /* 4 Byte TrueColor ABGR (A unused alpha channel) */ - RGBFB_R8G8B8A8, /* 4 Byte TrueColor RGBA (A unused alpha channel) */ - RGBFB_B8G8R8A8, /* 4 Byte TrueColor BGRA (A unused alpha channel) */ - RGBFB_R5G6B5, /* HiColor16 (5 bit R, 6 bit G, 5 bit B), - format: rrrrrggggggbbbbb */ - RGBFB_R5G5B5, /* HiColor15 (5 bit each), format: 0rrrrrgggggbbbbb */ - RGBFB_B5G6R5PC, /* HiColor16 (5 bit R, 6 bit G, 5 bit B), - format: gggrrrrrbbbbbggg */ - RGBFB_B5G5R5PC, /* HiColor15 (5 bit each), format: gggrrrrr0bbbbbbgg */ - - /* By now, the following formats are for use with a hardware window only - (bitmap operations may be implemented incompletely) */ - - RGBFB_YUV422CGX, /* 2 Byte TrueColor YUV (CCIR recommendation CCIR601). - Each two-pixel unit is stored as one longword - containing luminance (Y) for each of the two pixels, - and chrominance (U,V) for alternate pixels. - The missing chrominance values are generated by - interpolation. (Y0-V0-Y1-U0) */ - RGBFB_YUV411, /* 1 Byte TrueColor ACCUPAK. Four adjacent pixels form - a packet of 5 bits Y (luminance) each pixel and 6 bits - U and V (chrominance) shared by the four pixels */ - RGBFB_YUV411PC, /* 1 Byte TrueColor ACCUPAK byte swapped (1234 -> 4321) */ - RGBFB_YUV422, /* 2 Byte TrueColor YUV (CCIR recommendation CCIR601). - Each two-pixel unit is stored as one longword - containing luminance (Y) for each of the two pixels, - and chrominance (U,V) for alternate pixels. - The missing chrominance values are generated by - interpolation. (Y1-U0-Y0-V0) */ - RGBFB_YUV422PC, /* 2 Byte TrueColor CCIR601 byte swapped (V0-Y0-U0-Y1) */ - RGBFB_YUV422PA, /* 2 Byte TrueColor CCIR601 for use with YUV12 planar - assist mode on Cirrus Logic base graphics chips. - (Y0-Y1-V0-U0) */ - RGBFB_YUV422PAPC, /* 2 Byte TrueColor YUV12 byte swapped (U0-V0-Y1-Y0) */ - - RGBFB_MaxFormats - } RGBFTYPE; - -// legacy -#define RGBFB_Y4U2V2 RGBFB_YUV422CGX -#define RGBFB_Y4U1V1 RGBFB_YUV411 - - -#define RGBFF_NONE (1< 4321) */ + RGBFB_YUV422, /* 2 Byte TrueColor YUV (CCIR recommendation CCIR601). + Each two-pixel unit is stored as one longword + containing luminance (Y) for each of the two pixels, + and chrominance (U,V) for alternate pixels. + The missing chrominance values are generated by + interpolation. (Y1-U0-Y0-V0) */ + RGBFB_YUV422PC, /* 2 Byte TrueColor CCIR601 byte swapped (V0-Y0-U0-Y1) */ + RGBFB_YUV422PA, /* 2 Byte TrueColor CCIR601 for use with YUV12 planar + assist mode on Cirrus Logic base graphics chips. + (Y0-Y1-V0-U0) */ + RGBFB_YUV422PAPC, /* 2 Byte TrueColor YUV12 byte swapped (U0-V0-Y1-Y0) */ + + RGBFB_MaxFormats +} RGBFTYPE; + + // legacy + #define RGBFB_Y4U2V2 RGBFB_YUV422CGX + #define RGBFB_Y4U1V1 RGBFB_YUV411 + + #define RGBFF_NONE (1 << RGBFB_NONE) + #define RGBFF_CLUT (1 << RGBFB_CLUT) + #define RGBFF_R8G8B8 (1 << RGBFB_R8G8B8) + #define RGBFF_B8G8R8 (1 << RGBFB_B8G8R8) + #define RGBFF_R5G6B5PC (1 << RGBFB_R5G6B5PC) + #define RGBFF_R5G5B5PC (1 << RGBFB_R5G5B5PC) + #define RGBFF_A8R8G8B8 (1 << RGBFB_A8R8G8B8) + #define RGBFF_A8B8G8R8 (1 << RGBFB_A8B8G8R8) + #define RGBFF_R8G8B8A8 (1 << RGBFB_R8G8B8A8) + #define RGBFF_B8G8R8A8 (1 << RGBFB_B8G8R8A8) + #define RGBFF_R5G6B5 (1 << RGBFB_R5G6B5) + #define RGBFF_R5G5B5 (1 << RGBFB_R5G5B5) + #define RGBFF_B5G6R5PC (1 << RGBFB_B5G6R5PC) + #define RGBFF_B5G5R5PC (1 << RGBFB_B5G5R5PC) + #define RGBFF_YUV422CGX (1 << RGBFB_YUV422CGX) + #define RGBFF_YUV411 (1 << RGBFB_YUV411) + #define RGBFF_YUV411PC (1 << RGBFB_YUV411PC) + #define RGBFF_YUV422 (1 << RGBFB_YUV422) + #define RGBFF_YUV422PC (1 << RGBFB_YUV422PC) + #define RGBFF_YUV422PA (1 << RGBFB_YUV422PA) + #define RGBFF_YUV422PAPC (1 << RGBFB_YUV422PAPC) + + // legacy + #define RGBFF_Y4U2V2 RGBFF_YUV422CGX + #define RGBFF_Y4U1V1 RGBFF_YUV411 + + #define RGBFF_HICOLOR \ + (RGBFF_R5G6B5PC | RGBFF_R5G5B5PC | RGBFF_R5G6B5 | RGBFF_R5G5B5 | RGBFF_B5G6R5PC | RGBFF_B5G5R5PC) + #define RGBFF_TRUECOLOR (RGBFF_R8G8B8 | RGBFF_B8G8R8) + #define RGBFF_TRUEALPHA (RGBFF_A8R8G8B8 | RGBFF_A8B8G8R8 | RGBFF_R8G8B8A8 | RGBFF_B8G8R8A8) + + /************************************************************************/ + /* Flags for p96AllocBitMap + */ + #define BMF_USERPRIVATE \ + (0x8000) /* private user bitmap that will never \ +be put to a board, but may be used as a temporary render buffer and accessed \ +with OS blit functions, too. Bitmaps allocated with this flag do not need to \ +be locked. */ /************************************************************************/ /* Attributes for p96GetBitMapAttr */ -enum { - P96BMA_WIDTH, - P96BMA_HEIGHT, - P96BMA_DEPTH, - P96BMA_MEMORY, - P96BMA_BYTESPERROW, - P96BMA_BYTESPERPIXEL, - P96BMA_BITSPERPIXEL, - P96BMA_RGBFORMAT, - P96BMA_ISP96, - P96BMA_ISONBOARD, - P96BMA_BOARDMEMBASE, - P96BMA_BOARDIOBASE, - P96BMA_BOARDMEMIOBASE +enum +{ + P96BMA_WIDTH, + P96BMA_HEIGHT, + P96BMA_DEPTH, + P96BMA_MEMORY, + P96BMA_BYTESPERROW, + P96BMA_BYTESPERPIXEL, + P96BMA_BITSPERPIXEL, + P96BMA_RGBFORMAT, + P96BMA_ISP96, + P96BMA_ISONBOARD, + P96BMA_BOARDMEMBASE, + P96BMA_BOARDIOBASE, + P96BMA_BOARDMEMIOBASE }; /************************************************************************/ /* Attributes for p96GetModeIDAttr */ -enum { - P96IDA_WIDTH, - P96IDA_HEIGHT, - P96IDA_DEPTH, - P96IDA_BYTESPERPIXEL, - P96IDA_BITSPERPIXEL, - P96IDA_RGBFORMAT, - P96IDA_ISP96, - P96IDA_BOARDNUMBER, - P96IDA_STDBYTESPERROW, - P96IDA_BOARDNAME, - P96IDA_COMPATIBLEFORMATS, - P96IDA_VIDEOCOMPATIBLE, - P96IDA_PABLOIVCOMPATIBLE, - P96IDA_PALOMAIVCOMPATIBLE +enum +{ + P96IDA_WIDTH, + P96IDA_HEIGHT, + P96IDA_DEPTH, + P96IDA_BYTESPERPIXEL, + P96IDA_BITSPERPIXEL, + P96IDA_RGBFORMAT, + P96IDA_ISP96, + P96IDA_BOARDNUMBER, + P96IDA_STDBYTESPERROW, + P96IDA_BOARDNAME, + P96IDA_COMPATIBLEFORMATS, + P96IDA_VIDEOCOMPATIBLE, + P96IDA_PABLOIVCOMPATIBLE, + P96IDA_PALOMAIVCOMPATIBLE }; -/************************************************************************/ -/* Tags for p96BestModeIDTagList - */ -#define P96BIDTAG_Dummy (TAG_USER + 96) + /************************************************************************/ + /* Tags for p96BestModeIDTagList + */ + #define P96BIDTAG_Dummy (TAG_USER + 96) -#define P96BIDTAG_FormatsAllowed (P96BIDTAG_Dummy + 0x0001) -#define P96BIDTAG_FormatsForbidden (P96BIDTAG_Dummy + 0x0002) -#define P96BIDTAG_NominalWidth (P96BIDTAG_Dummy + 0x0003) -#define P96BIDTAG_NominalHeight (P96BIDTAG_Dummy + 0x0004) -#define P96BIDTAG_Depth (P96BIDTAG_Dummy + 0x0005) -#define P96BIDTAG_VideoCompatible (P96BIDTAG_Dummy + 0x0006) -#define P96BIDTAG_PabloIVCompatible (P96BIDTAG_Dummy + 0x0007) -#define P96BIDTAG_PalomaIVCompatible (P96BIDTAG_Dummy + 0x0008) + #define P96BIDTAG_FormatsAllowed (P96BIDTAG_Dummy + 0x0001) + #define P96BIDTAG_FormatsForbidden (P96BIDTAG_Dummy + 0x0002) + #define P96BIDTAG_NominalWidth (P96BIDTAG_Dummy + 0x0003) + #define P96BIDTAG_NominalHeight (P96BIDTAG_Dummy + 0x0004) + #define P96BIDTAG_Depth (P96BIDTAG_Dummy + 0x0005) + #define P96BIDTAG_VideoCompatible (P96BIDTAG_Dummy + 0x0006) + #define P96BIDTAG_PabloIVCompatible (P96BIDTAG_Dummy + 0x0007) + #define P96BIDTAG_PalomaIVCompatible (P96BIDTAG_Dummy + 0x0008) /************************************************************************/ /* Tags for p96RequestModeIDTagList */ -#define P96MA_Dummy (TAG_USER + 0x10000 + 96) - -#define P96MA_MinWidth (P96MA_Dummy + 0x0001) -#define P96MA_MinHeight (P96MA_Dummy + 0x0002) -#define P96MA_MinDepth (P96MA_Dummy + 0x0003) -#define P96MA_MaxWidth (P96MA_Dummy + 0x0004) -#define P96MA_MaxHeight (P96MA_Dummy + 0x0005) -#define P96MA_MaxDepth (P96MA_Dummy + 0x0006) -#define P96MA_DisplayID (P96MA_Dummy + 0x0007) -#define P96MA_FormatsAllowed (P96MA_Dummy + 0x0008) -#define P96MA_FormatsForbidden (P96MA_Dummy + 0x0009) -#define P96MA_WindowTitle (P96MA_Dummy + 0x000a) -#define P96MA_OKText (P96MA_Dummy + 0x000b) -#define P96MA_CancelText (P96MA_Dummy + 0x000c) -#define P96MA_Window (P96MA_Dummy + 0x000d) -#define P96MA_PubScreenName (P96MA_Dummy + 0x000e) -#define P96MA_Screen (P96MA_Dummy + 0x000f) -#define P96MA_VideoCompatible (P96MA_Dummy + 0x0010) -#define P96MA_PabloIVCompatible (P96MA_Dummy + 0x0011) -#define P96MA_PalomaIVCompatible (P96MA_Dummy + 0x0012) + #define P96MA_Dummy (TAG_USER + 0x10000 + 96) + + #define P96MA_MinWidth (P96MA_Dummy + 0x0001) + #define P96MA_MinHeight (P96MA_Dummy + 0x0002) + #define P96MA_MinDepth (P96MA_Dummy + 0x0003) + #define P96MA_MaxWidth (P96MA_Dummy + 0x0004) + #define P96MA_MaxHeight (P96MA_Dummy + 0x0005) + #define P96MA_MaxDepth (P96MA_Dummy + 0x0006) + #define P96MA_DisplayID (P96MA_Dummy + 0x0007) + #define P96MA_FormatsAllowed (P96MA_Dummy + 0x0008) + #define P96MA_FormatsForbidden (P96MA_Dummy + 0x0009) + #define P96MA_WindowTitle (P96MA_Dummy + 0x000a) + #define P96MA_OKText (P96MA_Dummy + 0x000b) + #define P96MA_CancelText (P96MA_Dummy + 0x000c) + #define P96MA_Window (P96MA_Dummy + 0x000d) + #define P96MA_PubScreenName (P96MA_Dummy + 0x000e) + #define P96MA_Screen (P96MA_Dummy + 0x000f) + #define P96MA_VideoCompatible (P96MA_Dummy + 0x0010) + #define P96MA_PabloIVCompatible (P96MA_Dummy + 0x0011) + #define P96MA_PalomaIVCompatible (P96MA_Dummy + 0x0012) /************************************************************************/ /* Tags for p96OpenScreenTagList */ -#define P96SA_Dummy (TAG_USER + 0x20000 + 96) -#define P96SA_Left (P96SA_Dummy + 0x0001) -#define P96SA_Top (P96SA_Dummy + 0x0002) -#define P96SA_Width (P96SA_Dummy + 0x0003) -#define P96SA_Height (P96SA_Dummy + 0x0004) -#define P96SA_Depth (P96SA_Dummy + 0x0005) -#define P96SA_DetailPen (P96SA_Dummy + 0x0006) -#define P96SA_BlockPen (P96SA_Dummy + 0x0007) -#define P96SA_Title (P96SA_Dummy + 0x0008) -#define P96SA_Colors (P96SA_Dummy + 0x0009) -#define P96SA_ErrorCode (P96SA_Dummy + 0x000a) -#define P96SA_Font (P96SA_Dummy + 0x000b) -#define P96SA_SysFont (P96SA_Dummy + 0x000c) -#define P96SA_Type (P96SA_Dummy + 0x000d) -#define P96SA_BitMap (P96SA_Dummy + 0x000e) -#define P96SA_PubName (P96SA_Dummy + 0x000f) -#define P96SA_PubSig (P96SA_Dummy + 0x0010) -#define P96SA_PubTask (P96SA_Dummy + 0x0011) -#define P96SA_DisplayID (P96SA_Dummy + 0x0012) -#define P96SA_DClip (P96SA_Dummy + 0x0013) -#define P96SA_ShowTitle (P96SA_Dummy + 0x0014) -#define P96SA_Behind (P96SA_Dummy + 0x0015) -#define P96SA_Quiet (P96SA_Dummy + 0x0016) -#define P96SA_AutoScroll (P96SA_Dummy + 0x0017) -#define P96SA_Pens (P96SA_Dummy + 0x0018) -#define P96SA_SharePens (P96SA_Dummy + 0x0019) -#define P96SA_BackFill (P96SA_Dummy + 0x001a) -#define P96SA_Colors32 (P96SA_Dummy + 0x001b) -#define P96SA_VideoControl (P96SA_Dummy + 0x001c) -#define P96SA_RGBFormat (P96SA_Dummy + 0x001d) -#define P96SA_NoSprite (P96SA_Dummy + 0x001e) -#define P96SA_NoMemory (P96SA_Dummy + 0x001f) -#define P96SA_RenderFunc (P96SA_Dummy + 0x0020) -#define P96SA_SaveFunc (P96SA_Dummy + 0x0021) -#define P96SA_UserData (P96SA_Dummy + 0x0022) -#define P96SA_Alignment (P96SA_Dummy + 0x0023) -#define P96SA_FixedScreen (P96SA_Dummy + 0x0024) -#define P96SA_Exclusive (P96SA_Dummy + 0x0025) -#define P96SA_ConstantBytesPerRow (P96SA_Dummy + 0x0026) -#define P96SA_ConstantByteSwapping (P96SA_Dummy + 0x0027) + #define P96SA_Dummy (TAG_USER + 0x20000 + 96) + #define P96SA_Left (P96SA_Dummy + 0x0001) + #define P96SA_Top (P96SA_Dummy + 0x0002) + #define P96SA_Width (P96SA_Dummy + 0x0003) + #define P96SA_Height (P96SA_Dummy + 0x0004) + #define P96SA_Depth (P96SA_Dummy + 0x0005) + #define P96SA_DetailPen (P96SA_Dummy + 0x0006) + #define P96SA_BlockPen (P96SA_Dummy + 0x0007) + #define P96SA_Title (P96SA_Dummy + 0x0008) + #define P96SA_Colors (P96SA_Dummy + 0x0009) + #define P96SA_ErrorCode (P96SA_Dummy + 0x000a) + #define P96SA_Font (P96SA_Dummy + 0x000b) + #define P96SA_SysFont (P96SA_Dummy + 0x000c) + #define P96SA_Type (P96SA_Dummy + 0x000d) + #define P96SA_BitMap (P96SA_Dummy + 0x000e) + #define P96SA_PubName (P96SA_Dummy + 0x000f) + #define P96SA_PubSig (P96SA_Dummy + 0x0010) + #define P96SA_PubTask (P96SA_Dummy + 0x0011) + #define P96SA_DisplayID (P96SA_Dummy + 0x0012) + #define P96SA_DClip (P96SA_Dummy + 0x0013) + #define P96SA_ShowTitle (P96SA_Dummy + 0x0014) + #define P96SA_Behind (P96SA_Dummy + 0x0015) + #define P96SA_Quiet (P96SA_Dummy + 0x0016) + #define P96SA_AutoScroll (P96SA_Dummy + 0x0017) + #define P96SA_Pens (P96SA_Dummy + 0x0018) + #define P96SA_SharePens (P96SA_Dummy + 0x0019) + #define P96SA_BackFill (P96SA_Dummy + 0x001a) + #define P96SA_Colors32 (P96SA_Dummy + 0x001b) + #define P96SA_VideoControl (P96SA_Dummy + 0x001c) + #define P96SA_RGBFormat (P96SA_Dummy + 0x001d) + #define P96SA_NoSprite (P96SA_Dummy + 0x001e) + #define P96SA_NoMemory (P96SA_Dummy + 0x001f) + #define P96SA_RenderFunc (P96SA_Dummy + 0x0020) + #define P96SA_SaveFunc (P96SA_Dummy + 0x0021) + #define P96SA_UserData (P96SA_Dummy + 0x0022) + #define P96SA_Alignment (P96SA_Dummy + 0x0023) + #define P96SA_FixedScreen (P96SA_Dummy + 0x0024) + #define P96SA_Exclusive (P96SA_Dummy + 0x0025) + #define P96SA_ConstantBytesPerRow (P96SA_Dummy + 0x0026) + #define P96SA_ConstantByteSwapping (P96SA_Dummy + 0x0027) /************************************************************************/ -/* +/* */ -#define MODENAMELENGTH 48 + #define MODENAMELENGTH 48 -struct P96Mode { - struct Node Node; - char Description[MODENAMELENGTH]; - UWORD Width; - UWORD Height; - UWORD Depth; - ULONG DisplayID; +struct P96Mode +{ + struct Node Node; + char Description[MODENAMELENGTH]; + UWORD Width; + UWORD Height; + UWORD Depth; + ULONG DisplayID; }; /************************************************************************/ @@ -268,11 +273,12 @@ struct P96Mode { * RGBFormat: RGBFormat of the data. */ -struct RenderInfo { - APTR Memory; - WORD BytesPerRow; - WORD pad; - RGBFTYPE RGBFormat; +struct RenderInfo +{ + APTR Memory; + WORD BytesPerRow; + WORD pad; + RGBFTYPE RGBFormat; }; /************************************************************************/ @@ -297,109 +303,115 @@ struct RenderInfo { * { 4, 640*4, array+1, array+2, array+3 }; */ -struct TrueColorInfo { - ULONG PixelDistance, BytesPerRow; - UBYTE *RedData, *GreenData, *BlueData; +struct TrueColorInfo +{ + ULONG PixelDistance, BytesPerRow; + UBYTE *RedData, *GreenData, *BlueData; }; /************************************************************************/ /* Tags for PIPs */ -#define P96PIP_Dummy (TAG_USER + 0x30000 + 96) -#define P96PIP_SourceFormat (P96PIP_Dummy+1) /* RGBFTYPE (I) */ -#define P96PIP_SourceBitMap (P96PIP_Dummy+2) /* struct BitMap * (G) */ -#define P96PIP_SourceRPort (P96PIP_Dummy+3) /* struct RastPort * (G) */ -#define P96PIP_SourceWidth (P96PIP_Dummy+4) /* ULONG (I) */ -#define P96PIP_SourceHeight (P96PIP_Dummy+5) /* ULONG (I) */ -#define P96PIP_Type (P96PIP_Dummy+6) /* ULONG (I) default: PIPT_MemoryWindow */ -#define P96PIP_ErrorCode (P96PIP_Dummy+7) /* LONG* (I) */ -#define P96PIP_Brightness (P96PIP_Dummy+8) /* ULONG (IGS) default: 0 */ -#define P96PIP_Left (P96PIP_Dummy+9) /* ULONG (I) default: 0 */ -#define P96PIP_Top (P96PIP_Dummy+10) /* ULONG (I) default: 0 */ -#define P96PIP_Width (P96PIP_Dummy+11) /* ULONG (I) default: inner width of window */ -#define P96PIP_Height (P96PIP_Dummy+12) /* ULONG (I) default: inner height of window */ -#define P96PIP_Relativity (P96PIP_Dummy+13) /* ULONG (I) default: PIPRel_Width|PIPRel_Height */ -#define P96PIP_Colors (P96PIP_Dummy+14) /* struct ColorSpec * (IS) - * ti_Data is an array of struct ColorSpec, - * terminated by ColorIndex = -1. Specifies - * initial screen palette colors. - * Also see P96PIP_Colors32. - * This only works with CLUT PIPs on non-CLUT - * screens. For CLUT PIPs on CLUT screens the - * PIP colors share the screen palette. - */ -#define P96PIP_Colors32 (P96PIP_Dummy+15) /* ULONG* (IS) - * Tag to set the palette colors at 32 bits-per-gun. - * ti_Data is a pointer * to a table to be passed to - * the graphics.library/LoadRGB32() function. - * This format supports both runs of color - * registers and sparse registers. See the - * autodoc for that function for full details. - * Any color set here has precedence over - * the same register set by P96PIP_Colors. - * This only works with CLUT PIPs on non-CLUT - * screens. For CLUT PIPs on CLUT screens the - * PIP colors share the screen palette. - */ -#define P96PIP_NoMemory (P96PIP_Dummy+16) -#define P96PIP_RenderFunc (P96PIP_Dummy+17) -#define P96PIP_SaveFunc (P96PIP_Dummy+18) -#define P96PIP_UserData (P96PIP_Dummy+19) -#define P96PIP_Alignment (P96PIP_Dummy+20) -#define P96PIP_ConstantBytesPerRow (P96PIP_Dummy+21) -#define P96PIP_AllowCropping (P96PIP_Dummy+22) -#define P96PIP_InitialIntScaling (P96PIP_Dummy+23) -#define P96PIP_ClipLeft (P96PIP_Dummy+24) /* ULONG (IS) */ -#define P96PIP_ClipTop (P96PIP_Dummy+25) /* ULONG (IS) */ -#define P96PIP_ClipWidth (P96PIP_Dummy+26) /* ULONG (IS) */ -#define P96PIP_ClipHeight (P96PIP_Dummy+27) /* ULONG (IS) */ -#define P96PIP_ConstantByteSwapping (P96PIP_Dummy+28) - -enum { - PIPT_MemoryWindow, /* default */ - PIPT_VideoWindow, - PIPT_NUMTYPES + #define P96PIP_Dummy (TAG_USER + 0x30000 + 96) + #define P96PIP_SourceFormat (P96PIP_Dummy + 1) /* RGBFTYPE (I) */ + #define P96PIP_SourceBitMap (P96PIP_Dummy + 2) /* struct BitMap * (G) */ + #define P96PIP_SourceRPort (P96PIP_Dummy + 3) /* struct RastPort * (G) */ + #define P96PIP_SourceWidth (P96PIP_Dummy + 4) /* ULONG (I) */ + #define P96PIP_SourceHeight (P96PIP_Dummy + 5) /* ULONG (I) */ + #define P96PIP_Type (P96PIP_Dummy + 6) /* ULONG (I) default: PIPT_MemoryWindow */ + #define P96PIP_ErrorCode (P96PIP_Dummy + 7) /* LONG* (I) */ + #define P96PIP_Brightness (P96PIP_Dummy + 8) /* ULONG (IGS) default: 0 */ + #define P96PIP_Left (P96PIP_Dummy + 9) /* ULONG (I) default: 0 */ + #define P96PIP_Top (P96PIP_Dummy + 10) /* ULONG (I) default: 0 */ + #define P96PIP_Width (P96PIP_Dummy + 11) /* ULONG (I) default: inner width of window */ + #define P96PIP_Height (P96PIP_Dummy + 12) /* ULONG (I) default: inner height of window */ + #define P96PIP_Relativity (P96PIP_Dummy + 13) /* ULONG (I) default: PIPRel_Width|PIPRel_Height */ + #define P96PIP_Colors \ + (P96PIP_Dummy + 14) /* struct ColorSpec * (IS) \ + * ti_Data is an array of struct ColorSpec, \ + * terminated by ColorIndex = -1. Specifies \ + * initial screen palette colors. \ + * Also see P96PIP_Colors32. \ + * This only works with CLUT PIPs on non-CLUT \ + * screens. For CLUT PIPs on CLUT screens the \ + * PIP colors share the screen palette. \ + */ + #define P96PIP_Colors32 \ + (P96PIP_Dummy + 15) /* ULONG* (IS) \ + * Tag to set the palette colors at 32 bits-per-gun. \ + * ti_Data is a pointer * to a table to be passed to \ + * the graphics.library/LoadRGB32() function. \ + * This format supports both runs of color \ + * registers and sparse registers. See the \ + * autodoc for that function for full details. \ + * Any color set here has precedence over \ + * the same register set by P96PIP_Colors. \ + * This only works with CLUT PIPs on non-CLUT \ + * screens. For CLUT PIPs on CLUT screens the \ + * PIP colors share the screen palette. \ + */ + #define P96PIP_NoMemory (P96PIP_Dummy + 16) + #define P96PIP_RenderFunc (P96PIP_Dummy + 17) + #define P96PIP_SaveFunc (P96PIP_Dummy + 18) + #define P96PIP_UserData (P96PIP_Dummy + 19) + #define P96PIP_Alignment (P96PIP_Dummy + 20) + #define P96PIP_ConstantBytesPerRow (P96PIP_Dummy + 21) + #define P96PIP_AllowCropping (P96PIP_Dummy + 22) + #define P96PIP_InitialIntScaling (P96PIP_Dummy + 23) + #define P96PIP_ClipLeft (P96PIP_Dummy + 24) /* ULONG (IS) */ + #define P96PIP_ClipTop (P96PIP_Dummy + 25) /* ULONG (IS) */ + #define P96PIP_ClipWidth (P96PIP_Dummy + 26) /* ULONG (IS) */ + #define P96PIP_ClipHeight (P96PIP_Dummy + 27) /* ULONG (IS) */ + #define P96PIP_ConstantByteSwapping (P96PIP_Dummy + 28) + +enum +{ + PIPT_MemoryWindow, /* default */ + PIPT_VideoWindow, + PIPT_NUMTYPES }; -#define P96PIPT_MemoryWindow PIPT_MemoryWindow -#define P96PIPT_VideoWindow PIPT_VideoWindow - -#define PIPRel_Right 1 /* P96PIP_Left is relative to the right side (negative value) */ -#define PIPRel_Bottom 2 /* P96PIP_Top is relative to the bottom (negative value) */ -#define PIPRel_Width 4 /* P96PIP_Width is amount of pixels not used by PIP at the - right side of the window (negative value) */ -#define PIPRel_Height 8 /* P96PIP_Height is amount of pixels not used by PIP at the - window bottom (negative value) */ - -#define PIPERR_NOMEMORY (1) /* couldn't get normal memory */ -#define PIPERR_ATTACHFAIL (2) /* Failed to attach to a screen */ -#define PIPERR_NOTAVAILABLE (3) /* PIP not available for other reason */ -#define PIPERR_OUTOFPENS (4) /* couldn't get a free pen for occlusion */ -#define PIPERR_BADDIMENSIONS (5) /* type, width, height or format invalid */ -#define PIPERR_NOWINDOW (6) /* couldn't open window */ -#define PIPERR_BADALIGNMENT (7) /* specified alignment is not ok */ -#define PIPERR_CROPPED (8) /* pip would be cropped, but isn't allowed to */ -/************************************************************************/ -/* Tags for P96GetRTGDataTagList - */ - -#define P96RD_Dummy (TAG_USER + 0x40000 + 96) -#define P96RD_NumberOfBoards (P96RD_Dummy+1) + #define P96PIPT_MemoryWindow PIPT_MemoryWindow + #define P96PIPT_VideoWindow PIPT_VideoWindow + + #define PIPRel_Right 1 /* P96PIP_Left is relative to the right side (negative value) */ + #define PIPRel_Bottom 2 /* P96PIP_Top is relative to the bottom (negative value) */ + #define PIPRel_Width \ + 4 /* P96PIP_Width is amount of pixels not used by PIP at the \ + right side of the window (negative value) */ + #define PIPRel_Height \ + 8 /* P96PIP_Height is amount of pixels not used by PIP at the \ + window bottom (negative value) */ + + #define PIPERR_NOMEMORY (1) /* couldn't get normal memory */ + #define PIPERR_ATTACHFAIL (2) /* Failed to attach to a screen */ + #define PIPERR_NOTAVAILABLE (3) /* PIP not available for other reason */ + #define PIPERR_OUTOFPENS (4) /* couldn't get a free pen for occlusion */ + #define PIPERR_BADDIMENSIONS (5) /* type, width, height or format invalid */ + #define PIPERR_NOWINDOW (6) /* couldn't open window */ + #define PIPERR_BADALIGNMENT (7) /* specified alignment is not ok */ + #define PIPERR_CROPPED (8) /* pip would be cropped, but isn't allowed to */ + /************************************************************************/ + /* Tags for P96GetRTGDataTagList + */ + + #define P96RD_Dummy (TAG_USER + 0x40000 + 96) + #define P96RD_NumberOfBoards (P96RD_Dummy + 1) /************************************************************************/ /* Tags for P96GetBoardDataTagList */ -#define P96BD_Dummy (TAG_USER + 0x50000 + 96) -#define P96BD_BoardName (P96BD_Dummy+1) -#define P96BD_ChipName (P96BD_Dummy+2) -#define P96BD_TotalMemory (P96BD_Dummy+4) -#define P96BD_FreeMemory (P96BD_Dummy+5) -#define P96BD_LargestFreeMemory (P96BD_Dummy+6) -#define P96BD_MonitorSwitch (P96BD_Dummy+7) -#define P96BD_RGBFormats (P96BD_Dummy+8) -#define P96BD_MemoryClock (P96BD_Dummy+9) + #define P96BD_Dummy (TAG_USER + 0x50000 + 96) + #define P96BD_BoardName (P96BD_Dummy + 1) + #define P96BD_ChipName (P96BD_Dummy + 2) + #define P96BD_TotalMemory (P96BD_Dummy + 4) + #define P96BD_FreeMemory (P96BD_Dummy + 5) + #define P96BD_LargestFreeMemory (P96BD_Dummy + 6) + #define P96BD_MonitorSwitch (P96BD_Dummy + 7) + #define P96BD_RGBFormats (P96BD_Dummy + 8) + #define P96BD_MemoryClock (P96BD_Dummy + 9) /************************************************************************/ #endif diff --git a/PrometheusCard/proto/.clang-format b/PrometheusCard/proto/.clang-format new file mode 100644 index 0000000..57af94e --- /dev/null +++ b/PrometheusCard/proto/.clang-format @@ -0,0 +1,4 @@ +{ + "DisableFormat": "true", + "SortIncludes": "false" +} diff --git a/PrometheusCard/settings.h b/PrometheusCard/settings.h old mode 100755 new mode 100644 index 253b8b2..731531d --- a/PrometheusCard/settings.h +++ b/PrometheusCard/settings.h @@ -3,63 +3,68 @@ /************************************************************************/ -enum{ - PLANAR, - CHUNKY, - HICOLOR, - TRUECOLOR, - TRUEALPHA, - MAXMODES +enum +{ + PLANAR, + CHUNKY, + HICOLOR, + TRUECOLOR, + TRUEALPHA, + MAXMODES }; /************************************************************************/ -#define SETTINGSNAMEMAXCHARS 30 -#define BOARDNAMEMAXCHARS 30 +#define SETTINGSNAMEMAXCHARS 30 +#define BOARDNAMEMAXCHARS 30 struct P96MonitorInfo { - UBYTE Name[32]; // Name des Monitortyps, z.B. "NEC P750" + UBYTE Name[32]; // Name des Monitortyps, z.B. "NEC P750" - ULONG HSyncMin; // Minimal unterstützte Horizontalfrequenz in Hz - ULONG HSyncMax; // Maximal unterstützte Horizontalfrequenz in Hz + ULONG HSyncMin; // Minimal unterstützte Horizontalfrequenz in Hz + ULONG HSyncMax; // Maximal unterstützte Horizontalfrequenz in Hz - UWORD VSyncMin; // Minimal unterstützte Vertikalfrequenz in Hz - UWORD VSyncMax; // Maximal unterstützte Vertikalfrequenz in Hz + UWORD VSyncMin; // Minimal unterstützte Vertikalfrequenz in Hz + UWORD VSyncMax; // Maximal unterstützte Vertikalfrequenz in Hz - ULONG Flags; // Siehe unten + ULONG Flags; // Siehe unten }; -#define MIB_DPMS_StandBy (0) // Monitor unterstützt DPMS-Level "stand-by". - // Dieses Feature ist optional, nicht jeder - // DPMS-fähige Monitor muß es unterstützen. - // Aktivierung: hsync aus, vsync an - -#define MIB_DPMS_Suspend (1) // Monitor unterstützt DPMS-Level "suspend". - // Dieses Feature ist Pflicht, jeder - // DPMS-fähige Monitor muß es unterstützen. - // Aktivierung: hsync an, vsync aus - -#define MIB_DPMS_ActiveOff (2) // Monitor unterstützt DPMS-Level "active off". - // Dieses Feature ist Pflicht, jeder - // DPMS-fähige Monitor muß es unterstützen. - // Aktivierung: hsync aus, vsync aus - -#define MIF_DPMS_StandBy (1UL << MIB_DPMS_StandBy) -#define MIF_DPMS_Suspend (1UL << MIB_DPMS_Suspend) -#define MIF_DPMS_ActiveOff (1UL << MIB_DPMS_ActiveOff) - -struct Settings{ - struct Node Node; - struct MinList Resolutions; - ULONG BoardType; -// a value discribing assignment to nth board local to boardtype -// to be used for reassignment when boards are added or removed. - UWORD LocalOrdering; - WORD LastSelected; - char NameField[SETTINGSNAMEMAXCHARS]; - char *BoardName; - struct P96MonitorInfo *MonitorInfo; +#define MIB_DPMS_StandBy \ + (0) // Monitor unterstützt DPMS-Level "stand-by". + // Dieses Feature ist optional, nicht jeder + // DPMS-fähige Monitor muß es unterstützen. + // Aktivierung: hsync aus, vsync an + +#define MIB_DPMS_Suspend \ + (1) // Monitor unterstützt DPMS-Level "suspend". + // Dieses Feature ist Pflicht, jeder + // DPMS-fähige Monitor muß es unterstützen. + // Aktivierung: hsync an, vsync aus + +#define MIB_DPMS_ActiveOff \ + (2) // Monitor unterstützt DPMS-Level "active off". + // Dieses Feature ist Pflicht, jeder + // DPMS-fähige Monitor muß es unterstützen. + // Aktivierung: hsync aus, vsync aus + +#define MIF_DPMS_StandBy (1UL << MIB_DPMS_StandBy) +#define MIF_DPMS_Suspend (1UL << MIB_DPMS_Suspend) +#define MIF_DPMS_ActiveOff (1UL << MIB_DPMS_ActiveOff) + +struct Settings +{ + struct Node Node; + struct MinList Resolutions; + ULONG BoardType; + // a value discribing assignment to nth board local to boardtype + // to be used for reassignment when boards are added or removed. + UWORD LocalOrdering; + WORD LastSelected; + char NameField[SETTINGSNAMEMAXCHARS]; + char * BoardName; + struct P96MonitorInfo *MonitorInfo; }; #define MAXRESOLUTIONNAMELENGTH 22 @@ -67,118 +72,122 @@ struct Settings{ /******************************** * only used within rtg.library * ********************************/ -struct LibResolution{ - struct Node Node; - char P96ID[6]; - char Name[MAXRESOLUTIONNAMELENGTH]; - ULONG DisplayID; - UWORD Width; - UWORD Height; - UWORD Flags; - struct ModeInfo *Modes[MAXMODES]; - struct BoardInfo *BoardInfo; - struct LibResolution *HashChain; +struct LibResolution +{ + struct Node Node; + char P96ID[6]; + char Name[MAXRESOLUTIONNAMELENGTH]; + ULONG DisplayID; + UWORD Width; + UWORD Height; + UWORD Flags; + struct ModeInfo * Modes[MAXMODES]; + struct BoardInfo * BoardInfo; + struct LibResolution *HashChain; }; /***************************** * only used within MoniTool * *****************************/ -struct Resolution{ - struct Node Node; - struct MinList ModeInfos; - ULONG DisplayID; - UWORD Width; - UWORD Height; - BOOL Active; - WORD LastSelected; - UWORD Flags; - char Name[MAXRESOLUTIONNAMELENGTH]; +struct Resolution +{ + struct Node Node; + struct MinList ModeInfos; + ULONG DisplayID; + UWORD Width; + UWORD Height; + BOOL Active; + WORD LastSelected; + UWORD Flags; + char Name[MAXRESOLUTIONNAMELENGTH]; }; -#define P96B_FAMILY 0 // obsolete (Resolution is an entire family) -#define P96B_PUBLIC 1 // Resolution should be added to the public -#define P96B_MONITOOL 2 +#define P96B_FAMILY 0 // obsolete (Resolution is an entire family) +#define P96B_PUBLIC 1 // Resolution should be added to the public +#define P96B_MONITOOL 2 -#define P96B_CHECKME 15 // Resolution has been attached to another board - // by AttachSettings without being checked against - // hardware limits +#define P96B_CHECKME \ + 15 // Resolution has been attached to another board + // by AttachSettings without being checked against + // hardware limits -#define P96F_FAMILY (1< -#include -#include -#include -#include +#include +#include #include -#include #include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include #include "card.h" /*--- Functions prototypes -------------------------------------------------*/ -struct CardBase *LibOpen (__REGA6(struct CardBase *cb)); -LONG LibClose (__REGA6(struct CardBase *cb)); -APTR LibExpunge (__REGA6(struct CardBase *cb)); -LONG LibReserved (void); -struct CardBase *LibInit (__REGD0(struct CardBase* cb), __REGA0(APTR seglist), __REGA6(struct Library *sysb)); +struct CardBase *LibOpen(__REGA6(struct CardBase *cb)); +LONG LibClose(__REGA6(struct CardBase *cb)); +APTR LibExpunge(__REGA6(struct CardBase *cb)); +LONG LibReserved(void); +struct CardBase *LibInit(__REGD0(struct CardBase *cb), __REGA0(APTR seglist), __REGA6(struct Library *sysb)); #define VERSION 7 #define REVISION 601 @@ -39,14 +38,14 @@ int main(void) } #ifdef DEBUG -#define __DBG__ "debug " -APTR __DRawPutChar(__reg("a6") void *, __reg("d0") UBYTE MyChar)="\tjsr\t-516(a6)"; + #define __DBG__ "debug " +APTR __DRawPutChar(__reg("a6") void *, __reg("d0") UBYTE MyChar) = "\tjsr\t-516(a6)"; -#define DRawPutChar(MyChar) __DRawPutChar(SysBase, (MyChar)) + #define DRawPutChar(MyChar) __DRawPutChar(SysBase, (MyChar)) void DPutChProc(__reg("d0") UBYTE mychar, __reg("a3") APTR PutChData) { - struct ExecBase* SysBase = (struct ExecBase*)PutChData; + struct ExecBase *SysBase = (struct ExecBase *)PutChData; DRawPutChar(mychar); return; } @@ -55,8 +54,8 @@ void kprintf(STRPTR format, ...) { if (format) { - struct ExecBase* SysBase = *(struct ExecBase **)4L; - va_list args; + struct ExecBase *SysBase = *(struct ExecBase **)4L; + va_list args; va_start(args, format); RawDoFmt(format, (APTR)args, &DPutChProc, (APTR)SysBase); va_end(args); @@ -64,123 +63,125 @@ void kprintf(STRPTR format, ...) return; } #else -#define __DBG__ + #define __DBG__ #endif - char libid[] = "\0$VER: Prometheus.card 7.601 " __DBG__ "(10.05.2023)\r\n"; char libname[] = "Prometheus.card\0"; -char build[] = "build date: " __DATE__ ", " __TIME__ "\n"; - +char build[] = "build date: " __DATE__ ", " __TIME__ "\n"; /*--------------------------------------------------------------------------*/ -void *FuncTable[] = - { - (APTR)LibOpen, - (APTR)LibClose, - (APTR)LibExpunge, - (APTR)LibReserved, - (APTR)FindCard, - (APTR)InitCard, - (APTR)AllocDMAMemory, - (APTR)FreeDMAMemory, - (APTR)-1 - }; - -struct MyDataInit /* do not change */ -{ - UWORD ln_Type_Init; UWORD ln_Type_Offset; UWORD ln_Type_Content; - UBYTE ln_Name_Init; UBYTE ln_Name_Offset; ULONG ln_Name_Content; - UWORD lib_Flags_Init; UWORD lib_Flags_Offset; UWORD lib_Flags_Content; - UWORD lib_Version_Init; UWORD lib_Version_Offset; UWORD lib_Version_Content; - UWORD lib_Revision_Init; UWORD lib_Revision_Offset; UWORD lib_Revision_Content; - UBYTE lib_IdString_Init; UBYTE lib_IdString_Offset; ULONG lib_IdString_Content; - ULONG ENDMARK; -} DataTab = -{ - 0xe000,8,NT_LIBRARY, - 0x0080,10,(ULONG) &libname[0], - 0xe000,14,LIBF_SUMUSED|LIBF_CHANGED, - 0xd000,20,VERSION, - 0xd000,22,REVISION, - 0x80,24,(ULONG) &libid[0], - (ULONG) 0 -}; - -struct InitTable /* do not change */ +void *FuncTable[] = {(APTR)LibOpen, + (APTR)LibClose, + (APTR)LibExpunge, + (APTR)LibReserved, + (APTR)FindCard, + (APTR)InitCard, + (APTR)AllocDMAMemory, + (APTR)FreeDMAMemory, + (APTR)-1}; + +struct MyDataInit /* do not change */ { - ULONG LibBaseSize; - APTR *FunctionTable; - struct MyDataInit *DataTable; - APTR InitLibTable; -} InitTab = + UWORD ln_Type_Init; + UWORD ln_Type_Offset; + UWORD ln_Type_Content; + UBYTE ln_Name_Init; + UBYTE ln_Name_Offset; + ULONG ln_Name_Content; + UWORD lib_Flags_Init; + UWORD lib_Flags_Offset; + UWORD lib_Flags_Content; + UWORD lib_Version_Init; + UWORD lib_Version_Offset; + UWORD lib_Version_Content; + UWORD lib_Revision_Init; + UWORD lib_Revision_Offset; + UWORD lib_Revision_Content; + UBYTE lib_IdString_Init; + UBYTE lib_IdString_Offset; + ULONG lib_IdString_Content; + ULONG ENDMARK; +} DataTab = {0xe000, + 8, + NT_LIBRARY, + 0x0080, + 10, + (ULONG)&libname[0], + 0xe000, + 14, + LIBF_SUMUSED | LIBF_CHANGED, + 0xd000, + 20, + VERSION, + 0xd000, + 22, + REVISION, + 0x80, + 24, + (ULONG)&libid[0], + (ULONG)0}; + +struct InitTable /* do not change */ { - (ULONG) sizeof(struct CardBase), - (APTR *) &FuncTable[0], - (struct MyDataInit *) &DataTab, - (APTR) LibInit -}; - + ULONG LibBaseSize; + APTR * FunctionTable; + struct MyDataInit *DataTable; + APTR InitLibTable; +} InitTab = {(ULONG)sizeof(struct CardBase), (APTR *)&FuncTable[0], (struct MyDataInit *)&DataTab, (APTR)LibInit}; /* ------------------- ROM Tag ------------------------ */ - -const struct Resident ROMTag = /* do not change */ -{ - RTC_MATCHWORD, - (APTR)&ROMTag, - &ROMTag.rt_Init + 1, - RTF_AUTOINIT, - VERSION, - NT_LIBRARY, - 0, - &libname[0], - &libid[0], - &InitTab -}; +const struct Resident ROMTag = /* do not change */ + {RTC_MATCHWORD, + (APTR)&ROMTag, + &ROMTag.rt_Init + 1, + RTF_AUTOINIT, + VERSION, + NT_LIBRARY, + 0, + &libname[0], + &libid[0], + &InitTab}; /*-------------------------------------------------------------------------*/ /* Init all library resources. Called from LibOpen() if open counter is 0 */ - static BOOL init_resources(struct CardBase *cb) - { - struct Library* SysBase = cb->cb_SysBase; +{ + struct Library * SysBase = cb->cb_SysBase; struct ConfigDev *cd; - struct Library *ExpansionBase; + struct Library * ExpansionBase; - if (!(cb->cb_PrometheusBase = OpenLibrary("prometheus.library", 2))) - return FALSE; - if (!(cb->cb_ExpansionBase = OpenLibrary("expansion.library", 39))) - return FALSE; + if (!(cb->cb_PrometheusBase = OpenLibrary("prometheus.library", 2))) return FALSE; + if (!(cb->cb_ExpansionBase = OpenLibrary("expansion.library", 39))) return FALSE; /* determining IO legacy address (first 64 kB of Prometheus addr space) */ ExpansionBase = cb->cb_ExpansionBase; if (cd = FindConfigDev(NULL, VENDOR_MATAY, DEVICE_PROMETHEUS)) - cb->cb_LegacyIOBase = cd->cd_BoardAddr; + cb->cb_LegacyIOBase = cd->cd_BoardAddr; else if (cd = FindConfigDev(NULL, VENDOR_E3B, DEVICE_FIRESTORM)) - cb->cb_LegacyIOBase = (APTR)((ULONG)cd->cd_BoardAddr + 0x1fe00000); - else return FALSE; + cb->cb_LegacyIOBase = (APTR)((ULONG)cd->cd_BoardAddr + 0x1fe00000); + else + return FALSE; /* creating memory pool */ - if (!(cb->cb_MemPool = CreatePool(MEMF_CLEAR | MEMF_PUBLIC, 1024, 512))) - return FALSE; + if (!(cb->cb_MemPool = CreatePool(MEMF_CLEAR | MEMF_PUBLIC, 1024, 512))) return FALSE; /* setting up memory list semaphore */ - if (!(cb->cb_MemSem = AllocPooled(cb->cb_MemPool, - sizeof(struct SignalSemaphore)))) return FALSE; + if (!(cb->cb_MemSem = AllocPooled(cb->cb_MemPool, sizeof(struct SignalSemaphore)))) return FALSE; -// NewList((struct List*)&cb->cb_MemList); + // NewList((struct List*)&cb->cb_MemList); InitSemaphore(cb->cb_MemSem); return TRUE; - } +} /*-------------------------------------------------------------------------*/ /* Free all library resources. Called: */ @@ -188,11 +189,11 @@ static BOOL init_resources(struct CardBase *cb) /* 2. From init_resources if any resource failed. */ static void free_resources(struct CardBase *cb) - { - struct Library* SysBase = cb->cb_SysBase; +{ + struct Library *SysBase = cb->cb_SysBase; if (cb->cb_MemSem) - { + { APTR sm = cb->cb_MemSem; Forbid(); @@ -201,29 +202,29 @@ static void free_resources(struct CardBase *cb) cb->cb_MemSem = NULL; Permit(); FreePooled(cb->cb_MemPool, sm, sizeof(struct SignalSemaphore)); - } + } if (cb->cb_MemPool) DeletePool(cb->cb_MemPool); - if (cb->cb_PrometheusBase) CloseLibrary (cb->cb_PrometheusBase); - if (cb->cb_ExpansionBase) CloseLibrary (cb->cb_ExpansionBase); + if (cb->cb_PrometheusBase) CloseLibrary(cb->cb_PrometheusBase); + if (cb->cb_ExpansionBase) CloseLibrary(cb->cb_ExpansionBase); return; - } +} /*-------------------------------------------------------------------------*/ /* INIT */ /*-------------------------------------------------------------------------*/ -struct CardBase *LibInit (__REGD0(struct CardBase* cb), __REGA0(APTR seglist), __REGA6(struct Library *sysb)) - { - struct ExecBase *SysBase = (struct ExecBase*)sysb; +struct CardBase *LibInit(__REGD0(struct CardBase *cb), __REGA0(APTR seglist), __REGA6(struct Library *sysb)) +{ + struct ExecBase *SysBase = (struct ExecBase *)sysb; D(kprintf("prometheus.card: LibInit()\n")); if (!(SysBase->AttnFlags & AFF_68020)) - { - FreeMem ((APTR)((ULONG)cb - (ULONG)cb->cb_Library.lib_NegSize), - (LONG)cb->cb_Library.lib_PosSize + (LONG)cb->cb_Library.lib_NegSize); + { + FreeMem((APTR)((ULONG)cb - (ULONG)cb->cb_Library.lib_NegSize), + (LONG)cb->cb_Library.lib_PosSize + (LONG)cb->cb_Library.lib_NegSize); return FALSE; - } + } cb->cb_SysBase = sysb; cb->cb_ExpansionBase = NULL; cb->cb_SegList = seglist; @@ -233,72 +234,70 @@ struct CardBase *LibInit (__REGD0(struct CardBase* cb), __REGA0(APTR seglist), _ cb->cb_MemPool = NULL; return cb; - } - +} /*-------------------------------------------------------------------------*/ /* OPEN */ /*-------------------------------------------------------------------------*/ -struct CardBase *LibOpen (__REGA6(struct CardBase *cb)) - { - struct CardBase *ret = cb; - BOOL open = TRUE; +struct CardBase *LibOpen(__REGA6(struct CardBase *cb)) +{ + struct CardBase *ret = cb; + BOOL open = TRUE; - if (cb->cb_Library.lib_OpenCnt == 0) open = init_resources(cb); + if (cb->cb_Library.lib_OpenCnt == 0) open = init_resources(cb); - if (open) + if (open) { - cb->cb_Library.lib_OpenCnt++; - cb->cb_Library.lib_Flags &= ~LIBF_DELEXP; + cb->cb_Library.lib_OpenCnt++; + cb->cb_Library.lib_Flags &= ~LIBF_DELEXP; - return cb; + return cb; } - free_resources(cb); - return NULL; - } + free_resources(cb); + return NULL; +} /*-------------------------------------------------------------------------*/ /* CLOSE */ /*-------------------------------------------------------------------------*/ -long LibClose (__REGA6(struct CardBase *cb)) - { - if (!(--cb->cb_Library.lib_OpenCnt)) - { - if (cb->cb_Library.lib_Flags & LIBF_DELEXP) return ((long)LibExpunge (cb)); - } - return 0; - } +long LibClose(__REGA6(struct CardBase *cb)) +{ + if (!(--cb->cb_Library.lib_OpenCnt)) + { + if (cb->cb_Library.lib_Flags & LIBF_DELEXP) return ((long)LibExpunge(cb)); + } + return 0; +} /*-------------------------------------------------------------------------*/ /* EXPUNGE */ /*-------------------------------------------------------------------------*/ -void *LibExpunge (__REGA6(struct CardBase *cb)) - { - APTR seglist; - struct Library* SysBase = cb->cb_SysBase; +void *LibExpunge(__REGA6(struct CardBase *cb)) +{ + APTR seglist; + struct Library *SysBase = cb->cb_SysBase; - if (cb->cb_Library.lib_OpenCnt) - { - cb->cb_Library.lib_Flags |= LIBF_DELEXP; - return 0; - } - Remove ((struct Node*)cb); - free_resources(cb); - seglist = cb->cb_SegList; - FreeMem ((APTR)((ULONG)cb - (ULONG)cb->cb_Library.lib_NegSize), - (LONG)cb->cb_Library.lib_PosSize + (LONG)cb->cb_Library.lib_NegSize); - return seglist; - } + if (cb->cb_Library.lib_OpenCnt) + { + cb->cb_Library.lib_Flags |= LIBF_DELEXP; + return 0; + } + Remove((struct Node *)cb); + free_resources(cb); + seglist = cb->cb_SegList; + FreeMem((APTR)((ULONG)cb - (ULONG)cb->cb_Library.lib_NegSize), + (LONG)cb->cb_Library.lib_PosSize + (LONG)cb->cb_Library.lib_NegSize); + return seglist; +} /*-------------------------------------------------------------------------*/ /* RESERVED */ /*-------------------------------------------------------------------------*/ -long LibReserved (void) - { - return 0; - } - +long LibReserved(void) +{ + return 0; +} diff --git a/_clang-format b/_clang-format new file mode 100755 index 0000000..9623f0e --- /dev/null +++ b/_clang-format @@ -0,0 +1,147 @@ +--- +Language: Cpp +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveMacros: true +AlignConsecutiveAssignments: true +AlignConsecutiveBitFields: false +AlignConsecutiveDeclarations: true +AlignEscapedNewlines: Left +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortEnumsOnASingleLine: true +AllowShortBlocksOnASingleLine: Never +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Inline +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterCaseLabel: false + AfterClass: true + AfterControlStatement: Always + AfterEnum: true + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: true + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DeriveLineEnding: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + - Regex: '.*' + Priority: 1 + SortPriority: 0 +IncludeIsMainRegex: '(Test)?$' +IncludeIsMainSourceRegex: '' +IndentCaseLabels: false +IndentCaseBlocks: false +IndentGotoLabels: true +IndentPPDirectives: BeforeHash +IndentExternBlock: AfterExternBlock +IndentWidth: 4 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeSquareBrackets: false +Standard: Auto +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 4 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE +... diff --git a/ne2000/driver.c b/ne2000/driver.c old mode 100755 new mode 100644 index 92b7b95..9ce78a4 --- a/ne2000/driver.c +++ b/ne2000/driver.c @@ -4,43 +4,43 @@ #define __NOLIBBASE__ +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include #include #include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include "rev.h" -#include "ne2000.h" #include "endian.h" +#include "ne2000.h" +#include "rev.h" -#define OK 0 +#define OK 0 -#define TX_BUFFER 0x40 -#define RX_BUFFER 0x46 -#define BUFFER_END 0x80 -#define INTMASK (INT_RXPACKET | INT_TXPACKET | INT_TXERROR) +#define TX_BUFFER 0x40 +#define RX_BUFFER 0x46 +#define BUFFER_END 0x80 +#define INTMASK (INT_RXPACKET | INT_TXPACKET | INT_TXERROR) /* PCI card ID's */ -#define PCI_VENDOR_REALTEK 0x10EC -#define PCI_DEVICE_RTL8029 0x8029 +#define PCI_VENDOR_REALTEK 0x10EC +#define PCI_DEVICE_RTL8029 0x8029 // Unit flags. -#define UF_CONFIGURED 0x01 -#define UF_ONLINE 0x02 -#define UF_PROMISCUOUS 0x04 +#define UF_CONFIGURED 0x01 +#define UF_ONLINE 0x02 +#define UF_PROMISCUOUS 0x04 // Macro for registerized parameters (used in some OS functions). @@ -48,7 +48,7 @@ // Macro for declaring local libraries bases. -#define USE(a) struct Library *##a = dd->dd_##a; +#define USE(a) struct Library *##a = dd->dd_##a; #define USE_U(a) struct Library *##a = ud->ud_##a; // Debug on/off switch (debug off if commented). @@ -58,104 +58,103 @@ // Macros for debug messages. #ifdef PDEBUG - #define USE_D(a) struct Library *##a = dd->dd_##a; - #define USE_UD(a) struct Library *##a = ud->ud_##a; - #define DBG(a) FPrintf(dd->debug, a "\n") - #define DBG_U(a) FPrintf(ud->debug, a "\n") - #define DBG_T(a) FPrintf(ud->tdebug, a "\n") - #define DBG1(a,b) FPrintf(dd->debug, a "\n",(LONG)b) - #define DBG1_U(a,b) FPrintf(ud->debug, a "\n",(LONG)b) - #define DBG1_T(a,b) FPrintf(ud->tdebug, a "\n",(LONG)b) - #define DBG2(a,b,c) FPrintf(dd->debug, a "\n",(LONG)b,(LONG)c) - #define DBG2_U(a,b,c) FPrintf(ud->debug, a "\n",(LONG)b,(LONG)c) - #define DBG2_T(a,b,c) FPrintf(ud->tdebug, a "\n",(LONG)b,(LONG)c) + #define USE_D(a) struct Library *##a = dd->dd_##a; + #define USE_UD(a) struct Library *##a = ud->ud_##a; + #define DBG(a) FPrintf(dd->debug, a "\n") + #define DBG_U(a) FPrintf(ud->debug, a "\n") + #define DBG_T(a) FPrintf(ud->tdebug, a "\n") + #define DBG1(a, b) FPrintf(dd->debug, a "\n", (LONG)b) + #define DBG1_U(a, b) FPrintf(ud->debug, a "\n", (LONG)b) + #define DBG1_T(a, b) FPrintf(ud->tdebug, a "\n", (LONG)b) + #define DBG2(a, b, c) FPrintf(dd->debug, a "\n", (LONG)b, (LONG)c) + #define DBG2_U(a, b, c) FPrintf(ud->debug, a "\n", (LONG)b, (LONG)c) + #define DBG2_T(a, b, c) FPrintf(ud->tdebug, a "\n", (LONG)b, (LONG)c) #else - #define USE_D(a) - #define USE_UD(a) - #define DBG(a) - #define DBG_U(a) - #define DBG_T(a) - #define DBG1(a,b) - #define DBG1_U(a,b) - #define DBG1_T(a,b) - #define DBG2(a,b,c) - #define DBG2_U(a,b,c) - #define DBG2_T(a,b,c) + #define USE_D(a) + #define USE_UD(a) + #define DBG(a) + #define DBG_U(a) + #define DBG_T(a) + #define DBG1(a, b) + #define DBG1_U(a, b) + #define DBG1_T(a, b) + #define DBG2(a, b, c) + #define DBG2_U(a, b, c) + #define DBG2_T(a, b, c) #endif // New Style Device support -#define NSCMD_DEVICEQUERY 0x4000 +#define NSCMD_DEVICEQUERY 0x4000 struct NSDeviceQueryResult - { - ULONG DevQueryFormat; /* this is type 0 */ - ULONG SizeAvailable; /* bytes available */ - UWORD DeviceType; /* what the device does */ - UWORD DeviceSubType; /* depends on the main type */ - UWORD *SupportedCommands; /* 0 terminated list of cmd's */ - }; +{ + ULONG DevQueryFormat; /* this is type 0 */ + ULONG SizeAvailable; /* bytes available */ + UWORD DeviceType; /* what the device does */ + UWORD DeviceSubType; /* depends on the main type */ + UWORD *SupportedCommands; /* 0 terminated list of cmd's */ +}; -#define NSDEVTYPE_SANA2 7 /* A >=SANA2R2 networking device */ +#define NSDEVTYPE_SANA2 7 /* A >=SANA2R2 networking device */ /// /// device structures struct DevData - { - struct Library dd_Lib; - APTR dd_SegList; - struct Library *dd_SysBase; - struct Library *dd_PrometheusBase; - struct Library *dd_UtilityBase; - struct Library *dd_DOSBase; - struct Library *dd_TimerBase; - struct UnitData *dd_Units[4]; - struct timerequest dd_Treq; - - - #ifdef PDEBUG - BPTR debug; - UBYTE dpath[128]; - #endif - }; +{ + struct Library dd_Lib; + APTR dd_SegList; + struct Library * dd_SysBase; + struct Library * dd_PrometheusBase; + struct Library * dd_UtilityBase; + struct Library * dd_DOSBase; + struct Library * dd_TimerBase; + struct UnitData * dd_Units[4]; + struct timerequest dd_Treq; + +#ifdef PDEBUG + BPTR debug; + UBYTE dpath[128]; +#endif +}; struct UnitData - { - struct Message ud_Message; - volatile struct Ne2000 *ud_Hardware; - struct Library *ud_SysBase; - struct Library *ud_DOSBase; - struct Library *ud_TimerBase; - struct Interrupt *ud_Interrupt; - struct Task *ud_Task; - struct MsgPort *ud_TaskPort; - struct MsgPort *ud_LifeTime; - struct MinList ud_RxQueue; - struct MinList ud_TxQueue; - struct IOSana2Req *ud_PendingWrite; - ULONG ud_OpenCnt; - ULONG ud_GoWriteMask; - UWORD ud_RxBuffer[768]; - UBYTE ud_Name[24]; - UBYTE ud_EtherAddress[6]; - UBYTE ud_SoftAddress[6]; - struct Sana2DeviceStats ud_DevStats; - UBYTE ud_Flags; - UBYTE ud_NextPage; - BYTE ud_GoWriteBit; - UBYTE pad; - #ifdef PDEBUG - BPTR debug; - BPTR tdebug; - #endif - }; +{ + struct Message ud_Message; + volatile struct Ne2000 *ud_Hardware; + struct Library * ud_SysBase; + struct Library * ud_DOSBase; + struct Library * ud_TimerBase; + struct Interrupt * ud_Interrupt; + struct Task * ud_Task; + struct MsgPort * ud_TaskPort; + struct MsgPort * ud_LifeTime; + struct MinList ud_RxQueue; + struct MinList ud_TxQueue; + struct IOSana2Req * ud_PendingWrite; + ULONG ud_OpenCnt; + ULONG ud_GoWriteMask; + UWORD ud_RxBuffer[768]; + UBYTE ud_Name[24]; + UBYTE ud_EtherAddress[6]; + UBYTE ud_SoftAddress[6]; + struct Sana2DeviceStats ud_DevStats; + UBYTE ud_Flags; + UBYTE ud_NextPage; + BYTE ud_GoWriteBit; + UBYTE pad; +#ifdef PDEBUG + BPTR debug; + BPTR tdebug; +#endif +}; struct BuffFunctions - { +{ APTR bf_CopyTo; APTR bf_CopyFrom; - }; +}; /// /// prototypes @@ -163,78 +162,65 @@ struct BuffFunctions extern LONG CopyB(APTR func reg(a2), APTR to reg(a0), APTR from reg(a1), ULONG n reg(d0)); struct DevData *DevInit(void *seglist reg(a0), struct Library *sysb reg(a6)); -LONG DevOpen(struct IOSana2Req *req reg(a1), LONG unit reg(d0), LONG flags reg(d1), - struct DevData *dd reg(a6)); -APTR DevClose(struct IOSana2Req *req reg(a1), struct DevData *dd reg(a6)); -APTR DevExpunge(struct DevData *dd reg(a6)); -long DevReserved(void); -void DevBeginIO(struct IOSana2Req *req reg(a1), struct DevData *dd reg(a6)); +LONG DevOpen(struct IOSana2Req *req reg(a1), LONG unit reg(d0), LONG flags reg(d1), struct DevData *dd reg(a6)); +APTR DevClose(struct IOSana2Req *req reg(a1), struct DevData *dd reg(a6)); +APTR DevExpunge(struct DevData *dd reg(a6)); +long DevReserved(void); +void DevBeginIO(struct IOSana2Req *req reg(a1), struct DevData *dd reg(a6)); ULONG DevAbortIO(struct IOSana2Req *req reg(a1), struct DevData *dd reg(a6)); -void IoDone(struct UnitData *ud, struct IOSana2Req *req, LONG err, LONG werr); -LONG OpenDeviceLibraries(struct DevData *dd); -void CloseDeviceLibraries(struct DevData *dd); -LONG PrepareCookie(struct IOSana2Req *req, struct DevData *dd); -LONG RunTask(struct DevData *dd, struct UnitData *ud); -void ClearGlobalStats(struct UnitData *ud); +void IoDone(struct UnitData *ud, struct IOSana2Req *req, LONG err, LONG werr); +LONG OpenDeviceLibraries(struct DevData *dd); +void CloseDeviceLibraries(struct DevData *dd); +LONG PrepareCookie(struct IOSana2Req *req, struct DevData *dd); +LONG RunTask(struct DevData *dd, struct UnitData *ud); +void ClearGlobalStats(struct UnitData *ud); struct UnitData *OpenUnit(struct DevData *dd, LONG unit, LONG flags); struct UnitData *InitializeUnit(struct DevData *dd, LONG unit); -void CloseUnit(struct DevData *dd, struct UnitData *ud); -void ExpungeUnit(struct DevData *dd, struct UnitData *ud); +void CloseUnit(struct DevData *dd, struct UnitData *ud); +void ExpungeUnit(struct DevData *dd, struct UnitData *ud); void __saveds CmdNSDQuery(struct UnitData *ud, struct IOStdReq *req); -void S2DeviceQuery(struct UnitData *ud, struct IOSana2Req *req); -void S2GetStationAddress(struct UnitData *ud, struct IOSana2Req *req); -void S2ConfigInterface(struct UnitData *ud, struct IOSana2Req *req); -void S2Online(struct UnitData *ud, struct IOSana2Req *req); -void S2Offline(struct UnitData *ud, struct IOSana2Req *req); -void S2GetGlobalStats(struct UnitData *ud, struct IOSana2Req *req); - -void HardwareReset(struct UnitData *ud); -void HardwareInit (struct UnitData *ud); +void S2DeviceQuery(struct UnitData *ud, struct IOSana2Req *req); +void S2GetStationAddress(struct UnitData *ud, struct IOSana2Req *req); +void S2ConfigInterface(struct UnitData *ud, struct IOSana2Req *req); +void S2Online(struct UnitData *ud, struct IOSana2Req *req); +void S2Offline(struct UnitData *ud, struct IOSana2Req *req); +void S2GetGlobalStats(struct UnitData *ud, struct IOSana2Req *req); + +void HardwareReset(struct UnitData *ud); +void HardwareInit(struct UnitData *ud); volatile struct Ne2000 *FindHardware(struct DevData *dd, WORD unit); -void GoOnline (struct UnitData *ud); -void GoOffline(struct UnitData *ud); -void GetHwAddress(struct UnitData *ud); -void WriteHwAddress(struct UnitData *ud); -LONG PacketReceived(struct UnitData *ud); -LONG RingBufferNotEmpty(struct UnitData *ud); +void GoOnline(struct UnitData *ud); +void GoOffline(struct UnitData *ud); +void GetHwAddress(struct UnitData *ud); +void WriteHwAddress(struct UnitData *ud); +LONG PacketReceived(struct UnitData *ud); +LONG RingBufferNotEmpty(struct UnitData *ud); struct IOSana2Req *SearchReadRequest(struct UnitData *ud, struct MinList *queue, ULONG type); -void UnitTask(void); +void UnitTask(void); /// /// tables and constans extern struct Resident romtag; -const UBYTE IdString[] = DEV_IDSTRING; - -const void *FuncTable[] = - { - DevOpen, - DevClose, - DevExpunge, - DevReserved, - DevBeginIO, - DevAbortIO, - (APTR)-1 - }; - -UWORD NSDSupported[] = - { - CMD_READ, - CMD_WRITE, - CMD_FLUSH, - S2_DEVICEQUERY, - S2_GETSTATIONADDRESS, - S2_CONFIGINTERFACE, - S2_BROADCAST, - S2_GETGLOBALSTATS, - S2_ONLINE, - S2_OFFLINE, - NSCMD_DEVICEQUERY, - 0 - }; +const UBYTE IdString[] = DEV_IDSTRING; + +const void *FuncTable[] = {DevOpen, DevClose, DevExpunge, DevReserved, DevBeginIO, DevAbortIO, (APTR)-1}; + +UWORD NSDSupported[] = {CMD_READ, + CMD_WRITE, + CMD_FLUSH, + S2_DEVICEQUERY, + S2_GETSTATIONADDRESS, + S2_CONFIGINTERFACE, + S2_BROADCAST, + S2_GETGLOBALSTATS, + S2_ONLINE, + S2_OFFLINE, + NSCMD_DEVICEQUERY, + 0}; /// @@ -243,229 +229,242 @@ UWORD NSDSupported[] = // libraries used by the device. Returns device base or NULL if init failed. struct DevData *DevInit(APTR seglist reg(a0), struct Library *sysb reg(a6)) - { +{ struct DevData *dd; struct Library *SysBase = sysb; - if (dd = (struct DevData*)MakeLibrary(FuncTable, NULL, NULL, sizeof(struct DevData), 0)) - { + if (dd = (struct DevData *)MakeLibrary(FuncTable, NULL, NULL, sizeof(struct DevData), 0)) + { dd->dd_Lib.lib_Node.ln_Type = NT_DEVICE; dd->dd_Lib.lib_Node.ln_Name = romtag.rt_Name; - dd->dd_Lib.lib_Flags = LIBF_CHANGED | LIBF_SUMUSED; - dd->dd_Lib.lib_Version = DEV_VERSION; - dd->dd_Lib.lib_Revision = DEV_REVISION; - dd->dd_Lib.lib_IdString = romtag.rt_IdString; - dd->dd_Lib.lib_OpenCnt = 0; - dd->dd_SegList = seglist; - dd->dd_SysBase = SysBase; + dd->dd_Lib.lib_Flags = LIBF_CHANGED | LIBF_SUMUSED; + dd->dd_Lib.lib_Version = DEV_VERSION; + dd->dd_Lib.lib_Revision = DEV_REVISION; + dd->dd_Lib.lib_IdString = romtag.rt_IdString; + dd->dd_Lib.lib_OpenCnt = 0; + dd->dd_SegList = seglist; + dd->dd_SysBase = SysBase; if (OpenDeviceLibraries(dd)) - { + { USE_D(DOSBase) WORD i; for (i = 0; i < 4; i++) dd->dd_Units[i] = NULL; - #ifdef PDEBUG +#ifdef PDEBUG strcpy(dd->dpath, "KCON:0/17/400/300/prm-rtl8029.device (main)/AUTO/CLOSE/WAIT"); GetVar("PrometheusDebug", dd->dpath, 128, 0); dd->debug = Open(dd->dpath, MODE_NEWFILE); - #endif +#endif DBG1("Device initialized, base at $%08lx.", dd); - AddDevice((struct Device*)dd); + AddDevice((struct Device *)dd); return dd; - } + } CloseDeviceLibraries(dd); - } + } return NULL; - } +} /// /// DevOpen() -LONG DevOpen(struct IOSana2Req *req reg(a1), LONG unit reg(d0), LONG flags reg(d1), - struct DevData *dd reg(a6)) - { +LONG DevOpen(struct IOSana2Req *req reg(a1), LONG unit reg(d0), LONG flags reg(d1), struct DevData *dd reg(a6)) +{ USE(SysBase) USE_D(DOSBase) struct UnitData *ud; DBG("DevOpen() called."); - dd->dd_Lib.lib_OpenCnt++; // expunge protection + dd->dd_Lib.lib_OpenCnt++; // expunge protection if ((unit >= 0) && (unit <= 3)) - { + { if (ud = OpenUnit(dd, unit, flags)) - { - req->ios2_Req.io_Error = 0; + { + req->ios2_Req.io_Error = 0; req->ios2_Req.io_Message.mn_Node.ln_Type = NT_REPLYMSG; - req->ios2_Req.io_Device = (struct Device*)dd; - req->ios2_Req.io_Unit = (struct Unit*)ud; + req->ios2_Req.io_Device = (struct Device *)dd; + req->ios2_Req.io_Unit = (struct Unit *)ud; if (PrepareCookie(req, dd)) - { + { dd->dd_Lib.lib_Flags &= ~LIBF_DELEXP; DBG("DevOpen(): device opened successfully."); return 0; - } + } DBG("PrepareCookie() failed."); CloseUnit(dd, ud); - } - } - req->ios2_Req.io_Error = IOERR_OPENFAIL; - req->ios2_Req.io_Device = (struct Device*)-1; - req->ios2_Req.io_Unit = (struct Unit*)-1; - dd->dd_Lib.lib_OpenCnt--; /* end of expunge protection */ + } + } + req->ios2_Req.io_Error = IOERR_OPENFAIL; + req->ios2_Req.io_Device = (struct Device *)-1; + req->ios2_Req.io_Unit = (struct Unit *)-1; + dd->dd_Lib.lib_OpenCnt--; /* end of expunge protection */ return IOERR_OPENFAIL; - } +} /// /// DevClose() APTR DevClose(struct IOSana2Req *req reg(a1), struct DevData *dd reg(a6)) - { +{ USE(SysBase) USE_D(DOSBase) WORD unit; - CloseUnit(dd, (struct UnitData*)req->ios2_Req.io_Unit); + CloseUnit(dd, (struct UnitData *)req->ios2_Req.io_Unit); - if (req->ios2_BufferManagement) FreeMem(req->ios2_BufferManagement, - sizeof(struct BuffFunctions)); + if (req->ios2_BufferManagement) FreeMem(req->ios2_BufferManagement, sizeof(struct BuffFunctions)); if (--dd->dd_Lib.lib_OpenCnt == 0) - { + { DBG("DevClose(): open counter reached 0."); if (dd->dd_Lib.lib_Flags & LIBF_DELEXP) return (DevExpunge(dd)); - } + } return 0; - } +} /// /// DevExpunge() -APTR DevExpunge (struct DevData *dd reg(a6)) - { +APTR DevExpunge(struct DevData *dd reg(a6)) +{ USE(SysBase) USE_D(DOSBase) APTR seglist; if (dd->dd_Lib.lib_OpenCnt) - { + { dd->dd_Lib.lib_Flags |= LIBF_DELEXP; return 0; - } - Remove((struct Node*)dd); + } + Remove((struct Node *)dd); CloseDeviceLibraries(dd); seglist = dd->dd_SegList; FreeMem((APTR)dd - dd->dd_Lib.lib_NegSize, (LONG)dd->dd_Lib.lib_PosSize + (LONG)dd->dd_Lib.lib_NegSize); DBG("DevExpunge(): expunged."); return seglist; - } +} /// /// DevReserved() -LONG DevReserved (void) - { +LONG DevReserved(void) +{ return 0; - } +} /// /// DevBeginIo() void DevBeginIO(struct IOSana2Req *req reg(a1), struct DevData *dd reg(a6)) - { +{ USE(SysBase) USE_D(DOSBase) - struct UnitData *ud = (struct UnitData*)req->ios2_Req.io_Unit; - WORD i; + struct UnitData *ud = (struct UnitData *)req->ios2_Req.io_Unit; + WORD i; - switch(req->ios2_Req.io_Command) - { - case NSCMD_DEVICEQUERY: CmdNSDQuery(ud, (struct IOStdReq*)req); break; - case S2_DEVICEQUERY: S2DeviceQuery(ud, req); break; - case S2_GETSTATIONADDRESS: S2GetStationAddress(ud, req); break; - case S2_CONFIGINTERFACE: S2ConfigInterface(ud, req); break; - case S2_ONLINE: S2Online(ud, req); break; - case S2_OFFLINE: S2Offline(ud, req); break; - case S2_GETGLOBALSTATS: S2GetGlobalStats(ud, req); break; - - case CMD_READ: - DBG1("CMD_READ [$%08lx].", (LONG)req); - req->ios2_Req.io_Flags &= ~IOF_QUICK; - PutMsg(ud->ud_TaskPort, &req->ios2_Req.io_Message); + switch (req->ios2_Req.io_Command) + { + case NSCMD_DEVICEQUERY: + CmdNSDQuery(ud, (struct IOStdReq *)req); + break; + case S2_DEVICEQUERY: + S2DeviceQuery(ud, req); + break; + case S2_GETSTATIONADDRESS: + S2GetStationAddress(ud, req); + break; + case S2_CONFIGINTERFACE: + S2ConfigInterface(ud, req); + break; + case S2_ONLINE: + S2Online(ud, req); + break; + case S2_OFFLINE: + S2Offline(ud, req); + break; + case S2_GETGLOBALSTATS: + S2GetGlobalStats(ud, req); + break; + + case CMD_READ: + DBG1("CMD_READ [$%08lx].", (LONG)req); + req->ios2_Req.io_Flags &= ~IOF_QUICK; + PutMsg(ud->ud_TaskPort, &req->ios2_Req.io_Message); break; - case S2_BROADCAST: - for (i = 0; i < 6; i++) req->ios2_DstAddr[i] = 0xFF; - case CMD_WRITE: - DBG1("CMD_WRITE [$%08lx].", (LONG)req); - req->ios2_Req.io_Flags &= ~IOF_QUICK; - PutMsg(ud->ud_TaskPort, &req->ios2_Req.io_Message); + case S2_BROADCAST: + for (i = 0; i < 6; i++) req->ios2_DstAddr[i] = 0xFF; + case CMD_WRITE: + DBG1("CMD_WRITE [$%08lx].", (LONG)req); + req->ios2_Req.io_Flags &= ~IOF_QUICK; + PutMsg(ud->ud_TaskPort, &req->ios2_Req.io_Message); break; - case CMD_FLUSH: - DBG1("CMD_FLUSH [$%08lx].", (LONG)req); - req->ios2_Req.io_Flags &= ~IOF_QUICK; - PutMsg(ud->ud_TaskPort, &req->ios2_Req.io_Message); + case CMD_FLUSH: + DBG1("CMD_FLUSH [$%08lx].", (LONG)req); + req->ios2_Req.io_Flags &= ~IOF_QUICK; + PutMsg(ud->ud_TaskPort, &req->ios2_Req.io_Message); break; - default: - DBG1("DevBeginIo(): unknown command code %ld.", req->ios2_Req.io_Command); - IoDone(ud, req, IOERR_NOCMD, S2WERR_GENERIC_ERROR); + default: + DBG1("DevBeginIo(): unknown command code %ld.", req->ios2_Req.io_Command); + IoDone(ud, req, IOERR_NOCMD, S2WERR_GENERIC_ERROR); break; - } + } return; - } +} /// /// DevAbortIo() ULONG DevAbortIO(struct IOSana2Req *req reg(a1), struct DevData *dd reg(a6)) - { +{ USE(SysBase) USE_D(DOSBase) - LONG ret = 0; - struct UnitData *ud = (struct UnitData*)req->ios2_Req.io_Unit; - struct MinList *list; - struct MinNode *node; + LONG ret = 0; + struct UnitData *ud = (struct UnitData *)req->ios2_Req.io_Unit; + struct MinList * list; + struct MinNode * node; DBG1("DevAbortIo: aborting $%08lx.", req); switch (req->ios2_Req.io_Command) - { - case CMD_READ: - list = &ud->ud_RxQueue; + { + case CMD_READ: + list = &ud->ud_RxQueue; break; - case CMD_WRITE: - case S2_BROADCAST: - list = &ud->ud_TxQueue; + case CMD_WRITE: + case S2_BROADCAST: + list = &ud->ud_TxQueue; break; - default: - list = NULL; - } + default: + list = NULL; + } if (list) - { + { Disable(); for (node = list->mlh_Head; node->mln_Succ; node = node->mln_Succ) - { - if (node == (struct MinNode*)req) - { - if (((struct Message*)node)->mn_Node.ln_Type != NT_REPLYMSG) - { - Remove((struct Node*)node); + { + if (node == (struct MinNode *)req) + { + if (((struct Message *)node)->mn_Node.ln_Type != NT_REPLYMSG) + { + Remove((struct Node *)node); req->ios2_Req.io_Error = IOERR_ABORTED; - ReplyMsg((struct Message*)node); + ReplyMsg((struct Message *)node); ret = 0; - } - } - } + } + } + } Enable(); - } - else ret = IOERR_NOCMD; + } + else + ret = IOERR_NOCMD; return ret; - } +} /// @@ -475,122 +474,119 @@ ULONG DevAbortIO(struct IOSana2Req *req reg(a1), struct DevData *dd reg(a6)) // Function ends IORequest with given error codes. Requests with IOF_QUICK cleared will be ReplyMsg()-ed. void IoDone(struct UnitData *ud, struct IOSana2Req *req, LONG err, LONG werr) - { +{ USE_U(SysBase) req->ios2_Req.io_Error = err; - req->ios2_WireError = werr; + req->ios2_WireError = werr; if (!(req->ios2_Req.io_Flags & IOF_QUICK)) ReplyMsg(&req->ios2_Req.io_Message); return; - } +} /// /// OpenDeviceLibraries(struct DevData *dd) LONG OpenDeviceLibraries(struct DevData *dd) - { +{ USE(SysBase) if (!(dd->dd_UtilityBase = OpenLibrary("utility.library", 39))) return FALSE; if (!(dd->dd_PrometheusBase = OpenLibrary("prometheus.library", 2))) return FALSE; if (!(dd->dd_DOSBase = OpenLibrary("dos.library", 38))) return FALSE; - if (OpenDevice ("timer.device", UNIT_MICROHZ, (struct IORequest*)&dd->dd_Treq, 0) == 0) - { - dd->dd_TimerBase = (struct Library*)dd->dd_Treq.tr_node.io_Device; - } + if (OpenDevice("timer.device", UNIT_MICROHZ, (struct IORequest *)&dd->dd_Treq, 0) == 0) + { + dd->dd_TimerBase = (struct Library *)dd->dd_Treq.tr_node.io_Device; + } return TRUE; - } +} /// /// CloseDeviceLibraries(struct DevData *dd) void CloseDeviceLibraries(struct DevData *dd) - { +{ USE(SysBase) if (dd->dd_DOSBase) CloseLibrary(dd->dd_DOSBase); if (dd->dd_PrometheusBase) CloseLibrary(dd->dd_PrometheusBase); if (dd->dd_UtilityBase) CloseLibrary(dd->dd_UtilityBase); - if (dd->dd_TimerBase) CloseDevice ((struct IORequest*)&dd->dd_Treq); - } + if (dd->dd_TimerBase) CloseDevice((struct IORequest *)&dd->dd_Treq); +} /// /// PrepareCookie(struct IOSana2Req *req, struct DevData *dd) LONG PrepareCookie(struct IOSana2Req *req, struct DevData *dd) - { +{ USE(SysBase) USE(UtilityBase) USE_D(DOSBase) if (req->ios2_BufferManagement) - { + { struct BuffFunctions *bfun; if (bfun = AllocMem(sizeof(struct BuffFunctions), MEMF_ANY)) - { - bfun->bf_CopyFrom = (APTR)GetTagData(S2_CopyFromBuff, NULL, - (struct TagItem*)req->ios2_BufferManagement); - bfun->bf_CopyTo = (APTR)GetTagData(S2_CopyToBuff, NULL, - (struct TagItem*)req->ios2_BufferManagement); + { + bfun->bf_CopyFrom = (APTR)GetTagData(S2_CopyFromBuff, NULL, (struct TagItem *)req->ios2_BufferManagement); + bfun->bf_CopyTo = (APTR)GetTagData(S2_CopyToBuff, NULL, (struct TagItem *)req->ios2_BufferManagement); if (bfun->bf_CopyFrom && bfun->bf_CopyTo) - { + { DBG1("CopyFrom [$%08lx].", bfun->bf_CopyFrom); req->ios2_BufferManagement = bfun; return TRUE; - } - else FreeMem(bfun, sizeof(struct BuffFunctions)); - } - } + } + else + FreeMem(bfun, sizeof(struct BuffFunctions)); + } + } return FALSE; - } +} /// /// RunTask(struct DevData *dd, struct UnitData *ud) LONG RunTask(struct DevData *dd, struct UnitData *ud) - { +{ USE(SysBase) USE(DOSBase) DBG("RunTask() called."); - if(ud->ud_LifeTime = CreateMsgPort()) - { - if (ud->ud_Task = (struct Task*)CreateNewProcTags( - NP_Entry, (LONG)UnitTask, - NP_Name, (LONG)ud->ud_Name, - NP_Priority, 6, - TAG_END)) - { + if (ud->ud_LifeTime = CreateMsgPort()) + { + if (ud->ud_Task = (struct Task *)CreateNewProcTags( + NP_Entry, (LONG)UnitTask, NP_Name, (LONG)ud->ud_Name, NP_Priority, 6, TAG_END)) + { WORD i; DBG1("Task [$%08lx] started.", ud->ud_Task); for (i = 0; i < 50; i++) - { - if (!(ud->ud_TaskPort = FindPort(ud->ud_Name))) Delay(1); + { + if (!(ud->ud_TaskPort = FindPort(ud->ud_Name))) + Delay(1); else - { + { DBG("Task port detected."); ud->ud_Message.mn_Node.ln_Type = NT_MESSAGE; - ud->ud_Message.mn_Length = sizeof(struct UnitData); - ud->ud_Message.mn_ReplyPort = ud->ud_LifeTime; + ud->ud_Message.mn_Length = sizeof(struct UnitData); + ud->ud_Message.mn_ReplyPort = ud->ud_LifeTime; PutMsg(ud->ud_TaskPort, &ud->ud_Message); return TRUE; - } - } - } - } + } + } + } + } return FALSE; - } +} /// /// KillTask(struct DevData *dd, struct UnitData *ud) void KillTask(struct DevData *dd, struct UnitData *ud) - { +{ USE(SysBase) USE_D(DOSBase) @@ -600,26 +596,26 @@ void KillTask(struct DevData *dd, struct UnitData *ud) DeleteMsgPort(ud->ud_LifeTime); DBG("Task dead."); return; - } +} /// /// ClearGlobalStats() void ClearGlobalStats(struct UnitData *ud) - { +{ USE_U(TimerBase) ud->ud_DevStats.PacketsReceived = 0; - ud->ud_DevStats.PacketsSent = 0; + ud->ud_DevStats.PacketsSent = 0; GetSysTime(&ud->ud_DevStats.LastStart); return; - } +} /// /// OpenUnit() struct UnitData *OpenUnit(struct DevData *dd, LONG unit, LONG flags) - { +{ USE_D(DOSBase) struct UnitData *ud = dd->dd_Units[unit]; @@ -632,9 +628,9 @@ struct UnitData *OpenUnit(struct DevData *dd, LONG unit, LONG flags) /* Initialize unit if opened first time. */ if (!ud) - { + { if (!(ud = InitializeUnit(dd, unit))) return NULL; - } + } /* Check exclusive flag - reject if already opened by someone else. */ @@ -650,91 +646,91 @@ struct UnitData *OpenUnit(struct DevData *dd, LONG unit, LONG flags) ud->ud_OpenCnt++; DBG2("%s opened [%ld].", ud->ud_Name, ud->ud_OpenCnt); return ud; - } +} /// /// CloseUnit() void CloseUnit(struct DevData *dd, struct UnitData *ud) - { +{ USE_D(DOSBase) DBG1("%s closed.", ud->ud_Name); if (!(--ud->ud_OpenCnt)) ExpungeUnit(dd, ud); return; - } +} /// /// InitializeUnit() struct UnitData *InitializeUnit(struct DevData *dd, LONG unit) - { +{ USE(SysBase) USE(DOSBase) struct UnitData *ud; - WORD i; + WORD i; DBG("InitializeUnit() called."); if (ud = AllocMem(sizeof(struct UnitData), MEMF_PUBLIC | MEMF_CLEAR)) - { + { if (ud->ud_Hardware = FindHardware(dd, unit)) - { - #ifdef PDEBUG + { +#ifdef PDEBUG ud->debug = dd->debug; - #endif +#endif for (i = 5; i >= 0; i--) - { - ud->ud_SoftAddress[i] = 0x00; + { + ud->ud_SoftAddress[i] = 0x00; ud->ud_EtherAddress[i] = 0x00; - } - ud->ud_SysBase = dd->dd_SysBase; - ud->ud_DOSBase = dd->dd_DOSBase; + } + ud->ud_SysBase = dd->dd_SysBase; + ud->ud_DOSBase = dd->dd_DOSBase; ud->ud_TimerBase = dd->dd_TimerBase; strcpy(ud->ud_Name, "prm-rtl8029.device (x)"); - ud->ud_Name[20] = '0' + unit; - ud->ud_RxQueue.mlh_Head = (struct MinNode*)&ud->ud_RxQueue.mlh_Tail; - ud->ud_RxQueue.mlh_Tail = NULL; - ud->ud_RxQueue.mlh_TailPred = (struct MinNode*)&ud->ud_RxQueue.mlh_Head; - ud->ud_TxQueue.mlh_Head = (struct MinNode*)&ud->ud_TxQueue.mlh_Tail; - ud->ud_TxQueue.mlh_Tail = NULL; - ud->ud_TxQueue.mlh_TailPred = (struct MinNode*)&ud->ud_TxQueue.mlh_Head; - ud->ud_NextPage = RX_BUFFER; + ud->ud_Name[20] = '0' + unit; + ud->ud_RxQueue.mlh_Head = (struct MinNode *)&ud->ud_RxQueue.mlh_Tail; + ud->ud_RxQueue.mlh_Tail = NULL; + ud->ud_RxQueue.mlh_TailPred = (struct MinNode *)&ud->ud_RxQueue.mlh_Head; + ud->ud_TxQueue.mlh_Head = (struct MinNode *)&ud->ud_TxQueue.mlh_Tail; + ud->ud_TxQueue.mlh_Tail = NULL; + ud->ud_TxQueue.mlh_TailPred = (struct MinNode *)&ud->ud_TxQueue.mlh_Head; + ud->ud_NextPage = RX_BUFFER; HardwareReset(ud); HardwareInit(ud); GetHwAddress(ud); if (RunTask(dd, ud)) - { + { dd->dd_Units[unit] = ud; DBG1("%s initialized.", (LONG)ud->ud_Name); return ud; - } - } - } + } + } + } ExpungeUnit(dd, ud); return NULL; - } +} /// /// ExpungeUnit() void ExpungeUnit(struct DevData *dd, struct UnitData *ud) - { +{ USE(SysBase) USE_D(DOSBase) WORD unit; if (ud) - { - unit = ud->ud_Name[20] - '0'; - if (ud->ud_Flags & UF_ONLINE) GoOffline(ud); - if (ud->ud_Task) KillTask(dd, ud); - FreeMem(ud, sizeof(struct UnitData)); - dd->dd_Units[unit] = NULL; - DBG1("%s expunged.", ud->ud_Name); - } + { + unit = ud->ud_Name[20] - '0'; + if (ud->ud_Flags & UF_ONLINE) GoOffline(ud); + if (ud->ud_Task) KillTask(dd, ud); + FreeMem(ud, sizeof(struct UnitData)); + dd->dd_Units[unit] = NULL; + DBG1("%s expunged.", ud->ud_Name); + } return; - } +} /// @@ -743,35 +739,37 @@ void ExpungeUnit(struct DevData *dd, struct UnitData *ud) /// S2DeviceQuery() void S2DeviceQuery(struct UnitData *ud, struct IOSana2Req *req) - { +{ USE_UD(DOSBase) struct Sana2DeviceQuery *query = req->ios2_StatData; DBG_U("S2_DEVICEQUERY."); if (query) - { + { if (query->SizeAvailable >= sizeof(struct Sana2DeviceQuery)) - { - query->SizeSupplied = sizeof(struct Sana2DeviceQuery); + { + query->SizeSupplied = sizeof(struct Sana2DeviceQuery); query->DevQueryFormat = 0; - query->DeviceLevel = 0; - query->AddrFieldSize = 48; - query->MTU = 1500; - query->BPS = 10000000; - query->HardwareType = S2WireType_Ethernet; + query->DeviceLevel = 0; + query->AddrFieldSize = 48; + query->MTU = 1500; + query->BPS = 10000000; + query->HardwareType = S2WireType_Ethernet; IoDone(ud, req, OK, OK); - } - else IoDone(ud, req, S2ERR_BAD_ARGUMENT, S2WERR_GENERIC_ERROR); - } - else IoDone(ud, req, S2ERR_BAD_ARGUMENT, S2WERR_NULL_POINTER); + } + else + IoDone(ud, req, S2ERR_BAD_ARGUMENT, S2WERR_GENERIC_ERROR); + } + else + IoDone(ud, req, S2ERR_BAD_ARGUMENT, S2WERR_NULL_POINTER); return; - } +} /// /// S2GetStationAddress() void S2GetStationAddress(struct UnitData *ud, struct IOSana2Req *req) - { +{ USE_U(SysBase) USE_UD(DOSBase) @@ -780,135 +778,139 @@ void S2GetStationAddress(struct UnitData *ud, struct IOSana2Req *req) CopyMem(ud->ud_EtherAddress, req->ios2_DstAddr, 6); IoDone(ud, req, OK, OK); return; - } +} /// /// S2Online() void S2Online(struct UnitData *ud, struct IOSana2Req *req) - { +{ USE_UD(DOSBase) DBG_U("S2_ONLINE."); ClearGlobalStats(ud); if (!(ud->ud_Flags & UF_ONLINE)) - { + { GoOnline(ud); ud->ud_Flags |= UF_ONLINE; IoDone(ud, req, OK, OK); - } - else IoDone(ud, req, S2ERR_BAD_STATE, S2WERR_UNIT_ONLINE); + } + else + IoDone(ud, req, S2ERR_BAD_STATE, S2WERR_UNIT_ONLINE); return; - } +} /// /// S2ConfigInterface() BOOL address_has_all(UBYTE *addr, UBYTE num) - { +{ WORD i; for (i = 5; i >= 0; i--) - { + { if (addr[i] != num) return FALSE; - } + } return TRUE; - } - +} void S2ConfigInterface(struct UnitData *ud, struct IOSana2Req *req) - { +{ USE_U(SysBase) USE_UD(DOSBase) DBG_U("S2_CONFIGINTERFACE."); ClearGlobalStats(ud); if (ud->ud_Flags & UF_CONFIGURED) - { + { IoDone(ud, req, S2ERR_BAD_STATE, S2WERR_IS_CONFIGURED); - } - else if (address_has_all(req->ios2_SrcAddr, 0x00) || - address_has_all(req->ios2_SrcAddr, 0xFF)) - { + } + else if (address_has_all(req->ios2_SrcAddr, 0x00) || address_has_all(req->ios2_SrcAddr, 0xFF)) + { IoDone(ud, req, S2ERR_BAD_ADDRESS, S2WERR_SRC_ADDRESS); - } + } else - { + { HardwareInit(ud); CopyMem(req->ios2_SrcAddr, ud->ud_SoftAddress, 6); WriteHwAddress(ud); if (!(ud->ud_Flags & UF_ONLINE)) - { + { GoOnline(ud); ud->ud_Flags |= UF_ONLINE; - } + } ud->ud_Flags |= UF_CONFIGURED; IoDone(ud, req, OK, OK); - } + } return; - } +} /// /// S2Offline() void S2Offline(struct UnitData *ud, struct IOSana2Req *req) - { +{ USE_UD(DOSBase) DBG_U("S2_OFFLINE."); if (ud->ud_Flags & UF_ONLINE) - { + { GoOffline(ud); ud->ud_Flags &= ~UF_ONLINE; IoDone(ud, req, OK, OK); - } - else IoDone(ud, req, S2ERR_BAD_STATE, S2WERR_UNIT_OFFLINE); + } + else + IoDone(ud, req, S2ERR_BAD_STATE, S2WERR_UNIT_OFFLINE); return; - } +} /// /// S2GetGlobalStats() void S2GetGlobalStats(struct UnitData *ud, struct IOSana2Req *req) - { +{ USE_U(SysBase) if (req->ios2_StatData) - { + { CopyMem(&ud->ud_DevStats, req->ios2_StatData, sizeof(struct Sana2DeviceStats)); IoDone(ud, req, OK, OK); - } - else IoDone(ud, req, S2ERR_BAD_ARGUMENT, S2WERR_NULL_POINTER); - } + } + else + IoDone(ud, req, S2ERR_BAD_ARGUMENT, S2WERR_NULL_POINTER); +} /// /// CmdNSDQuery() void __saveds CmdNSDQuery(struct UnitData *ud, struct IOStdReq *req) - { +{ USE_U(SysBase) USE_UD(DOSBase) struct NSDeviceQueryResult *qdata; - LONG error = OK; + LONG error = OK; DBG_U("NSCMD_DEVICEQUERY."); if (req->io_Length >= sizeof(struct NSDeviceQueryResult)) - { - if (qdata = (struct NSDeviceQueryResult*)req->io_Data) - { + { + if (qdata = (struct NSDeviceQueryResult *)req->io_Data) + { if ((qdata->DevQueryFormat == 0) && (qdata->SizeAvailable == 0)) - { - qdata->SizeAvailable = sizeof(struct NSDeviceQueryResult); - qdata->DeviceType = NSDEVTYPE_SANA2; - qdata->DeviceSubType = 0; + { + qdata->SizeAvailable = sizeof(struct NSDeviceQueryResult); + qdata->DeviceType = NSDEVTYPE_SANA2; + qdata->DeviceSubType = 0; qdata->SupportedCommands = NSDSupported; - req->io_Actual = sizeof(struct NSDeviceQueryResult); - } - else error = IOERR_BADLENGTH; - } - else error = IOERR_BADADDRESS; - } - else error = IOERR_BADLENGTH; + req->io_Actual = sizeof(struct NSDeviceQueryResult); + } + else + error = IOERR_BADLENGTH; + } + else + error = IOERR_BADADDRESS; + } + else + error = IOERR_BADLENGTH; /* I don't use IoDone() here, because it writes to ios2_WireError */ /* but this request can be simple IOStdReq one. */ @@ -916,7 +918,7 @@ void __saveds CmdNSDQuery(struct UnitData *ud, struct IOStdReq *req) req->io_Error = error; if (!(req->io_Flags & IOF_QUICK)) ReplyMsg(&req->io_Message); return; - } +} /// @@ -925,339 +927,334 @@ void __saveds CmdNSDQuery(struct UnitData *ud, struct IOStdReq *req) /// IntCode() LONG IntCode(struct UnitData *ud reg(a1)) - { +{ USE_U(SysBase) - UBYTE intstatus; + UBYTE intstatus; struct IOSana2Req *req; - LONG my_int = 0; + LONG my_int = 0; while (intstatus = (ud->ud_Hardware->regs[NE2000_INT_STATUS] & INTMASK)) - { + { if (intstatus & INT_TXERROR) - { + { ud->ud_Hardware->regs[NE2000_INT_STATUS] = INT_TXERROR; - req = ud->ud_PendingWrite; + req = ud->ud_PendingWrite; IoDone(ud, req, S2ERR_TX_FAILURE, S2WERR_TOO_MANY_RETIRES); Signal(ud->ud_Task, ud->ud_GoWriteMask); my_int = 1; - } + } if (intstatus & INT_TXPACKET) - { + { ud->ud_Hardware->regs[NE2000_INT_STATUS] = INT_TXPACKET; - req = ud->ud_PendingWrite; + req = ud->ud_PendingWrite; ud->ud_DevStats.PacketsSent++; IoDone(ud, req, OK, OK); Signal(ud->ud_Task, ud->ud_GoWriteMask); my_int = 1; - } + } if (intstatus & INT_RXPACKET) - { + { ULONG offset, len; UWORD mask = 0xFFFF; - WORD i; + WORD i; while (RingBufferNotEmpty(ud)) - { + { ud->ud_Hardware->regs[NE2000_INT_STATUS] = INT_RXPACKET; - len = PacketReceived(ud); + len = PacketReceived(ud); if (req = SearchReadRequest(ud, &ud->ud_RxQueue, ud->ud_RxBuffer[6])) - { - if (req->ios2_Req.io_Flags & SANA2IOF_RAW) offset = 0; - else offset = 7; - CopyB(((struct BuffFunctions*)req->ios2_BufferManagement)->bf_CopyTo, - req->ios2_Data, &ud->ud_RxBuffer[offset], len - (offset << 1)); + { + if (req->ios2_Req.io_Flags & SANA2IOF_RAW) + offset = 0; + else + offset = 7; + CopyB(((struct BuffFunctions *)req->ios2_BufferManagement)->bf_CopyTo, + req->ios2_Data, + &ud->ud_RxBuffer[offset], + len - (offset << 1)); CopyMem(&ud->ud_RxBuffer[0], req->ios2_DstAddr, 6); CopyMem(&ud->ud_RxBuffer[3], req->ios2_SrcAddr, 6); req->ios2_DataLength = len - (offset << 1); for (i = 2; i >= 0; i--) mask &= ud->ud_RxBuffer[i]; - if (mask == 0xFFFF) req->ios2_Req.io_Flags |= SANA2IOF_BCAST; + if (mask == 0xFFFF) req->ios2_Req.io_Flags |= SANA2IOF_BCAST; ud->ud_DevStats.PacketsReceived++; IoDone(ud, req, OK, OK); - } - } + } + } my_int = 1; - } - } + } + } return my_int; - } +} /// /// InstallInterrupt() LONG InstallInterrupt(struct UnitData *ud) - { +{ USE_U(SysBase) struct Interrupt *intr; if (intr = AllocMem(sizeof(struct Interrupt), MEMF_PUBLIC | MEMF_CLEAR)) - { + { intr->is_Node.ln_Type = NT_INTERRUPT; intr->is_Node.ln_Name = ud->ud_Name; - intr->is_Data = ud; - intr->is_Code = (APTR)IntCode; + intr->is_Data = ud; + intr->is_Code = (APTR)IntCode; AddIntServer(INTB_PORTS, intr); ud->ud_Interrupt = intr; return TRUE; - } + } return FALSE; - } +} /// /// RemoveInterrupt() void RemoveInterrupt(struct UnitData *ud) - { +{ USE_U(SysBase) RemIntServer(INTB_PORTS, ud->ud_Interrupt); FreeMem(ud->ud_Interrupt, sizeof(struct Interrupt)); return; - } +} /// /// FindHardware() volatile struct Ne2000 *FindHardware(struct DevData *dd, WORD unit) - { +{ USE(PrometheusBase) - WORD u = unit; - APTR board = NULL; + WORD u = unit; + APTR board = NULL; struct Ne2000 *hwbase; while (u-- >= 0) - { - board = Prm_FindBoardTags(board, - PRM_Vendor, PCI_VENDOR_REALTEK, - PRM_Device, PCI_DEVICE_RTL8029, - TAG_END); + { + board = Prm_FindBoardTags(board, PRM_Vendor, PCI_VENDOR_REALTEK, PRM_Device, PCI_DEVICE_RTL8029, TAG_END); if (!board) break; - } + } if (board) - { - Prm_GetBoardAttrsTags(board, - PRM_MemoryAddr0, (LONG)&hwbase, - TAG_END); - Prm_SetBoardAttrsTags(board, - PRM_BoardOwner, (LONG)dd, - TAG_END); + { + Prm_GetBoardAttrsTags(board, PRM_MemoryAddr0, (LONG)&hwbase, TAG_END); + Prm_SetBoardAttrsTags(board, PRM_BoardOwner, (LONG)dd, TAG_END); return hwbase; - } + } return NULL; - } +} /// /// HardwareInit() -void HardwareInit (struct UnitData *ud) - { +void HardwareInit(struct UnitData *ud) +{ volatile struct Ne2000 *hw = ud->ud_Hardware; - hw->regs[NE2000_COMMAND] = 0x21; - hw->regs[NE2000_DATA_CONFIG] = DTCFG_FIFO_8 | DTCFG_WIDE | DTCFG_LOOPSEL; + hw->regs[NE2000_COMMAND] = 0x21; + hw->regs[NE2000_DATA_CONFIG] = DTCFG_FIFO_8 | DTCFG_WIDE | DTCFG_LOOPSEL; hw->regs[NE2000_DMA_COUNTER0] = 0; hw->regs[NE2000_DMA_COUNTER1] = 0; - hw->regs[NE2000_TX_CONFIG] = 0x02; - hw->regs[NE2000_PAGE_START] = RX_BUFFER; - hw->regs[NE2000_PAGE_STOP] = BUFFER_END; - hw->regs[NE2000_BOUNDARY] = BUFFER_END - 1; - hw->regs[NE2000_INT_STATUS] = 0xFF; - hw->regs[NE2000_INT_MASK] = 0x00; - hw->regs[NE2000_COMMAND] = 0x61; + hw->regs[NE2000_TX_CONFIG] = 0x02; + hw->regs[NE2000_PAGE_START] = RX_BUFFER; + hw->regs[NE2000_PAGE_STOP] = BUFFER_END; + hw->regs[NE2000_BOUNDARY] = BUFFER_END - 1; + hw->regs[NE2000_INT_STATUS] = 0xFF; + hw->regs[NE2000_INT_MASK] = 0x00; + hw->regs[NE2000_COMMAND] = 0x61; hw->regs[NE2000_CURRENT_PAGE] = RX_BUFFER; - hw->regs[NE2000_COMMAND] = 0x21; + hw->regs[NE2000_COMMAND] = 0x21; return; - } +} /// /// HardwareReset() -void HardwareReset (struct UnitData *ud) - { +void HardwareReset(struct UnitData *ud) +{ USE_U(DOSBase) volatile struct Ne2000 *hw = ud->ud_Hardware; - UBYTE trash; + UBYTE trash; hw->ResetPort = trash; Delay(1); trash = hw->ResetPort; HardwareInit(ud); return; - } +} /// /// GoOnline() -void GoOnline (struct UnitData *ud) - { +void GoOnline(struct UnitData *ud) +{ volatile struct Ne2000 *hw = ud->ud_Hardware; HardwareReset(ud); WriteHwAddress(ud); InstallInterrupt(ud); - hw->regs[NE2000_COMMAND] = 0x22; - hw->regs[NE2000_TX_CONFIG] = 0x00; - hw->regs[NE2000_RX_CONFIG] = RXCFG_BCAST | RXCFG_MCAST | - ((ud->ud_Flags & UF_PROMISCUOUS) ? RXCFG_PROM : 0); + hw->regs[NE2000_COMMAND] = 0x22; + hw->regs[NE2000_TX_CONFIG] = 0x00; + hw->regs[NE2000_RX_CONFIG] = RXCFG_BCAST | RXCFG_MCAST | ((ud->ud_Flags & UF_PROMISCUOUS) ? RXCFG_PROM : 0); hw->regs[NE2000_INT_STATUS] = 0xFF; - hw->regs[NE2000_INT_MASK] = INTMASK; + hw->regs[NE2000_INT_MASK] = INTMASK; return; - } +} /// /// GoOffline() void GoOffline(struct UnitData *ud) - { +{ volatile struct Ne2000 *hw = ud->ud_Hardware; - hw->regs[NE2000_COMMAND] = 0x21; - hw->regs[NE2000_TX_CONFIG] = 0x02; - hw->regs[NE2000_RX_CONFIG] = 0x20; + hw->regs[NE2000_COMMAND] = 0x21; + hw->regs[NE2000_TX_CONFIG] = 0x02; + hw->regs[NE2000_RX_CONFIG] = 0x20; hw->regs[NE2000_INT_STATUS] = 0xFF; - hw->regs[NE2000_INT_MASK] = 0; + hw->regs[NE2000_INT_MASK] = 0; RemoveInterrupt(ud); return; - } +} /// /// BoardShutdown() void BoardShutdown(struct UnitData *ud) - { +{ volatile struct Ne2000 *hw = ud->ud_Hardware; GoOffline(ud); - hw->regs[NE2000_INT_MASK] = 0; + hw->regs[NE2000_INT_MASK] = 0; hw->regs[NE2000_INT_STATUS] = 0xFF; return; - } +} /// /// GetPacketHeader() ULONG GetPacketHeader(volatile struct Ne2000 *ne, UBYTE page) - { +{ UWORD hdr[2]; - ne->regs[NE2000_DMA_COUNTER0] = 4; - ne->regs[NE2000_DMA_COUNTER1] = 0; + ne->regs[NE2000_DMA_COUNTER0] = 4; + ne->regs[NE2000_DMA_COUNTER1] = 0; ne->regs[NE2000_DMA_START_ADDR0] = 0; ne->regs[NE2000_DMA_START_ADDR1] = page; - ne->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_START | COMMAND_READ; - hdr[0] = ne->DMAPort; - hdr[1] = ne->DMAPort; - return *(ULONG*)hdr; - } + ne->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_START | COMMAND_READ; + hdr[0] = ne->DMAPort; + hdr[1] = ne->DMAPort; + return *(ULONG *)hdr; +} /// /// GetPacket() GetPacket(volatile struct Ne2000 *ne, UBYTE startpage, UWORD len, UWORD *buffer) - { +{ UWORD count; - ne->regs[NE2000_DMA_COUNTER0] = len & 0xFF; - ne->regs[NE2000_DMA_COUNTER1] = len >> 8; + ne->regs[NE2000_DMA_COUNTER0] = len & 0xFF; + ne->regs[NE2000_DMA_COUNTER1] = len >> 8; ne->regs[NE2000_DMA_START_ADDR0] = 4; ne->regs[NE2000_DMA_START_ADDR1] = startpage; - ne->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_START | COMMAND_READ; + ne->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_START | COMMAND_READ; for (count = (len + 1) >> 1; count; count--) - { + { *buffer++ = ne->DMAPort; - } + } return; - } +} /// /// PacketReceived() LONG PacketReceived(struct UnitData *ud) - { +{ ULONG header, len; header = GetPacketHeader(ud->ud_Hardware, ud->ud_NextPage); - len = swapw(header & 0xFFFF); - GetPacket(ud->ud_Hardware, ud->ud_NextPage, len, (UWORD*)ud->ud_RxBuffer); - ud->ud_Hardware->regs[NE2000_BOUNDARY] = ud->ud_NextPage; - ud->ud_NextPage = (header >> 16) & 0xFF; + len = swapw(header & 0xFFFF); + GetPacket(ud->ud_Hardware, ud->ud_NextPage, len, (UWORD *)ud->ud_RxBuffer); + ud->ud_Hardware->regs[NE2000_BOUNDARY] = ud->ud_NextPage; + ud->ud_NextPage = (header >> 16) & 0xFF; ud->ud_Hardware->regs[NE2000_INT_STATUS] = INT_RXPACKET; return len; - } +} /// /// BufferOverflow() void BufferOverflow(struct UnitData *ud) - { - struct Library *DOSBase = ud->ud_DOSBase; - volatile struct Ne2000 *hw = ud->ud_Hardware; - UBYTE txp, resent = FALSE, intstatus; +{ + struct Library * DOSBase = ud->ud_DOSBase; + volatile struct Ne2000 *hw = ud->ud_Hardware; + UBYTE txp, resent = FALSE, intstatus; - txp = hw->regs[NE2000_COMMAND] & COMMAND_TXP; + txp = hw->regs[NE2000_COMMAND] & COMMAND_TXP; hw->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_ABORT | COMMAND_STOP; Delay(1); hw->regs[NE2000_DMA_COUNTER0] = 0; hw->regs[NE2000_DMA_COUNTER1] = 0; if (txp) - { + { intstatus = hw->regs[NE2000_INT_STATUS]; if (!(intstatus & (INT_TXPACKET | INT_TXERROR))) resent = TRUE; - } + } - hw->regs[NE2000_TX_CONFIG] = TXCFG_LOOP_INT; - hw->regs[NE2000_COMMAND] = COMMAND_PAGE1 | COMMAND_ABORT | COMMAND_START; + hw->regs[NE2000_TX_CONFIG] = TXCFG_LOOP_INT; + hw->regs[NE2000_COMMAND] = COMMAND_PAGE1 | COMMAND_ABORT | COMMAND_START; hw->regs[NE2000_CURRENT_PAGE] = RX_BUFFER; - hw->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_ABORT | COMMAND_START; - hw->regs[NE2000_BOUNDARY] = BUFFER_END - 1; - ud->ud_NextPage = RX_BUFFER; + hw->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_ABORT | COMMAND_START; + hw->regs[NE2000_BOUNDARY] = BUFFER_END - 1; + ud->ud_NextPage = RX_BUFFER; hw->regs[NE2000_TX_CONFIG] = TXCFG_LOOP_NONE; - if (resent) hw->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_START | - COMMAND_ABORT | COMMAND_TXP; + if (resent) hw->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_START | COMMAND_ABORT | COMMAND_TXP; hw->regs[NE2000_INT_STATUS] = INT_OVERFLOW; return; - } +} /// /// SendPacket() void SendPacket(struct UnitData *ud, struct IOSana2Req *req) - { +{ USE_U(SysBase) USE_UD(DOSBase) volatile struct Ne2000 *hw = ud->ud_Hardware; - UBYTE ethbuffer[1536], *datapointer; - UWORD *ethdata = (UWORD*)ethbuffer; - ULONG data_len = req->ios2_DataLength; - UWORD cycles; - WORD i; + UBYTE ethbuffer[1536], *datapointer; + UWORD * ethdata = (UWORD *)ethbuffer; + ULONG data_len = req->ios2_DataLength; + UWORD cycles; + WORD i; /* If not raw packets, fill in Dst, Src and Type fields of Ethernet frame. 'datapointer' is a vairable */ /* holding address of data to copy from network stack. If packet is raw, datapointer points to start */ /* of ethbuffer, otherwise points to ef_Data field (first byte after Ethernet header. */ if (!(req->ios2_Req.io_Flags & SANA2IOF_RAW)) - { - struct EthFrame *ef = (struct EthFrame*)ethbuffer; + { + struct EthFrame *ef = (struct EthFrame *)ethbuffer; CopyMem(req->ios2_DstAddr, ef->ef_DestAddr, 6); CopyMem(ud->ud_EtherAddress, ef->ef_SrcAddr, 6); ef->ef_Type = req->ios2_PacketType; datapointer = ef->ef_Data; - } - else datapointer = ethbuffer; + } + else + datapointer = ethbuffer; /* Copy data from network stack using supplied CopyFrom() function. */ - CopyB(((struct BuffFunctions*)req->ios2_BufferManagement)->bf_CopyFrom, - datapointer, req->ios2_Data, data_len); + CopyB(((struct BuffFunctions *)req->ios2_BufferManagement)->bf_CopyFrom, datapointer, req->ios2_Data, data_len); /* Now we need length of data to send to hardware. IORequest ios2_DataLength does not include header */ /* length if packet is not RAW. So we sholud add it. */ @@ -1272,11 +1269,11 @@ void SendPacket(struct UnitData *ud, struct IOSana2Req *req) /* Now the packet is ready to send it to NIC buffer. It is done by Remote Write DMA command. Firstly */ /* write addres and counter should be initialized, then command register. */ - hw->regs[NE2000_DMA_COUNTER0] = data_len & 0xFF; - hw->regs[NE2000_DMA_COUNTER1] = data_len >> 8; + hw->regs[NE2000_DMA_COUNTER0] = data_len & 0xFF; + hw->regs[NE2000_DMA_COUNTER1] = data_len >> 8; hw->regs[NE2000_DMA_START_ADDR0] = 0; hw->regs[NE2000_DMA_START_ADDR1] = TX_BUFFER; - hw->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_START | COMMAND_WRITE; + hw->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_START | COMMAND_WRITE; /* Now we can send packet data to DMAPort word by word. */ @@ -1285,8 +1282,8 @@ void SendPacket(struct UnitData *ud, struct IOSana2Req *req) /* Send packet to the wire. Register setup first. */ hw->regs[NE2000_TX_PAGE_START] = TX_BUFFER; - hw->regs[NE2000_TX_COUNTER0] = data_len & 0xFF; - hw->regs[NE2000_TX_COUNTER1] = data_len >> 8; + hw->regs[NE2000_TX_COUNTER0] = data_len & 0xFF; + hw->regs[NE2000_TX_COUNTER1] = data_len >> 8; /* Three, two, one, go! */ @@ -1297,70 +1294,72 @@ void SendPacket(struct UnitData *ud, struct IOSana2Req *req) DBG_T("Packet sent."); return; - } +} /// /// GetHwAddress() void GetHwAddress(struct UnitData *ud) - { +{ USE_UD(DOSBase) volatile struct Ne2000 *hw = ud->ud_Hardware; - WORD i; + WORD i; - hw->regs[NE2000_DMA_COUNTER0] = 6; - hw->regs[NE2000_DMA_COUNTER1] = 0; + hw->regs[NE2000_DMA_COUNTER0] = 6; + hw->regs[NE2000_DMA_COUNTER1] = 0; hw->regs[NE2000_DMA_START_ADDR0] = 0; hw->regs[NE2000_DMA_START_ADDR1] = 0; - hw->regs[NE2000_COMMAND] = COMMAND_READ; + hw->regs[NE2000_COMMAND] = COMMAND_READ; for (i = 0; i < 6; i++) ud->ud_EtherAddress[i] = hw->DMAPort; - #ifdef PDEBUG - DBG_U("\thardware address (read):"); - for (i = 0; i < 6; i++) DBG1_U("\t%02lx", ud->ud_EtherAddress[i]); - #endif +#ifdef PDEBUG + DBG_U("\thardware address (read):"); + for (i = 0; i < 6; i++) DBG1_U("\t%02lx", ud->ud_EtherAddress[i]); +#endif return; - } +} /// /// WriteHwAddress() void WriteHwAddress(struct UnitData *ud) - { +{ USE_UD(DOSBase) volatile struct Ne2000 *hw = ud->ud_Hardware; - WORD i; + WORD i; - #ifdef PDEBUG - DBG_U("\thardware address (write):"); - for (i = 0; i < 6; i++) DBG1_U("\t%02lx", ud->ud_SoftAddress[i]); - #endif +#ifdef PDEBUG + DBG_U("\thardware address (write):"); + for (i = 0; i < 6; i++) DBG1_U("\t%02lx", ud->ud_SoftAddress[i]); +#endif hw->regs[NE2000_COMMAND] = COMMAND_PAGE1 | COMMAND_ABORT | COMMAND_STOP; for (i = 0; i < 6; i++) - { + { hw->regs[NE2000_PHYSICAL_ADDR0 + i] = ud->ud_SoftAddress[i]; - } + } hw->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_ABORT | COMMAND_STOP; return; - } +} /// /// RingBufferNotEmpty() LONG RingBufferNotEmpty(struct UnitData *ud) - { - UBYTE current; +{ + UBYTE current; volatile struct Ne2000 *hw = ud->ud_Hardware; hw->regs[NE2000_COMMAND] = COMMAND_PAGE1 | COMMAND_ABORT | COMMAND_START; - current = hw->regs[NE2000_CURRENT_PAGE]; + current = hw->regs[NE2000_CURRENT_PAGE]; hw->regs[NE2000_COMMAND] = COMMAND_PAGE0 | COMMAND_ABORT | COMMAND_START; - if (ud->ud_NextPage == current) return FALSE; - else return TRUE; - } + if (ud->ud_NextPage == current) + return FALSE; + else + return TRUE; +} /// @@ -1369,179 +1368,177 @@ LONG RingBufferNotEmpty(struct UnitData *ud) /// SearchReadRequest() struct IOSana2Req *SearchReadRequest(struct UnitData *ud, struct MinList *queue, ULONG type) - { - struct Library *SysBase = ud->ud_SysBase; +{ + struct Library * SysBase = ud->ud_SysBase; struct IOSana2Req *req, *found = NULL, *x; - for (req = (struct IOSana2Req*)queue->mlh_Head; - req->ios2_Req.io_Message.mn_Node.ln_Succ; - req = (struct IOSana2Req*)req->ios2_Req.io_Message.mn_Node.ln_Succ) - { + for (req = (struct IOSana2Req *)queue->mlh_Head; req->ios2_Req.io_Message.mn_Node.ln_Succ; + req = (struct IOSana2Req *)req->ios2_Req.io_Message.mn_Node.ln_Succ) + { if (req->ios2_PacketType == type) - { - Remove((struct Node*)req); + { + Remove((struct Node *)req); found = req; break; - } - } + } + } return found; - } +} /// /// FlushQueues() void FlushQueues(struct UnitData *ud) - { +{ USE_U(SysBase) USE_UD(DOSBase) struct IOSana2Req *xreq; for (;;) - { + { Disable(); - xreq = (struct IOSana2Req*)RemHead((struct List*)&ud->ud_RxQueue); + xreq = (struct IOSana2Req *)RemHead((struct List *)&ud->ud_RxQueue); Enable(); if (!xreq) break; DBG1_T("<- READ [$08%lx] [F].", xreq); IoDone(ud, xreq, IOERR_ABORTED, S2WERR_GENERIC_ERROR); - } + } for (;;) - { + { Disable(); - xreq = (struct IOSana2Req*)RemHead((struct List*)&ud->ud_TxQueue); + xreq = (struct IOSana2Req *)RemHead((struct List *)&ud->ud_TxQueue); Enable(); if (!xreq) break; DBG1_T("<- WRITE [$08%lx] [F].", xreq); IoDone(ud, xreq, IOERR_ABORTED, S2WERR_GENERIC_ERROR); - } + } return; - } +} /// /// MainLoop() void MainLoop(struct UnitData *ud, struct MsgPort *port) - { +{ USE_U(SysBase) USE_UD(DOSBase) - ULONG signals, sigmask; + ULONG signals, sigmask; struct IOSana2Req *req; - #ifdef PDEBUG +#ifdef PDEBUG UBYTE wname[60], *ptr; ptr = strcpy(wname, "CON:400/17/400/300/"); ptr = strcpy(ptr, ud->ud_Name); - strcpy(ptr,"/AUTO/CLOSE/WAIT"); + strcpy(ptr, "/AUTO/CLOSE/WAIT"); ud->tdebug = Open(wname, MODE_NEWFILE); - #endif +#endif sigmask = 1 << port->mp_SigBit; for (;;) - { + { DBG_T("Waiting..."); signals = Wait(SIGBREAKF_CTRL_C | sigmask | ud->ud_GoWriteMask); if (signals & ud->ud_GoWriteMask) - { + { DBG_T("GoWrite"); Disable(); - req = (struct IOSana2Req*)RemHead((struct List*)&ud->ud_TxQueue); + req = (struct IOSana2Req *)RemHead((struct List *)&ud->ud_TxQueue); Enable(); ud->ud_PendingWrite = req; if (req) SendPacket(ud, req); - } + } if (signals & SIGBREAKF_CTRL_C) - { + { DBG1_T("TASK: %s task killed.", ud->ud_Name); return; - } + } if (signals & sigmask) - { + { struct IOSana2Req *req; DBG_T("port"); - while (req = (struct IOSana2Req*)GetMsg(port)) - { + while (req = (struct IOSana2Req *)GetMsg(port)) + { switch (req->ios2_Req.io_Command) - { - case CMD_READ: - DBG1_T("-> READ [$%08lx].", req); - Disable(); - AddTail((struct List*)&ud->ud_RxQueue, (struct Node*)req); - Enable(); + { + case CMD_READ: + DBG1_T("-> READ [$%08lx].", req); + Disable(); + AddTail((struct List *)&ud->ud_RxQueue, (struct Node *)req); + Enable(); break; - case S2_BROADCAST: - case CMD_WRITE: - DBG1_T("-> WRITE [$%08lx].", req); - if (ud->ud_PendingWrite) - { - Disable(); - AddTail((struct List*)&ud->ud_TxQueue, (struct Node*)req); - Enable(); - } - else - { - ud->ud_PendingWrite = req; - SendPacket(ud, req); - DBG_T("Packet sent 2."); - } + case S2_BROADCAST: + case CMD_WRITE: + DBG1_T("-> WRITE [$%08lx].", req); + if (ud->ud_PendingWrite) + { + Disable(); + AddTail((struct List *)&ud->ud_TxQueue, (struct Node *)req); + Enable(); + } + else + { + ud->ud_PendingWrite = req; + SendPacket(ud, req); + DBG_T("Packet sent 2."); + } break; - case CMD_FLUSH: - DBG1_T("-> FLUSH [$%08lx].", req); - FlushQueues(ud); - DBG1_T("<- FLUSH [$%08lx].", req); - IoDone(ud, req, OK, OK); + case CMD_FLUSH: + DBG1_T("-> FLUSH [$%08lx].", req); + FlushQueues(ud); + DBG1_T("<- FLUSH [$%08lx].", req); + IoDone(ud, req, OK, OK); break; - default: - DBG2_T("-> Unknown ($%lx) [$%08lx].", req->ios2_Req.io_Command, req); - } - } - } - } - } + default: + DBG2_T("-> Unknown ($%lx) [$%08lx].", req->ios2_Req.io_Command, req); + } + } + } + } +} /// /// UnitTask() void UnitTask(void) - { - struct Library *SysBase = *(struct Library**)4; - struct Task *task; - struct MsgPort *port; +{ + struct Library * SysBase = *(struct Library **)4; + struct Task * task; + struct MsgPort * port; struct UnitData *ud; - #ifdef PDEBUG +#ifdef PDEBUG struct Library *DOSBase; - #endif +#endif task = FindTask(NULL); if (port = CreateMsgPort()) - { + { port->mp_Node.ln_Name = task->tc_Node.ln_Name; - port->mp_Node.ln_Pri = 20; + port->mp_Node.ln_Pri = 20; AddPort(port); WaitPort(port); RemPort(port); - ud = (struct UnitData*)GetMsg(port); + ud = (struct UnitData *)GetMsg(port); if ((ud->ud_GoWriteBit = AllocSignal(-1)) != -1) - { + { ud->ud_GoWriteMask = 1 << ud->ud_GoWriteBit; MainLoop(ud, port); FreeSignal(ud->ud_GoWriteBit); - } + } DeleteMsgPort(port); Forbid(); ReplyMsg(&ud->ud_Message); - } + } return; - } +} /// - diff --git a/ne2000/driver.h b/ne2000/driver.h old mode 100755 new mode 100644 index 359abba..9530c35 --- a/ne2000/driver.h +++ b/ne2000/driver.h @@ -2,17 +2,17 @@ /* Main option switches */ -#define PDEBUG 1 /* Debug on/off switch (debug off if commented). */ -#define USE_TASK 1 /* Uncomment if unit runs own task. */ -#define USE_INTERRUPT 1 /* Uncomment if unit uses interrupt. */ +#define PDEBUG 1 /* Debug on/off switch (debug off if commented). */ +#define USE_TASK 1 /* Uncomment if unit runs own task. */ +#define USE_INTERRUPT 1 /* Uncomment if unit uses interrupt. */ -#define MAX_UNITS 4 /* How many units can device have? */ -#define OK 0 +#define MAX_UNITS 4 /* How many units can device have? */ +#define OK 0 /* PCI card ID's - put your board ID's, you can obtain them using PrmScan */ -#define PCI_VENDOR 0x10EC -#define PCI_DEVICE 0x8029 +#define PCI_VENDOR 0x10EC +#define PCI_DEVICE 0x8029 /* Macro for registerized parameters (used in some OS functions). */ @@ -20,36 +20,36 @@ /* Macro for declaring local libraries bases. */ -#define USE(a) struct Library *##a = dd->dd_##a; /* local base from DevData */ -#define USE_U(a) struct Library *##a = ud->ud_##a; /* local base from UnitData */ +#define USE(a) struct Library *##a = dd->dd_##a; /* local base from DevData */ +#define USE_U(a) struct Library *##a = ud->ud_##a; /* local base from UnitData */ /* Macros for debug messages. Replace FPrintf() with KPrintf() */ /* if you want traditional serial terminal debug output. */ #ifdef PDEBUG - #define USE_D(a) struct Library *##a = dd->dd_##a; - #define USE_UD(a) struct Library *##a = ud->ud_##a; - #define DBG(a) FPrintf(dd->debug, a "\n") - #define DBG_U(a) FPrintf(ud->debug, a "\n") - #define DBG_T(a) FPrintf(ud->tdebug, a "\n") - #define DBG1(a,b) FPrintf(dd->debug, a "\n",(LONG)b) - #define DBG1_U(a,b) FPrintf(ud->debug, a "\n",(LONG)b) - #define DBG1_T(a,b) FPrintf(ud->tdebug, a "\n",(LONG)b) - #define DBG2(a,b,c) FPrintf(dd->debug, a "\n",(LONG)b,(LONG)c) - #define DBG2_U(a,b,c) FPrintf(ud->debug, a "\n",(LONG)b,(LONG)c) - #define DBG2_T(a,b,c) FPrintf(ud->tdebug, a "\n",(LONG)b,(LONG)c) + #define USE_D(a) struct Library *##a = dd->dd_##a; + #define USE_UD(a) struct Library *##a = ud->ud_##a; + #define DBG(a) FPrintf(dd->debug, a "\n") + #define DBG_U(a) FPrintf(ud->debug, a "\n") + #define DBG_T(a) FPrintf(ud->tdebug, a "\n") + #define DBG1(a, b) FPrintf(dd->debug, a "\n", (LONG)b) + #define DBG1_U(a, b) FPrintf(ud->debug, a "\n", (LONG)b) + #define DBG1_T(a, b) FPrintf(ud->tdebug, a "\n", (LONG)b) + #define DBG2(a, b, c) FPrintf(dd->debug, a "\n", (LONG)b, (LONG)c) + #define DBG2_U(a, b, c) FPrintf(ud->debug, a "\n", (LONG)b, (LONG)c) + #define DBG2_T(a, b, c) FPrintf(ud->tdebug, a "\n", (LONG)b, (LONG)c) #else - #define USE_D(a) - #define USE_UD(a) - #define DBG(a) - #define DBG_U(a) - #define DBG_T(a) - #define DBG1(a,b) - #define DBG1_U(a,b) - #define DBG1_T(a,b) - #define DBG2(a,b,c) - #define DBG2_U(a,b,c) - #define DBG2_T(a,b,c) + #define USE_D(a) + #define USE_UD(a) + #define DBG(a) + #define DBG_U(a) + #define DBG_T(a) + #define DBG1(a, b) + #define DBG1_U(a, b) + #define DBG1_T(a, b) + #define DBG2(a, b, c) + #define DBG2_U(a, b, c) + #define DBG2_T(a, b, c) #endif /* device structures */ @@ -61,71 +61,69 @@ typedef struct IOSana2Req IOMyReq; /* Device base */ struct DevData - { - struct Library dd_Lib; - APTR dd_SegList; - struct Library *dd_SysBase; - struct Library *dd_PrometheusBase; - struct Library *dd_UtilityBase; - struct Library *dd_DOSBase; - struct UnitData *dd_Units[MAX_UNITS]; - - #ifdef PDEBUG - BPTR debug; - #endif +{ + struct Library dd_Lib; + APTR dd_SegList; + struct Library * dd_SysBase; + struct Library * dd_PrometheusBase; + struct Library * dd_UtilityBase; + struct Library * dd_DOSBase; + struct UnitData *dd_Units[MAX_UNITS]; - /* add your own stuff here */ +#ifdef PDEBUG + BPTR debug; +#endif - }; + /* add your own stuff here */ +}; struct UnitData - { - struct Message ud_Message; - struct Library *ud_SysBase; - struct Library *ud_DOSBase; - LONG ud_OpenCnt; - char *ud_Name; - - #ifdef USE_INTERRUPT - struct Interrupt *ud_Interrupt; - #endif - - #ifdef USE_TASK - struct Task *ud_Task; - struct MsgPort *ud_TaskPort; - struct MsgPort *ud_LifeTime; - #endif - - APTR ud_Hardware; /* you can change the type to structure */ - /* describing hardware registers */ - - #ifdef PDEBUG - BPTR debug; - BPTR tdebug; - #endif +{ + struct Message ud_Message; + struct Library *ud_SysBase; + struct Library *ud_DOSBase; + LONG ud_OpenCnt; + char * ud_Name; + +#ifdef USE_INTERRUPT + struct Interrupt *ud_Interrupt; +#endif - /* add your own stuff here */ - }; +#ifdef USE_TASK + struct Task * ud_Task; + struct MsgPort *ud_TaskPort; + struct MsgPort *ud_LifeTime; +#endif + APTR ud_Hardware; /* you can change the type to structure */ + /* describing hardware registers */ + +#ifdef PDEBUG + BPTR debug; + BPTR tdebug; +#endif + + /* add your own stuff here */ +}; /* prototypes */ struct DevData *DevInit(void *seglist reg(a0), struct Library *sysb reg(a6)); -LONG DevOpen(IOMyReq *req reg(a1), LONG unit reg(d0), LONG flags reg(d1), struct DevData *dd reg(a6)); -APTR DevClose(IOMyReq *req reg(a1), struct DevData *dd reg(a6)); -APTR DevExpunge(struct DevData *dd reg(a6)); -long DevReserved(void); -void DevBeginIO(IOMyReq *req reg(a1), struct DevData *dd reg(a6)); -ULONG DevAbortIO(IOMyReq *req reg(a1), struct DevData *dd reg(a6)); - -void IoDone(struct UnitData *ud, IOMyReq *req, LONG err); -LONG OpenDeviceLibraries(struct DevData *dd); -void CloseDeviceLibraries(struct DevData *dd); -LONG RunTask(struct DevData *dd, struct UnitData *ud); +LONG DevOpen(IOMyReq *req reg(a1), LONG unit reg(d0), LONG flags reg(d1), struct DevData *dd reg(a6)); +APTR DevClose(IOMyReq *req reg(a1), struct DevData *dd reg(a6)); +APTR DevExpunge(struct DevData *dd reg(a6)); +long DevReserved(void); +void DevBeginIO(IOMyReq *req reg(a1), struct DevData *dd reg(a6)); +ULONG DevAbortIO(IOMyReq *req reg(a1), struct DevData *dd reg(a6)); + +void IoDone(struct UnitData *ud, IOMyReq *req, LONG err); +LONG OpenDeviceLibraries(struct DevData *dd); +void CloseDeviceLibraries(struct DevData *dd); +LONG RunTask(struct DevData *dd, struct UnitData *ud); struct UnitData *OpenUnit(struct DevData *dd, LONG unit, LONG flags); struct UnitData *InitializeUnit(struct DevData *dd, LONG unit); -void CloseUnit(struct DevData *dd, struct UnitData *ud); -void ExpungeUnit(struct DevData *dd, struct UnitData *ud); +void CloseUnit(struct DevData *dd, struct UnitData *ud); +void ExpungeUnit(struct DevData *dd, struct UnitData *ud); void __saveds CmdNSDQuery(struct UnitData *ud, struct IOStdReq *req); @@ -134,4 +132,3 @@ LONG InstallInterrupt(struct UnitData *ud); void RemoveInterrupt(struct UnitData *ud); void UnitTask(void); - diff --git a/ne2000/endian.h b/ne2000/endian.h old mode 100755 new mode 100644 index 55ac604..e77f33e --- a/ne2000/endian.h +++ b/ne2000/endian.h @@ -2,23 +2,23 @@ /* swap word */ -#define swapw(arg)\ - ({short __arg = (arg);\ - asm ("ROL.W #8,%0"\ - :"=d" (__arg)\ - :"0" (__arg)\ - :"cc");\ - __arg;}) +#define swapw(arg) \ + ({ \ + short __arg = (arg); \ + asm("ROL.W #8,%0" : "=d"(__arg) : "0"(__arg) : "cc"); \ + __arg; \ + }) /* swap long */ -#define swapl(arg)\ - ({long __arg = (arg);\ - asm ("ROL.W #8,%0;\ +#define swapl(arg) \ + ({ \ + long __arg = (arg); \ + asm("ROL.W #8,%0;\ SWAP %0;\ - ROL.W #8,%0"\ - :"=d" (__arg)\ - :"0" (__arg)\ - :"cc");\ - __arg;}) - + ROL.W #8,%0" \ + : "=d"(__arg) \ + : "0"(__arg) \ + : "cc"); \ + __arg; \ + }) diff --git a/ne2000/ne2000.h b/ne2000/ne2000.h old mode 100755 new mode 100644 index aac472a..0b41a62 --- a/ne2000/ne2000.h +++ b/ne2000/ne2000.h @@ -4,92 +4,91 @@ #include #ifndef PRMNE2000_NE2000_H -#define PRMNE2000_NE2000_H + #define PRMNE2000_NE2000_H /* some register constans */ -#define COMMAND_PAGE0 0x00 -#define COMMAND_PAGE1 0x40 -#define COMMAND_PAGE2 0x80 -#define COMMAND_READ 0x08 -#define COMMAND_WRITE 0x10 -#define COMMAND_SEND 0x18 -#define COMMAND_ABORT 0x20 -#define COMMAND_TXP 0x04 -#define COMMAND_START 0x02 -#define COMMAND_STOP 0x01 + #define COMMAND_PAGE0 0x00 + #define COMMAND_PAGE1 0x40 + #define COMMAND_PAGE2 0x80 + #define COMMAND_READ 0x08 + #define COMMAND_WRITE 0x10 + #define COMMAND_SEND 0x18 + #define COMMAND_ABORT 0x20 + #define COMMAND_TXP 0x04 + #define COMMAND_START 0x02 + #define COMMAND_STOP 0x01 -#define TXCFG_COLOFFSET 0x10 -#define TXCFG_ATDIS 0x08 -#define TXCFG_LOOP_MASK 0x06 -#define TXCFG_LOOP_NONE 0x00 -#define TXCFG_LOOP_INT 0x02 -#define TXCFG_LOOP_EXT 0x04 -#define TXCFG_CRC 0x01 + #define TXCFG_COLOFFSET 0x10 + #define TXCFG_ATDIS 0x08 + #define TXCFG_LOOP_MASK 0x06 + #define TXCFG_LOOP_NONE 0x00 + #define TXCFG_LOOP_INT 0x02 + #define TXCFG_LOOP_EXT 0x04 + #define TXCFG_CRC 0x01 -#define RXCFG_MONITOR 0x20 -#define RXCFG_PROM 0x10 -#define RXCFG_MCAST 0x08 -#define RXCFG_BCAST 0x04 -#define RXCFG_SHORTPKT 0x02 -#define RXCFG_RXERR 0x01 + #define RXCFG_MONITOR 0x20 + #define RXCFG_PROM 0x10 + #define RXCFG_MCAST 0x08 + #define RXCFG_BCAST 0x04 + #define RXCFG_SHORTPKT 0x02 + #define RXCFG_RXERR 0x01 -#define DTCFG_FIFOTRSH 0x60 -#define DTCFG_FIFO_8 0x40 -#define DTCFG_AUTORM 0x10 -#define DTCFG_LOOPSEL 0x08 -#define DTCFG_LAS 0x04 -#define DTCFG_BYTESWAP 0x02 -#define DTCFG_WIDE 0x01 + #define DTCFG_FIFOTRSH 0x60 + #define DTCFG_FIFO_8 0x40 + #define DTCFG_AUTORM 0x10 + #define DTCFG_LOOPSEL 0x08 + #define DTCFG_LAS 0x04 + #define DTCFG_BYTESWAP 0x02 + #define DTCFG_WIDE 0x01 -#define INT_RESET 0x80 -#define INT_DMAFINISH 0x40 -#define INT_COUNTEROVF 0x20 -#define INT_OVERFLOW 0x10 -#define INT_TXERROR 0x08 -#define INT_RXERROR 0x04 -#define INT_TXPACKET 0x02 -#define INT_RXPACKET 0x01 + #define INT_RESET 0x80 + #define INT_DMAFINISH 0x40 + #define INT_COUNTEROVF 0x20 + #define INT_OVERFLOW 0x10 + #define INT_TXERROR 0x08 + #define INT_RXERROR 0x04 + #define INT_TXPACKET 0x02 + #define INT_RXPACKET 0x01 -#define TXS_TRANSMITTED_OK 0x01 + #define TXS_TRANSMITTED_OK 0x01 -#define NE2000_COMMAND 0 -#define NE2000_PAGE_START 1 -#define NE2000_PHYSICAL_ADDR0 1 /* register page 1 */ -#define NE2000_PAGE_STOP 2 -#define NE2000_BOUNDARY 3 -#define NE2000_TX_PAGE_START 4 /* write */ -#define NE2000_TX_STATUS 4 /* read */ -#define NE2000_TX_COUNTER0 5 -#define NE2000_TX_COUNTER1 6 -#define NE2000_CURRENT_PAGE 7 /* register page 1 */ -#define NE2000_INT_STATUS 7 -#define NE2000_DMA_START_ADDR0 8 -#define NE2000_DMA_START_ADDR1 9 -#define NE2000_DMA_COUNTER0 10 -#define NE2000_DMA_COUNTER1 11 -#define NE2000_RX_CONFIG 12 -#define NE2000_TX_CONFIG 13 -#define NE2000_DATA_CONFIG 14 -#define NE2000_INT_MASK 15 + #define NE2000_COMMAND 0 + #define NE2000_PAGE_START 1 + #define NE2000_PHYSICAL_ADDR0 1 /* register page 1 */ + #define NE2000_PAGE_STOP 2 + #define NE2000_BOUNDARY 3 + #define NE2000_TX_PAGE_START 4 /* write */ + #define NE2000_TX_STATUS 4 /* read */ + #define NE2000_TX_COUNTER0 5 + #define NE2000_TX_COUNTER1 6 + #define NE2000_CURRENT_PAGE 7 /* register page 1 */ + #define NE2000_INT_STATUS 7 + #define NE2000_DMA_START_ADDR0 8 + #define NE2000_DMA_START_ADDR1 9 + #define NE2000_DMA_COUNTER0 10 + #define NE2000_DMA_COUNTER1 11 + #define NE2000_RX_CONFIG 12 + #define NE2000_TX_CONFIG 13 + #define NE2000_DATA_CONFIG 14 + #define NE2000_INT_MASK 15 struct Ne2000 - { - UBYTE regs[16]; - UWORD DMAPort; - UWORD pad0; - UWORD pad1; - UWORD pad2; - UWORD ResetPort; - }; - +{ + UBYTE regs[16]; + UWORD DMAPort; + UWORD pad0; + UWORD pad1; + UWORD pad2; + UWORD ResetPort; +}; struct EthFrame - { - UBYTE ef_DestAddr[6]; - UBYTE ef_SrcAddr[6]; - UWORD ef_Type; - UBYTE ef_Data[46]; /* shortest possible */ - }; +{ + UBYTE ef_DestAddr[6]; + UBYTE ef_SrcAddr[6]; + UWORD ef_Type; + UBYTE ef_Data[46]; /* shortest possible */ +}; #endif diff --git a/ne2000/nsd.h b/ne2000/nsd.h old mode 100755 new mode 100644 index 617d4ec..1f321e0 --- a/ne2000/nsd.h +++ b/ne2000/nsd.h @@ -1,28 +1,26 @@ /* New Style Device support */ -#define NSCMD_DEVICEQUERY 0x4000 +#define NSCMD_DEVICEQUERY 0x4000 struct NSDeviceQueryResult - { - ULONG DevQueryFormat; /* this is type 0 */ - ULONG SizeAvailable; /* bytes available */ - UWORD DeviceType; /* what the device does */ - UWORD DeviceSubType; /* depends on the main type */ - UWORD *SupportedCommands; /* 0 terminated list of cmd's */ - }; - -#define NSDEVTYPE_UNKNOWN 0 /* No suitable category, anything */ -#define NSDEVTYPE_GAMEPORT 1 /* like gameport.device */ -#define NSDEVTYPE_TIMER 2 /* like timer.device */ -#define NSDEVTYPE_KEYBOARD 3 /* like keyboard.device */ -#define NSDEVTYPE_INPUT 4 /* like input.device */ -#define NSDEVTYPE_TRACKDISK 5 /* like trackdisk.device */ -#define NSDEVTYPE_CONSOLE 6 /* like console.device */ -#define NSDEVTYPE_SANA2 7 /* A >=SANA2R2 networking device */ -#define NSDEVTYPE_AUDIO 8 /* like audio.device */ -#define NSDEVTYPE_CLIPBOARD 9 /* like clipboard.device */ -#define NSDEVTYPE_PRINTER 10 /* like printer.device */ -#define NSDEVTYPE_SERIAL 11 /* like serial.device */ -#define NSDEVTYPE_PARALLEL 12 /* like parallel.device */ - +{ + ULONG DevQueryFormat; /* this is type 0 */ + ULONG SizeAvailable; /* bytes available */ + UWORD DeviceType; /* what the device does */ + UWORD DeviceSubType; /* depends on the main type */ + UWORD *SupportedCommands; /* 0 terminated list of cmd's */ +}; +#define NSDEVTYPE_UNKNOWN 0 /* No suitable category, anything */ +#define NSDEVTYPE_GAMEPORT 1 /* like gameport.device */ +#define NSDEVTYPE_TIMER 2 /* like timer.device */ +#define NSDEVTYPE_KEYBOARD 3 /* like keyboard.device */ +#define NSDEVTYPE_INPUT 4 /* like input.device */ +#define NSDEVTYPE_TRACKDISK 5 /* like trackdisk.device */ +#define NSDEVTYPE_CONSOLE 6 /* like console.device */ +#define NSDEVTYPE_SANA2 7 /* A >=SANA2R2 networking device */ +#define NSDEVTYPE_AUDIO 8 /* like audio.device */ +#define NSDEVTYPE_CLIPBOARD 9 /* like clipboard.device */ +#define NSDEVTYPE_PRINTER 10 /* like printer.device */ +#define NSDEVTYPE_SERIAL 11 /* like serial.device */ +#define NSDEVTYPE_PARALLEL 12 /* like parallel.device */ diff --git a/ne2000/rev.h b/ne2000/rev.h old mode 100755 new mode 100644 index 2d63f09..4a3fb30 --- a/ne2000/rev.h +++ b/ne2000/rev.h @@ -1,7 +1,7 @@ /* $Id: rev.h,v 1.1 2022/10/20 15:38:08 rkujawa Exp $ */ -#define DEV_VERSION 1 -#define DEV_REVISION 3 -#define DEV_NAME "prm-rtl8029.device" -#define DEV_IDSTRING "$VER: prm-rtl8029.device 1.3 (11.11.2002) (c) by Matay 2001\n" -#define DEV_UNITNAME "prm-rtl8029.device (x)" +#define DEV_VERSION 1 +#define DEV_REVISION 3 +#define DEV_NAME "prm-rtl8029.device" +#define DEV_IDSTRING "$VER: prm-rtl8029.device 1.3 (11.11.2002) (c) by Matay 2001\n" +#define DEV_UNITNAME "prm-rtl8029.device (x)" diff --git a/ne2000/sana2.h b/ne2000/sana2.h old mode 100755 new mode 100644 index b189cff..9469941 --- a/ne2000/sana2.h +++ b/ne2000/sana2.h @@ -8,4 +8,3 @@ void S2ConfigInterface(struct UnitData *ud, struct IOSana2Req *req); void S2Online(struct UnitData *ud, struct IOSana2Req *req); void S2Offline(struct UnitData *ud, struct IOSana2Req *req); void S2GetGlobalStats(struct UnitData *ud, struct IOSana2Req *req); - diff --git a/prmscan/prmscan.c b/prmscan/prmscan.c old mode 100755 new mode 100644 index 32ba313..89f7fb3 --- a/prmscan/prmscan.c +++ b/prmscan/prmscan.c @@ -1,207 +1,220 @@ /* Source code of prmscan - program scanning system for PCI cards plugged */ /* into Prometheus board. It demonstrates use of prometheus.library. */ -#define __NOLIBBASE__ /* we do not want to peeking library bases */ +#define __NOLIBBASE__ /* we do not want to peeking library bases */ -#include +#include #include +#include #include -#include struct Library *SysBase, *DOSBase, *PrometheusBase; const char *VString = "$VER: prmscan 1.6 (14.9.2002) by Grzegorz Kraszewski.\n"; - UWORD HexStrToWord(UBYTE *buffer) - { - WORD i; - UWORD result = 0, ch; - - for (i = 0; i < 4; i++) - { - result <<= 4; - ch = buffer[i]; - if (ch >= '0' && ch <= '9') ch -= 48; - else if (ch >= 'A' && ch <= 'F') ch -= 55; - else if (ch >= 'a' && ch <= 'f') ch -= 87; - else return 0xFFFF; - result += ch; - } - return result; - } - +{ + WORD i; + UWORD result = 0, ch; + + for (i = 0; i < 4; i++) + { + result <<= 4; + ch = buffer[i]; + if (ch >= '0' && ch <= '9') + ch -= 48; + else if (ch >= 'A' && ch <= 'F') + ch -= 55; + else if (ch >= 'a' && ch <= 'f') + ch -= 87; + else + return 0xFFFF; + result += ch; + } + return result; +} void ShiftBufferLeft(UBYTE *buffer, WORD shift) - { - UBYTE *ptr = buffer; - - while (ptr[shift]) {ptr[0] = ptr[shift]; ptr++;} - } +{ + UBYTE *ptr = buffer; + while (ptr[shift]) + { + ptr[0] = ptr[shift]; + ptr++; + } +} void StripLeadingSpaces(UBYTE *buffer) - { - WORD idx = 0; - - while (buffer[idx] == 0x09 || buffer[idx] == 0x20) idx++; - if (idx) ShiftBufferLeft(buffer, idx); - } +{ + WORD idx = 0; + while (buffer[idx] == 0x09 || buffer[idx] == 0x20) idx++; + if (idx) ShiftBufferLeft(buffer, idx); +} void RemoveEOL(UBYTE *buffer) - { - UBYTE *ptr = buffer; - while (*buffer++ != 0x0A); - *--buffer = 0x00; - } - +{ + UBYTE *ptr = buffer; + while (*buffer++ != 0x0A) + ; + *--buffer = 0x00; +} LONG GetVendorString(BPTR vendors_file, UWORD vendor, UBYTE *buffer, LONG bufsize) - { - LONG error; - - if (vendors_file) - { - Seek(vendors_file, 0, OFFSET_BEGINNING); - while (FGets(vendors_file, buffer, bufsize)) - { - if (*buffer == ';') continue; /* comment */ - if (*buffer == 0x09) continue; /* device description */ - if (*buffer == 0x20) continue; - if (HexStrToWord(buffer) == vendor) - { - ShiftBufferLeft(buffer, 5); - StripLeadingSpaces(buffer); - RemoveEOL(buffer); - return 0; - } - } - if (error = IoErr()) return error; - } - else sprintf (buffer, "unknown ($%04lx)", vendor); - return 0; - } - +{ + LONG error; -LONG GetDeviceString(BPTR vendors_file, UWORD device, UBYTE *buffer, LONG bufsize) - { - LONG error; - - if (device != 0xFFFF) - { if (vendors_file) - { - while (FGets(vendors_file, buffer, bufsize)) - { - if (*buffer == ';') continue; /* comment */ - if (*buffer != 0x09 && *buffer != 0x20) break; /* vendor -> dev not found */ - StripLeadingSpaces(buffer); - if (HexStrToWord(buffer) == device) - { - ShiftBufferLeft(buffer, 5); - StripLeadingSpaces(buffer); - RemoveEOL(buffer); - return 0; - } - } - if (error = IoErr()) return error; - } - } - sprintf (buffer, "unknown ($%04lx)", device); - return 0; - } - - -LONG Main (void) - { - UBYTE vendor_name[80]; - UBYTE device_name[80]; - - Printf ("\nPrmscan 1.6 by Grzegorz Kraszewski.\n"); - Printf ("PCI cards listing:\n-------------------------------------------------\n"); - if (PrometheusBase = OpenLibrary ("prometheus.library", 2)) - { - APTR board = NULL; - ULONG vendor, device, revision, dclass, dsubclass, blkaddr, blksize, slot, function; - ULONG romaddr, romsize; - WORD blk; - BPTR vendors_file; - struct Node *owner; - STRPTR owner_name = "NONE"; - - vendors_file = Open("DEVS:PCI/vendors.txt", MODE_OLDFILE); - - while (board = Prm_FindBoardTags(board, TAG_END)) - { - Prm_GetBoardAttrsTags(board, - PRM_Vendor, (ULONG)&vendor, - PRM_Device, (ULONG)&device, - PRM_Revision, (ULONG)&revision, - PRM_Class, (ULONG)&dclass, - PRM_SubClass, (ULONG)&dsubclass, - PRM_SlotNumber, (ULONG)&slot, - PRM_FunctionNumber, (ULONG)&function, - PRM_BoardOwner, (ULONG)&owner, - TAG_END); - GetVendorString(vendors_file, vendor, vendor_name, 80); - GetDeviceString(vendors_file, device, device_name, 80); - Printf("Board in slot %ld, function %ld\n", slot, function); - Printf("Vendor: \033[1m%s\033[0m\nDevice: \033[1m%s\033[0m\nRevision: %ld.\n", - (LONG)vendor_name, (LONG)device_name, revision); - Printf("Device class %02lx, subclass %02lx.\n", dclass, dsubclass); - for (blk = 0; blk < 6; blk++) - { - Prm_GetBoardAttrsTags (board, - PRM_MemoryAddr0 + blk, (ULONG)&blkaddr, - PRM_MemorySize0 + blk, (ULONG)&blksize, - TAG_END); - if (blkaddr && blksize) - { - ULONG normsize = blksize; - STRPTR unit = "B"; - - if (normsize >= 1024) + { + Seek(vendors_file, 0, OFFSET_BEGINNING); + while (FGets(vendors_file, buffer, bufsize)) + { + if (*buffer == ';') continue; /* comment */ + if (*buffer == 0x09) continue; /* device description */ + if (*buffer == 0x20) continue; + if (HexStrToWord(buffer) == vendor) { - normsize >>= 10; - unit = "kB"; + ShiftBufferLeft(buffer, 5); + StripLeadingSpaces(buffer); + RemoveEOL(buffer); + return 0; } + } + if (error = IoErr()) return error; + } + else + sprintf(buffer, "unknown ($%04lx)", vendor); + return 0; +} + +LONG GetDeviceString(BPTR vendors_file, UWORD device, UBYTE *buffer, LONG bufsize) +{ + LONG error; - if (normsize >= 1024) + if (device != 0xFFFF) + { + if (vendors_file) + { + while (FGets(vendors_file, buffer, bufsize)) { - normsize >>= 10; - unit = "MB"; + if (*buffer == ';') continue; /* comment */ + if (*buffer != 0x09 && *buffer != 0x20) break; /* vendor -> dev not found */ + StripLeadingSpaces(buffer); + if (HexStrToWord(buffer) == device) + { + ShiftBufferLeft(buffer, 5); + StripLeadingSpaces(buffer); + RemoveEOL(buffer); + return 0; + } } - - Printf ("Address range: %08lx - %08lx (%ld %s).\n", blkaddr, - blkaddr + blksize - 1, normsize, (LONG)unit); - } - } - Prm_GetBoardAttrsTags(board, - PRM_ROM_Address, (ULONG)&romaddr, - PRM_ROM_Size, (ULONG)&romsize, - TAG_END); - if (romaddr && romsize) - { - Printf ("%ld kB of ROM at %08lx - %08lx.\n", romsize >> 10, romaddr, - romaddr + romsize - 1); - } - if (owner) + if (error = IoErr()) return error; + } + } + sprintf(buffer, "unknown ($%04lx)", device); + return 0; +} + +LONG Main(void) +{ + UBYTE vendor_name[80]; + UBYTE device_name[80]; + + Printf("\nPrmscan 1.6 by Grzegorz Kraszewski.\n"); + Printf("PCI cards listing:\n-------------------------------------------------\n"); + if (PrometheusBase = OpenLibrary("prometheus.library", 2)) + { + APTR board = NULL; + ULONG vendor, device, revision, dclass, dsubclass, blkaddr, blksize, slot, function; + ULONG romaddr, romsize; + WORD blk; + BPTR vendors_file; + struct Node *owner; + STRPTR owner_name = "NONE"; + + vendors_file = Open("DEVS:PCI/vendors.txt", MODE_OLDFILE); + + while (board = Prm_FindBoardTags(board, TAG_END)) { - if (owner->ln_Name) owner_name = owner->ln_Name; - else owner_name = "unknown"; + Prm_GetBoardAttrsTags(board, + PRM_Vendor, + (ULONG)&vendor, + PRM_Device, + (ULONG)&device, + PRM_Revision, + (ULONG)&revision, + PRM_Class, + (ULONG)&dclass, + PRM_SubClass, + (ULONG)&dsubclass, + PRM_SlotNumber, + (ULONG)&slot, + PRM_FunctionNumber, + (ULONG)&function, + PRM_BoardOwner, + (ULONG)&owner, + TAG_END); + GetVendorString(vendors_file, vendor, vendor_name, 80); + GetDeviceString(vendors_file, device, device_name, 80); + Printf("Board in slot %ld, function %ld\n", slot, function); + Printf("Vendor: \033[1m%s\033[0m\nDevice: \033[1m%s\033[0m\nRevision: %ld.\n", + (LONG)vendor_name, + (LONG)device_name, + revision); + Printf("Device class %02lx, subclass %02lx.\n", dclass, dsubclass); + for (blk = 0; blk < 6; blk++) + { + Prm_GetBoardAttrsTags( + board, PRM_MemoryAddr0 + blk, (ULONG)&blkaddr, PRM_MemorySize0 + blk, (ULONG)&blksize, TAG_END); + if (blkaddr && blksize) + { + ULONG normsize = blksize; + STRPTR unit = "B"; + + if (normsize >= 1024) + { + normsize >>= 10; + unit = "kB"; + } + + if (normsize >= 1024) + { + normsize >>= 10; + unit = "MB"; + } + + Printf("Address range: %08lx - %08lx (%ld %s).\n", + blkaddr, + blkaddr + blksize - 1, + normsize, + (LONG)unit); + } + } + Prm_GetBoardAttrsTags(board, PRM_ROM_Address, (ULONG)&romaddr, PRM_ROM_Size, (ULONG)&romsize, TAG_END); + if (romaddr && romsize) + { + Printf("%ld kB of ROM at %08lx - %08lx.\n", romsize >> 10, romaddr, romaddr + romsize - 1); + } + if (owner) + { + if (owner->ln_Name) + owner_name = owner->ln_Name; + else + owner_name = "unknown"; + } + else + owner_name = "NONE"; + Printf("Board driver: \033[32m%s\033[0m.\n", (ULONG)owner_name); + Printf("-------------------------------------------------\n"); } - else owner_name = "NONE"; - Printf ("Board driver: \033[32m%s\033[0m.\n", (ULONG)owner_name); - Printf ("-------------------------------------------------\n"); - } - - if (vendors_file) Close(vendors_file); - Printf ("\n"); - CloseLibrary (PrometheusBase); - } - else Printf ("Can't open prometheus.library v2.\n\n"); - return 0; - } + if (vendors_file) Close(vendors_file); + Printf("\n"); + CloseLibrary(PrometheusBase); + } + else + Printf("Can't open prometheus.library v2.\n\n"); + return 0; +} diff --git a/prmscan/startup.c b/prmscan/startup.c old mode 100755 new mode 100644 index af07708..208d4f7 --- a/prmscan/startup.c +++ b/prmscan/startup.c @@ -9,31 +9,32 @@ struct Library *SysBase, *DOSBase; -__saveds long _main (void) - { - long return_value, wb; - struct Process *process; - struct Message *wbmessage = NULL; - - SysBase = *(struct Library**)4; - if (DOSBase = (struct Library*)OpenLibrary ("dos.library", 37)) - { - process = (struct Process*)FindTask (NULL); - if (process->pr_CLI) wb = FALSE; - else - { - WaitPort (&process->pr_MsgPort); - wbmessage = GetMsg (&process->pr_MsgPort); - wb = TRUE; - } - return_value = Main (wb); - CloseLibrary (DOSBase); - if (wbmessage) - { - Forbid (); - ReplyMsg (wbmessage); - } - return (return_value); - } - return (10); - } +__saveds long _main(void) +{ + long return_value, wb; + struct Process *process; + struct Message *wbmessage = NULL; + + SysBase = *(struct Library **)4; + if (DOSBase = (struct Library *)OpenLibrary("dos.library", 37)) + { + process = (struct Process *)FindTask(NULL); + if (process->pr_CLI) + wb = FALSE; + else + { + WaitPort(&process->pr_MsgPort); + wbmessage = GetMsg(&process->pr_MsgPort); + wb = TRUE; + } + return_value = Main(wb); + CloseLibrary(DOSBase); + if (wbmessage) + { + Forbid(); + ReplyMsg(wbmessage); + } + return (return_value); + } + return (10); +} diff --git a/prmscan/testreadcfg.c b/prmscan/testreadcfg.c old mode 100755 new mode 100644 index b8a56d7..b1eb633 --- a/prmscan/testreadcfg.c +++ b/prmscan/testreadcfg.c @@ -1,47 +1,45 @@ /* Test of ReadConfigXxxx() functions */ -#define __NOLIBBASE__ /* we do not want to peeking library bases */ +#define __NOLIBBASE__ /* we do not want to peeking library bases */ -#include #include +#include #include struct Library *SysBase, *DOSBase, *PrometheusBase; const char *VString = "$VER: testreadcfg 1.0 (5.1.2002) © 2002 Matay.\n"; - -LONG main (void) - { - Printf ("\ntestreadcfg 1.0 © 2002 Matay.\n"); - if (PrometheusBase = OpenLibrary ("prometheus.library", 2)) - { - APTR board = NULL; - - while (board = Prm_FindBoardTags(board, - PRM_Vendor, 0x10EC, - PRM_Device, 0x8139, - TAG_END)) - { - Printf("$%08lx\n", Prm_ReadConfigLong(board, 0)); - Printf("$%04lx $%04lx\n", Prm_ReadConfigWord(board, 0), Prm_ReadConfigWord(board, 2)); - Printf("$%02lx $%02lx $%02lx $%02lx\n", Prm_ReadConfigByte(board, 0), - Prm_ReadConfigByte(board, 1), Prm_ReadConfigByte(board, 2), - Prm_ReadConfigByte(board, 3)); - Printf("-------------------------------------------------\n"); - Printf("command word: %04lx\n", Prm_ReadConfigByte(board, 7)); - Prm_WriteConfigByte(board, 0x00, 7); - CacheClearU(); - Delay(20); - Printf("command word: %04lx\n", Prm_ReadConfigByte(board, 7)); - Prm_WriteConfigByte(board, 0x07, 7); - Delay(20); - Printf("command word: %04lx\n", Prm_ReadConfigByte(board, 7)); - } - Printf("\n"); - CloseLibrary(PrometheusBase); - } - else Printf ("prometheus.library V2 not found or initialization failed.\n\n"); - return 0; - } - +LONG main(void) +{ + Printf("\ntestreadcfg 1.0 © 2002 Matay.\n"); + if (PrometheusBase = OpenLibrary("prometheus.library", 2)) + { + APTR board = NULL; + + while (board = Prm_FindBoardTags(board, PRM_Vendor, 0x10EC, PRM_Device, 0x8139, TAG_END)) + { + Printf("$%08lx\n", Prm_ReadConfigLong(board, 0)); + Printf("$%04lx $%04lx\n", Prm_ReadConfigWord(board, 0), Prm_ReadConfigWord(board, 2)); + Printf("$%02lx $%02lx $%02lx $%02lx\n", + Prm_ReadConfigByte(board, 0), + Prm_ReadConfigByte(board, 1), + Prm_ReadConfigByte(board, 2), + Prm_ReadConfigByte(board, 3)); + Printf("-------------------------------------------------\n"); + Printf("command word: %04lx\n", Prm_ReadConfigByte(board, 7)); + Prm_WriteConfigByte(board, 0x00, 7); + CacheClearU(); + Delay(20); + Printf("command word: %04lx\n", Prm_ReadConfigByte(board, 7)); + Prm_WriteConfigByte(board, 0x07, 7); + Delay(20); + Printf("command word: %04lx\n", Prm_ReadConfigByte(board, 7)); + } + Printf("\n"); + CloseLibrary(PrometheusBase); + } + else + Printf("prometheus.library V2 not found or initialization failed.\n\n"); + return 0; +}