source: src/router/services/sysinit/sysinit-rcaa01.c @ 18928

Last change on this file since 18928 was 18928, checked in by BrainSlayer, 14 months ago

work in progress

File size: 4.1 KB
Line 
1/*
2 * sysinit-ca8.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
55#include <bcmnvram.h>
56#include <shutils.h>
57#include <utils.h>
58#include <cymac.h>
59#include "devices/wireless.c"
60
61// highly experimental
62
63void start_sysinit(void)
64{
65        time_t tm = 0;
66
67        eval("/bin/tar", "-xzf", "/dev/mtdblock/3", "-C", "/");
68        FILE *in = fopen("/tmp/nvram/nvram.db", "rb");
69
70        if (in != NULL) {
71                fclose(in);
72                eval("/usr/sbin/convertnvram");
73                eval("/sbin/mtd", "erase", "nvram");
74                nvram_commit();
75        }
76        if (!nvram_match("disable_watchdog", "1"))
77                eval("watchdog");
78        /*
79         * Setup console
80         */
81
82        cprintf("sysinit() klogctl\n");
83        klogctl(8, NULL, atoi(nvram_safe_get("console_loglevel")));
84        cprintf("sysinit() get router\n");
85
86        /*
87         * network drivers
88         */
89#ifdef HAVE_HOTPLUG2
90        insmod("ar231x");
91#else
92        insmod("ar2313");
93#endif
94        detect_wireless_devices();
95        int s;
96        struct ifreq ifr;
97        if (getRouterBrand() == ROUTER_BOARD_RDAT81) {
98                writeproc("/proc/sys/dev/wifi0/ledpin","7");
99                writeproc("/proc/sys/dev/wifi0/softled","1");
100                writeproc("/proc/sys/dev/wifi1/ledpin","5");
101                writeproc("/proc/sys/dev/wifi1/softled","1");
102        }
103        if (getRouterBrand() == ROUTER_BOARD_RCAA01) {
104                insmod("mvswitch");
105//              eval("ifconfig", "eth0", "up", "promisc");      // required for vlan config
106                eval("/sbin/vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD");
107                eval("/sbin/vconfig", "add", "eth0", "0");
108                eval("/sbin/vconfig", "add", "eth0", "1");
109
110                if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) {
111                        char eabuf[32];
112
113                        strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);
114                        ioctl(s, SIOCGIFHWADDR, &ifr);
115                        char macaddr[32];
116
117                        strcpy(macaddr,
118                               ether_etoa((unsigned char *)ifr.ifr_hwaddr.
119                                          sa_data, eabuf));
120                        nvram_set("et0macaddr", macaddr);
121//          MAC_ADD( macaddr );
122                        ether_atoe(macaddr,
123                                   (unsigned char *)ifr.ifr_hwaddr.sa_data);
124                        strncpy(ifr.ifr_name, "vlan1", IFNAMSIZ);
125                        ioctl(s, SIOCSIFHWADDR, &ifr);
126                        close(s);
127                }
128                writeproc("/proc/sys/dev/wifi0/ledpin","4");
129                writeproc("/proc/sys/dev/wifi0/softled","1");
130                writeproc("/proc/sys/dev/wifi1/ledpin","5");
131                writeproc("/proc/sys/dev/wifi1/softled","1");
132        }
133        if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) {
134                char eabuf[32];
135
136                strncpy(ifr.ifr_name, "eth0", IFNAMSIZ);
137                ioctl(s, SIOCGIFHWADDR, &ifr);
138                char macaddr[32];
139
140                strcpy(macaddr,
141                       ether_etoa((unsigned char *)ifr.ifr_hwaddr.sa_data,
142                                  eabuf));
143                nvram_set("et0macaddr", macaddr);
144                nvram_set("et0macaddr_safe", macaddr);
145                close(s);
146        }
147
148        /*
149         * Set a sane date
150         */
151        stime(&tm);
152        nvram_set("wl0_ifname", "ath0");
153
154        return;
155        cprintf("done\n");
156}
157
158int check_cfe_nv(void)
159{
160        nvram_set("portprio_support", "0");
161        return 0;
162}
163
164int check_pmon_nv(void)
165{
166        return 0;
167}
168
169void start_overclocking(void)
170{
171}
172
173void enable_dtag_vlan(int enable)
174{
175
176}
Note: See TracBrowser for help on using the repository browser.