source: mainline/uspace/srv/drivers/pciintel/pci.h@ d1fc8f0

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d1fc8f0 was d1fc8f0, checked in by Lenka Trochtova <trochtova.lenka@…>, 15 years ago

pci base address registers reading - parts of code

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 * Copyright (c) 2010 Lenka Trochtova
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup pciintel
30 * @{
31 */
32/** @file
33 */
34
35#ifndef PCI_H
36#define PCI_H
37
38
39#include <stdlib.h>
40#include <driver.h>
41#include <malloc.h>
42
43typedef struct pci_dev_data {
44 int bus;
45 int dev;
46 int fn;
47 int vendor_id;
48 int device_id;
49 hw_resource_list_t hw_resources;
50} pci_dev_data_t;
51
52static inline pci_dev_data_t *create_pci_dev_data()
53{
54 pci_dev_data_t *res = (pci_dev_data_t *)malloc(sizeof(pci_dev_data_t));
55 if (NULL != res) {
56 memset(res, 0, sizeof(pci_dev_data_t));
57 }
58 return res;
59}
60
61static inline void init_pci_dev_data(pci_dev_data_t *d, int bus, int dev, int fn)
62{
63 d->bus = bus;
64 d->dev = dev;
65 d->fn = fn;
66}
67
68static inline void delete_pci_dev_data(pci_dev_data_t *d)
69{
70 if (NULL != d) {
71 clean_hw_resource_list(&d->hw_resources);
72 free(d);
73 }
74}
75
76static inline void create_pci_dev_name(device_t *dev)
77{
78 pci_dev_data_t *dev_data = (pci_dev_data_t *)dev->driver_data;
79 char *name = NULL;
80 asprintf(&name, "%02x:%02x.%01x", dev_data->bus, dev_data->dev, dev_data->fn);
81 dev->name = name;
82}
83
84void create_pci_match_ids(device_t *dev);
85
86uint8_t pci_conf_read_8(device_t *dev, int reg);
87uint16_t pci_conf_read_16(device_t *dev, int reg);
88uint32_t pci_conf_read_32(device_t *dev, int reg);
89void pci_conf_write_8(device_t *dev, int reg, uint8_t val);
90void pci_conf_write_16(device_t *dev, int reg, uint16_t val);
91void pci_conf_write_32(device_t *dev, int reg, uint32_t val);
92
93void pci_bus_scan(device_t *parent, int bus_num);
94
95#endif
96
97
98/**
99 * @}
100 */
Note: See TracBrowser for help on using the repository browser.