source: src/router/services/sysinit/sysinit-mr3202a.c @ 9114

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

vdsl support for broadcom vlan switch supported routers too

File size: 3.3 KB
Line 
1/*
2 * sysinit-mr3202a.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
42#include <bcmnvram.h>
43#include <shutils.h>
44#include <utils.h>
45
46
47
48extern void vlan_init (int num);
49
50int
51start_sysinit (void)
52{
53  char buf[PATH_MAX];
54  struct utsname name;
55  struct stat tmp_stat;
56  time_t tm = 0;
57  unlink ("/etc/nvram/.lock");
58  cprintf ("sysinit() proc\n");
59  /* /proc */
60  mount ("proc", "/proc", "proc", MS_MGC_VAL, NULL);
61  mount ("sysfs", "/sys", "sysfs", MS_MGC_VAL, NULL);
62  cprintf ("sysinit() tmp\n");
63
64  /* /tmp */
65  mount ("ramfs", "/tmp", "ramfs", MS_MGC_VAL, NULL);
66  // fix for linux kernel 2.6
67  mount ("devpts", "/dev/pts", "devpts", MS_MGC_VAL, NULL);
68  eval ("mkdir", "/tmp/www");
69  eval ("mknod", "/dev/nvram", "c", "229", "0");
70  eval ("mknod", "/dev/ppp", "c", "108", "0");
71
72  unlink ("/tmp/nvram/.lock");
73#ifndef HAVE_WRK54G
74  eval ("mkdir", "/tmp/nvram");
75  eval ("/bin/tar", "-xzf", "/dev/mtdblock/3", "-C", "/");
76  FILE *in = fopen ("/tmp/nvram/nvram.db", "rb");
77  if (in != NULL)
78    {
79      fclose (in);
80      eval ("/usr/sbin/convertnvram");
81      eval ("/usr/sbin/mtd", "erase", "nvram");
82      nvram_commit ();
83    }
84#endif
85  cprintf ("sysinit() var\n");
86
87  /* /var */
88  mkdir ("/tmp/var", 0777);
89  mkdir ("/var/lock", 0777);
90  mkdir ("/var/log", 0777);
91  mkdir ("/var/run", 0777);
92  mkdir ("/var/tmp", 0777);
93  cprintf ("sysinit() setup console\n");
94//  eval ("/sbin/watchdog");
95  /* Setup console */
96
97  cprintf ("sysinit() klogctl\n");
98  klogctl (8, NULL, atoi (nvram_safe_get ("console_loglevel")));
99  cprintf ("sysinit() get router\n");
100
101
102
103  /* Modules */
104  uname (&name);
105/* network drivers */
106  eval ("insmod", "ar2313");
107  eval ("insmod", "ath_hal");
108  eval ("insmod", "ath_ahb");
109#ifdef HAVE_WRK54G
110  system ("echo 2 >/proc/sys/dev/wifi0/ledpin");
111  system ("echo 1 >/proc/sys/dev/wifi0/softled");
112#endif
113  eval ("ifconfig", "wifi0", "up");
114  eval ("ifconfig", "eth0", "up");
115  vlan_init (5);                // 1 lan + 1 wan
116
117  /* Set a sane date */
118  stime (&tm);
119  nvram_set ("wl0_ifname", "ath0");
120
121  return 0;
122}
123
124int
125check_cfe_nv (void)
126{
127  nvram_set ("portprio_support", "0");
128  return 0;
129}
130
131int
132check_pmon_nv (void)
133{
134  return 0;
135}
136
137void
138start_overclocking (void)
139{
140}
141void enable_dtag_vlan(int enable)
142{
143
144}
Note: See TracBrowser for help on using the repository browser.