changeset 7:a6db579d8c11

level 2 rom preparing...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 05 Jul 2018 02:00:14 +0900
parents 9c2602e1d716
children 96a067cf4c4f
files Makefile a09.c engine.c io.c os9/Makefile os9/level2/Makefile os9/level2/cc3go.asm os9/level2/clock.asm os9/level2/d0.asm os9/level2/d1.asm os9/level2/pty-dd.asm os9/makerom.c
diffstat 12 files changed, 512 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Jul 05 00:02:54 2018 +0900
+++ b/Makefile	Thu Jul 05 02:00:14 2018 +0900
@@ -36,7 +36,7 @@
 	$(CC) -o v09 $(CFLAGS) v09.o engine.o io.o os9disass.o
 
 v09c: v09.c engine.c io.c os9disass.o
-	$(CC) -o v09c $(CFLAGS) $(V09FLAGS) -DIOBASE=0xff00 -DUSE_MMU=1 v09.c engine.c io.c os9disass.o
+	$(CC) -o v09c $(CFLAGS) $(V09FLAGS) -DIOBASE=0xff80 -DUSE_MMU=1 v09.c engine.c io.c os9disass.o
 
 v09.o: v09.c v09.h
 	$(CC) -c $(CFLAGS) $(V09FLAGS) v09.c
--- a/a09.c	Thu Jul 05 00:02:54 2018 +0900
+++ b/a09.c	Thu Jul 05 02:00:14 2018 +0900
@@ -305,7 +305,7 @@
 {
     generating = 1;
     if (prevloc) {
-       loccounter  = prevloc-1 ;
+       oldlc = loccounter  = prevloc-1 ;
        prevloc = 0;
     }
 }
--- a/engine.c	Thu Jul 05 00:02:54 2018 +0900
+++ b/engine.c	Thu Jul 05 02:00:14 2018 +0900
@@ -133,9 +133,9 @@
 
 /* Macros for load and store of accumulators. Can be modified to check
    for port addresses */
-#define LOADAC(reg) if((eaddr&0xff00)!=IOPAGE)reg=mem(eaddr);else\
+#define LOADAC(reg) if((eaddr&0xff00)!=(IOPAGE&0xff00))reg=mem(eaddr);else\
            reg=do_input(eaddr&0xff);
-#define STOREAC(reg) if((eaddr&0xff00)!=IOPAGE)SETBYTE(eaddr,reg)else\
+#define STOREAC(reg) if((eaddr&0xff00)!=(IOPAGE&0xff00))SETBYTE(eaddr,reg)else\
 	   do_output(eaddr&0xff,reg);
 
 #define LOADREGS ixreg=xreg;iyreg=yreg;\
