Annotation of uae/src/ersatz.c, revision 1.1.1.4

1.1.1.3   root        1:  /*
1.1       root        2:   * UAE - The Un*x Amiga Emulator
1.1.1.3   root        3:   *
1.1       root        4:   * A "replacement" for a missing Kickstart
                      5:   * Warning! Q&D
                      6:   *
                      7:   * (c) 1995 Bernd Schmidt
                      8:   */
                      9: 
                     10: #include "sysconfig.h"
                     11: #include "sysdeps.h"
                     12: 
                     13: #include "config.h"
                     14: #include "options.h"
1.1.1.4 ! root       15: #include "uae.h"
1.1       root       16: #include "memory.h"
                     17: #include "custom.h"
1.1.1.2   root       18: #include "readcpu.h"
1.1       root       19: #include "newcpu.h"
                     20: #include "cia.h"
                     21: #include "disk.h"
                     22: #include "ersatz.h"
                     23: 
                     24: #define EOP_INIT     0
                     25: #define EOP_NIMP     1
                     26: #define EOP_SERVEINT 2
                     27: #define EOP_DOIO     3
                     28: #define EOP_OPENLIB  4
                     29: #define EOP_AVAILMEM 5
                     30: #define EOP_ALLOCMEM 6
                     31: #define EOP_ALLOCABS 7
1.1.1.4 ! root       32: #define EOP_LOOP 8
1.1       root       33: 
1.1.1.3   root       34: void init_ersatz_rom (uae_u8 *data)
1.1       root       35: {
                     36:     fprintf(stderr, "Trying to use Kickstart replacement.\n");
                     37:     *data++ = 0x00; *data++ = 0x08; /* initial SP */
                     38:     *data++ = 0x00; *data++ = 0x00;
                     39:     *data++ = 0x00; *data++ = 0xF8; /* initial PC */
                     40:     *data++ = 0x00; *data++ = 0x08;
                     41: 
                     42:     *data++ = 0xFF; *data++ = 0x0D;
                     43:     *data++ = 0x00; *data++ = EOP_INIT;
                     44:     *data++ = 0xFF; *data++ = 0x0D;
                     45:     *data++ = 0x00; *data++ = EOP_NIMP;
1.1.1.3   root       46: 
1.1       root       47:     *data++ = 0xFF; *data++ = 0x0D;
1.1.1.4 ! root       48:     *data++ = 0x00; *data++ = EOP_LOOP;
        !            49:     *data++ = 0xFF; *data++ = 0x0D;
1.1       root       50:     *data++ = 0x00; *data++ = EOP_DOIO;
1.1.1.4 ! root       51: 
1.1       root       52:     *data++ = 0x4E; *data++ = 0x75;
                     53:     *data++ = 0xFF; *data++ = 0x0D;
                     54:     *data++ = 0x00; *data++ = EOP_SERVEINT;
                     55:     *data++ = 0x4E; *data++ = 0x73;
1.1.1.4 ! root       56: 
1.1       root       57:     *data++ = 0xFF; *data++ = 0x0D;
                     58:     *data++ = 0x00; *data++ = EOP_AVAILMEM;
                     59:     *data++ = 0x4E; *data++ = 0x75;
                     60:     *data++ = 0xFF; *data++ = 0x0D;
1.1.1.4 ! root       61: 
1.1.1.3   root       62:     *data++ = 0x00; *data++ = EOP_ALLOCMEM;
1.1       root       63:     *data++ = 0x4E; *data++ = 0x75;
                     64:     *data++ = 0xFF; *data++ = 0x0D;
                     65:     *data++ = 0x00; *data++ = EOP_ALLOCABS;
1.1.1.4 ! root       66: 
1.1       root       67:     *data++ = 0x4E; *data++ = 0x75;
                     68: }
                     69: 
                     70: static void ersatz_doio (void)
                     71: {
1.1.1.3   root       72:     uaecptr request = m68k_areg(regs, 1);
1.1       root       73:     switch (get_word (request + 0x1C)) {
                     74:      case 9: /* TD_MOTOR is harmless */
                     75:      case 2: case 0x8002: /* READ commands */
                     76:        break;
1.1.1.3   root       77: 
1.1       root       78:      default:
                     79:        fprintf(stderr, "Only CMD_READ supported in DoIO()\n");
                     80:        abort();
                     81:     }
                     82:     {
1.1.1.3   root       83:        uaecptr dest = get_long (request + 0x28);
1.1       root       84:        int start = get_long (request + 0x2C) / 512;
                     85:        int nsecs = get_long (request + 0x24) / 512;
                     86:        int tr = start / 11;
                     87:        int sec = start % 11;
                     88:        while (nsecs--) {
                     89:            DISK_ersatz_read (tr, sec, dest);
                     90:            dest += 512;
                     91:            if (++sec == 11)
                     92:                sec = 0, tr++;
                     93:        }
                     94:     }
                     95: }
                     96: 
                     97: static void ersatz_init (void)
                     98: {
                     99:     int f;
1.1.1.3   root      100:     uaecptr request;
                    101:     uaecptr a;
                    102: 
1.1.1.4 ! root      103:     if (disk_empty (0)) {
        !           104:        fprintf (stderr, "You need to have a diskfile in DF0 to use the Kickstart replacement!\n");
        !           105:        uae_quit ();
        !           106:        m68k_setpc (0xF80010);
        !           107:        return;
        !           108:     }
        !           109: 
1.1       root      110:     regs.s = 0;
                    111:     /* Set some interrupt vectors */
                    112:     for (a = 8; a < 0xC0; a += 4) {
1.1.1.4 ! root      113:        put_long (a, 0xF8001A);
1.1       root      114:     }
                    115:     regs.isp = regs.msp = regs.usp = 0x800;
1.1.1.2   root      116:     m68k_areg(regs, 7) = 0x80000;
1.1       root      117:     regs.intmask = 0;
1.1.1.3   root      118: 
1.1       root      119:     /* Build a dummy execbase */
1.1.1.2   root      120:     put_long (4, m68k_areg(regs, 6) = 0x676);
1.1.1.3   root      121:     put_byte (0x676 + 0x129, 0);
                    122:     for (f = 1; f < 105; f++) {
                    123:        put_word (0x676 - 6*f, 0x4EF9);
1.1       root      124:        put_long (0x676 - 6*f + 2, 0xF8000C);
                    125:     }
                    126:     /* Some "supported" functions */
1.1.1.4 ! root      127:     put_long (0x676 - 456 + 2, 0xF80014);
        !           128:     put_long (0x676 - 216 + 2, 0xF80020);
        !           129:     put_long (0x676 - 198 + 2, 0xF80026);
        !           130:     put_long (0x676 - 204 + 2, 0xF8002c);
        !           131:     put_long (0x676 - 210 + 2, 0xF8002a);
1.1.1.3   root      132: 
1.1       root      133:     /* Build an IORequest */
                    134:     request = 0x800;
                    135:     put_word (request + 0x1C, 2);
                    136:     put_long (request + 0x28, 0x4000);
                    137:     put_long (request + 0x2C, 0);
                    138:     put_long (request + 0x24, 0x200 * 4);
1.1.1.2   root      139:     m68k_areg(regs, 1) = request;
1.1       root      140:     ersatz_doio ();
                    141:     m68k_setpc (0x400C);
1.1.1.3   root      142:     fill_prefetch_0 ();
1.1       root      143: 
                    144:     /* Init the hardware */
1.1.1.2   root      145:     put_long (0x3000, 0xFFFFFFFEul);
1.1       root      146:     put_long (0xDFF080, 0x3000);
                    147:     put_word (0xDFF088, 0);
                    148:     put_word (0xDFF096, 0xE390);
                    149:     put_word (0xDFF09A, 0xE02C);
                    150:     put_word (0xDFF09E, 0x0000);
                    151:     put_word (0xDFF092, 0x0038);
                    152:     put_word (0xDFF094, 0x00D0);
                    153:     put_word (0xDFF08E, 0x2C81);
                    154:     put_word (0xDFF090, 0xF4C1);
                    155:     put_word (0xDFF02A, 0x8000);
1.1.1.3   root      156: 
1.1       root      157:     put_byte (0xBFD100, 0xF7);
                    158:     put_byte (0xBFEE01, 0);
                    159:     put_byte (0xBFEF01, 0x08);
                    160:     put_byte (0xBFDE00, 0x04);
                    161:     put_byte (0xBFDF00, 0x84);
                    162:     put_byte (0xBFDD00, 0x9F);
                    163:     put_byte (0xBFED01, 0x9F);
                    164: }
                    165: 
