1 | /*␊ |
2 | * Copyright (c) 2009 Evan Lojewski. All rights reserved.␊ |
3 | *␊ |
4 | * Merge into file from module compcept by ErmaC and Marchrius ␊ |
5 | *␊ |
6 | */␊ |
7 | ␊ |
8 | #include "boot.h"␊ |
9 | #include "bootstruct.h"␊ |
10 | #include "pci.h"␊ |
11 | #include "platform.h"␊ |
12 | #include "device_inject.h"␊ |
13 | #include "networking.h"␊ |
14 | ␊ |
15 | #ifndef DEBUG_NETWORKING␊ |
16 | ␉#define DEBUG_NETWORKING 0␊ |
17 | #endif␊ |
18 | ␊ |
19 | #if DEBUG_NETWORKING␊ |
20 | ␉#define DBG(x...)␉printf(x)␊ |
21 | #else␊ |
22 | ␉#define DBG(x...)␊ |
23 | #endif␊ |
24 | ␊ |
25 | uint32_t␉builtin_set␉= 0;␊ |
26 | extern uint32_t devices_number;␊ |
27 | ␊ |
28 | int devprop_add_network_template(DevPropDevice *device, uint16_t vendor_id)␊ |
29 | {␊ |
30 | ␉if(!device)␊ |
31 | ␉{␊ |
32 | ␉␉return 0;␊ |
33 | ␉}␊ |
34 | ␊ |
35 | ␉uint8_t builtin = 0x0;␊ |
36 | ␉if((vendor_id != 0x168c) && (builtin_set == 0))␊ |
37 | ␉{␊ |
38 | ␉␉builtin_set = 1;␊ |
39 | ␉␉builtin = 0x01;␊ |
40 | ␉}␊ |
41 | ␊ |
42 | ␉if(!devprop_add_value(device, "built-in", (uint8_t*)&builtin, 1))␊ |
43 | ␉{␊ |
44 | ␉␉return 0;␊ |
45 | ␉}␊ |
46 | ␊ |
47 | ␉devices_number++;␊ |
48 | ␉return 1;␊ |
49 | }␊ |
50 | ␊ |
51 | void setup_eth_builtin(pci_dt_t *eth_dev)␊ |
52 | {␊ |
53 | ␉char *devicepath = get_pci_dev_path(eth_dev);␊ |
54 | ␉DevPropDevice *device = NULL;␊ |
55 | ␊ |
56 | ␉verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);␊ |
57 | ␊ |
58 | ␉if(!string)␊ |
59 | ␉{␊ |
60 | ␉␉string = devprop_create_string();␊ |
61 | ␉}␊ |
62 | ␊ |
63 | ␉device = devprop_add_device(string, devicepath);␊ |
64 | ␉if(device)␊ |
65 | ␉{␊ |
66 | ␉␉verbose("Setting up lan keys\n");␊ |
67 | ␉␉devprop_add_network_template(device, eth_dev->vendor_id);␊ |
68 | ␉␉stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);␊ |
69 | ␉␉if(stringdata)␊ |
70 | ␉␉{␊ |
71 | ␉␉␉memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);␊ |
72 | ␉␉␉stringlength = string->length;␊ |
73 | ␉␉}␊ |
74 | ␉}␊ |
75 | }␊ |
76 | ␊ |
77 | |