PMON for MIPS

advertisement
The 4th Linux Seminar
Firmware in Linux
http://alpha.secsm.org
Mar 26, 2000
ssmLUG
Byungsoo Jung
What’s the Firmware?
• BIOS
– Low Level, Loading the OS kernel.
• Monitor Program
– As a part of BIOS
– mainboard debuging
• OS Kernel
– Monolithic in Linux
– Currently micro kernel
Developing Tools
• GAŚ™€ Binutils
– GNU Assembler and Binary utilities
• NASM
– Free Assembler for i86
• GCC
– GNU C compiler
– I386,Alpha,PowerPC,MIPS,ARM,M68K
Simple GAS source code
• Get the Assembly source code from
C source code
– % gcc –S hello.c
• Compile with GAS
– % as –o hello.o hello.S
• Get the executabable file with GCC
– % gcc –o hello hello.o
.file "hello.c"
.version "01.01"
gcc2_compiled.:
.section .rodata
.LC0:
.string "Hello World!\n"
.text
.align 4
.globl main
.type main,@function
main:
pushl %ebp
movl %esp,%ebp
pushl $.LC0
call printf
addl $4,%esp
.L1:
leave
ret
.Lfe1:
.size main,.Lfe1-main
Simple GAS example
#
# File : hello.S
# Author : Byungsoo Jung
# Date : Aug 8, 1999
#
.data
# section declaration
msg:
.string
"Hello, world!"
# our dear string
msgend:
.equ
.text
len, msgend - msg
# length of our dear string
# section declaration
# we must export the entry point to the ELF linker or
.global
_start
# loader. They conventionally recognize _start as their
# entry point. Use ld -e hello to override the default.
_start:
# write our string to stdout
movl
$4, %eax
# system call number (sys_write)
movl
$1, %ebx
# first argument: file handle (stdout)
movl
$msg, %ecx
message to write
movl
int
# second argument: pointer to
$len, %edx # third argument: message length
$0x80
# INT 80h
# and exit
movl
$1,%eax
# system call number (sys_exit)
xorl
%ebx,%ebx
int
$0x80
# first syscall argument: exit code
# INT 80h
Making CrossGCC
•
•
•
•
Patch packages for the CrossGCC
Configure for CrossGCC
Make CrossGCC with Makefile
Installing CrossGCC
CrossGCC for ARM
• Binutils for ARM
–
–
–
–
–
–
#
#
#
#
#
#
tar zxvf binutils-2.9.5.0.24.tar.gz
cd bintutils-2.9. 5.0.24
export CC=/usr/bin/gcc
configure –target=arm-linux
make
make install
CrossGCC for ARM
• GCC for ARM
–
–
–
–
–
–
–
–
#
#
#
#
#
#
#
#
export CC=/usr/bin/gcc
tar zxvf gcc-core-2.95.1.tar.gz
cd gcc-core-2.95.1
gzip –d gcc-2.95-diff-990730.gz
patch –p0 < gcc-2.95-diff-990730
configure –target=arm-linux
make
make install
I. BIOS :
Alpha MILO and OpenBIOS
• Alpha MILO
– Introduction on the Alpha
MILO
• OpenBIOS Project
– Overview on the
OpenBIOS Project
II. Monitor Program :
PROM for MIPS
• PROM Monitor Program : PROM
– Serial Monitoring and Program
Downloading
– Ethernet Monitoring and Program
Downloading
III. Embedded Linux Kernel :
ELKS
• Embedded Linux Kernel : ELKS
– Introduction on ELKS
– ELKS Kernel Structure
– ELKS Device Driver
I. BIOS
Alpha MILÓ™€ OpenBIOS
http://alpha.secsm.org
ssmLUG
Byungsoo Jung
Alpha MILO
Alpha MILO’s History
• At 1993, Jim Paradis in Alpha Migration
Tools Group had a project Linux porting on
Alpha AXP
• At 1994, John Hall, senior manager, gave
the Jensen to Linus Torvals
• At 1994, Dave Rusling made MILO
bootloader for Alpha
• Now, Jay Easterbrook porting XFree86 to
the Alpha Linux
What’s the MILO?
•
MILO’s function
–
–
–
–
–
–
–
–
PALcode
Memory Setup code
Video Code
Linux kernel code
File System support (ext2, fat, iso9660)
User interface code
Kernel interface code
NVRAM code
MILO’s structure
• Two part
– System indepent part : MILO
– Most System dependt part : PALcode
• Code
–
–
–
–
MILo core : about 24,000 lines
PALcode : about 1,1000 lines
X86 emulation : about 1,6000 lines
Etc : about 40,000 lines
Alpha’s history
• At 1988, Dick Sites and Rich Witek
had a project designing Alpha
Architecture
• They predicted it would be a 64bit
world in the future
• They created Alpha architecture in the
long peorid more than 10 years
PALcode’s history
• New Architecture -> New Instruction?
– They solved this problem with PALcode.
• PALcode is like software emulation
– FX32 : x86 emulator
– Freeport Express : sparc emulator
PALcode’s structure
– Power-Up Initialization
– Memory management control
– Interuppt and exception
control
– Privileged instructions
– VAX and x86 instruction
emulation
Making PALcode
PALcode’s Image
MILO’s image
MILO Loading
• Loading MILO from
System firmware
– Windows NT ARC Firmware
– SRM Console
• Loading MILO from Debug
monitor
• Loading MILo from Flash
OpenBIOS
OpenBIOS Project
• OpenBIOS Project : x86 BIOS for PC
– http://www.freiburg.linux.de/openbios
• OpenFirmware Project : commertial
– http://www.openfirmware.org
• GNU BIOS Project : On emerging
– http://www.niklas.ekstrom.com/gnubios
• Linux BIOS Project : BIOS + Linux Kernel
– http://www.acl.lanl.gov/linuxbios
• GRUB Project : Multi-boot
– http://www.uruk.org/grub
• NILO Project : Network Lilo
– http://nilo.sourceforge.net
OpenBIOS’s structure :
similar to the OpenFimware
OpenFirmware’s Structure
Initial state of i386 in boot
How to boot in i386?
• At Reset
– CS : 0xFFFF F000h
– EIP : 0x0000 FFF0h
• Absolut physical address
– CS:EIP : 0xFFFF FFF0h
– ROM BIOS intial routine
Startup code in OpenBIOS
SEGMENT .text
BITS 16
; entry point into startup code - the bootstrap will vector
; here with a near JMP generated by the builder. This
; label must be in the top 64K of linear memory.
global
_main
_main:
jmp startup
sig:
db 0xde, 0xad, 0xbe, 0xef
startup:
mov
bx, cs
mov
ds, bx
xor
bx, bx
; es:bx == 0000:0000
mov
es, bx
mov
fs, ax
; Might contain BIST result
mov
gs, dx
; CPU model/rev info
CPU_TEST
PORT_80 0x01
Application of OpenBIOS
• Free i386 PC BIOS
– Finally no commertial software in PC!
– No trivial job for DOS 1.0 and fast booting
• Linux Cluster
– Linux BIOS project in Bewolf project in
NANL(Los Alamos National Laboratory)
II. Monitor Program
PMON for MIPS
http://alpha.secsm.org
ssmLUG
Byungsoo Jung
PMON for MIPS
Introduction to the PMON
• Made by Phil Bunce for MIPS PROM
monitor program
• Support the LSI logic MIPS CPU
• Support the serial and ethernet
• Source code available
• http://www.carmel.com/pmon
PMON’s environment
• PMON : the general debug monitor
– Require about 300KB memory
– Support serial and ethernet
• SerialICE-1A : with control board
– Same as PMON’s function
– Require about 1KB memory
• SerialICE-1B : no control board
– Same as PMON’s function
– Support only Windows 9x/NT
PMON’s directory
•
•
•
•
•
imon : source code for SerialICE
pmon : source code for PMON
mon : main source code for PMON and SerialICE
lib : C runtime library for PMON and SerialICE
bsps : the drivers and kernels that are need for
SerialICE-1.
• include : the include files used by this package
• examples : example programs for execution under
PMON and the SerialICE
• tools : tools that are executed on the host
PMON’s usage
• RS232 serial port
% tip –19200 hadwire
% set hostport tty0
PMON> set dlecho off
PMON> set dlproto none
PMON> load –c “cat
bubble.bin”
– PMON> g
–
–
–
–
–
• Ethernet port
– Set the host ip in /etc/hosts
as 210.118.74.129 beta
– PMON> set etheraddr
08:00:69:03:00:00
– # arp –s beta
08:00:69:03:00:00
– PMON> set hostport ethernet
– PMON> load
– % tftp beta
tftp> put bubble.bin
tftp> quit
– PMON> g
III. Embedded Linux Kernel
ELKS
http://alpha.secsm.org
ssmLUG
Byungsoo Jung
ELKS
Commertial Embedded Linux
• Lineo
– Embedix
– PowerPC, x86
– Close relation with
Motorolla
• FSMLabs + Synergy
– Real Time Linux
– VME, CompactPCI
– PowerPC, M68K
• Transmeta
– Crusoe (x86 emulation)
– Linux Tobals
ELKS Kernel
• Embedded Linux Kernel
• 512KB ROM and 1MB RAM
• Now, only 16bit x86
ELKS’s Structure
• Kernel
– i86 8086 boot code in i86 directory
• File system
– minix : MINIX file system
– elksfs : ELKS file system
– romfs : ROM file system
• Device Driver
– serial : serial device driver
– parallel : parallel device driver
– network : ethernet device driver
ELKS’s directory
•
•
•
•
•
•
•
•
•
•
1. arch/
2. kernel/
3. fs/
4. lib/
5. scripts/
6. include/
7. modules/
8. Documentation/
9. init/
10. net/
booting of ELKS
• ROM BIOS
– Move the first sector to the 0x7c00 in
memory
• arch/i86/bootsect.S
– Move itself to the 0x90000 and jump it.
• arch/i86/boot/setup.S
– System initialize
Thanks a lot!
Download