1 | /*␊ |
2 | *␉Copyright 2009 Jasmin Fazlic All rights reserved.␊ |
3 | */␊ |
4 | /*␊ |
5 | *␉Cleaned and merged by iNDi␊ |
6 | */␊ |
7 | ␊ |
8 | #ifndef __LIBSAIO_DEVICE_INJECT_H␊ |
9 | #define __LIBSAIO_DEVICE_INJECT_H␊ |
10 | ␊ |
11 | #define DP_ADD_TEMP_VAL(dev, val) devprop_add_value(dev, (char*)val[0], (uint8_t*)val[1], strlen(val[1]) + 1)␊ |
12 | #define DP_ADD_TEMP_VAL_DATA(dev, val) devprop_add_value(dev, (char*)val.name, (uint8_t*)val.data, val.size)␊ |
13 | #define MAX_PCI_DEV_PATHS 4␊ |
14 | ␊ |
15 | #define DEV_PROP_DEVICE_MAX_ENTRIES 64␊ |
16 | ␊ |
17 | extern void setupDeviceProperties(Node *node);␊ |
18 | ␊ |
19 | struct ACPIDevPath␊ |
20 | {␊ |
21 | ␉uint8_t␉␉type;␉␉// = 2 ACPI device-path␊ |
22 | ␉uint8_t␉␉subtype;␉// = 1 ACPI Device-path␊ |
23 | ␉uint16_t␉length;␉␉// = 0x0c␊ |
24 | ␉uint32_t␉_HID;␉␉// = 0xD041030A ?␊ |
25 | ␉uint32_t␉_UID;␉␉// = 0x00000000 PCI ROOT␊ |
26 | ␉uint32_t␉_CID;␉␉// = Optional variable length␊ |
27 | ␊ |
28 | };␊ |
29 | ␊ |
30 | struct PCIDevPath␊ |
31 | {␊ |
32 | ␉uint8_t␉␉type;␉␉// = 1 Hardware device-path␊ |
33 | ␉uint8_t␉␉subtype;␉// = 1 PCI␊ |
34 | ␉uint16_t␉length;␉␉// = 6␊ |
35 | ␉uint8_t␉␉function;␉// pci func number␊ |
36 | ␉uint8_t␉␉device;␉␉// pci dev number␊ |
37 | };␊ |
38 | ␊ |
39 | struct DevicePathEnd␊ |
40 | {␊ |
41 | ␉uint8_t␉␉type;␉␉// = 0x7f␊ |
42 | ␉uint8_t␉␉subtype;␉// = 0xff␊ |
43 | ␉uint16_t␉length;␉␉// = 4;␊ |
44 | };␊ |
45 | ␊ |
46 | struct DevPropDevice␊ |
47 | {␊ |
48 | ␉uint32_t length;␊ |
49 | ␉uint16_t numentries;␊ |
50 | ␉uint16_t WHAT2;␉␉␉␉␉␉␉␉// 0x0000 ?␊ |
51 | ␉struct ACPIDevPath acpi_dev_path;␉␉␉␉␉// = 0x02010c00 0xd041030a␊ |
52 | ␉struct PCIDevPath pci_dev_path[MAX_PCI_DEV_PATHS];␉␉␉// = 0x01010600 func dev␊ |
53 | ␉struct DevicePathEnd path_end;␉␉␉␉␉␉// = 0x7fff0400␊ |
54 | ␉uint8_t *data;␊ |
55 | ␉␊ |
56 | ␉// ------------------------␊ |
57 | ␉uint8_t␉ num_pci_devpaths;␊ |
58 | ␉struct DevPropString *string;␊ |
59 | ␉// ------------------------␉␊ |
60 | };␊ |
61 | ␊ |
62 | typedef struct DevPropDevice DevPropDevice;␊ |
63 | ␊ |
64 | struct DevPropString␊ |
65 | {␊ |
66 | ␉uint32_t length;␊ |
67 | ␉uint32_t WHAT2;␉␉␉// 0x01000000 ?␊ |
68 | ␉uint16_t numentries;␊ |
69 | ␉uint16_t WHAT3;␉␉␉// 0x0000 ?␊ |
70 | ␉struct DevPropDevice **entries;␊ |
71 | };␊ |
72 | ␊ |
73 | typedef struct DevPropString DevPropString;␊ |
74 | ␊ |
75 | extern DevPropString *string;␊ |
76 | extern uint8_t *stringdata;␊ |
77 | extern uint32_t stringlength;␊ |
78 | ␊ |
79 | DevPropString␉␉*devprop_create_string(void);␊ |
80 | DevPropDevice␉␉*devprop_add_device(DevPropString *string, char *path);␊ |
81 | char␉␉␉*efi_inject_get_devprop_string(uint32_t *len);␊ |
82 | int␉␉␉devprop_add_value(DevPropDevice *device, char *nm, uint8_t *vl, uint32_t len);␊ |
83 | char␉␉␉*devprop_generate_string(DevPropString *string);␊ |
84 | void␉␉␉devprop_free_string(DevPropString *string);␊ |
85 | int␉␉␉devprop_add_network_template(DevPropDevice *device, uint16_t vendor_id);␊ |
86 | ␊ |
87 | /* Converters */␊ |
88 | int␉␉␉hex2dec(unsigned const char *hex); //long␉␉hex2dec(unsigned const char *hex);␊ |
89 | char␉␉␉*bin2hex(const uint8_t* bin, char* hex, int len);␊ |
90 | //char␉␉␉int2hex(int val);␊ |
91 | int␉␉␉hex2bin(const char *hex, uint8_t *bin, int len);␊ |
92 | ␊ |
93 | #endif /* !__LIBSAIO_DEVICE_INJECT_H */␊ |
94 | |