simh中安装运行unix v7

参考http://gunkies.org/wiki/Installing_v7_on_SIMH

一、用perl或C生成磁带镜像

$ cat mkdisttap.pl 

#!/usr/bin/perl -w
use strict;

# Based on mkdisttap.pl
# ftp://ftp.mrynet.com/pub/os/PUPS/PDP-11/Boot_Images/2.11_on_Simh/211bsd/mkdisttap.pl

#
# $Id: mkdisttap.pl,v 1.1 2006/09/16 23:33:46 kirk Exp kirk $
#

# Based on the example in the HOWTO using dd.  Does not work!
# add_file("cat mtboot mtboot boot |", 512);

# Based on the maketape.c program and the maketape.data data file.
add_file("f0", 512);
end_file();
add_file("f1", 512);
end_file();
add_file("f2", 512);
end_file();
add_file("f3", 512);
end_file();
add_file("f4", 512);
end_file();
add_file("f5", 10240);
end_file();
add_file("f6", 10240);
end_file();
end_file();

sub end_file {
  print "\x00\x00\x00\x00";
}

sub add_file {
  my($filename, $blocksize) = @_;
  my($block, $bytes_read, $length);

  open(FILE, $filename) || die("Can't open $filename: $!");
  while($bytes_read = read(FILE, $block, $blocksize)) {
    if($bytes_read < $blocksize) {
      $block .= "\x00" x ($blocksize - $bytes_read);
      $bytes_read = $blocksize;
    }
    $length = pack("V", $bytes_read);
    print $length, $block, $length;
  }
  close(FILE);
}

c语言:

/*
 * mktape.c
 */


#include <stdio.h>
#include <stdlib.h>


struct {
  char *name;
  int blocksize;
} files[] = {
  { "f0",   512 },
  { "f1",   512 },
  { "f2",   512 },
  { "f3",   512 },
  { "f4",   512 },
  { "f5", 10240 },
  { "f6", 10240 }
};


void error(char *msg) {
  printf("**** Error: %s ****\n", msg);
  exit(0);
}


void writeCount(long count, FILE *file) {
  if (fwrite(&count, 4, 1, file) != 1) {
    error("cannot write byte count");
  }
}


int main(void) {
  FILE *outfile;
  FILE *infile;
  long size;
  int blocksize;
  int blocks;
  int i, j;
  unsigned char buffer[20000];

  outfile = fopen("unix_v7.tm", "wb");
  if (outfile == NULL) {
    error("cannot open output file");
  }
  for (i = 0; i < sizeof(files)/sizeof(files[0]); i++) {
    printf("%s: ", files[i].name);
    infile = fopen(files[i].name, "rb");
    if (infile == NULL) {
      error("cannot open input file");
    }
    fseek(infile, 0, SEEK_END);
    size = ftell(infile);
    fseek(infile, 0, SEEK_SET);
    blocksize = files[i].blocksize;
    blocks = size / blocksize;
    printf("%ld bytes = %d records (blocksize %d bytes)\n",
           size, blocks, blocksize);
    if (size % blocksize != 0) {
      error("file size is not a multiple of block size");
    }
    for (j = 0; j < blocks; j++) {
      if (fread(buffer, blocksize, 1, infile) != 1) {
        error("cannot read input file");
      }
      writeCount(blocksize, outfile);
      if (fwrite(buffer, blocksize, 1, outfile) != 1) {
        error("cannot write output file");
      }
      writeCount(blocksize, outfile);
    }
    fclose(infile);
    writeCount(0, outfile);
  }
  writeCount(0xFFFFFFFF, outfile);
  fclose(outfile);
  return 0;
}


二、到ftp://minnie.tuhs.org/UnixArchive/PDP-11/Distributions/research/Keith_Bostic_v7/下载

f0.gz  f1.gz  f2.gz  f3.gz  f4.gz  f5.gz  f6.gz并解压为:f0  f1  f2  f3  f4  f5  f6

三、生成磁带镜像文件: 

$ ./mkdisttap.pl > v7.tap

$gcc -Wall -g -o mktape mktape.c

$./mktape

直接到http://sourceforge.net/projects/bsd42/files/Install tapes/Research Unix/Unix-v7-Keith-Bostic.tap.bz2/download下载Unix-v7-Keith-Bostic.tap.bz2解压后修改名字

$ mv Unix-v7-Keith-Bostic.tap v7.tap

四、安装

$ vi tapei.ini

$ cat tapei.ini 

set cpu 11/45

set cpu idle

set rp0 rp06

att rp0 rp06-0.disk

att tm0 v7.tap

boot tm0

$ pdp11 tapei.ini 

PDP-11 simulator V3.9-0

Disabling XQ

RP: creating new file

Overwrite last track? [N] 

Boot

: tm(0,3)

file sys size: 5000

file system: hp(0,0)

isize = 1600

m/n = 3 500

Exit called

Boot

: tm(0,4)

Tape? tm(0,5)

Disk? hp(0,0)

Last chance before scribbling on disk. 

End of tape

Boot

