Chameleon

Chameleon Svn Source Tree

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

1/*
2 * Copyright (c) 2011 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#define kEnableSATA"EnableSATAModule"
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;
34char*devicepath;
35if (current && current->class_id == PCI_CLASS_STORAGE_SATA)
36{
37devicepath = get_pci_dev_path(current);
38if (devicepath)
39{
40verbose("SATA device : [%04x:%04x :: %04x] :: %s\n",
41current->vendor_id, current->device_id,current->class_id,
42devicepath);
43
44if (!string)
45{
46string = devprop_create_string();
47}
48device = devprop_add_device(string, devicepath);
49
50devprop_add_value(device, "device-id", default_SATA_ID, SATA_ID_LEN);
51
52
53stringdata = malloc(sizeof(uint8_t) * string->length);
54memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
55stringlength = string->length;
56
57}
58}
59
60}
61
62void YellowIconFixer_start(void);
63void YellowIconFixer_start(void)
64{
65bool enable = true;
66getBoolForKey(kEnableSATA, &enable, DEFAULT_BOOT_CONFIG) ;
67
68if (enable)
69{
70register_hook_callback("PCIDevice", &SATA_hook);
71}
72}
73
74

Archive Download this file

Revision: 1919