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 "boot.h"
9#include "bootstruct.h"
10#include "pci.h"
11#include "device_inject.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#define kEnableSATA"EnableSATAModule"
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[0] != 0)
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()
63{
64bool enable = true;
65getBoolForKey(kEnableSATA, &enable, &bootInfo->bootConfig) ;
66
67if (enable)
68{
69register_hook_callback("PCIDevice", &SATA_hook);
70}
71}
72
73

Archive Download this file

Revision: 1468