Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / mips / loongson / pci.h
bloba81f7d75d829bd994d50203b64a34129a3ccb65c
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2008 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_MACHINE_PCI_H
20 #define GRUB_MACHINE_PCI_H 1
22 #ifndef ASM_FILE
23 #include <grub/types.h>
24 #include <grub/cpu/io.h>
25 #endif
27 #define GRUB_LOONGSON_OHCI_PCIID 0x00351033
28 #define GRUB_LOONGSON_EHCI_PCIID 0x00e01033
30 #define GRUB_PCI_NUM_BUS 1
31 #define GRUB_PCI_NUM_DEVICES 16
33 #define GRUB_MACHINE_PCI_IO_BASE 0xbfd00000
34 #define GRUB_MACHINE_PCI_CONFSPACE 0xbfe80000
35 #define GRUB_MACHINE_PCI_CONTROLLER_HEADER 0xbfe00000
37 #define GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR 0xbfe00118
39 #ifndef ASM_FILE
40 #define GRUB_MACHINE_PCI_CONF_CTRL_REG (*(volatile grub_uint32_t *) \
41 GRUB_MACHINE_PCI_CONF_CTRL_REG_ADDR)
42 #define GRUB_MACHINE_PCI_IO_CTRL_REG (*(volatile grub_uint32_t *) 0xbfe00110)
43 #endif
44 #define GRUB_MACHINE_PCI_WIN_MASK_SIZE 6
45 #define GRUB_MACHINE_PCI_WIN_MASK ((1 << GRUB_MACHINE_PCI_WIN_MASK_SIZE) - 1)
47 /* We have 3 PCI windows. */
48 #define GRUB_MACHINE_PCI_NUM_WIN 3
49 /* Each window is 64MiB. */
50 #define GRUB_MACHINE_PCI_WIN_SHIFT 26
51 #define GRUB_MACHINE_PCI_WIN_OFFSET_MASK ((1 << GRUB_MACHINE_PCI_WIN_SHIFT) - 1)
53 #define GRUB_MACHINE_PCI_WIN_SIZE 0x04000000
54 /* Graphical acceleration takes 1 MiB away. */
55 #define GRUB_MACHINE_PCI_WIN1_SIZE 0x03f00000
57 #define GRUB_MACHINE_PCI_WIN1_ADDR 0xb0000000
58 #define GRUB_MACHINE_PCI_WIN2_ADDR 0xb4000000
59 #define GRUB_MACHINE_PCI_WIN3_ADDR 0xb8000000
61 #ifndef ASM_FILE
62 static inline grub_uint32_t
63 grub_pci_read (grub_pci_address_t addr)
65 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
66 return *(volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONFSPACE
67 | (addr & 0x07ff));
70 static inline grub_uint16_t
71 grub_pci_read_word (grub_pci_address_t addr)
73 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
74 return *(volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONFSPACE
75 | (addr & 0x07ff));
78 static inline grub_uint8_t
79 grub_pci_read_byte (grub_pci_address_t addr)
81 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
82 return *(volatile grub_uint8_t *) (GRUB_MACHINE_PCI_CONFSPACE
83 | (addr & 0x07ff));
86 static inline void
87 grub_pci_write (grub_pci_address_t addr, grub_uint32_t data)
89 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
90 *(volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONFSPACE
91 | (addr & 0x07ff)) = data;
94 static inline void
95 grub_pci_write_word (grub_pci_address_t addr, grub_uint16_t data)
97 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
98 *(volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONFSPACE
99 | (addr & 0x07ff)) = data;
102 static inline void
103 grub_pci_write_byte (grub_pci_address_t addr, grub_uint8_t data)
105 GRUB_MACHINE_PCI_CONF_CTRL_REG = 1 << ((addr >> 11) & 0xf);
106 *(volatile grub_uint8_t *) (GRUB_MACHINE_PCI_CONFSPACE
107 | (addr & 0x07ff)) = data;
110 volatile void *
111 EXPORT_FUNC (grub_pci_device_map_range) (grub_pci_device_t dev,
112 grub_addr_t base, grub_size_t size);
113 void *
114 EXPORT_FUNC (grub_pci_device_map_range_cached) (grub_pci_device_t dev,
115 grub_addr_t base,
116 grub_size_t size);
117 void
118 EXPORT_FUNC (grub_pci_device_unmap_range) (grub_pci_device_t dev,
119 volatile void *mem,
120 grub_size_t size);
121 #endif
123 #endif /* GRUB_MACHINE_PCI_H */