Chameleon

Chameleon Commit Details

Date:2011-05-11 09:18:09 (12 years 11 months ago)
Author:Kabyl
Commit:785
Parents: 784
Message:PCI code changes
Changes:
M/trunk/i386/libsaio/pci.c
M/trunk/i386/libsaio/pci.h

File differences

trunk/i386/libsaio/pci.c
8484
8585
8686
87
88
89
90
87
88
89
90
91
9192
9293
9394
......
134135
135136
136137
138
137139
138140
139141
......
176178
177179
178180
179
181
180182
181183
184
182185
183186
184187
}
new = (pci_dt_t*)malloc(sizeof(pci_dt_t));
bzero(new, sizeof(pci_dt_t));
new->dev.addr= pci_addr;
new->vendor_id= id & 0xffff;
new->device_id= (id >> 16) & 0xffff;
new->class_id= pci_config_read16(pci_addr, PCI_CLASS_DEVICE);
new->dev.addr= pci_addr;
new->vendor_id= id & 0xffff;
new->device_id= (id >> 16) & 0xffff;
new->subsys_id.subsys_id= pci_config_read32(pci_addr, PCI_SUBSYSTEM_VENDOR_ID);
new->class_id= pci_config_read16(pci_addr, PCI_CLASS_DEVICE);
new->parent= start;
header_type = pci_config_read8(pci_addr, PCI_HEADER_TYPE);
bzero(root_pci_dev, sizeof(pci_dt_t));
enable_pci_devs();
scan_pci_bus(root_pci_dev, 0);
#if DEBUG_PCI
dump_pci_dt(root_pci_dev->children);
pause();
current = pci_dt;
while (current) {
printf("%02x:%02x.%x [%04x] [%04x:%04x] :: %s\n",
printf("%02x:%02x.%x [%04x] [%04x:%04x] (subsys [%04x:%04x]):: %s\n",
current->dev.bits.bus, current->dev.bits.dev, current->dev.bits.func,
current->class_id, current->vendor_id, current->device_id,
current->subsys_id.subsys.vendor_id, current->subsys_id.subsys.device_id,
get_pci_dev_path(current));
dump_pci_dt(current->children);
current = current->next;
trunk/i386/libsaio/pci.h
2323
2424
2525
26
26
2727
28
29
30
28
29
3130
32
33
34
31
32
33
34
35
36
37
38
39
40
41
42
43
3544
3645
3746
......
4251
4352
4453
45
46
47
48
49
50
54
55
56
57
58
59
5160
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
5287
5388
5489
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
90
7191
7292
7393
......
83103
84104
85105
86
106
87107
88
89
90
91
92
93
94
95
96
97108
98109
99110
} pci_dev_t;
typedef struct pci_dt_t {
pci_dev_tdev;
pci_dev_tdev;
uint16_tvendor_id;
uint16_tdevice_id;
uint16_tclass_id;
uint16_tvendor_id;
uint16_tdevice_id;
struct pci_dt_t*parent;
struct pci_dt_t*children;
struct pci_dt_t*next;
union {
struct {
uint16_tvendor_id;
uint16_tdevice_id;
}subsys;
uint32_tsubsys_id;
}subsys_id;
uint16_tclass_id;
struct pci_dt_t*parent;
struct pci_dt_t*children;
struct pci_dt_t*next;
} pci_dt_t;
#define PCIADDR(bus, dev, func)(1 << 31) | (bus << 16) | (dev << 11) | (func << 8)
extern uint8_tpci_config_read8(uint32_t, uint8_t);
extern uint16_tpci_config_read16(uint32_t, uint8_t);
extern uint32_tpci_config_read32(uint32_t, uint8_t);
extern voidpci_config_write8(uint32_t, uint8_t, uint8_t);
extern voidpci_config_write16(uint32_t, uint8_t, uint16_t);
extern voidpci_config_write32(uint32_t, uint8_t, uint32_t);
extern char*get_pci_dev_path(pci_dt_t *);
extern voidbuild_pci_dt(void);
extern voiddump_pci_dt(pci_dt_t *);
extern voidpci_config_write8(uint32_t, uint8_t, uint8_t);
extern voidpci_config_write16(uint32_t, uint8_t, uint16_t);
extern voidpci_config_write32(uint32_t, uint8_t, uint32_t);
extern char*get_pci_dev_path(pci_dt_t *);
extern voidbuild_pci_dt(void);
extern voiddump_pci_dt(pci_dt_t *);
/* Option ROM header */
typedef struct {
uint16_tsignature;// 0xAA55
uint8_trom_size;
uint32_tentry_point;
uint8_treserved[15];
uint16_tpci_header_offset;
uint16_texpansion_header_offset;
} option_rom_header_t;
/* Option ROM PCI Data Structure */
typedef struct {
uint32_tsignature;// 0x52494350'PCIR'
uint16_tvendor_id;
uint16_tdevice_id;
uint16_tvital_product_data_offset;
uint16_tstructure_length;
uint8_tstructure_revision;
uint8_tclass_code[3];
uint16_timage_length;
uint16_timage_revision;
uint8_tcode_type;
uint8_tindicator;
uint16_treserved;
} option_rom_pci_header_t;
//-----------------------------------------------------------------------------
// added by iNDi
struct pci_rom_pci_header_t {
uint32_tsignature;// 0x50434952 'PCIR'
uint16_tvendor;
uint16_tdevice;
uint16_tproduct;
uint16_tlength;
uint8_trevision;// 0 = PCI 2.1
uint8_tclass[3];
uint16_trom_size;
uint16_tcode_revision;
uint8_tcode_type;// 0 = x86
uint8_tlast_image;// 0x80
uint16_treserverd;
};
struct pci_rom_pnp_header_t {
typedef struct {
uint32_tsignature;// 0x24506E50 '$PnP'
uint8_trevision;// 1
uint8_tlength;//
uint16_tbootstrap_vector;
uint16_treserved;
uint16_tresource_vector;
};
} option_rom_pnp_header_t;
struct pci_rom_bios_t {
uint16_tsignature;// 0x55AA
uint8_tsize;// Multiples of 512
uint8_tchecksum;// 0x00
uint16_tpci_header;
uint16_tpnp_header;
};
/*
* Under PCI, each device has 256 bytes of configuration address space,
* of which the first 64 bytes are standardized as follows:

Archive Download the corresponding diff file

Revision: 785