Chameleon

Chameleon Svn Source Tree

Root/trunk/i386/libsaio/networking.c

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
25uint32_tbuiltin_set= 0;
26extern uint32_t devices_number;
27
28int devprop_add_network_template(DevPropDevice *device, uint16_t vendor_id)
29{
30if(!device)
31{
32return 0;
33}
34
35uint8_t builtin = 0x0;
36if((vendor_id != 0x168c) && (builtin_set == 0))
37{
38builtin_set = 1;
39builtin = 0x01;
40}
41
42if(!devprop_add_value(device, "built-in", (uint8_t*)&builtin, 1))
43{
44return 0;
45}
46
47devices_number++;
48return 1;
49}
50
51void setup_eth_builtin(pci_dt_t *eth_dev)
52{
53char *devicepath = get_pci_dev_path(eth_dev);
54DevPropDevice *device = NULL;
55
56verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);
57
58if(!string)
59{
60string = devprop_create_string();
61}
62
63device = devprop_add_device(string, devicepath);
64if(device)
65{
66verbose("Setting up lan keys\n");
67devprop_add_network_template(device, eth_dev->vendor_id);
68stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);
69if(stringdata)
70{
71memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
72stringlength = string->length;
73}
74}
75}
76
77

Archive Download this file

Revision: 2683