home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / KAYPRO / KPNUROM.LBR / KBOOT.ZQ0 / KBOOT.Z80
Text File  |  2000-06-30  |  7KB  |  244 lines

  1. title KAYPRO IV RESIDENT SOFTWARE PACKAGE
  2. subttl Cold start and configure
  3. ;
  4.     .z80
  5. ;
  6. ; ########################################################
  7. ; ##                            ##
  8. ; ##    Cold start routine, reset and configure        ##
  9. ; ##    system for power up condition.            ##
  10. ; ##                            ##
  11. ; ##    Copyright (C) 1982 By Non-Linear Systems, Inc    ##
  12. ; ##    No warranty is made, expressed or implied.    ##
  13. ; ##                            ##
  14. ; ########################################################
  15. ; ##    Last update: july 13/1982    [001]        ##
  16. ; ##        by JIM NICKERSON            ##
  17. ; ##        change list out with busy jump to    ##
  18. ; ##         to check status of serial port        ##
  19. ; ########################################################
  20. ; ## Code revised to Kaypro 4 rom - 3 Mar. 84 cbf    ##
  21. ; ########################################################
  22. ; ## Revised to eliminate anomalous corrections and to  ##
  23. ; ## reserve space for future connectors.  All routines ##
  24. ; ## are now connected through the vector. 85/6/14 cbf  ##
  25. ; ########################################################
  26. ; ## Modified initial diskinit call, to allow for error ##
  27. ; ## summary retention.                    85/6/18 cbf  ##
  28. ; ########################################################
  29. ;
  30. true    equ    -1
  31. false    equ    not true
  32. debug    equ    false
  33. ;
  34.     extrn    diskinit, vidinit, devinit, datainit
  35.     extrn    home
  36.     extrn    seldsk, settrk, setsec, setdma
  37.     extrn    read, write
  38.     extrn    sectran, diskon, diskoff
  39.     extrn    kbdstat, kbdin, kbdout
  40.     extrn    ttystat, ttyin, ttyout, ttyostat
  41.     extrn    liststat, list
  42.     extrn    vidout
  43.     extrn    thnsd, clkspd
  44.     if    debug
  45.      extrn    bitport, bankbit
  46.      extrn    initvid, initdev, initdisk, outvid
  47.     endif
  48. ;
  49. ; Jump vector entry points, for external linkages
  50.     entry    .start, .dinit, .vinit, .pinit;    initializers
  51.     entry    .home
  52.     entry    .seldsk, .settrk, .setsec, .setdma
  53.     entry    .read, .write
  54.     entry    .sectran, .diskon, .diskoff
  55.     entry    .kbdstat, .kbdin, .kbdout
  56.     entry    .ttystat, .ttyin;        serial input
  57.     entry    .ttyout, .ttyostat;        serial output
  58.     entry    .liststat, .list;        parallel output
  59.     entry    .vidout, .print;        screen output
  60.     entry    .thnsd;                delay b*10 millisec
  61. ;
  62. cr    equ    0dh
  63. lf    equ    0ah
  64. esc    equ    1bh;        ascii esc
  65. bell    equ    07h;        kbd bell
  66. ;
  67. ;
  68. ; This data segment will be the FIRST to be allocated.
  69. ;
  70.     dseg;        OVERLAYS start of all system storage
  71. bootld:    ds    512;        (usually at 0fa00h, overwritten)
  72. stack    equ    $ + 1024;    (usually 0, wrapped around)
  73. ;
  74.     cseg    
  75. ;
  76. ; ROM master jump table
  77. .start:        jp    start;        start up computer
  78. .dinit:    if    debug
  79.         jp    initdisk
  80.     else
  81.         jp    diskinit;    disk initialize
  82.     endif
  83. .vinit:    if    debug
  84.         jp    initvid;    needs rom to run
  85.     else    
  86.         jp    vidinit;    video initialize
  87.     endif
  88. .pinit:    if    debug
  89.         jp    initdev
  90.     else
  91.         jp    devinit;    device initialize
  92.     endif
  93. ;
  94. .home:        jp    home;        home selected disk drive
  95. .seldsk:    jp    seldsk;        select a disk drive
  96. .settrk:    jp    settrk;        seek a track
  97. .setsec:    jp    setsec;        set sector number to read
  98. .setdma:    jp    setdma;        set dma address
  99. .read:        jp    read;        read logical sector
  100. .write:        jp    write;        write logical sector
  101. .sectran:    jp    sectran;    xlate sector number
  102. .diskon:    jp    diskon;        turn on disk
  103. .diskoff:    jp    diskoff;    turn off disk
  104. ;    
  105. .kbdstat:    jp    kbdstat;    KeyBoarD character ready
  106. .kbdin:        jp    kbdin;        input from keyboard
  107. .kbdout:    jp    kbdout;        output to keyboard
  108. ;                    (used to ring bell)
  109. ;
  110. .ttystat:    jp    ttystat;    status of serial input port
  111. .ttyin:        jp    ttyin;        serial input
  112. .ttyout:    jp    ttyout;        serial output
  113. ;
  114. .liststat:    jp    liststat;    list out status (Centronics)
  115. .list:        jp    list;        list output
  116. ;
  117. .ttyostat:    jp    ttyostat;    teststatus of serial output
  118. ;
  119. .vidout: if    debug
  120.         jp    outvid;        needs rom to run
  121.     else
  122.         jp    vidout;        video output
  123.     endif
  124. ;
  125. .thnsd:        jp    thnsd;        short delay
  126. ; END of vectors originally known to system.
  127. ;
  128. .xinit        jp    datainit;    Clear error summaries
  129. .print        jp    print;        string de^ to video
  130. ;
  131. ;
  132.     ds    66h - ($-.start),0;    spare connectors, zeroed
  133. ;
  134. ; NMI vector used for disk driver synchronization. Must be at 066h
  135.     ret;        return from "halt", NMI sequence when in rom
  136. ;
  137. ; ------------------------------------------------------------------
  138. ;
  139. ; System initialization
  140. start:    di;            stop interupts while setup
  141.     ld    sp,stack;    rom stack point
  142.     ld    hl,1670;    approx delay count, preliminary
  143.     ld    (clkspd),hl;    will be set right on .pinit
  144.     ld    b,10;        delay to let the hardware stabilize
  145.     call    .thnsd
  146.     call    .pinit;        init device sub-system
  147.     call    .vinit;        init video sub-system
  148.     call    .xinit;        Clear the error summaries etc
  149.     call    .dinit;        init disk sub-system
  150. ;    "    "
  151. ; boot system, the first sector (0) of the first track (0) holds
  152. ; system boot information. It does NOT hold a short boot routine!
  153. ; the image is:
  154. ;    self:    jr    self;    hang if booted and run
  155. ;        defw    loadpt;    where to load the opsys image
  156. ;        defw    bios;    where to go after booting system
  157. ;        defw    length;    length of image in 128 byte sectors
  158. ;    (* the rest of the sector is not used *)
  159. ;
  160. ; This image is loaded and inspected at bootld during boot process
  161. ; (bootld is normally 0fa00h)
  162.     ld    de,bmsg
  163.     call    print
  164.     ld    c,0
  165.     call    .seldsk;    select disk, set density,
  166. ;                do home after diskinit
  167.     ld    bc,0;        set track
  168.     call    .settrk
  169.     ld    c,0;        read the first sector
  170.     call    .setsec
  171.     ld    bc,bootld;    header sector to go here
  172.     call    .setdma
  173.     call    .read;        read sector to FA00
  174.     di;            read does EI upon exit
  175.     or    a;        trouble reading?
  176.     jp    nz,booterr;    tell crt
  177. ;    "    "
  178.     ld    hl,(bootld+4);    where to go after loading system
  179.     push    hl;        save for latter use
  180.     ld    hl,(bootld+2);    where to load system image
  181.     push    hl;        save dma
  182.     ld    b,h
  183.     ld    c,l
  184.     call    .setdma
  185.     ld    hl,(bootld+6);    length of system in 128 byte sectors
  186.     ld    b,l;        reg B holds # of sectors to load
  187.     ld    c,1;        initial sector (0 was header sector)
  188. ;    "    "
  189. cb1:    push    bc;        save sector count and current sector
  190.     ld    b,0
  191.     call    .setsec;    select sector
  192.     call    .read
  193.     di;            read does EI upon exit
  194.     pop    bc
  195.     pop    hl;        dma
  196.     or    a
  197.     jp    nz,booterr;    bad read of sector
  198.     ld    de,128
  199.     add    hl,de;        advance dma address
  200.     dec    b
  201.     ret    z;        done booting, goto system
  202.     push    hl;        save dma
  203.     push    bc;        save sector/count
  204.     ld    b,h
  205.     ld    c,l
  206.     call    .setdma
  207.     pop    bc
  208.     inc    c;        bump sector count
  209.     ld    a,40;        over sectors/track?
  210.     cp    c
  211.     jp    nz,cb1;        fetch another sector
  212.     ld    c,16;        first sector to read on next track
  213.     push    bc;        save counts
  214.     ld    bc,1;        set for next track
  215.     call    .settrk
  216.     pop    bc
  217.     jp    cb1
  218. ;
  219. booterr:
  220.     ld    de,xmsg
  221.     call    print
  222.     call    .diskoff;    turn off disk drive
  223. self:    jp    self;        hang till user pushes reset
  224. ;
  225. bmsg:    db    esc,'=',' '+10,' '+30
  226.     db    '*  Kaypro 4-83 1.2  *'
  227.     db    esc,'=',' '+13,' '+20
  228.     db    ' Please place your diskette into Drive A',8,0
  229. ;
  230. xmsg:    db    cr,lf, cr,lf
  231.     db    bell,'I cannot read your diskette.',0
  232. ;
  233. ; Output string de^ until zero byte
  234. ; a,f,c,d,e,h,l
  235. print:    ld    a,(de)
  236.     inc    de
  237.     or    a
  238.     ret    z
  239.     ld    c,a
  240.     call    .vidout
  241.     jp    print
  242. ;
  243.     end
  244.