--- a/io.c	Thu Jul 05 00:02:54 2018 +0900
+++ b/io.c	Thu Jul 05 02:00:14 2018 +0900
@@ -1,4 +1,4 @@
-/* 6809 Simulator V09.
+/* 6808 Simulator V09.
 
    created 1993,1994 by L.C. Benschop.
    copyleft (c) 1994-2014 by the sbc09 team, see AUTHORS for more details.
@@ -46,25 +46,17 @@
 /*
  *   IO Map ( can be overrupped by ROM )
  *
- *   IOPAGE ~ IOPAGE+0xff
+ *   IOPAGE ~ IOPAGE+0x7f
+ *       for OS9 level2
+ *       IOPAGE 0xff80 means ioport beging 0xff80 but IOPAGE itself starts 0xff00
+ *       0xff00-0xff7f, 0xffe0-0xffff can be used as ROM in fixed area
  *
  *   IOPAGE + 0x00   ACIA  control
  *   IOPAGE + 0x01   ACIA  data
  *
- *   IOPAGE + 0x10   Timer control       0x8f start timer/0x80 stop timer/0x04 update date
- *   IOPAGE + 0x11-  YY/MM/DD/HH/MM/SS
- *
- *   IOPAGE + 0x20   Disk control        0x81 read/0x55 write   0 ... ok / 0xff .. error
- *   IOPAGE + 0x21   drive no
- *   IOPAGE + 0x22   LSN2
- *   IOPAGE + 0x23   LSN1
- *   IOPAGE + 0x24   LSN0
- *   IOPAGE + 0x25   ADR2
- *   IOPAGE + 0x26   ADR1
- *
- *   IOPAGE + 0x91   MMU Taskreg         0  system map, 1 user map
- *   IOPAGE + 0xa0-0xa7   MMU reg        system map
- *   IOPAGE + 0xa8-0xaf   MMU reg        user   map
+ *   IOPAGE + 0x11   MMU Taskreg         0  system map, 1 user map
+ *   IOPAGE + 0x20-0x27   MMU reg        system map
+ *   IOPAGE + 0x28-0x2f   MMU reg        user   map
  *
  *        on reset tr==0 and only IOPAGE is valid
  *        translatation occur only on non-IOPAGE
@@ -73,6 +65,18 @@
  *            tr=0  mmu=IOPAGE+0xa0
  *            tr=1  mmu=IOPAGE+0xa8
  *
+ *   IOPAGE + 0x30   Timer control       0x8f start timer/0x80 stop timer/0x04 update date
+ *   IOPAGE + 0x31-  YY/MM/DD/HH/MM/SS
+ *
+ *   IOPAGE + 0x40   Disk control        0x81 read/0x55 write   0 ... ok / 0xff .. error
+ *   IOPAGE + 0x41   drive no
+ *   IOPAGE + 0x42   LSN2
+ *   IOPAGE + 0x43   LSN1
+ *   IOPAGE + 0x44   LSN0
+ *   IOPAGE + 0x45   ADR2
+ *   IOPAGE + 0x46   ADR1
+ *
+ *
  */
 
 #define SECSIZE 256
