source: src/router/services/sysinit/sysinit-ca8.c @ 9356

Last change on this file since 9356 was 9356, checked in by BrainSlayer, 5 years ago

wistron ca8-pro/rdaa-81 support

File size: 4.2 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
60//highly experimental
61
62
63int
64start_sysinit (void)
65{
66  struct utsname name;
67  time_t tm = 0;
68  unlink ("/etc/nvram/.lock");
69  cprintf ("sysinit() proc\n");
70  /* /proc */
71  mount ("proc", "/proc", "proc", MS_MGC_VAL, NULL);
72  mount ("sysfs", "/sys", "sysfs", MS_MGC_VAL, NULL);
73  cprintf ("sysinit() tmp\n");
74
75  /* /tmp */
76  mount ("ramfs", "/tmp", "ramfs", MS_MGC_VAL, NULL);
77  // fix for linux kernel 2.6
78  mount ("devpts", "/dev/pts", "devpts", MS_MGC_VAL, NULL);
79  eval ("mkdir", "/tmp/www");
80  eval ("mknod", "/dev/nvram", "c", "229", "0");
81  eval ("mknod", "/dev/ppp", "c", "108", "0");
82
83  unlink ("/tmp/nvram/.lock");
84  eval ("mkdir", "/tmp/nvram");
85  eval ("/bin/tar", "-xzf", "/dev/mtdblock/3", "-C", "/");
86  FILE *in = fopen ("/tmp/nvram/nvram.db", "rb");
87  if (in != NULL)
88    {
89      fclose (in);
90      eval ("/usr/sbin/convertnvram");
91      eval ("/usr/sbin/mtd", "erase", "nvram");
92      nvram_commit ();
93    }
94  cprintf ("sysinit() var\n");
95
96  /* /var */
97  mkdir ("/tmp/var", 0777);
98  mkdir ("/var/lock", 0777);
99  mkdir ("/var/log", 0777);
100  mkdir ("/var/run", 0777);
101  mkdir ("/var/tmp", 0777);
102  cprintf ("sysinit() setup console\n");
103  eval ("/sbin/watchdog");
104  /* Setup console */
105
106  cprintf ("sysinit() klogctl\n");
107  klogctl (8, NULL, atoi (nvram_safe_get ("console_loglevel")));
108  cprintf ("sysinit() get router\n");
109
110
111
112  /* Modules */
113  uname (&name);
114
115/* network drivers */
116  eval ("insmod", "ar2313");
117  if (getRouterBrand () == ROUTER_BOARD_CA8PRO)
118    {
119      eval ("ifconfig", "eth0", "up");  // required for vlan config
120      eval ("/sbin/vconfig", "set_name_type", "VLAN_PLUS_VID_NO_PAD");
121      eval ("/sbin/vconfig", "add", "eth0", "0");
122      eval ("/sbin/vconfig", "add", "eth0", "1");
123      struct ifreq ifr;
124      int s;
125      if ((s = socket (AF_INET, SOCK_RAW, IPPROTO_RAW)))
126        {
127          char eabuf[32];
128          strncpy (ifr.ifr_name, "eth0", IFNAMSIZ);
129          ioctl (s, SIOCGIFHWADDR, &ifr);
130          char macaddr[32];
131          strcpy (macaddr,
132                  ether_etoa ((unsigned char *) ifr.ifr_hwaddr.sa_data,
133                              eabuf));
134          nvram_set ("et0macaddr", macaddr);
135          MAC_ADD (macaddr);
136          ether_atoe (macaddr, (unsigned char *) ifr.ifr_hwaddr.sa_data);
137          strncpy (ifr.ifr_name, "vlan1", IFNAMSIZ);
138          ioctl (s, SIOCSIFHWADDR, &ifr);
139          close (s);
140        }
141    }
142
143  eval ("insmod", "ath_hal");
144  eval ("insmod", "ath_ahb");
145//  eval ("ifconfig", "wifi0", "up");
146
147  eval ("insmod", "ipv6");
148
149  /* Set a sane date */
150  stime (&tm);
151  nvram_set ("wl0_ifname", "ath0");
152
153  return 0;
154  cprintf ("done\n");
155}
156
157int
158check_cfe_nv (void)
159{
160  nvram_set ("portprio_support", "0");
161  return 0;
162}
163
164int
165check_pmon_nv (void)
166{
167  return 0;
168}
169
170void
171start_overclocking (void)
172{
173}
174
175void
176enable_dtag_vlan (int enable)
177{
178
179}
Note: See TracBrowser for help on using the repository browser.