Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/modules/YellowIconFixer/YellowIconFixer.c

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
23void SATA_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6);
24
25uint8_t default_SATA_ID[]= {
260x81, 0x26, 0x00, 0x00
27};
28#define SATA_ID_LEN ( sizeof(default_SATA_ID) / sizeof(uint8_t) )
29
30void SATA_hook(void* arg1, void* arg2, void* arg3, void* arg4, void* arg5, void* arg6)
31{
32pci_dt_t* current = arg1;
33struct DevPropDevice*device;
34 struct DevPropString *string;
35if (current && current->class_id == PCI_CLASS_STORAGE_SATA)
36{
37string = (struct DevPropString *)(uint32_t)get_env(envEFIString);
38
39 if (!string)
40 {
41 string = devprop_create_string();
42 if (!string) return;
43 safe_set_env(envEFIString,(uint32_t)string);
44 }
45 device = devprop_add_device(string, current);
46 if (!device) return;
47
48#if PROOFOFCONCEPT
49 uint16_t vendor_id = current->vendor_id & 0xFFFF;
50 uint16_t device_id = current->device_id & 0xFFFF;
51
52 devprop_add_value(device, "vendor-id", (uint8_t*)&vendor_id, 4);
53 devprop_add_value(device, "device-id", (uint8_t*)&device_id, 4);
54#else
55 devprop_add_value(device, "device-id", default_SATA_ID, SATA_ID_LEN);
56
57#endif
58 verbose("SATA device : [%04x:%04x :: %04x]\n",
59 current->vendor_id, current->device_id,current->class_id);
60}
61
62}
63
64void YellowIconFixer_start(void);
65void YellowIconFixer_start(void)
66{
67 register_hook_callback("PCIDevice", &SATA_hook);
68}
69
70

Archive Download this file

Revision: 1984