1.1.1.3   root      166: void ersatz_perform (uae_u16 what)
1.1       root      167: {
                    168:     switch (what) {
                    169:      case EOP_INIT:
                    170:        ersatz_init ();
                    171:        break;
1.1.1.3   root      172: 
1.1       root      173:      case EOP_SERVEINT:
                    174:        /* Just reset all the interrupt request bits */
                    175:        put_word (0xDFF09C, get_word (0xDFF01E) & 0x3FFF);
                    176:        break;
1.1.1.3   root      177: 
1.1       root      178:      case EOP_DOIO:
                    179:        ersatz_doio ();
                    180:        break;
1.1.1.3   root      181: 
1.1       root      182:      case EOP_AVAILMEM:
1.1.1.2   root      183:        m68k_dreg(regs, 0) = m68k_dreg(regs, 1) & 4 ? 0 : 0x70000;
1.1       root      184:        break;
1.1.1.3   root      185: 
1.1       root      186:      case EOP_ALLOCMEM:
1.1.1.2   root      187:        m68k_dreg(regs, 0) = m68k_dreg(regs, 1) & 4 ? 0 : 0x0F000;
1.1       root      188:        break;
                    189: 
                    190:      case EOP_ALLOCABS:
1.1.1.2   root      191:        m68k_dreg(regs, 0) = m68k_areg(regs, 1);
1.1       root      192:        break;
                    193: 
                    194:      case EOP_NIMP:
1.1.1.4 ! root      195:        fprintf (stderr, "Unimplemented Kickstart function called\n");
        !           196:        uae_quit ();
        !           197:        
        !           198:        /* fall through */
        !           199:      case EOP_LOOP:
        !           200:        m68k_setpc (0xF80010);
        !           201:        break;
        !           202: 
1.1.1.3   root      203:      case EOP_OPENLIB:
1.1       root      204:      default:
                    205:        fprintf(stderr, "Internal error. Giving up.\n");
                    206:        abort ();
                    207:     }
                    208: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.