Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
587 | giacomo | 1 | /* |
2 | * Project: S.Ha.R.K. |
||
3 | * |
||
4 | * Coordinators: |
||
5 | * Giorgio Buttazzo <giorgio@sssup.it> |
||
6 | * Paolo Gai <pj@gandalf.sssup.it> |
||
7 | * |
||
8 | * Authors : |
||
9 | * Mauro Marinoni <mauro.marinoni@unipv.it> |
||
10 | * (see the web pages for full authors list) |
||
11 | * |
||
12 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
13 | * |
||
14 | * http://www.sssup.it |
||
15 | * http://retis.sssup.it |
||
16 | * http://shark.sssup.it |
||
17 | */ |
||
18 | |||
19 | /* |
||
20 | * This program is free software; you can redistribute it and/or modify |
||
21 | * it under the terms of the GNU General Public License as published by |
||
22 | * the Free Software Foundation; either version 2 of the License, or |
||
23 | * (at your option) any later version. |
||
24 | * |
||
25 | * This program is distributed in the hope that it will be useful, |
||
26 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
28 | * GNU General Public License for more details. |
||
29 | * |
||
30 | * You should have received a copy of the GNU General Public License |
||
31 | * along with this program; if not, write to the Free Software |
||
32 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
||
33 | */ |
||
34 | |||
35 | #include <linuxcomp.h> |
||
36 | #include <linux/pci.h> |
||
37 | |||
38 | //#define __DEBUG_20TO26__ |
||
39 | |||
40 | void linuxpci_init(void) |
||
41 | { |
||
42 | // PCI26_init MUST be called first ( TODO - Check ) |
||
43 | } |
||
44 | |||
45 | int pci20to26_find_class(unsigned int class_code, int index, BYTE *bus, BYTE *dev) |
||
46 | { |
||
47 | struct pci_dev *ptmp = NULL; |
||
48 | int curr = 0; |
||
49 | |||
50 | ptmp = pci_find_class(class_code, ptmp); |
||
51 | while (ptmp) { |
||
52 | #ifdef __DEBUG_20TO26__ |
||
53 | printk(KERN_DEBUG "pci20to26_find_class %x: found at bus %d, dev %d.\n", ptmp->class, ptmp->bus->number, ptmp->devfn); |
||
54 | #endif |
||
55 | |||
56 | if (curr == index) { |
||
57 | *bus = ptmp->bus->number; |
||
58 | *dev = ptmp->devfn; |
||
59 | |||
60 | #ifdef __DEBUG_20TO26__ |
||
61 | printk(KERN_DEBUG "pci20to26_find_class: found at bus %d, dev %d\n", *bus, *dev); |
||
62 | #endif |
||
63 | |||
64 | return PCIBIOS_SUCCESSFUL; |
||
65 | } |
||
66 | ++curr; |
||
67 | ptmp = pci_find_class(class_code, ptmp); |
||
68 | } |
||
69 | |||
70 | return PCIBIOS_DEVICE_NOT_FOUND; |
||
71 | } |
||
72 | |||
73 | int pcibios_present(void) |
||
74 | { |
||
75 | return 1; // PCI26 initialized? ( TODO - Check ) |
||
76 | } |
||
77 | |||
78 | int pci20to26_read_config_byte(unsigned int bus, unsigned int dev, int where, u8 *val) |
||
79 | { |
||
80 | struct pci_dev tmp; |
||
81 | struct pci_dev *ptmp = &tmp; |
||
82 | |||
83 | ptmp = pci_find_slot(bus, dev); |
||
84 | pci_read_config_byte(ptmp, where, val); |
||
85 | |||
86 | #ifdef __DEBUG_20TO26__ |
||
87 | printk(KERN_DEBUG "pci20to26_read_config_byte: (bus %d, dev %d) -> %d\n", bus, dev, *val); |
||
88 | #endif |
||
89 | |||
90 | return 1; |
||
91 | } |
||
92 | |||
93 | int pci20to26_read_config_word(unsigned int bus, unsigned int dev, int where, u16 *val) |
||
94 | { |
||
95 | struct pci_dev tmp; |
||
96 | struct pci_dev *ptmp = &tmp; |
||
97 | |||
98 | ptmp = pci_find_slot(bus, dev); |
||
99 | pci_read_config_word(ptmp, where, val); |
||
100 | |||
101 | #ifdef __DEBUG_20TO26__ |
||
102 | printk(KERN_DEBUG "pci20to26_read_config_word: (bus %d, dev %d) -> %d\n", bus, dev, *val); |
||
103 | #endif |
||
104 | |||
105 | return 1; |
||
106 | } |
||
107 | |||
108 | int pci20to26_read_config_dword(unsigned int bus, unsigned int dev, int where, u32 *val) |
||
109 | { |
||
110 | struct pci_dev tmp; |
||
111 | struct pci_dev *ptmp = &tmp; |
||
112 | |||
113 | ptmp = pci_find_slot(bus, dev); |
||
114 | pci_read_config_dword(ptmp, where, val); |
||
115 | |||
116 | #ifdef __DEBUG_20TO26__ |
||
117 | printk(KERN_DEBUG "pci20to26_read_config_dword: (bus %d, dev %d) -> %uld\n", bus, dev, *val); |
||
118 | #endif |
||
119 | |||
120 | return 1; |
||
121 | } |
||
122 | |||
123 | int pci20to26_write_config_byte(unsigned int bus, unsigned int dev, int where, u8 val) |
||
124 | { |
||
125 | struct pci_dev tmp; |
||
126 | struct pci_dev *ptmp = &tmp; |
||
127 | |||
128 | ptmp = pci_find_slot(bus, dev); |
||
129 | pci_write_config_byte(ptmp, where, val); |
||
130 | |||
131 | return 1; |
||
132 | } |
||
133 | |||
134 | int pci20to26_write_config_word(unsigned int bus, unsigned int dev, int where, u16 val) |
||
135 | { |
||
136 | struct pci_dev tmp; |
||
137 | struct pci_dev *ptmp = &tmp; |
||
138 | |||
139 | ptmp = pci_find_slot(bus, dev); |
||
140 | pci_write_config_word(ptmp, where, val); |
||
141 | |||
142 | return 1; |
||
143 | } |
||
144 | |||
145 | int pci20to26_write_config_dword(unsigned int bus, unsigned int dev, int where, u32 val) |
||
146 | { |
||
147 | struct pci_dev tmp; |
||
148 | struct pci_dev *ptmp = &tmp; |
||
149 | |||
150 | ptmp = pci_find_slot(bus, dev); |
||
151 | pci_write_config_dword(ptmp, where, val); |
||
152 | |||
153 | return 1; |
||
154 | } |