Annotation of uae/autoconf.c, revision 1.1

1.1     ! root        1:  /* 
        !             2:   * UAE - The Un*x Amiga Emulator
        !             3:   * 
        !             4:   * AutoConfig devices
        !             5:   *
        !             6:   * (c) 1995 Bernd Schmidt
        !             7:   * (c) 1996 Ed Hanway
        !             8:   */
        !             9: 
        !            10: #include <stdio.h>
        !            11: #include <stdlib.h>
        !            12: #include <string.h>
        !            13: 
        !            14: #include "config.h"
        !            15: #include "amiga.h"
        !            16: #include "options.h"
        !            17: #include "events.h"
        !            18: #include "memory.h"
        !            19: #include "custom.h"
        !            20: #include "newcpu.h"
        !            21: #include "disk.h"
        !            22: #include "xwin.h"
        !            23: #include "autoconf.h"
        !            24: #include "filesys.h"
        !            25: #include "hardfile.h"
        !            26: 
        !            27: /* Commonly used autoconfig strings */
        !            28: 
        !            29: ULONG explibname;
        !            30: 
        !            31: /* ROM tag area memory access */
        !            32: 
        !            33: static UWORD rtarea[32768];
        !            34: 
        !            35: static ULONG rtarea_lget(CPTR) REGPARAM;
        !            36: static UWORD rtarea_wget(CPTR) REGPARAM;
        !            37: static UBYTE rtarea_bget(CPTR) REGPARAM;
        !            38: static void  rtarea_lput(CPTR, ULONG) REGPARAM;
        !            39: static void  rtarea_wput(CPTR, UWORD) REGPARAM;
        !            40: static void  rtarea_bput(CPTR, UBYTE) REGPARAM;
        !            41: static UWORD *rtarea_xlate(CPTR) REGPARAM;
        !            42: 
        !            43: addrbank rtarea_bank = {
        !            44:     rtarea_lget, rtarea_wget, rtarea_bget,
        !            45:     rtarea_lput, rtarea_wput, rtarea_bput,
        !            46:     rtarea_xlate, default_check
        !            47: };
        !            48: 
        !            49: UWORD *rtarea_xlate(CPTR addr)
        !            50: {
        !            51:     addr &= 0xFFFF;
        !            52:     return rtarea + (addr >> 1);
        !            53: }
        !            54: 
        !            55: ULONG rtarea_lget(CPTR addr)
        !            56: {
        !            57:     addr &= 0xFFFF;
        !            58:     return (ULONG)(rtarea_wget(addr) << 16) + rtarea_wget(addr+2);
        !            59: }
        !            60: 
        !            61: UWORD rtarea_wget(CPTR addr)
        !            62: {
        !            63:     addr &= 0xFFFF;
        !            64:     return rtarea[addr >> 1];
        !            65: }
        !            66: 
        !            67: UBYTE rtarea_bget(CPTR addr)
        !            68: {
        !            69:     UWORD data;
        !            70:     addr &= 0xFFFF;
        !            71:     data = rtarea[addr >> 1];
        !            72:     return addr & 1 ? data : data >> 8;
        !            73: }
        !            74: 
        !            75: void rtarea_lput(CPTR addr, ULONG value) { }
        !            76: void rtarea_bput(CPTR addr, UBYTE value) { }
        !            77: 
        !            78: /* Don't start at 0 -- can get bogus writes there. */
        !            79: static ULONG trap_base_addr = 0x00F00180; 
        !            80: 
        !            81: TrapFunction traps[256];
        !            82: static int max_trap = 0;
        !            83: 
        !            84: void rtarea_wput(CPTR addr, UWORD value) 
        !            85: {
        !            86:     /* Save all registers */
        !            87:     struct regstruct backup_regs = regs;
        !            88:     ULONG retval = 0;
        !            89: 
        !            90:     ULONG func = ((addr  - trap_base_addr) & 0xFFFF) >> 1;
        !            91:     if(func < max_trap) {
        !            92:        retval = (*traps[func])();
        !            93:     } else {
        !            94:        fprintf(stderr, "illegal emulator trap\n");
        !            95:     }
        !            96:     regs = backup_regs;
        !            97:     regs.d[0] = retval;
        !            98: }
        !            99: 
        !           100: /* some quick & dirty code to fill in the rt area and save me a lot of
        !           101:  * scratch paper
        !           102:  */
        !           103: 
        !           104: static int rt_addr = 0;
        !           105: static int rt_straddr = 0xF000/2 - 1;
        !           106: 
        !           107: ULONG
        !           108: addr(int ptr)
        !           109: {
        !           110:     return ((ULONG)ptr << 1) + 0x00F00000;
        !           111: }
        !           112: 
        !           113: void
        !           114: dw(UWORD data)
        !           115: {
        !           116:     rtarea[rt_addr++] = data;
        !           117: }
        !           118: 
        !           119: void
        !           120: dl(ULONG data)
        !           121: {
        !           122:     rtarea[rt_addr++] = data >> 16;
        !           123:     rtarea[rt_addr++] = data;
        !           124: }
        !           125: 
        !           126: /* store strings starting at the end of the rt area and working
        !           127:  * backward.  store pointer at current address
        !           128:  */
        !           129: 
        !           130: ULONG
        !           131: ds(char *str)
        !           132: {
        !           133:     UWORD data;
        !           134:     char c;
        !           135:     int start;
        !           136: 
        !           137:     int len = (strlen(str) + 1) >> 1;
        !           138:     rt_straddr -= len;
        !           139:     start = rt_straddr;
        !           140:     
        !           141:     do {
        !           142:        data = c = *str++;
        !           143:        if (c) {
        !           144:            data <<= 8;
        !           145:            c = *str++;
        !           146:            data |= c;
        !           147:        }
        !           148:        rtarea[start++] = data;
        !           149:     } while (c);
        !           150:     
        !           151:     return addr(rt_straddr--);
        !           152: }
        !           153: 
        !           154: void
        !           155: calltrap(ULONG n)
        !           156: {
        !           157:     dw(0x33C0);        /* MOVE.W D0,abs32 */
        !           158:     dl(n*2 + trap_base_addr);
        !           159: }
        !           160: 
        !           161: void
        !           162: org(ULONG a)
        !           163: {
        !           164:     rt_addr = (a - 0x00F00000) >> 1;
        !           165: }
        !           166: 
        !           167: ULONG
        !           168: here(void)
        !           169: {
        !           170:     return addr(rt_addr);
        !           171: }
        !           172: 
        !           173: int
        !           174: deftrap(TrapFunction func)
        !           175: {
        !           176:     int num = max_trap++;
        !           177:     traps[num] = func;
        !           178:     return num;
        !           179: }
        !           180: 
        !           181: void
        !           182: align(int b)
        !           183: {
        !           184:     rt_addr = (rt_addr + (b-1)) & ~(b-1);
        !           185: }
        !           186: 
        !           187: ULONG CallLib(CPTR base, WORD offset)
        !           188: {
        !           189:     /* Make tracing through this possible */
        !           190:     int oldspc = specialflags & SPCFLAG_BRK;
        !           191:     
        !           192:     CPTR olda6 = regs.a[6];
        !           193:     CPTR oldpc = m68k_getpc();
        !           194:     regs.a[6] = base;
        !           195:     regs.a[7] -= 4;
        !           196:     put_long (regs.a[7], 0xF0FFFE);
        !           197:     m68k_setpc (base + offset);
        !           198:     MC68000_skip (0xF0FFFE);
        !           199:     regs.a[6] = olda6;
        !           200:     m68k_setpc (oldpc);
        !           201:     specialflags |= oldspc;
        !           202:     return regs.d[0];
        !           203: }
        !           204: 
        !           205: void
        !           206: rtarea_init()
        !           207: {
        !           208:     explibname = ds("expansion.library");
        !           209: 
        !           210:     hardfile_install();
        !           211: //    filesys_install(); Not Implemented in Mac yet.
        !           212: }

unix.superglobalmegacorp.com

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