Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Linux/VAX Hacking

Linux/VAX Hacking

Toolchain

To build a Linux kernel image, we need a cross-compiling toolchain that consists of:

  • Binutils
  • GCC

We will be installing the toolchain under the /opt/cross directory:

[penberg@nero binutils-bin]$ sudo mkdir /opt/cross

Binutils

To build Binutils:

[penberg@nero vax-toolchain]$ mkdir vax-toolchain
[penberg@nero vax-toolchain]$ cd vax-toolchain
[penberg@nero vax-toolchain]$ wget http://www.nic.funet.fi/pub/gnu/ftp.gnu.org/pub/gnu/binutils/binutils-2.25.tar.bz2
[penberg@nero vax-toolchain]$ mkdir binutils-bin
[penberg@nero vax-toolchain]$ tar xf binutils-2.25.tar.bz2 
[penberg@nero vax-toolchain]$ cd binutils-bin/
[penberg@nero binutils-bin]$ ../binutils-2.25/configure --prefix=/opt/cross/vax-linux/ --target=vax-linux
[penberg@nero binutils-bin]$ make
[penberg@nero binutils-bin]$ sudo make install

VAX bintools are now installed in /opt/cross/vax-linux!

Remember to make the freshly built executables visible in PATH:

export PATH=/opt/cross/vax-linux/bin:$PATH

To try it out, create the following VAX assembly source file:

[penberg@nero tmp]$ cat hello.S 
	movl r0, r1
	ret

Assemble it:

[penberg@nero tmp]$ vax-linux-as hello.S 

and disassable it with objdump:

[penberg@nero tmp]$ vax-linux-objdump -d a.out 

a.out:     file format elf32-vax


Disassembly of section .text:

00000000 <.text>:
   0:	d0 ef 00 00 	movl 0x6,0xb
   4:	00 00 ef 00 
   8:	00 00 00 
   b:	04          	ret

GCC

[penberg@nero vax-toolchain]$ wget ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-5.1.0/gcc-5.1.0.tar.bz2
[penberg@nero vax-toolchain]$ tar xf gcc-gcc-5.1.0.tar.bz2 
[penberg@nero vax-toolchain]$ mkdir gcc-bin
[penberg@nero vax-toolchain]$ cd gcc-bin/
[penberg@nero gcc-bin]$ ../gcc-5.1.0/configure --target=vax-linux --prefix=/opt/cross/vax-linux/ --enable-languages=c --disable-threads
[penberg@nero gcc-bin]$ make all-gcc
[penberg@nero gcc-bin]$ sudo make install-gcc

GCC is now installed in /opt/cross/vax-linux!

To make sure it's working, create a simple C source file:

[penberg@nero tmp]$ cat hello.c 
int foo(int x)
{
	return x;
}

Compile it:

[penberg@nero tmp]$ vax-linux-gcc -O2 -c hello.c -o hello.o

and then disassemble it:

[penberg@nero tmp]$ vax-linux-objdump -d hello.o

hello.o:     file format elf32-vax


Disassembly of section .text:

00000000 <foo>:
   0:	00 00       	.word 0x0000 # Entry mask: < >
   2:	c2 04 5e    	subl2 $0x4,sp
   5:	d0 ac 04 50 	movl 0x4(ap),r0
   9:	04          	ret

SIMH

[penberg@nero vax-toolchain]$ wget http://simh.trailing-edge.com/sources/simhv39-0.zip
[penberg@nero vax-toolchain]$ mkdir simh
[penberg@nero vax-toolchain]$ cd simh/
[penberg@nero simh]$ unzip ../simhv39-0.zip 
[penberg@nero simh]$ make BIN/vax
[penberg@nero simh]$ sudo mkdir -p $HOME/simh/vax/bin
[penberg@nero simh]$ sudo mkdir -p $HOME/simh/vax/data
[penberg@nero simh]$ cp BIN/vax $HOME/simh/vax/bin/
[penberg@nero simh]$ cp VAX/ka655x.bin $HOME/simh/vax/data/
[penberg@nero simh]$ cat $HOME/simh/vax/data/simh.ini 
;
; Load CPU microcode
load -r /home/<user>/shm/vax/data/ka655.bin
;
; Attach non-volatile RAM to a file
attach nvr /home/<user>/shm/vax/data/nvram.bin
;
; This virtual machine has 64M memory
set cpu 64m
;
; Define disk drive types. RA92 is largest-supported VAX drive.
set rq0 ra92
set rq1 ra92
set rq2 ra92
set rq3 cdrom
;
; Attach defined drives to local files
attach rq0 /home/<user>/shm/vax/data/d0.dsk
attach rq1 /home/<user>/shm/vax/data/d1.dsk
attach rq2 /home/<user>/shm/vax/data/d2.dsk
;
; Attach the CD-ROM to its file (read-only) 
attach -r rq3 /home/<user>/shm/vax/data/cd.iso
;
; Disable unused devices. It's also possible to disable individual devices,
; using a construction like "set rq2 disable" if desired. 
;
set rl disable
set ts disable
; 
; Attach Ethernet to a network interface
set xq mac=08-00-2B-AA-BB-CC
attach xq eth0
;
; Now start the emulator
boot cpu
ln -s $HOME/sim/vax/data/vax.ini $HOME/simh/vax/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.