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 | ␊ |
12 | #ifndef DEBUG_SATA␊ |
13 | #define DEBUG_SATA 0␊ |
14 | #endif␊ |
15 | ␊ |
16 | #if DEBUG_SATA␊ |
17 | #define DBG(x...) printf(x)␊ |
18 | #else␊ |
19 | #define DBG(x...)␊ |
20 | #endif␊ |
21 | ␉␊ |
22 | void SATA_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);␊ |
23 | ␊ |
24 | uint8_t default_SATA_ID[]= {␊ |
25 | ␉0x81, 0x26, 0x00, 0x00␊ |
26 | };␊ |
27 | #define SATA_ID_LEN ( sizeof(default_SATA_ID) / sizeof(uint8_t) )␊ |
28 | ␊ |
29 | void SATA_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)␊ |
30 | {␊ |
31 | ␉pci_dt_t* current = arg1;␊ |
32 | ␉struct DevPropDevice␉␉*device;␊ |
33 | ␉char␉␉␉␉␉␉*devicepath;␊ |
34 | ␉if (current && current->class_id == PCI_CLASS_STORAGE_SATA)␊ |
35 | ␉{␊ |
36 | ␉␉devicepath = get_pci_dev_path(current);␊ |
37 | ␉␉if (devicepath)␊ |
38 | ␉␉{␊ |
39 | ␉␉␉verbose("SATA device : [%04x:%04x :: %04x] :: %s\n", ␊ |
40 | ␉␉␉␉␉current->vendor_id, current->device_id,current->class_id,␊ |
41 | ␉␉␉␉␉devicepath);␊ |
42 | ␉␉␉␊ |
43 | ␉␉␉if (!string)␊ |
44 | ␉␉␉{␊ |
45 | ␉␉␉␉string = devprop_create_string();␊ |
46 | ␉␉␉}␊ |
47 | ␉␉␉device = devprop_add_device(string, devicepath);␊ |
48 | ␉␉␉␊ |
49 | ␉␉␉devprop_add_value(device, "device-id", default_SATA_ID, SATA_ID_LEN);␊ |
50 | ␉␉␉␉␉␉␊ |
51 | ␉␉␉␊ |
52 | ␉␉␉stringdata = malloc(sizeof(uint8_t) * string->length);␊ |
53 | ␉␉␉memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);␊ |
54 | ␉␉␉stringlength = string->length;␊ |
55 | ␉␉␉␊ |
56 | ␉␉}␊ |
57 | ␉}␉␊ |
58 | ␉␊ |
59 | }␊ |
60 | ␊ |
61 | void YellowIconFixer_start(void);␊ |
62 | void YellowIconFixer_start(void)␊ |
63 | {␊ |
64 | register_hook_callback("PCIDevice", &SATA_hook);␊ |
65 | }␊ |
66 | ␊ |
67 | |