Root/
Source at commit 548 created 13 years 8 months ago. By meklort, Bugfixes (hpet, gui, etc) | |
---|---|
1 | /*␊ |
2 | * Copyright (c) 2009 Evan Lojewski. 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 "hpet.h"␊ |
12 | ␊ |
13 | #ifndef DEBUG_HPET␊ |
14 | #define DEBUG_HPET 0␊ |
15 | #endif␊ |
16 | ␊ |
17 | #if DEBUG_HPET␊ |
18 | #define DBG(x...) printf(x)␊ |
19 | #else␊ |
20 | #define DBG(x...)␊ |
21 | #endif␊ |
22 | ␊ |
23 | void set_eth_builtin(pci_dt_t *eth_dev);␊ |
24 | ␊ |
25 | ␊ |
26 | void Ethernet_hook(void* arg1, void* arg2, void* arg3, void* arg4)␊ |
27 | {␊ |
28 | ␉pci_dt_t* current = arg1;␊ |
29 | ␉␊ |
30 | ␉if(current->class_id != PCI_CLASS_NETWORK_ETHERNET) return;␊ |
31 | ␉␊ |
32 | ␉␊ |
33 | ␉bool do_eth_devprop = false;␉␊ |
34 | ␉getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->bootConfig);␊ |
35 | ␉␊ |
36 | ␉if (do_eth_devprop)␊ |
37 | ␉␉set_eth_builtin(current);␊ |
38 | }␊ |
39 | ␊ |
40 | void Ethernet_start()␊ |
41 | {␊ |
42 | ␉register_hook_callback("PCIDevice", &Ethernet_hook);␊ |
43 | }␊ |
44 | ␊ |
45 | /* a fine place for this code */␊ |
46 | ␊ |
47 | int devprop_add_network_template(struct DevPropDevice *device, uint16_t vendor_id)␊ |
48 | {␊ |
49 | ␉if(!device)␊ |
50 | ␉␉return 0;␊ |
51 | ␉uint8_t builtin = 0x0;␊ |
52 | ␉if((vendor_id != 0x168c) && (builtin_set == 0)) ␊ |
53 | ␉{␊ |
54 | ␉␉builtin_set = 1;␊ |
55 | ␉␉builtin = 0x01;␊ |
56 | ␉}␊ |
57 | ␉if(!devprop_add_value(device, "built-in", (uint8_t*)&builtin, 1))␊ |
58 | ␉␉return 0;␊ |
59 | ␉devices_number++;␊ |
60 | ␉return 1;␊ |
61 | }␊ |
62 | ␊ |
63 | void set_eth_builtin(pci_dt_t *eth_dev)␊ |
64 | {␊ |
65 | ␉char *devicepath = get_pci_dev_path(eth_dev);␊ |
66 | ␉struct DevPropDevice *device = (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice));␊ |
67 | ␉␊ |
68 | ␉verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);␊ |
69 | ␉␊ |
70 | ␉if (!string)␊ |
71 | ␉␉string = devprop_create_string();␊ |
72 | ␉␊ |
73 | ␉device = devprop_add_device(string, devicepath);␊ |
74 | ␉if(device)␊ |
75 | ␉{␊ |
76 | ␉␉verbose("Setting up lan keys\n");␊ |
77 | ␉␉devprop_add_network_template(device, eth_dev->vendor_id);␊ |
78 | ␉␉stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);␊ |
79 | ␉␉if(stringdata)␊ |
80 | ␉␉{␊ |
81 | ␉␉␉memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);␊ |
82 | ␉␉␉stringlength = string->length;␊ |
83 | ␉␉}␊ |
84 | ␉}␊ |
85 | }␊ |
86 |