@@ -178,13 +182,13 @@
 
 int do_input( a) {
         static int c, f = EOF;
-        if (a == 0) {
+        if (a == 0+(IOPAGE&0xff)) {
                 if (f == EOF)
                         f = char_input();
                 if (f != EOF)
                         c = f;
                 return 2 + (f != EOF);
-        } else if (a == 1) { /*data port*/
+        } else if (a == 1+(IOPAGE&0xff)) { /*data port*/
                 if (f == EOF)
                         f = char_input();
                 if (f != EOF) {
@@ -198,7 +202,7 @@
 
 void do_output(int a, int c) {
         int i, sum;
-        if (a == 1) { /* ACIA data port,ignore address */
+        if (a == 1+(IOPAGE&0xff)) { /* ACIA data port,ignore address */
                 if (!xmstat) {
                         if (logfile && c != 127 && (c >= ' ' || c == '\n'))
                                 putc(c, logfile);
@@ -244,12 +248,12 @@
                                 xidx = 0;
                         }
                 }
-        } else if (a >= 0x90) { /* mmu */
+        } else if (a >= 0x10+(IOPAGE&0xff)) { /* mmu */
              do_mmu(a,c);
-        } else if (a >= 0x20) { /* disk */
+        } else if (a >= 0x30+(IOPAGE&0xff)) { /* timer */
+             do_timer(a,c);
+        } else if (a >= 0x40+(IOPAGE&0xff)) { /* disk */
              do_disk(a,c);
-        } else if (a >= 0x10) { /* disk */
-             do_timer(a,c);
         }
 }
 
@@ -266,38 +270,38 @@
 
 void do_timer(int a, int c) {
    struct itimerval timercontrol;
-   if (a==0x10 && c==0x8f) {
+   if (a==0x30 && c==0x8f) {
         timercontrol.it_interval.tv_sec = 0;
         timercontrol.it_interval.tv_usec = 20000;
         timercontrol.it_value.tv_sec = 0;
         timercontrol.it_value.tv_usec = 20000;
         setitimer(ITIMER_REAL, &timercontrol, NULL);
-   } else if (a==0x10 && c==0x80) {
+   } else if (a==0x30 && c==0x80) {
         timercontrol.it_interval.tv_sec = 0;
         timercontrol.it_interval.tv_usec = 0;
         setitimer(ITIMER_REAL, &timercontrol, NULL);
-   } else if (a==0x10 && c==0x04) {
+   } else if (a==0x30 && c==0x04) {
       time_t tm = time(0);
       struct tm *t = localtime(&tm);
-      mem[IOPAGE+0x11] = t->tm_year;
-      mem[IOPAGE+0x12] = t->tm_mon;
-      mem[IOPAGE+0x13] = t->tm_mday;
-      mem[IOPAGE+0x14] = t->tm_hour;
-      mem[IOPAGE+0x15] = t->tm_min;
-      mem[IOPAGE+0x16] = t->tm_sec;
+      mem[IOPAGE+0x31] = t->tm_year;
+      mem[IOPAGE+0x32] = t->tm_mon;
+      mem[IOPAGE+0x33] = t->tm_mday;
+      mem[IOPAGE+0x34] = t->tm_hour;
+      mem[IOPAGE+0x35] = t->tm_min;
+      mem[IOPAGE+0x36] = t->tm_sec;
    } else {
       mem[IOPAGE+a]=c;
    }
 }
 
 void do_disk(int a, int c) {
-   if (a!=0x20) {
+   if (a!=0x40) {
       mem[IOPAGE+a]=c;
       return;
    }
-   int drv = mem[IOPAGE+0x21];
-   int lsn = (mem[IOPAGE+0x22]<<16) + (mem[IOPAGE+0x23]<<8) + mem[IOPAGE+0x24];
-   int buf = (mem[IOPAGE+0x25]<<8) + mem[IOPAGE+0x26];
+   int drv = mem[IOPAGE+0x41];
+   int lsn = (mem[IOPAGE+0x42]<<16) + (mem[IOPAGE+0x43]<<8) + mem[IOPAGE+0x44];
+   int buf = (mem[IOPAGE+0x45]<<8) + mem[IOPAGE+0x46];
    if (drv > 1 || disk[drv]==0) goto error;
    if (c==0x81) {
       if (lseek(fileno(disk[drv]),lsn*SECSIZE,SEEK_SET)==-1) goto error;
@@ -306,24 +310,24 @@
       if (lseek(fileno(disk[drv]),lsn*SECSIZE,SEEK_SET)==-1) goto error;
       if (write(fileno(disk[drv]),&mem[buf],SECSIZE)==-1) goto error;
    }
-   mem[IOPAGE+0x20] = 0;
+   mem[IOPAGE+0x40] = 0;
    return;
 error :
-   mem[IOPAGE+0x20] = 0xff;
+   mem[IOPAGE+0x40] = 0xff;
 }
 
 void do_mmu(int a, int c)
 {
 #ifdef USE_MMU
 
-   if (a==0x91) {
+   if (a==0x11) {
        if (c&0) {
            mmu = phymem+memsize-0x10000+0xffa0;
        } else {
            mmu = phymem+memsize-0x10000+0xffa8;
        }
        mem[IOPAGE+a] = c;
-   } if (0xa0 <= a && a <= 0xaf) {
+   } if (0x20 <= a && a <= 0x2f) {
        mem[IOPAGE+a] = c;
    }
 
--- a/os9/Makefile	Thu Jul 05 00:02:54 2018 +0900
+++ b/os9/Makefile	Thu Jul 05 02:00:14 2018 +0900
@@ -12,6 +12,9 @@
 os9disass : os9disass.c
 	$(CC) $(CFLAGS) -Wno-format-security -o os9disass  os9disass.c
 
+clean :
+	rm -f makerom *.rom os9mod os9disass
+
 os9.rom : makerom modules/init.b modules/pty.b
 	./makerom -o os9.rom modules/Shell modules/init.b modules/mdir modules/SysGo modules/IOMan modules/SCF modules/pty-dd.b modules/pty.b modules/OS9p2 modules/OS9
 
@@ -22,4 +25,4 @@
 	./makerom -o os9d.rom  modules/Shell modules/dir.b  modules/init.b modules/mdir modules/SysGo modules/IOMan modules/pty-dd.b modules/pty.b modules/pdisk.b modules/d0.b modules/d1.b modules/clock.b modules/SCF modules/rbf.b modules/OS9p2 modules/OS9
    
 os9lv2.rom : level2/init
-	./makerom -o os9lv2.rom -i 0xff00 level2/init level2/ioman level2/os9p2 level2/os9p3_perr level2/os9p4_regdump level2/pdisk level2/pipe level2/pipeman level2/pipeman_named level2/piper level2/pty level2/rbf level2/scf level2/term level2/os9p1 
+	./makerom -o os9lv2.rom -2 level2/init level2/ioman level2/os9p2 level2/os9p3_perr level2/os9p4_regdump level2/pdisk level2/pipe level2/piper level2/pipeman level2/pty level2/rbf level2/scf level2/term level2/os9p1 
--- a/os9/level2/Makefile	Thu Jul 05 00:02:54 2018 +0900
+++ b/os9/level2/Makefile	Thu Jul 05 02:00:14 2018 +0900
@@ -3,13 +3,11 @@
 
 SRCDIR=../../CoCoOS9/level2v3/MODULES
 
-all : ioman pdisk init os9p1 os9p2 os9p3_perr os9p4_regdump pipe pipeman pipeman_named piper rbf scf term pty
+all : ioman pdisk init os9p1 os9p2 os9p3_perr os9p4_regdump pipe pipeman pipeman_named piper rbf scf term pty d0 d1 clock
 
 clean : 
-	rm -f ioman pdisk init os9p1 os9p2 os9p3_perr os9p4_regdump pipe pipeman pipeman_named piper rbf scf term pty
+	rm -f ioman pdisk init os9p1 os9p2 os9p3_perr os9p4_regdump pipe pipeman pipeman_named piper rbf scf term pty d0 d1 clock
 
-ioman :
-	$(A09) ${SRCDIR}/ioman.asm -o ioman
 
 pdisk :
 	$(A09) ../modules/pdisk.asm -o pdisk
@@ -17,6 +15,22 @@
 init :
 	$(A09) ../modules/init.asm -o init
 
+term :
+	$(A09) pty-dd.asm -o term
+
+d0 :
+	$(A09) d0.asm -o d0
+
+d1 :
+	$(A09) d1.asm -o d1
+
+clock :
+	$(A09) clock.asm -o clock
+
+pty :
+	$(A09) ../modules/pty.asm -o pty
+
+
 os9p1 :
 	$(A09) ${SRCDIR}/os9p1.asm -o os9p1
 
@@ -29,6 +43,9 @@
 os9p4_regdump :
 	$(A09) ${SRCDIR}/os9p4_regdump.asm -o os9p4_regdump
 
+ioman :
+	$(A09) ${SRCDIR}/ioman.asm -o ioman
+
 pipe :
 	$(A09) ${SRCDIR}/pipe.asm -o pipe
 
@@ -47,9 +64,3 @@
 scf :
 	$(A09) ${SRCDIR}/scf.asm -o scf
 
-term :
-	$(A09) ../modules/pty-dd.asm -o term
-
-pty :
-	$(A09) ../modules/pty.asm -o pty
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/os9/level2/cc3go.asm	Thu Jul 05 02:00:14 2018 +0900
@@ -0,0 +1,159 @@
+********************************************************************
+* CC3Go - Kickstart program module
+*
+* $Id: cc3go.asm,v 1.1.1.1 2001/02/21 23:30:54 boisy Exp $ 
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+* 5      Taken from OS-9 L2 Tandy distribution and      BGP 98/10/12
+*        modified banner for V3
+
+         nam   CC3Go
+         ttl   Kickstart program module
+
+         ifp1
+         use   defsfile
+         use   scfdefs
+         endc
+
+tylg     set   Prgrm+Objct
+atrv     set   ReEnt+rev
+rev      set   $01
+edition  set   $05
+
+         mod   eom,name,tylg,atrv,start,size
+
+u0000    rmb   32
+u0020    rmb   42
+u004A    rmb   33
+u006B    rmb   6
+u0071    rmb   655
+size     equ   .
+
+name     fcs   /CC3Go/
+         fcb  edition
+
+Banner   fcc   / OS-9 LEVEL TWO VR. 0/
+         fcb   48+OS9Vrsn
+         fcc   /.0/
+         fcb   48+OS9Major
+         fcc   /.0/
+         fcb   48+OS9Minor
+         fcb   C$CR,C$LF
+         fcc   /     COPYRIGHT 1988 BY/
+         fcb   C$CR,C$LF
+         fcc   /   MICROWARE SYSTEMS CORP./
+         fcb   C$CR,C$LF
+         fcc   /   LICENSED TO TANDY CORP./
+         fcb   C$CR,C$LF
+         fcc   /    ALL RIGHTS RESERVED./
+         fcb   C$CR,C$LF
+         fcb   C$LF
+BannLen  equ   *-Banner
+DefDev   fcc   "/H0"
+         fcb   C$CR
+HDDev    fcc   "/H0/"
+ExecDir  fcc   "Cmds"
+         fcb   C$CR
+         fcc   ",,,,,"
+Shell    fcc   "Shell"
+         fcb   C$CR
+         fcc   ",,,,,"
+AutoEx   fcc   "AutoEx"
+         fcb   C$CR
+         fcc   ",,,,,"
+Startup  fcc   "STARTUP -P"
+         fcb   C$CR
+         fcc   ",,,,,"
+ShellPrm fcc   "i=/1"
+CRtn     fcb   C$CR
+         fcc   ",,,,,"
+ShellPL  equ   *-ShellPrm
+
+DefTime  fcb   88,10,01,00,00,00
+
+start    leax  >IcptRtn,pcr
+         os9   F$Icpt
+         os9   F$ID
+         ldb   #$80
+         os9   F$SPrior
+         leax  >Banner,pcr
+         ldy   #BannLen
+         lda   #$01                    standard output
+         os9   I$Write                 write out banner
+         leax  >DefTime,pcr
+         os9   F$STime                 set time to default
+         leax  >ExecDir,pcr
+         lda   #EXEC.
+         os9   I$ChgDir                change exec. dir
+         leax  >DefDev,pcr
+         lda   #READ.+WRITE.
+         os9   I$ChgDir                change data dir.
+         bcs   L0125
+         leax  >HDDev,pcr
+         lda   #EXEC.
+         os9   I$ChgDir                change exec. dir to HD
+L0125    pshs  u,y
+         os9   F$ID
+         bcs   L01A9
+         leax  ,u
+         os9   F$GPrDsc
+         bcs   L01A9
+         leay  ,u
+         ldx   #$0000
+         ldb   #$01
+         os9   F$MapBlk
+         bcs   L01A9
+* Set flag for Color BASIC
+         lda   #$55
+         sta   <D.CBStrt,u
+* Copy our default I/O ptrs to the system process
+         ldd   <D.SysPrc,u
+         leau  d,u
+         leau  <P$DIO,u
+         leay  <P$DIO,y
+         ldb   #DefIOSiz-1
+L0151    lda   b,y
+         sta   b,u
+         decb
+         bpl   L0151
+* Fork shell startup here
+         leax  >Shell,pcr
+         leau  >Startup,pcr
+         ldd   #256
+         ldy   #16
+         os9   F$Fork
+         bcs   L01A5
+         os9   F$Wait
+* Fork AutoEx here
+         leax  >AutoEx,pcr
+         leau  >CRtn,pcr
+         ldd   #$0100
+         ldy   #$0001
+         os9   F$Fork
+         bcs   L0186
+         os9   F$Wait
+L0186    puls  u,y
+         leax  >ShellPrm,pcr
+         leay  ,u
+         ldb   #ShellPL
+L0190    lda   ,x+
+         sta   ,y+
+         decb
+         bne   L0190
+* Fork final shell here
+         leax  >Shell,pcr
+         ldd   #$0100
+         ldy   #ShellPL
+         os9   F$Chain
+L01A5    ldb   #$06
+         bra   Crash
+L01A9    ldb   #$04
+Crash    clr   $FFA8                   turn off disk motor
+         jmp   <D.Crash
+
+IcptRtn  rti
+
+         emod
+eom      equ   *
+         end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/os9/level2/clock.asm	Thu Jul 05 02:00:14 2018 +0900
@@ -0,0 +1,75 @@
+********************************************************************
+* Clock - OS-9 Level One V2 Clock module
+*
+* $Id: clock.asm,v 1.1.1.1 2001/02/21 23:30:52 boisy Exp $
+*
+* NOTE:  This clock is TOTALLY VALID for ALL DATES between 1900-2155
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+* 5      Tandy/Microware original version
+* 6      Modified to handle leap years properly for     BGP 99/05/03
+*        1900 and 2100 A.D.
+
+         nam   Clock
+         ttl   OS-9 Level One V2 Clock module
+
+         ifp1
+         use   os9defs
+         endc
+
+tylg     set   Systm+Objct
+atrv     set   ReEnt+rev
+rev      set   $01
+edition  set   $06
+TimerPort set  $f8b0
+
+         mod   eom,name,tylg,atrv,ClkEnt,size
+
+size     equ   .
+
+name     fcs   /Clock/
+         fcb   edition
+
+SysTbl   fcb   F$Time
+         fdb   FTime-*-2
+         fcb   $80
+
+
+ClockIRQ clra
+         tfr   a,dp
+L00AE    jsr   [>D.Poll]
+         bcc   L00AE
+L00B4    jmp   [>D.AltIRQ]
+         rts
+
+ClkEnt   equ   *
+         pshs  cc
+         orcc  #FIRQMask+IRQMask       mask ints
+         leax  >ClockIRQ,pcr
+         stx   <D.IRQ
+* install system calls
+         leay  >SysTbl,pcr
+         os9   F$SSvc
+         ldx   #TimerPort
+         ldb   #$8f     start timer
+         stb   ,x
+         puls  pc,cc
+
+* F$Time system call code
+FTime    ldx   R$X,u
+         ldy   #TimerPort
+         ldb   #$04
+         stb   ,y
+         ldd   1,y
+         std   ,x
+         ldd   3,y
+         std   2,x
+         ldd   5,y
+         std   4,x
+         clrb
+         rts
+
+         emod
+eom      equ   *
+         end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/os9/level2/d0.asm	Thu Jul 05 02:00:14 2018 +0900
@@ -0,0 +1,50 @@
+********************************************************************
+* progname - program module
+*
+* $Id: d0.asm,v 1.1 2002/06/14 12:35:43 roug Exp $
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+*  -     Original Dragon Data distribution version
+*
+* $Log: d0.asm,v $
+* Revision 1.1  2002/06/14 12:35:43  roug
+* Add work done on ideal devices
+*
+*
+
+         nam   D0
+         ttl   40-track floppy disk device descriptor
+
+         ifp1
+         use   os9defs
+         endc
+tylg     set   Devic+Objct   
+atrv     set   ReEnt+rev
+rev      set   $02
+         mod   eom,name,tylg,atrv,mgrnam,drvnam
+         fcb   $FF mode byte
+         fcb   $00  extended controller address
+         fdb   $f8c0  physical controller address
+         fcb   initsize-*-1  initilization table size
+         fcb   $01 device type:0=scf,1=rbf,2=pipe,3=scf
+         fcb   $00 drive number
+         fcb   $00 step rate
+         fcb   $20 drive device type
+         fcb   $01 media density:0=single,1=double
+         fdb   $0100 number of cylinders (tracks)
+         fcb   $01 number of sides
+         fcb   $00 verify disk writes:0=on
+         fdb   $0012 # of sectors per track
+         fdb   $0012 # of sectors per track (track 0)
+         fcb   $01 sector interleave factor
+         fcb   $08 minimum size of sector allocation
+initsize equ   *
+name     equ   *
+         fcs   /D0/
+mgrnam   equ   *
+         fcs   /RBF/
+drvnam   equ   *
+         fcs   /PDisk/
+         emod
+eom      equ   *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/os9/level2/d1.asm	Thu Jul 05 02:00:14 2018 +0900
@@ -0,0 +1,50 @@
+********************************************************************
+* progname - program module
+*
+* $Id: d0.asm,v 1.1 2002/06/14 12:35:43 roug Exp $
+*
+* Ed.    Comments                                       Who YY/MM/DD
+* ------------------------------------------------------------------
+*  -     Original Dragon Data distribution version
+*
+* $Log: d0.asm,v $
+* Revision 1.1  2002/06/14 12:35:43  roug
+* Add work done on ideal devices
+*
+*
+
+         nam   D1
+         ttl   40-track floppy disk device descriptor
+
+         ifp1
+         use   os9defs
+         endc
+tylg     set   Devic+Objct   
+atrv     set   ReEnt+rev
+rev      set   $02
+         mod   eom,name,tylg,atrv,mgrnam,drvnam
+         fcb   $FF mode byte
+         fcb   $00  extended controller address
+         fdb   $f8c0  physical controller address
+         fcb   initsize-*-1  initilization table size
+         fcb   $01 device type:0=scf,1=rbf,2=pipe,3=scf
+         fcb   $01 drive number
+         fcb   $00 step rate
+         fcb   $20 drive device type
+         fcb   $01 media density:0=single,1=double
+         fdb   $0100 number of cylinders (tracks)
+         fcb   $01 number of sides
+         fcb   $00 verify disk writes:0=on
+         fdb   $0012 # of sectors per track
+         fdb   $0012 # of sectors per track (track 0)
+         fcb   $01 sector interleave factor
+         fcb   $08 minimum size of sector allocation
+initsize equ   *
+name     equ   *
+         fcs   /D1/
+mgrnam   equ   *
+         fcs   /RBF/
+drvnam   equ   *
+         fcs   /PDisk/
+         emod
+eom      equ   *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/os9/level2/pty-dd.asm	Thu Jul 05 02:00:14 2018 +0900
@@ -0,0 +1,48 @@
+****************************************
+* PTY Descriptor module
+*
+* Source by Soren Roug 2001
+*
+         ifp1
+         use os9defs
+         endc
+
+         nam P1
+         ttl PTY Device Descriptor
+
+         mod PEND,PNAM,DEVIC+OBJCT,REENT+1,PMGR,PDRV
+
+         fcb READ.+WRITE.+SHARE.
+         fcb $FF IOBlock (unused)
+         fdb $f800 hardware address
+         fcb PNAM-*-1 option byte count
+         fcb $0 SCF device
+         fcb $0 Case (upper & lower)
+         fcb $1 Erase on backspace
+         fcb $0 delete (BSE over line)
+         fcb $1 echo on
+         fcb $1 lf on
+         fcb $0 eol null count
+         fcb $0 no pause
+         fcb 24 lines per page
+         fcb $8 backspace
+         fcb $18 delete line char
+         fcb $0D end of record
+         fcb $1b eof
+         fcb $04 reprint line char
+         fcb $01 duplicate last line char
+         fcb $17 pause char
+         fcb $03 interrupt char
+         fcb $05 quit char
+         fcb $08 backspace echo char
+         fcb $07 bell
+         fcb $00 n/a
+         fcb $00 n/a
+         fdb pnam offset to name
+         fdb $0000 offset to status routine
+pnam     fcs "TERM"
+pmgr     fcs "SCF"
+pdrv     fcs "PTY"
+         emod
+pend     equ *
+         end
--- a/os9/makerom.c	Thu Jul 05 00:02:54 2018 +0900
+++ b/os9/makerom.c	Thu Jul 05 02:00:14 2018 +0900
@@ -7,6 +7,7 @@
 #include <strings.h>
 #include <sys/stat.h>
 
+int level = 1;
 int IOBASE = 0xe000;
 int IOSIZE = 0x100;
 char * outfile ;
@@ -64,7 +65,12 @@
 int findLocation(MPTR m, int loc) {
    if (m==0) return loc;
    int top = findLocation(m->next, loc) - m->size;
-   if (m->next==0) top = 0xf800;  // OS9p1
+   if (m->next==0) {
+       if (level == 1)
+          top = 0xf800;  // OS9p1
+       else
+          top = 0x10000-(m->size+0x80);
+   }
    if (!(( top+m->size < IOBASE )  || ( IOBASE+IOSIZE < top)) ) {
       top = IOBASE-m->size-1;
       m->ioflag = 1;
@@ -88,9 +94,9 @@
 
  for(int i = 1 ; i<ac ; i++ ) {
     if (*av[i]=='-') {
-        if (av[i][1] =='i') {
-            IOBASE = strtol(av[i],(char**)0,0);
-            i += 1;
+        if (av[i][1] =='2') {  // for level 2
+            level = 2;
+            IOBASE = 0xff00;
         } else if (av[i][1] =='o') {
             outfile = av[i+1];
             i += 1;
@@ -123,37 +129,64 @@
  pos = start;
  for(struct os9module *cur = root.next; cur ; cur = cur->next ) {
     // last module have to os9p1
-    if ( cur->next == 0 ) { //   cur->size && (cur->name[0]=='O' && cur->name[1]=='S' && cur->name[2]== -71)) {
-       for(; pos < 0xf800 ; pos++) {   // os9p1 begins at 0xf800
-          fputc(0xff,romfile);
-       }
+    if ( cur->next == 0 ) {
+        if ( level==1 ) { 
+           for(; pos < 0xf800 ; pos++) {   // os9p1 begins at 0xf800
+              fputc(0xff,romfile);
+           }
+        } else {
+           int pend = 0x10000-( cur->size +0x80);
+           for(; pos < pend ; pos++) {      // os9p1 ends 0xff7f
+              fputc(0xff,romfile);
+           }
+        }
     }
     printf("mod ");
     printOs9Str(cur->name);
     fwrite(cur->mod, cur->size, 1, romfile);
-    printf(" \t: 0x%x - 0x%x\n",pos, pos + cur->size);
+    printf(" \t: 0x%x - 0x%x\n",pos, pos + cur->size-1);
     // printf(" \t: 0x%x - 0x%x : 0x%lx \n",pos, pos + cur->size, ftell(romfile)+start);
     pos = pos+cur->size;
     if (cur->ioflag) {
-       for(; pos < IOBASE + IOSIZE; pos++) {
-          fputc(0xff,romfile);
+       if (level==1) {
+           for(; pos < IOBASE + IOSIZE; pos++) {
+              fputc(0xff,romfile);
+           }
+           printf("*");
+       } else {
+           for(; pos < IOBASE + IOSIZE - 2*7 ; pos++) {
+              fputc(0xff,romfile);
+           }
        }
-       printf("*");
     } 
  }
  printf("os9 end %x\n",pos);
- vectable  = 0x10000 - 2*7;
- for( ; pos<vectable; pos++) fputc(0xff,romfile);
- printf("vectbl %x\n",pos);
- fputword(0xF82d,romfile);
- fputword(0xF831,romfile);
- fputword(0xF835,romfile);
- fputword(0xF839,romfile);
- fputword(0xF83d,romfile);
- fputword(0xF841,romfile);
- fputword(0xF876,romfile);
- 
- printf("boot rom from 0x%lx\n",0x10000-ftell(romfile)); 
+ if (level==1) {
+     vectable  = 0x10000 - 2*7;
+     for( ; pos<vectable; pos++) fputc(0xff,romfile);
+     printf("vectbl %x\n",pos);
+     fputword(0xF82d,romfile);
+     fputword(0xF831,romfile);
+     fputword(0xF835,romfile);
+     fputword(0xF839,romfile);
+     fputword(0xF83d,romfile);
+     fputword(0xF841,romfile);
+     fputword(0xF876,romfile);
+ } else {
+     vectable  = 0x10000 - 2*6;
+     for( ; pos<vectable; pos++) fputc(0xff,romfile);
+     printf("vectbl %x\n",pos);
+     fputword(0xff6e,romfile);
+     fputword(0xff71,romfile);
+     fputword(0xff74,romfile);
+     fputword(0xff7a,romfile);
+     fputword(0xff7d,romfile);
+     fputword(0xff7d,romfile);
+ }
+ if (level==1) 
+     printf("boot rom from 0x%lx\n",0x10000-ftell(romfile)); 
+ else
+     printf("boot rom from 0x%lx\n",512*1024-ftell(romfile)); 
  fclose(romfile);
  return 0;
 }