1/*
2 * Copyright 2005-2008, Axel D��rfler, axeld@pinc-software.de. All rights reserved.
3 * Copyright 2003-2006, Marcus Overhagen. All rights reserved.
4 *
5 * Distributed under the terms of the MIT License.
6 */
7#ifndef __PCI_PRIV_H__
8#define __PCI_PRIV_H__
9
10
11#include <KernelExport.h>
12#include <device_manager.h>
13#include <bus/PCI.h>
14
15// name of PCI legacy driver endpoint module
16#define PCI_LEGACY_DRIVER_MODULE_NAME "bus_managers/pci/legacy_v1"
17
18// name of PCI device modules
19#define PCI_DEVICE_MODULE_NAME "bus_managers/pci/driver_v1"
20
21extern device_manager_info *gDeviceManager;
22
23
24// PCI root.
25// apart from being the common parent of all PCI devices, it
26// manages access to PCI config space
27typedef struct pci_root_module_info {
28	driver_module_info info;
29
30	// read PCI config space
31	uint32 (*read_pci_config)(uint8 bus, uint8 device, uint8 function,
32				uint8 offset, uint8 size);
33
34	// write PCI config space
35	void (*write_pci_config)(uint8 bus, uint8 device, uint8 function,
36				uint8 offset, uint8 size, uint32 value);
37} pci_root_module_info;
38
39extern pci_root_module_info gPCIRootModule;
40extern pci_device_module_info gPCIDeviceModule;
41
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47void *		pci_ram_address(const void *physical_address_in_system_memory);
48
49status_t 	pci_find_capability(uchar bus, uchar device, uchar function, uchar cap_id, uchar *offset);
50
51status_t	pci_reserve_device(uchar virtualBus, uchar device, uchar function,
52			const char *driverName, void *nodeCookie);
53status_t	pci_unreserve_device(uchar virtualBus, uchar device, uchar function,
54			const char *driverName, void *nodeCookie);
55
56status_t	pci_update_interrupt_line(uchar virtualBus, uchar device,
57				uchar function, uchar newInterruptLineValue);
58
59status_t 	pci_io_init(void);
60uint8		pci_read_io_8(int mapped_io_addr);
61void		pci_write_io_8(int mapped_io_addr, uint8 value);
62uint16		pci_read_io_16(int mapped_io_addr);
63void		pci_write_io_16(int mapped_io_addr, uint16 value);
64uint32		pci_read_io_32(int mapped_io_addr);
65void		pci_write_io_32(int mapped_io_addr, uint32 value);
66
67#ifdef __cplusplus
68}
69#endif
70
71#endif	/* __PCI_PRIV_H__ */
72