vak: (Daemon)
[personal profile] vak
Довел я наконец управление памятью до состояния, когда все работает вполне устойчиво. Система успешно стартует в многопользовательском режиме. Из сетевых интерфейсов, правда, имеется только lo0, да и тот почему-то не пингуется. Надо разбираться.

Чтобы заработали утилиты статуса и статистики (примеры здесь), пришлось провести одну существенную доработку. Традиционно программа пользователя получает данные из памяти ядра, читая устройство /dev/kmem. Но надо знать адреса, для этого считывается таблица символов ядреного бинарника /vmunix. Проблема в том, что во встроенной системе ядро не лежит в файловой системе, а записано в flash-память микроконтроллера, и ни таблицы символов там нет, ни доступа к нему в любом случае.

Но есть простое и эффективное решение: запрашивать адреса символов у самого ядра, тем более что список нужных имен довольно ограниченный. Для этого достаточно расширить стандартный системный вызов sysctl() нужными кодами операций. Все удовольствие - несколько десятков строчек кода в ядре. В машинно-зависимой части, конечно.
Copyright (c) 1982, 1986, 1989, 1991, 1993
   The Regents of the University of California.  All rights reserved.

4.4BSD-Lite build 16 compiled 2014-11-25
    sergev@ubuntu-sergev:Tilden/sys/compile/WIFIRE.pic32
cpu: PIC32MZ2048ECG100 rev A4, 200 MHz
oscillator: system PLL div 1:6 mult x50
real mem = 512 kbytes
avail mem = 344 kbytes
using 10 buffers containing 49152 bytes of memory
spi1 at pins sdi=F1/sdo=C1/sck=D1
spi2 at pins sdi=F0/sdo=D11/sck=G6
spi3 at pins sdi=B10/sdo=C4/sck=B14
spi4 at pins sdi=F5/sdo=G0/sck=D10
uart1 at pins rx=D14/tx=D15, interrupts 112/113/114
uart4 at pins rx=F2/tx=F8, interrupts 170/171/172, console
sd0 at port spi3, pin cs=C3
sd0: type I, size 679936 kbytes, speed 12 Mbit/sec
sd0a: partition type b7, sector 2, size 204800 kbytes
sd0b: partition type b8, sector 409602, size 32768 kbytes
sd0c: partition type b7, sector 475138, size 102400 kbytes
bpf: lo0 attached
WARNING: preposterous clock chip time -- CHECK AND RESET THE DATE!

starting network
starting system logger.
clearing /tmp
standard daemons: update.
Tue Nov 25 22:16:09 PST 2014


4.4BSD-Lite (bsd.net) (tty4)

login: root
root
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
        The Regents of the University of California.   All rights reserved.

4.4BSD-Lite UNIX #1: Fri Apr 01 00:00:00 PDT 1994

Welcome to 4.4BSD-Lite!

erase ^H, kill ^U, intr ^C status ^T
Don't login as root, use the su command.
# ps alx
  UID   PID  PPID CPU PRI NI   VSZ  RSS WCHAN  STAT TT       TIME COMMAND
    0     0     0   0 -18  0     0    0 schedu DLs  ??    0:00.00 (swapper)
    0     1     0   0  10  0   172    0 wait   Ss   ??    0:00.00 /sbin/init
    0     2     0   0 -18  0     0    0 -      RL   ??    0:00.65 (pagedaemon)
    0    21     1   0   2  0   144    0 select Ss   ??    0:00.00 syslogd
    0    32     1   0  18  0    20    0 pause  SWs  ??    0:00.00 update
    0    39     1   0  10  0   332    0 wait   Ss    4    0:00.00 -sh (sh)
    0    41    39   0  28  0   200    0 -      R+    4    0:00.00 (ps)
# sysctl -a
kern.ostype = 4.4BSD
kern.osrelease = 4.4BSD-Lite
kern.osrevision = 199506
kern.version = 4.4BSD-Lite build 16 compiled 2014-11-25
    sergev@ubuntu-sergev:Tilden/sys/compile/WIFIRE.pic32

kern.maxvnodes = 54
kern.maxproc = 24
kern.maxfiles = 64
kern.argmax = 4096
kern.securelevel = 1
kern.hostname = bsd.net
kern.hostid = 0
kern.clockrate: hz = 20, tick = 50000, profhz = 20, stathz = 20
kern.posix1version = 198808
kern.ngroups = 16
kern.job_control = 1
kern.saved_ids = 0
kern.boottime = Tue Nov 25 22:16:09 2014

vm.loadavg: 0.07 0.02 0.01
vfs.ufs has 1 mounted instance
net.inet.ip.forwarding = 0
net.inet.ip.redirect = 1
net.inet.ip.ttl = 64
net.inet.icmp.maskrepl = 0
net.inet.udp.checksum = 1
debug.syncprt = 0
debug.busyprt = 0
debug.lockpausetime = 0
hw.machine = MIPS
hw.model = PIC32MZ2048ECG100
hw.ncpu = 1
hw.byteorder = 1234
hw.physmem = 524288
hw.usermem = 348160
hw.pagesize = 4096
machdep.console_device = tty4
user.cs_path = /usr/bin:/bin:/usr/sbin:/sbin:/usr/contrib/bin:/usr/old/bin
user.bc_base_max = 99
user.bc_dim_max = 2048
user.bc_scale_max = 99
user.bc_string_max = 1000
user.coll_weights_max = 0
user.expr_nest_max = 32
user.line_max = 2048
user.re_dup_max = 255
user.posix2_version = 199212
user.posix2_c_bind = 0
user.posix2_c_dev = 0
user.posix2_char_term = 0
user.posix2_fort_dev = 0
user.posix2_fort_run = 0
user.posix2_localedef = 0
user.posix2_sw_dev = 0
user.posix2_upe = 0
user.stream_max = 20
user.tzname_max = 255
# _
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org