source: src/router/services/sysinit/sysinit-danube.c @ 18303

Last change on this file since 18303 was 18303, checked in by BrainSlayer, 16 months ago

voodoo todo

File size: 6.7 KB
Line 
1/*
2 * sysinit-danube.c
3 *
4 * Copyright (C) 2006 Sebastian Gottschall <gottschall@dd-wrt.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 *
20 * $Id:
21 */
22#include <stdio.h>
23#include <stdlib.h>
24#include <limits.h>
25#include <time.h>
26#include <unistd.h>
27#include <errno.h>
28#include <syslog.h>
29#include <signal.h>
30#include <string.h>
31#include <termios.h>
32#include <sys/klog.h>
33#include <sys/types.h>
34#include <sys/mount.h>
35#include <sys/reboot.h>
36#include <sys/stat.h>
37#include <sys/sysmacros.h>
38#include <sys/time.h>
39#include <sys/utsname.h>
40#include <sys/wait.h>
41#include <sys/ioctl.h>
42
43#include <bcmnvram.h>
44#include <shutils.h>
45#include <utils.h>
46
47#define SIOCGMIIREG     0x8948  /* Read MII PHY register.  */
48#define SIOCSMIIREG     0x8949  /* Write MII PHY register.  */
49#include <arpa/inet.h>
50#include <sys/socket.h>
51#include <linux/if.h>
52#include <linux/sockios.h>
53#include <linux/mii.h>
54#include <cymac.h>
55#include "devices/wireless.c"
56
57/*
58        option unit             0
59        option encaps   llc
60        option vpi              1
61        option vci              32
62        option payload  bridged # some ISPs need this set to 'routed'
63
64        local cfg="$1"
65
66        local atmdev
67        config_get atmdev "$cfg" atmdev 0
68
69        local unit
70        config_get unit "$cfg" unit 0
71
72        local vpi
73        config_get vpi "$cfg" vpi 8
74
75        local vci
76        config_get vci "$cfg" vci 35
77
78        local encaps
79        config_get encaps "$cfg" encaps
80
81        case "$encaps" in
82                1|vc) encaps=1;;
83                *) encaps=0;;
84        esac
85
86        local payload
87        config_get payload "$cfg" payload
88
89        case "$payload" in
90                0|routed) payload=0;;
91                *) payload=1;;
92        esac
93
94        local qos
95        config_get qos "$cfg" qos
96
97        local circuit="$atmdev.$vpi.$vci"
98        local pid="/var/run/br2684ctl-$circuit.pid"
99
100        start-stop-daemon -S -b -x /usr/sbin/br2684ctl -m -p "$pid" -- \
101                -c "$unit" -e "$encaps" -p "$payload" \
102                -a "$circuit" ${qos:+-q "$qos"}
103
104*/
105
106void start_sysinit(void)
107{
108        char buf[PATH_MAX];
109        struct stat tmp_stat;
110        time_t tm = 0;
111
112        cprintf("sysinit() setup console\n");
113        if (!nvram_match("disable_watchdog", "1"))
114                eval("watchdog");
115        /*
116         * Setup console
117         */
118
119        cprintf("sysinit() klogctl\n");
120        klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel")));
121        cprintf("sysinit() get router\n");
122
123        int brand = getRouterBrand();
124        char *annex;
125
126        /*
127         * Modules
128         */
129
130        /*
131         * network drivers
132         */
133        // insmod("ag7100_mod");
134        // sleep(1);
135        //load dsl drivers
136        insmod("lantiq_mei");
137        insmod("lantiq_atm");
138        insmod("drv_dsl_cpe_api");
139#ifdef HAVE_TELCOM
140        nvram_default_get("annex", "a");
141        nvram_default_get("vpi", "0");
142        nvram_default_get("vci", "35");
143#else
144        nvram_default_get("vpi", "1");
145        nvram_default_get("vci", "32");
146#endif
147        nvram_set("dsl_iface_status", "DOWN");
148        nvram_set("dsl_snr_down", "");
149        nvram_set("dsl_snr_up", "");
150        nvram_set("dsl_datarate_ds", "");
151        nvram_set("dsl_datarate_us", "");
152        nvram_set("dsl_xtu_status", "");
153        nvram_set("dsl_tcl_status", "");
154/*
155todo
156Annex-B | 10_00_10_00_00_04_00_00
157Annex-B DMT | 10_00_00_00_00_00_00_00
158Annex-B ADSL2 | 00_00_10_00_00_00_00_00
159Annex-B ADSL2+ | 00_00_00_00_00_04_00_00
160Annex-A | 04_01_04_00_00_01_00_00
161Annex-A T1 | 01_00_00_00_00_00_00_00
162Annex-A Lite | 00_01_00_00_00_00_00_00
163Annex-A DMT | 04_00_00_00_00_00_00_00
164Annex-A ADSL2 | 00_00_04_00_00_00_00_00
165Annex-A ADSL2+ | 00_00_00_00_00_01_00_00
166Annex-L | 00_00_00_00_04_00_00_00
167Annex-M ADSL2 | 00_00_00_00_40_00_00_00
168Annex-M ADSL2+ | 00_00_00_00_00_00_04_00
169*/
170
171#ifdef HAVE_ANNEXB
172        sysprintf
173            ("/usr/sbin/dsl_cpe_control -i -f /usr/lib/firmware/annex_b.bin -n /usr/sbin/dsl_notification.sh &");
174#elif HAVE_ANNEXA
175        sysprintf
176            ("/usr/sbin/dsl_cpe_control -i -f /usr/lib/firmware/annex_a.bin -n /usr/sbin/dsl_notification.sh &");
177#else
178#ifdef HAVE_WMBR_G300NH
179        if (!strcmp(getUEnv("region"), "DE"))
180                annex = nvram_default_get("annex", "b");
181        else
182#endif
183                annex = nvram_default_get("annex", "a");
184
185        if (!strcmp(annex, "a"))
186                sysprintf
187                    ("/usr/sbin/dsl_cpe_control -i -f /usr/lib/firmware/annex_a.bin -n /usr/sbin/dsl_notification.sh &");
188        else if (!strcmp(annex, "m")) {
189                sysprintf
190                    ("/usr/sbin/dsl_cpe_control -i05_00_04_00_4c_01_04_00 -f /usr/lib/firmware/annex_a.bin -n /usr/sbin/dsl_notification.sh &");
191        } else
192                sysprintf
193                    ("/usr/sbin/dsl_cpe_control -i -f /usr/lib/firmware/annex_b.bin -n /usr/sbin/dsl_notification.sh &");
194#endif
195        eval("ifconfig", "eth0", "up");
196        detect_wireless_devices();
197        struct ifreq ifr;
198        int s;
199
200        if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) {
201                char eabuf[32];
202
203                strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);
204                ioctl(s, SIOCGIFHWADDR, &ifr);
205                nvram_set("et0macaddr",
206                          ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data,
207                                     eabuf));
208                nvram_set("et0macaddr_safe",
209                          ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data,
210                                     eabuf));
211                close(s);
212        }
213#ifdef HAVE_WMBR_G300NH
214        FILE *fp = fopen("/dev/mtdblock/6", "rb");
215        if (fp) {
216                char mactmp[6];
217                int copy[6];
218                int i;
219                char mac1[32];
220                fseek(fp, 0x1fd0024 + 12, SEEK_SET);
221                fread(mactmp, 6, 1, fp);
222                for (i = 0; i < 6; i++)
223                        copy[i] = mactmp[i];
224                for (i = 0; i < 6; i++)
225                        copy[i] &= 0xff;
226                sprintf(mac1, "%02X:%02X:%02X:%02X:%02X:%02X", copy[0],
227                        copy[1], copy[2], copy[3], copy[4], copy[5]);
228                eval("ifconfig", "wifi0", "hw", "ether", mac1);
229        }
230#ifdef HAVE_ATH9K
231        sysprintf
232            ("echo phy0tpt > /sys/devices/platform/leds-gpio/leds/soc:green:wlan/trigger");
233#else
234        system2("echo 15 >/proc/sys/dev/wifi0/ledpin");
235        system2("echo 1 >/proc/sys/dev/wifi0/softled");
236#endif
237
238        led_control(LED_POWER, LED_ON);
239        led_control(LED_SES, LED_OFF);
240        led_control(LED_SES2, LED_OFF);
241        led_control(LED_DIAG, LED_OFF);
242        led_control(LED_BRIDGE, LED_OFF);
243        led_control(LED_WLAN0, LED_OFF);
244        led_control(LED_WLAN1, LED_OFF);
245        led_control(LED_CONNECTED, LED_OFF);
246        system2("gpio disable 1");
247        system2("gpio disable 18");
248#endif
249#ifdef HAVE_SX763
250        char mac[18];
251        strcpy(mac, nvram_safe_get("et0macaddr"));
252        MAC_ADD(mac);
253        eval("ifconfig", "wifi0", "hw", "ether", mac);
254        system2("echo 219 >/proc/sys/dev/wifi0/ledpin");
255        system2("echo 1 >/proc/sys/dev/wifi0/softled");
256#endif
257
258        /*
259         * Set a sane date
260         */
261        stime(&tm);
262        nvram_set("wl0_ifname", "ath0");
263
264        return;
265        cprintf("done\n");
266}
267
268int check_cfe_nv(void)
269{
270        nvram_set("portprio_support", "0");
271        return 0;
272}
273
274int check_pmon_nv(void)
275{
276        return 0;
277}
278
279void start_overclocking(void)
280{
281}
282
283void enable_dtag_vlan(int enable)
284{
285
286}
Note: See TracBrowser for help on using the repository browser.