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

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

unix.superglobalmegacorp.com

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