4 Copyright (C) 2004,2005 ADDI-DATA GmbH for the source code of this module.
10 Fax: +49(0)7223/9493-92
11 http://www.addi-data-com
14 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
16 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 You shoud also find the complete GPL in the COPYING file accompanying this source code.
25 +-----------------------------------------------------------------------+
26 | (C) ADDI-DATA GmbH Dieselstraße 3 D-77833 Ottersweier |
27 +-----------------------------------------------------------------------+
28 | Tel : +49 (0) 7223/9493-0 | email : info@addi-data.com |
29 | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com |
30 +-------------------------------+---------------------------------------+
31 | Project : ADDI HEADER READ WRITER | Compiler : Visual C++ |
32 | Module name : S5920.cpp | Version : 6.0 |
33 +-------------------------------+---------------------------------------+
34 | Author : E. LIBS Date : 02/05/2002 |
35 +-----------------------------------------------------------------------+
36 | Description : DLL with the S5920 PCI Controller functions |
37 +-----------------------------------------------------------------------+
39 +-----------------------------------------------------------------------+
40 | Date | Author | Description of updates |
41 +----------+-----------+------------------------------------------------+
42 | 28/08/02 | LIBS Eric | Add return codes each time a function of the |
43 | | | Addi Library is called |
44 +-----------------------------------------------------------------------+
45 | 31/07/03 | KRAUTH J. | Changes for the MSX-Box |
46 +-----------------------------------------------------------------------+
49 #include "addi_amcc_S5920.h"
51 /*+----------------------------------------------------------------------------+*/
52 /*| Function Name : int i_AddiHeaderRW_ReadEeprom |*/
53 /*| (int i_NbOfWordsToRead, |*/
54 /*| DWORD dw_PCIBoardEepromAddress, |*/
55 /*| unsigned short w_EepromStartAddress, |*/
56 /*| unsigned short * pw_DataRead) |*/
57 /*+----------------------------------------------------------------------------+*/
58 /*| Task : Read word from the 5920 eeprom. |*/
59 /*+----------------------------------------------------------------------------+*/
60 /*| Input Parameters : int i_NbOfWordsToRead : Nbr. of word to read |*/
61 /*| DWORD dw_PCIBoardEepromAddress : Address of the eeprom |*/
62 /*| unsigned short w_EepromStartAddress : Eeprom strat address |*/
63 /*+----------------------------------------------------------------------------+*/
64 /*| Output Parameters : unsigned short * pw_DataRead : Read data |*/
65 /*+----------------------------------------------------------------------------+*/
66 /*| Return Value : - |*/
67 /*+----------------------------------------------------------------------------+*/
69 int i_AddiHeaderRW_ReadEeprom(int i_NbOfWordsToRead,
70 DWORD dw_PCIBoardEepromAddress,
71 unsigned short w_EepromStartAddress, unsigned short * pw_DataRead)
73 DWORD dw_eeprom_busy = 0;
77 unsigned char pb_ReadByte[1];
78 unsigned char b_ReadLowByte = 0;
79 unsigned char b_ReadHighByte = 0;
80 unsigned char b_SelectedAddressLow = 0;
81 unsigned char b_SelectedAddressHigh = 0;
82 unsigned short w_ReadWord = 0;
84 for (i_WordCounter = 0; i_WordCounter < i_NbOfWordsToRead;
88 inl(dw_PCIBoardEepromAddress +
90 dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
92 while (dw_eeprom_busy == EEPROM_BUSY);
94 for (i_Counter = 0; i_Counter < 2; i_Counter++) {
95 b_SelectedAddressLow = (w_EepromStartAddress + i_Counter) % 256; //Read the low 8 bit part
96 b_SelectedAddressHigh = (w_EepromStartAddress + i_Counter) / 256; //Read the high 8 bit part
98 //Select the load low address mode
100 dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
106 inl(dw_PCIBoardEepromAddress +
108 dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
110 while (dw_eeprom_busy == EEPROM_BUSY);
112 //Load the low address
113 outb(b_SelectedAddressLow,
114 dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
120 inl(dw_PCIBoardEepromAddress +
122 dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
124 while (dw_eeprom_busy == EEPROM_BUSY);
126 //Select the load high address mode
127 outb(NVCMD_LOAD_HIGH,
128 dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
134 inl(dw_PCIBoardEepromAddress +
136 dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
138 while (dw_eeprom_busy == EEPROM_BUSY);
140 //Load the high address
141 outb(b_SelectedAddressHigh,
142 dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
148 inl(dw_PCIBoardEepromAddress +
150 dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
152 while (dw_eeprom_busy == EEPROM_BUSY);
154 //Select the READ mode
155 outb(NVCMD_BEGIN_READ,
156 dw_PCIBoardEepromAddress + AMCC_OP_REG_MCSR +
162 inl(dw_PCIBoardEepromAddress +
164 dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
166 while (dw_eeprom_busy == EEPROM_BUSY);
168 //Read data into the EEPROM
170 inb(dw_PCIBoardEepromAddress +
171 AMCC_OP_REG_MCSR + 2);
176 inl(dw_PCIBoardEepromAddress +
178 dw_eeprom_busy = dw_eeprom_busy & EEPROM_BUSY;
180 while (dw_eeprom_busy == EEPROM_BUSY);
182 //Select the upper address part
183 if (i_Counter == 0) {
184 b_ReadLowByte = pb_ReadByte[0];
186 b_ReadHighByte = pb_ReadByte[0];
190 for (i = 0; i < 10000; i++) ;
194 (b_ReadLowByte | (((unsigned short)b_ReadHighByte) *
197 pw_DataRead[i_WordCounter] = w_ReadWord;
199 w_EepromStartAddress += 2; // to read the next word
201 } // for (...) i_NbOfWordsToRead