1 | /*␊ |
2 | * Copyright (c) 2011,2012 cparm <armelcadetpetit@gmail.com>. All rights reserved.␊ |
3 | *␊ |
4 | */␊ |
5 | ␊ |
6 | #include "libsaio.h"␊ |
7 | #include "modules.h"␊ |
8 | #include "bootstruct.h"␊ |
9 | #include "pci.h"␊ |
10 | #include "device_inject.h"␊ |
11 | #include "platform.h"␊ |
12 | ␊ |
13 | #ifndef DEBUG_SATA␊ |
14 | #define DEBUG_SATA 0␊ |
15 | #endif␊ |
16 | ␊ |
17 | #if DEBUG_SATA␊ |
18 | #define DBG(x...) printf(x)␊ |
19 | #else␊ |
20 | #define DBG(x...)␊ |
21 | #endif␊ |
22 | ␊ |
23 | uint8_t default_SATA_ID[]= {␊ |
24 | ␉0x81, 0x26, 0x00, 0x00␊ |
25 | };␊ |
26 | #define SATA_ID_LEN ( sizeof(default_SATA_ID) / sizeof(uint8_t) )␊ |
27 | ␊ |
28 | void SATA_hook(void* arg1, void* arg2, void* arg3, void* arg4);␊ |
29 | void SATA_hook(void* arg1, void* arg2, void* arg3, void* arg4)␊ |
30 | {␊ |
31 | ␉pci_dt_t* current = arg1;␊ |
32 | ␉struct DevPropDevice␉␉*device = NULL;␊ |
33 | ␉char *devicepath = NULL;␊ |
34 | ␉␊ |
35 | ␉if (current && current->class_id == PCI_CLASS_STORAGE_SATA)␊ |
36 | ␉{ ␊ |
37 | if (!string)␊ |
38 | {␊ |
39 | string = devprop_create_string();␊ |
40 | if (!string) return;␊ |
41 | }␊ |
42 | ␉␉devicepath = get_pci_dev_path(current);␊ |
43 | if (!devicepath) return;␊ |
44 | ␉␉␊ |
45 | device = devprop_add_device(string, devicepath);␊ |
46 | if (!device) return;␊ |
47 | ␊ |
48 | devprop_add_value(device, "device-id", default_SATA_ID, SATA_ID_LEN);␊ |
49 | ␊ |
50 | verbose("SATA device : [%04x:%04x :: %04x], changed to ICH6 ESB2 \n", ␊ |
51 | current->vendor_id, current->device_id,current->class_id);␊ |
52 | ␉␉␊ |
53 | ␉}␉␊ |
54 | ␉␊ |
55 | }␊ |
56 | ␊ |
57 | void Sata_start(void);␊ |
58 | void Sata_start(void)␊ |
59 | {␊ |
60 | register_hook_callback("PCIDevice", &SATA_hook);␊ |
61 | }␊ |
62 | ␊ |
63 | |