Chameleon

Chameleon Commit Details

Date:2010-09-26 08:09:46 (9 years 1 month ago)
Author:Evan Lojewski
Commit:557
Parents: 556
Message:Disabled HelloWorld in makefile. Added some wifi specific code to the netwokr module.
Changes:
D/branches/meklort/i386/modules/Networking/Ethernet.c
R/branches/meklort/i386/modules/Ethernet → /branches/meklort/i386/modules/Networking
C/branches/meklort/i386/modules/Ethernet/Ethernet.c → /branches/meklort/i386/modules/Networking/Networking.c
M/branches/meklort/i386/modules/Makefile
M/branches/meklort/i386/modules/GUI/GUI_module.c
M/branches/meklort/i386/boot2/boot.c
M/branches/meklort/i386/modules/Networking/Makefile
M/branches/meklort/i386/modules/HelloWorld/HelloWorld.c

File differences

branches/meklort/i386/boot2/boot.c
192192
193193
194194
195
196
197
195198
196
197
198199
199200
200201
if (bootArgs->Video.v_display == VGA_TEXT_MODE)
{
setVideoMode( GRAPHICS_MODE, 0 );
// Draw gray screen. NOTE: no boot image, that's in the gui module
if(!gVerboseMode) drawColorRectangle(0, 0, DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 0x01);
}
// Draw gray screen. NOTE: no boot image, that's in the gui module
if(!gVerboseMode) drawColorRectangle(0, 0, DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 0x01);
setupBooterLog();
branches/meklort/i386/modules/GUI/GUI_module.c
6464
6565
6666
67
67
6868
6969
7070
......
127127
128128
129129
130
130
131
131132
132133
133134
** The kernel is about to start, draw the boot graphics if we are not in
** verbose mode.
**/
void GUI_Kernel_Start_hook(void* kernelEntry, void* arg2, void* arg3, void* arg4)
void GUI_ExecKernel_hook(void* kernelEntry, void* arg2, void* arg3, void* arg4)
{
if(!gVerboseMode)
{
}
// Hoot for the boot screen
register_hook_callback("Kernel Start", &GUI_Kernel_Start_hook);
//ExecKernel register_hook_callback("Kernel Start", &GUI_Kernel_Start_hook);
register_hook_callback("ExecKernel", &GUI_ExecKernel_hook);
register_hook_callback("PreBoot", &GUI_PreBoot_hook);
}
branches/meklort/i386/modules/Networking/Networking.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
* Copyright (c) 2009 Evan Lojewski. All rights reserved.
*
*/
#include "libsaio.h"
#include "modules.h"
#include "boot.h"
#include "bootstruct.h"
#include "pci.h"
#include "device_inject.h"
#ifndef DEBUG_ETHERNET
#define DEBUG_ETHERNET 0
#endif
#if DEBUG_ETHERNET
#define DBG(x...) printf(x)
#else
#define DBG(x...)
#endif
void set_eth_builtin(pci_dt_t *eth_dev);
void set_wifi_airport(pci_dt_t *wlan_dev);
uint32_t builtin_set = 0;
void Networking_hook(void* arg1, void* arg2, void* arg3, void* arg4)
{
pci_dt_t* current = arg1;
if(current->class_id == PCI_CLASS_NETWORK_ETHERNET)
{
// LAN
bool do_eth_devprop = false;
getBoolForKey(kEthernetBuiltIn, &do_eth_devprop, &bootInfo->bootConfig);
if (do_eth_devprop)
{
set_eth_builtin(current);
}
}
else if(current->class_id == PCI_CLASS_NETWORK_OTHER)
{
// WIFI
set_wifi_airport(current);
}
}
void Networking_start()
{
register_hook_callback("PCIDevice", &Networking_hook);
}
/* a fine place for this code */
int devprop_add_network_template(struct DevPropDevice *device, uint16_t vendor_id)
{
uint8_t builtin = 0x0;
if(device)
{
if((vendor_id != 0x168c) && (builtin_set == 0))
{
builtin_set = 1;
builtin = 0x01;
}
if(!devprop_add_value(device, "built-in", (uint8_t*)&builtin, 1))
{
return 0;
}
devices_number++;
return 1;
}
else
{
return 0;
}
}
void set_eth_builtin(pci_dt_t *eth_dev)
{
char *devicepath = get_pci_dev_path(eth_dev);
struct DevPropDevice *device = (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice));
verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);
if (!string)
string = devprop_create_string();
device = devprop_add_device(string, devicepath);
if(device)
{
verbose("Setting up lan keys\n");
devprop_add_network_template(device, eth_dev->vendor_id);
stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);
if(stringdata)
{
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
stringlength = string->length;
}
}
}
struct wifi_cards
{
uint16_tvendor_id;
uint16_tdevice_id;
char*model;
};
struct wifi_cards known_wifi_cards[] =
{
{0x14e4, 0x4315, "Dell Wireless 1395"},
{0x14e4, 0x432b, "Dell Wireless 1510"},
{0x168C, 0x002B, "Atheros 9285 8802.11 b/g/n Wireless Network Adapter"},
};
void set_wifi_airport(pci_dt_t *wlan_dev)
{
char tmp[16];
uint32_t temp2;
char *devicepath = get_pci_dev_path(wlan_dev);
struct DevPropDevice *device = (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice));
verbose("Wifi Controller [%04x:%04x] :: %s\n", wlan_dev->vendor_id, wlan_dev->device_id, devicepath);
if (!string)
string = devprop_create_string();
device = devprop_add_device(string, devicepath);
if(device)
{
sprintf(tmp, "Airport");
devprop_add_value(device, "AAPL,slot-name", (uint8_t *) tmp, strlen(tmp) + 1);
devprop_add_value(device, "device_type", (uint8_t *) tmp, strlen(tmp) + 1);
int i = 0;
for( ; i < sizeof(known_wifi_cards) / sizeof(known_wifi_cards[0]); i++)
{
if(wlan_dev->vendor_id == known_wifi_cards[i].vendor_id &&
wlan_dev->device_id == known_wifi_cards[i].device_id)
{
verbose("Setting up wifi keys\n");
devprop_add_value(device, "model", (uint8_t*)known_wifi_cards[i].model, (strlen(known_wifi_cards[i].model) + 1));
// NOTE: I would set the subsystem id and subsystem vendor id here,
// however, those values seem to be ovverriden in the boot process.
// A batter method would be injecting the DTGP dsdt method
// and then injectinve the subsystem id there.
stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);
if(stringdata)
{
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
stringlength = string->length;
}
return;
}
}
}
}
branches/meklort/i386/modules/Networking/Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
MODULE_NAME = Networking
MODULE_VERSION = "1.0.0"
MODULE_COMPAT_VERSION = "1.0.0"
MODULE_START = _$(MODULE_NAME)_start
MODULE_DEPENDENCIES =
DIR = Networking
include ../../MakePaths.dir
OBJROOT=../../../obj/i386/modules/$(DIR)
SYMROOT=../../../sym/i386/modules/
DSTROOT=../../../dst/i386/modules/
UTILDIR = ../../util
LIBSADIR = ../../libsa
LIBSAIODIR = ../../libsaio
BOOT2DIR = ../../boot2
INSTALLDIR = $(DSTROOT)/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders/standalone
OPTIM = -Os -Oz
DEBUG = -DNOTHING
#DEBUG = -DDEBUG_HELLO_WORLD=1
CFLAGS= $(RC_CFLAGS) $(OPTIM) $(MORECPP) -arch i386 -g -Wmost \
-D__ARCHITECTURE__=\"i386\" -DSAIO_INTERNAL_USER \
-DRCZ_COMPRESSED_FILE_SUPPORT $(DEBUG) \
-fno-builtin $(OMIT_FRAME_POINTER_CFLAG) \
-mpreferred-stack-boundary=2 -fno-align-functions -fno-stack-protector \
-march=pentium4 -msse2 -mfpmath=sse -msoft-float -fno-common -mdynamic-no-pic
DEFINES=
CONFIG = hd
INC = -I. -I.. -I$(SYMROOT) -I$(UTILDIR) -I$(LIBSADIR) -I$(LIBSAIODIR) -I$(BOOT2DIR)
ifneq "" "$(wildcard /bin/mkdirs)"
MKDIRS = /bin/mkdirs
else
MKDIRS = /bin/mkdir -p
endif
AS = as
LD = ld
# LIBS= -lc_static
LIBS=
VPATH = $(OBJROOT):$(SYMROOT)
NET_OBJS = Networking.o
SFILES =
CFILES =
HFILES =
EXPORTED_HFILES =
INSTALLED_HFILES =
OTHERFILES = Makefile
ALLSRC = $(SFILES) $(CFILES) \
$(HFILES) $(OTHERFILES)
DIRS_NEEDED = $(OBJROOT) $(SYMROOT)
all embedtheme optionrom: ${NET_OBJS} dylib
dylib: ${NET_OBJS}
ld -flat_namespace -arch i386 \
-undefined suppress \
-alias $(MODULE_START) start \
-dylib -read_only_relocs suppress \
-S -x -Z -dead_strip_dylibs \
-no_uuid \
-current_version $(MODULE_VERSION) -compatibility_version $(MODULE_COMPAT_VERSION) \
-final_output $(MODULE_NAME) \
$(OBJROOT)/Networking.o -o $(SYMROOT)/$(MODULE_NAME).dylib
Networking.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c "Networking.c" $(INC) -o "$(OBJROOT)/Networking.o"
include ../../MakeInc.dir
# dependencies
-include $(OBJROOT)/Makedep
branches/meklort/i386/modules/HelloWorld/HelloWorld.c
99
1010
1111
12
12
1313
1414
1515
void helloWorld(void* binary, void* arg2, void* arg3, void* arg4)
{
printf("Hello world from ExecKernel hook. Binary located at 0x%X\n", binary);
//getc();
getc();
}
branches/meklort/i386/modules/Makefile
2727
2828
2929
30
30
3131
3232
3333
# The order of building is important.
# TODO: exclude Symbols from find so it isn't compiled twice
SUBDIRS = Symbols Resolution KernelPatcher KextPatcher HelloWorld GUI GraphicsEnabler ACPIPatcher HPET USBFix
SUBDIRS = Symbols Resolution KernelPatcher KextPatcher GUI GraphicsEnabler ACPIPatcher HPET USBFix Memory Networking
all embedtheme optionrom tags debug install installhdrs:
@rm -rf $(OBJROOT)

Archive Download the corresponding diff file

Revision: 557