Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/i386/modules/Sata/Sata.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);
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)
31{
32pci_dt_t* current = arg1;
33struct DevPropDevice*device = NULL;
34char *devicepath = NULL;
35
36if (current && current->class_id == PCI_CLASS_STORAGE_SATA)
37{
38 if (!string)
39 {
40 string = devprop_create_string();
41 if (!string) return;
42 }
43devicepath = get_pci_dev_path(current);
44 if (!devicepath) return;
45
46 device = devprop_add_device(string, devicepath);
47 if (!device) return;
48
49 devprop_add_value(device, "device-id", default_SATA_ID, SATA_ID_LEN);
50
51 verbose("SATA device : [%04x:%04x :: %04x], changed to ICH6 ESB2 \n",
52 current->vendor_id, current->device_id,current->class_id);
53
54}
55
56}
57
58void Sata_start(void);
59void Sata_start(void)
60{
61 register_hook_callback("PCIDevice", &SATA_hook);
62}
63
64

Archive Download this file

Revision: 2024