| 1 | /* |
|---|
| 2 | * sysinit-rb532.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 | |
|---|
| 23 | #include <stdio.h> |
|---|
| 24 | #include <stdlib.h> |
|---|
| 25 | #include <limits.h> |
|---|
| 26 | #include <time.h> |
|---|
| 27 | #include <unistd.h> |
|---|
| 28 | #include <errno.h> |
|---|
| 29 | #include <syslog.h> |
|---|
| 30 | #include <signal.h> |
|---|
| 31 | #include <string.h> |
|---|
| 32 | #include <termios.h> |
|---|
| 33 | #include <sys/klog.h> |
|---|
| 34 | #include <sys/types.h> |
|---|
| 35 | #include <sys/mount.h> |
|---|
| 36 | #include <sys/reboot.h> |
|---|
| 37 | #include <sys/stat.h> |
|---|
| 38 | #include <sys/sysmacros.h> |
|---|
| 39 | #include <sys/time.h> |
|---|
| 40 | #include <sys/utsname.h> |
|---|
| 41 | #include <sys/wait.h> |
|---|
| 42 | |
|---|
| 43 | #include <bcmnvram.h> |
|---|
| 44 | #include <shutils.h> |
|---|
| 45 | #include <utils.h> |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | int |
|---|
| 49 | start_sysinit (void) |
|---|
| 50 | { |
|---|
| 51 | char buf[PATH_MAX]; |
|---|
| 52 | struct utsname name; |
|---|
| 53 | struct stat tmp_stat; |
|---|
| 54 | time_t tm = 0; |
|---|
| 55 | unlink ("/etc/nvram/.lock"); |
|---|
| 56 | cprintf ("sysinit() proc\n"); |
|---|
| 57 | /* /proc */ |
|---|
| 58 | mount ("proc", "/proc", "proc", MS_MGC_VAL, NULL); |
|---|
| 59 | cprintf ("sysinit() tmp\n"); |
|---|
| 60 | |
|---|
| 61 | /* /tmp */ |
|---|
| 62 | mount ("ramfs", "/tmp", "ramfs", MS_MGC_VAL, NULL); |
|---|
| 63 | // fix for linux kernel 2.6 |
|---|
| 64 | mount ("devpts", "/dev/pts", "devpts", MS_MGC_VAL, NULL); |
|---|
| 65 | eval ("mkdir", "/tmp/www"); |
|---|
| 66 | |
|---|
| 67 | //load ext2 |
|---|
| 68 | // eval("insmod","jbd"); |
|---|
| 69 | eval ("insmod", "ext2"); |
|---|
| 70 | #ifndef KERNEL_24 |
|---|
| 71 | if (mount ("/dev/cf/card0/part3", "/usr/local", "ext2", MS_MGC_VAL, NULL)) |
|---|
| 72 | #else |
|---|
| 73 | if (mount |
|---|
| 74 | ("/dev/discs/disc0/part3", "/usr/local", "ext2", MS_MGC_VAL, NULL)) |
|---|
| 75 | #endif |
|---|
| 76 | { |
|---|
| 77 | //not created yet, create ext2 partition |
|---|
| 78 | eval ("/sbin/mke2fs", "-F", "-b", "1024", "/dev/cf/card0/part3"); |
|---|
| 79 | //mount ext2 |
|---|
| 80 | mount ("/dev/cf/card0/part3", "/usr/local", "ext2", MS_MGC_VAL, NULL); |
|---|
| 81 | eval ("/bin/tar", "-xvvjf", "/etc/local.tar.bz2", "-C", "/"); |
|---|
| 82 | } |
|---|
| 83 | eval ("mkdir", "-p", "/usr/local/nvram"); |
|---|
| 84 | unlink ("/tmp/nvram/.lock"); |
|---|
| 85 | eval ("mkdir", "/tmp/nvram"); |
|---|
| 86 | eval ("cp", "/etc/nvram/nvram.db", "/tmp/nvram"); |
|---|
| 87 | |
|---|
| 88 | eval ("mount", "/usr/local", "-o", "remount,ro"); |
|---|
| 89 | |
|---|
| 90 | // eval ("cp", "/etc/nvram/offsets.db", "/tmp/nvram"); |
|---|
| 91 | cprintf ("sysinit() var\n"); |
|---|
| 92 | |
|---|
| 93 | /* /var */ |
|---|
| 94 | mkdir ("/tmp/var", 0777); |
|---|
| 95 | mkdir ("/var/lock", 0777); |
|---|
| 96 | mkdir ("/var/log", 0777); |
|---|
| 97 | mkdir ("/var/run", 0777); |
|---|
| 98 | mkdir ("/var/tmp", 0777); |
|---|
| 99 | cprintf ("sysinit() setup console\n"); |
|---|
| 100 | |
|---|
| 101 | /* Setup console */ |
|---|
| 102 | |
|---|
| 103 | cprintf ("sysinit() klogctl\n"); |
|---|
| 104 | klogctl (8, NULL, atoi (nvram_safe_get ("console_loglevel"))); |
|---|
| 105 | cprintf ("sysinit() get router\n"); |
|---|
| 106 | |
|---|
| 107 | int brand = getRouterBrand (); |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | /* Modules */ |
|---|
| 111 | uname (&name); |
|---|
| 112 | /* |
|---|
| 113 | eval ("insmod", "md5"); |
|---|
| 114 | eval ("insmod", "aes"); |
|---|
| 115 | eval ("insmod", "blowfish"); |
|---|
| 116 | eval ("insmod", "deflate"); |
|---|
| 117 | eval ("insmod", "des"); |
|---|
| 118 | eval ("insmod", "michael_mic"); |
|---|
| 119 | eval ("insmod", "cast5"); |
|---|
| 120 | eval ("insmod", "crypto_null"); |
|---|
| 121 | */ |
|---|
| 122 | // eval ("insmod", "ath_hal"); |
|---|
| 123 | // eval ("insmod", "wlan"); |
|---|
| 124 | // eval ("insmod", "ath_rate_sample"); |
|---|
| 125 | eval ("insmod", "ath_hal"); |
|---|
| 126 | eval ("insmod", "ath_pci"); |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | /*eval ("insmod", "wlan_acl"); |
|---|
| 130 | eval ("insmod", "wlan_ccmp"); |
|---|
| 131 | eval ("insmod", "wlan_tkip"); |
|---|
| 132 | eval ("insmod", "wlan_wep"); |
|---|
| 133 | eval ("insmod", "wlan_xauth"); |
|---|
| 134 | eval ("insmod", "wlan_scan_ap"); |
|---|
| 135 | eval ("insmod", "wlan_scan_sta"); |
|---|
| 136 | */ |
|---|
| 137 | eval ("ifconfig", "wifi0", "up"); |
|---|
| 138 | eval ("ifconfig", "wifi1", "up"); |
|---|
| 139 | eval ("ifconfig", "wifi2", "up"); |
|---|
| 140 | eval ("ifconfig", "wifi3", "up"); |
|---|
| 141 | eval ("ifconfig", "wifi4", "up"); |
|---|
| 142 | eval ("ifconfig", "wifi5", "up"); |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | /* eval ("insmod", "mii"); |
|---|
| 146 | eval ("insmod", "korina"); |
|---|
| 147 | eval ("insmod", "via-rhine"); |
|---|
| 148 | eval ("insmod", "ipv6");*/ |
|---|
| 149 | /* Set a sane date */ |
|---|
| 150 | stime (&tm); |
|---|
| 151 | nvram_set ("use_crypto", "0"); |
|---|
| 152 | nvram_set ("wl0_ifname", "ath0"); |
|---|
| 153 | |
|---|
| 154 | cprintf ("done\n"); |
|---|
| 155 | return 0; |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | int |
|---|
| 159 | check_cfe_nv (void) |
|---|
| 160 | { |
|---|
| 161 | nvram_set ("portprio_support", "0"); |
|---|
| 162 | return 0; |
|---|
| 163 | } |
|---|
| 164 | |
|---|
| 165 | int |
|---|
| 166 | check_pmon_nv (void) |
|---|
| 167 | { |
|---|
| 168 | return 0; |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | void |
|---|
| 172 | start_overclocking (void) |
|---|
| 173 | { |
|---|
| 174 | } |
|---|
| 175 | void |
|---|
| 176 | enable_dtag_vlan (int enable) |
|---|
| 177 | { |
|---|
| 178 | |
|---|
| 179 | } |
|---|