: hp(0,0)hptmunix

mem = 177344

# MV HPTMUNIX UNIX

# RM HP*IX

# LS *IX

RPHTUNIX

RPTMUNIX

UNIX

# RM RP*IX

# CD /DEV

# MAKE RP06

/ETC/MKNOD RP0 B 6 0

/ETC/MKNOD SWAP B 6 1

/ETC/MKNOD RP3 B 6 7

/ETC/MKNOD RRP0 C 14 0

/ETC/MKNOD RRP3 C 14 7

CHMOD GO-W RP0 SWAP RP3 RRP0 RRP3

# MAKE TM

/ETC/MKNOD MT0 B 3 0

/ETC/MKNOD RMT0 C 12 0

/ETC/MKNOD NRMT0 C 12 128

CHMOD GO+W MT0 RMT0 NRMT0

# CD /

# /ETC/MKFS /DEV/RP3 322276

ISIZE = 65496

M/N = 3 500

# DD IF=/DEV/NRMT0 OF=/DEV/NULL BS=20B FILES=6

202+80 RECORDS IN

202+75 RECORDS OUT

# RESTOR RF /DEV/RMT0 /DEV/RP3

LAST CHANCE BEFORE SCRIBBLING ON /DEV/RP3. 

END OF TAPE

# /ETC/MOUNT /DEV/RP3 /USR

# DD IF=/USR/MDEC/HPUBOOT OF=/DEV/RP0 COUNT=1

0+1 RECORDS IN

0+1 RECORDS OUT

# SYNC

# SYNC

# SYNC

# SYNC

Simulation stopped, PC: 002306 (MOV (SP)+,177776)

sim> q

Goodbye$ pdp11 tboot.ini

PDP-11 simulator V3.9-0

at the prompt type in

@ hp(0,0)unix

Disabling XQ

Boot

: hp(0,0)unix

mem = 2020544

# RESTRICTED RIGHTS: USE, DUPLICATION, OR DISCLOSURE

IS SUBJECT TO RESTRICTIONS STATED IN YOUR CONTRACT WITH

WESTERN ELECTRIC COMPANY, INC.

WED DEC 31 19:05:41 EST 1969

login: root

Password:

You have mail.

# ls

bin

boot

dev

etc

lib

tmp

unix

usr

# df

/dev/rp0 1297

/dev/rp3 297414

Simulation stopped, PC: 002306 (MOV (SP)+,177776)

sim> q

Goodbye

五、运行(这个tboot.ini解决的维基这篇文章中不能用磁盘rp06启动的问题

$ cat tboot.ini

echo

echo at the prompt type in

echo @ hp(0,0)unix

echo

set cpu 11/70

set cpu 2M

set cpu idle

set rp0 rp06

attach rp0 rp06-0.disk

d cpu 2000 042102

d cpu 2002 012706

d cpu 2004 002000

d cpu 2006 012700

d cpu 2010 000000

d cpu 2012 012701

d cpu 2014 176700

d cpu 2016 012761

d cpu 2020 000040

d cpu 2022 000010

d cpu 2024 010061

d cpu 2026 000010

d cpu 2030 012711

d cpu 2032 000021

d cpu 2034 012761

d cpu 2036 010000

d cpu 2040 000032

d cpu 2042 012761

d cpu 2044 177000

d cpu 2046 000002

d cpu 2050 005061

d cpu 2052 000004

d cpu 2054 005061

d cpu 2056 000006

d cpu 2060 005061

d cpu 2062 000034

d cpu 2064 012711

d cpu 2066 000071

d cpu 2070 105711

d cpu 2072 100376

d cpu 2074 005002

d cpu 2076 005003

d cpu 2100 012704

d cpu 2102 002020

d cpu 2104 005005

d cpu 2106 105011

d cpu 2110 005007

run 2002

$ pdp11 tboot.ini

PDP-11 simulator V3.9-0

at the prompt type in

@ hp(0,0)unix

Disabling XQ

boot

Boot

at the prompt type in

@ hp(0,0)unix

Disabling XQ

Boot

: hp(0,0)unix

mem = 2020544

#^D

# RESTRICTED RIGHTS: USE, DUPLICATION, OR DISCLOSURE

IS SUBJECT TO RESTRICTIONS STATED IN YOUR CONTRACT WITH

WESTERN ELECTRIC COMPANY, INC.

WED DEC 31 19:06:34 EST 1969

login: root

Password:root

You have mail.

# cat /etc/passwd

root:VwL97VCAx1Qhs:0:1::/:

daemon:x:1:1::/:

sys::2:2::/usr/sys:

bin::3:3::/bin:

uucp::4:4::/usr/lib/uucp:/usr/lib/uucico

dmr::7:3::/usr/dmr:

^D

login: dmr

$ cat >> hello.c

main()

{

   printf("Hello World!\n");

}

$ cc hello.c

$ ./a.out

Hello World!

unix v7源代码下载

http://cloud.189.cn/t/rUB32qraeuum


你可能感兴趣的:(simh中安装运行unix v7)