% this is a generic MMIX BIOS % it is considert to be in ROM mapped % at physical address 0000 0000 0000 0000 % used with % virtual address 8000 0000 0000 0000 % Definition of Constants % Physical Addresses and Interrupt Numbers of Devices PREFIX :RAM: (0000000000008000) HI IS #8000 (0000000000000001) MH IS #0001 PREFIX :FLASH: (0000000000008000) HI IS #8000 physical address (0000000000000002) MH IS #0002 (0000000000002000) USERHI IS #2000 virtual mapped address (0000000000000001) USERML IS #0001 PREFIX :VRAM: (0000000000008002) HI IS #8002 PREFIX :IO: (0000000000008001) HI IS #8001 (0000000000000000) Keyboard IS #00 (0000000000000008) Screen IS #08 (0000000000000010) Mouse IS #10 (0000000000000020) GPU IS #20 (0000000000000080) Sevenseg IS #80 (0000000000000090) Timer IS #90 (00000000000000b0) Led0 IS #B0 (00000000000000b8) Led1 IS #B8 (00000000000000c0) Led2 IS #C0 (00000000000000c8) Led3 IS #C8 (00000000000000d0) Serial IS #D0 PREFIX :Interrupt: (000000000000002c) Timer IS 44 (000000000000002d) SerialIn IS 45 (0000000000000030) Button IS 48 % Code .section .text,"ax",@progbits LOC #8000000000000000 PREFIX :Boot: ($000) tmp IS $0 % page table setup (see small model in address.howto) (8000000000000000) :Main IS @ dummy %Main, to keep mmixal happy 8000000000000000: :Boot GETA tmp,:DTrap %set dynamic- and forced-trap handler ...000: f400xxxx ...004: f60e0000 PUT :rTT,tmp ...008: f400xxxx GETA tmp,:FTrap ...00c: f60d0000 PUT :rT,tmp ...010: f200xxxx PUSHJ tmp,:memory %initialize the memory setup ...014: fe000010 GET tmp,:rQ ...018: f7100000 PUT :rQ,0 %clear interrupts % here we start a loaded user program % rXX should be #FB0000FF = UNSAVE $255 % rBB is coppied to $255, it should be the place in the stack % where UNSAVE will find its data % rWW should be the entry point in the main program, % thats where the program % continues after the UNSAVE. % If no program is loaded, rXX will be 0, that is TRAP 0,Halt,0 % and we end the program before it has started in the Trap handler. ...01c: 35ff0001 NEG $255,1 % enable interrupt $255->rK with resume 1 ...020: f9000001 RESUME 1 % loading a file sets up special registers for that % Dynamic Trap Handling PREFIX :DTrap: ...024: f2ffxxxx :DTrap PUSHJ $255,Handler ...028: f60400ff PUT :rJ,$255 ...02c: 35ff0001 NEG $255,1 % enable interrupt $255->rK with resume 1 ...030: f9000001 RESUME 1 ($000) tmp IS $0 ($001) ibits IS $1 ($002) inumber IS $2 ($003) base IS $3 ...034: fe010010 Handler GET ibits,:rQ ...038: 27000101 SUBU tmp,ibits,1 %from xxx...xxx1000 to xxx...xxx0111 ...03c: da020001 SADD inumber,tmp,ibits %position of lowest bit ...040: ca000100 ANDN tmp,ibits,tmp %the lowest bit ...044: ca000100 ANDN tmp,ibits,tmp %delete lowest bit ...048: f6100000 PUT :rQ,tmp %and return to rQ ...04c: 3b000202 SLU tmp,inumber,2 %scale ...050: f403xxxx GETA base,Table %and jump ...054: 9e000300 GO tmp,base,tmp ...058: f0xxxxxx Table JMP Reboot %0 the machine bits ...05c: f0xxxxxx JMP MemParityError %1 ...060: f0xxxxxx JMP MemNonExiistent %2 ...064: f0xxxxxx JMP PowerFail %3 ...068: f0xxxxxx JMP PageTableError %4 ...06c: f0xxxxxx JMP Unhandled %5 ...070: f0xxxxxx JMP Unhandled %6 ...074: f0xxxxxx JMP Intervall %7 ...078: f0xxxxxx JMP Unhandled %8 ...07c: f0xxxxxx JMP Unhandled %9 ...080: f0xxxxxx JMP Unhandled %10 ...084: f0xxxxxx JMP Unhandled %11 ...088: f0xxxxxx JMP Unhandled %12 ...08c: f0xxxxxx JMP Unhandled %13 ...090: f0xxxxxx JMP Unhandled %14 ...094: f0xxxxxx JMP Unhandled %15 ...098: f0xxxxxx JMP Unhandled %16 ...09c: f0xxxxxx JMP Keyboard %17 ...0a0: f0xxxxxx JMP Screen %18 ...0a4: f0xxxxxx JMP Mouse %19 ...0a8: f0xxxxxx JMP GPU %20 ...0ac: f0xxxxxx JMP Timer %21 ...0b0: f0xxxxxx JMP Disk %22 ...0b4: f0xxxxxx JMP Unhandled %23 ...0b8: f0xxxxxx JMP Unhandled %24 ...0bc: f0xxxxxx JMP Unhandled %25 ...0c0: f0xxxxxx JMP Unhandled %26 ...0c4: f0xxxxxx JMP Unhandled %27 ...0c8: f0xxxxxx JMP Unhandled %28 ...0cc: f0xxxxxx JMP Unhandled %29 ...0d0: f0xxxxxx JMP Unhandled %30 ...0d4: f0xxxxxx JMP Unhandled %31 ...0d8: f0xxxxxx JMP Privileged %32 % Program bits ...0dc: f0xxxxxx JMP Security %33 ...0e0: f0xxxxxx JMP RuleBreak %34 ...0e4: f0xxxxxx JMP KernelOnly %35 ...0e8: f0xxxxxx JMP TanslationBypass %36 ...0ec: f0xxxxxx JMP NoExec %37 ...0f0: f0xxxxxx JMP NoWrite %38 ...0f4: f0xxxxxx JMP NoRead %39 ...0f8: f0xxxxxx JMP Unhandled %40 ...0fc: f0xxxxxx JMP Unhandled %41 ...100: f0xxxxxx JMP Unhandled %42 ...104: f0xxxxxx JMP Unhandled %43 ...108: f0xxxxxx JMP Unhandled %44 ...10c: f0xxxxxx JMP Unhandled %45 ...110: f0xxxxxx JMP Unhandled %46 ...114: f0xxxxxx JMP Unhandled %47 ...118: f0xxxxxx JMP Button %48 ...11c: f0xxxxxx JMP Unhandled %49 ...120: f0xxxxxx JMP Unhandled %50 ...124: f0xxxxxx JMP Unhandled %51 ...128: f0xxxxxx JMP Unhandled %52 ...12c: f0xxxxxx JMP Unhandled %53 ...130: f0xxxxxx JMP Unhandled %54 ...134: f0xxxxxx JMP Unhandled %55 ...138: f0xxxxxx JMP Unhandled %56 ...13c: f0xxxxxx JMP Unhandled %57 ...140: f0xxxxxx JMP Unhandled %58 ...144: f0xxxxxx JMP Unhandled %59 ...148: f0xxxxxx JMP Unhandled %60 ...14c: f0xxxxxx JMP Unhandled %61 ...150: f0xxxxxx JMP Unhandled %62 ...154: f0xxxxxx JMP Unhandled %63 ...158: f0xxxxxx JMP Ignore %64 rQ was zero % Default Dynamic Trap Handlers ...15c: f400xxxx Unhandled GETA tmp,1F ...160: fd000005 SWYM tmp,5 % tell the debugger ...164: f8000000 POP 0,0 ...168: 44454255 1H BYTE "DEBUG Trap unhandled",0 ...16c: 47205472 ...170: 61702075 ...174: 6e68616e ...178: 646c6564 ...17c: 00 ...180: f8000000 Ignore POP 0,0 % Required Dynamic Trap Handlers ...184: f400xxxx Reboot GETA tmp,1F ...188: fd000005 SWYM tmp,5 % tell the debugger ...18c: f0xxxxxx JMP Boot ...190: 44454255 1H BYTE "DEBUG Rebooting",0 ...194: 47205265 ...198: 626f6f74 ...19c: 696e6700 ...1a0: f400xxxx MemParityError GETA tmp,1F ...1a4: fd000005 SWYM tmp,5 % tell the debugger ...1a8: f8000000 POP 0,0 ...1ac: 44454255 1H BYTE "DEBUG Memory parity error",0 ...1b0: 47204d65 ...1b4: 6d6f7279 ...1b8: 20706172 ...1bc: 69747920 ...1c0: 6572726f ...1c4: 7200 ...1c8: f400xxxx MemNonExiistent GETA tmp,1F ...1cc: fd000005 SWYM tmp,5 % tell the debugger ...1d0: f8000000 POP 0,0 ...1d4: 44454255 1H BYTE "DEBUG Access to nonexistent Memory",0 ...1d8: 47204163 ...1dc: 63657373 ...1e0: 20746f20 ...1e4: 6e6f6e65 ...1e8: 78697374 ...1ec: 656e7420 ...1f0: 4d656d6f ...1f4: 727900 ...1f8: f400xxxx PowerFail GETA tmp,1F ...1fc: fd000005 SWYM tmp,5 % tell the debugger ...200: f8000000 POP 0,0 ...204: 44454255 1H BYTE "DEBUG Power Fail - switching to battery ;-)",0 ...208: 4720506f ...20c: 77657220 ...210: 4661696c ...214: 202d2073 ...218: 77697463 ...21c: 68696e67 ...220: 20746f20 ...224: 62617474 ...228: 65727920 ...22c: 3b2d2900 ...230: f400xxxx PageTableError GETA tmp,1F ...234: fd000005 SWYM tmp,5 % tell the debugger ...238: f8000000 POP 0,0 ...23c: 44454255 1H BYTE "DEBUG Error in page table structure",0 ...240: 47204572 ...244: 726f7220 ...248: 696e2070 ...24c: 61676520 ...250: 7461626c ...254: 65207374 ...258: 72756374 ...25c: 75726500 ...260: f400xxxx Intervall GETA tmp,1F ...264: fd000005 SWYM tmp,5 % tell the debugger ...268: f8000000 POP 0,0 ...26c: 44454255 1H BYTE "DEBUG Intervall Counter rI is zero",0 ...270: 4720496e ...274: 74657276 ...278: 616c6c20 ...27c: 436f756e ...280: 74657220 ...284: 72492069 ...288: 73207a65 ...28c: 726f00 ...290: f400xxxx Privileged GETA tmp,1F ...294: fd000005 SWYM tmp,5 % tell the debugger ...298: f8000000 POP 0,0 ...29c: 44454255 1H BYTE "DEBUG Privileged Instruction",0 ...2a0: 47205072 ...2a4: 6976696c ...2a8: 65676564 ...2ac: 20496e73 ...2b0: 74727563 ...2b4: 74696f6e ...2b8: 00 ...2bc: f400xxxx Security GETA tmp,1F ...2c0: fd000005 SWYM tmp,5 % tell the debugger ...2c4: f8000000 POP 0,0 ...2c8: 44454255 1H BYTE "DEBUG Security violation",0 ...2cc: 47205365 ...2d0: 63757269 ...2d4: 74792076 ...2d8: 696f6c61 ...2dc: 74696f6e ...2e0: 00 ...2e4: f400xxxx RuleBreak GETA tmp,1F ...2e8: fd000005 SWYM tmp,5 % tell the debugger ...2ec: f8000000 POP 0,0 ...2f0: 44454255 1H BYTE "DEBUG Illegal Instruction",0 ...2f4: 4720496c ...2f8: 6c656761 ...2fc: 6c20496e ...300: 73747275 ...304: 6374696f ...308: 6e00 ...30c: f400xxxx KernelOnly GETA tmp,1F ...310: fd000005 SWYM tmp,5 % tell the debugger ...314: f8000000 POP 0,0 ...318: 44454255 1H BYTE "DEBUG Instruction for kernel use only",0 ...31c: 4720496e ...320: 73747275 ...324: 6374696f ...328: 6e20666f ...32c: 72206b65 ...330: 726e656c ...334: 20757365 ...338: 206f6e6c ...33c: 7900 ...340: f400xxxx TanslationBypass GETA tmp,1F ...344: fd000005 SWYM tmp,5 % tell the debugger ...348: f8000000 POP 0,0 ...34c: 44454255 1H BYTE "DEBUG Illegal access to negative address",0 ...350: 4720496c ...354: 6c656761 ...358: 6c206163 ...35c: 63657373 ...360: 20746f20 ...364: 6e656761 ...368: 74697665 ...36c: 20616464 ...370: 72657373 ...374: 00 ...378: f400xxxx NoExec GETA tmp,1F ...37c: fd000005 SWYM tmp,5 % tell the debugger ...380: f8000000 POP 0,0 ...384: 44454255 1H BYTE "DEBUG Missing execute permission",0 ...388: 47204d69 ...38c: 7373696e ...390: 67206578 ...394: 65637574 ...398: 65207065 ...39c: 726d6973 ...3a0: 73696f6e ...3a4: 00 ...3a8: f400xxxx NoWrite GETA tmp,1F ...3ac: fd000005 SWYM tmp,5 % tell the debugger ...3b0: f8000000 POP 0,0 ...3b4: 44454255 1H BYTE "DEBUG Missing write permission",0 ...3b8: 4720204d ...3bc: 69737369 ...3c0: 6e672077 ...3c4: 72697465 ...3c8: 20706572 ...3cc: 6d697373 ...3d0: 696f6e00 ...3d4: f400xxxx NoRead GETA tmp,1F ...3d8: fd000005 SWYM tmp,5 % tell the debugger ...3dc: f8000000 POP 0,0 ...3e0: 44454255 1H BYTE "DEBUG Missing read permission",0 ...3e4: 47204d69 ...3e8: 7373696e ...3ec: 67207265 ...3f0: 61642070 ...3f4: 65726d69 ...3f8: 7373696f ...3fc: 6e00 % Devicespecific Dynamic Trap Handlers PREFIX Keyboard: ($001) base IS $1 ($002) data IS $2 ($003) count IS $3 ($004) return IS $4 ($005) tmp IS $5 % echo a character from the keyboard ...400: e0018001 :DTrap:Keyboard SETH base,:IO:HI ...404: 8d020100 LDO data,base,:IO:Keyboard keyboard status/data ...408: 4002xxxx BN data,1F ...40c: 3d030220 SR count,data,32 ...410: c90303ff AND count,count,#FF ...414: 4203xxxx BZ count,1F ...418: fe040004 GET return,:rJ ...41c: c90602ff AND tmp+1,data,#FF ...420: f205xxxx PUSHJ tmp,:ScreenC ...424: f6040004 PUT :rJ,return ...428: f8000000 1H POP 0,0 ****************** :DTrap:Screen IS :Dtrap:Ignore ********** error: relative address in location #80000000000000a0 is too far away! (8000000000000180) :Dtrap:Mouse IS :DTrap:Ignore (8000000000000180) :DTrap:GPU IS :DTrap:Ignore (8000000000000180) :DTrap:Timer IS :DTrap:Ignore (8000000000000180) :DTrap:Disk IS :DTrap:Ignore (8000000000000180) :DTrap:Button IS :DTrap:Ignore Symbol table: Boot = #8000000000000000 (32) Boot:tmp = $000 (30) DTrap = #8000000000000024 (31) DTrap:Boot = ? (65) DTrap:Button = #8000000000000180 (63) DTrap:Disk = #8000000000000180 (54) DTrap:GPU = #8000000000000180 (52) DTrap:Handler = #8000000000000034 (36) DTrap:Ignore = #8000000000000180 (64) DTrap:Intervall = #8000000000000260 (48) DTrap:KernelOnly = #800000000000030c (58) DTrap:Keyboard = #8000000000000400 (49) DTrap:Keyboard:base = $001 (67) DTrap:Keyboard:count = $003 (69) DTrap:Keyboard:data = $002 (68) DTrap:Keyboard:return = $004 (70) DTrap:Keyboard:tmp = $005 (71) DTrap:MemNonExiistent = #80000000000001c8 (44) DTrap:MemParityError = #80000000000001a0 (43) DTrap:Mouse = ? (51) DTrap:NoExec = #8000000000000378 (60) DTrap:NoRead = #80000000000003d4 (62) DTrap:NoWrite = #80000000000003a8 (61) DTrap:PageTableError = #8000000000000230 (46) DTrap:PowerFail = #80000000000001f8 (45) DTrap:Privileged = #8000000000000290 (55) DTrap:Reboot = #8000000000000184 (42) DTrap:RuleBreak = #80000000000002e4 (57) DTrap:Security = #80000000000002bc (56) DTrap:Table = #8000000000000058 (41) DTrap:TanslationBypass = #8000000000000340 (59) DTrap:Timer = #8000000000000180 (53) DTrap:Unhandled = #800000000000015c (47) DTrap:base = $003 (40) DTrap:ibits = $001 (38) DTrap:inumber = $002 (39) DTrap:tmp = $000 (37) Dtrap:Mouse = #8000000000000180 (74) FLASH:HI = #0000000000008000 (6) FLASH:MH = #0000000000000002 (7) FLASH:USERHI = #0000000000002000 (8) FLASH:USERML = #0000000000000001 (9) FTrap = ? (33) IO:GPU = #0000000000000020 (17) IO:HI = #0000000000008001 (13) IO:Keyboard = #0000000000000000 (14) IO:Led0 = #00000000000000b0 (20) IO:Led1 = #00000000000000b8 (21) IO:Led2 = #00000000000000c0 (22) IO:Led3 = #00000000000000c8 (23) IO:Mouse = #0000000000000010 (16) IO:Screen = #0000000000000008 (15) IO:Serial = #00000000000000d0 (24) IO:Sevenseg = #0000000000000080 (18) IO:Timer = #0000000000000090 (19) Interrupt:Button = #0000000000000030 (28) Interrupt:SerialIn = #000000000000002d (27) Interrupt:Timer = #000000000000002c (26) Main = #8000000000000000 (1) RAM:HI = #0000000000008000 (3) RAM:MH = #0000000000000001 (4) ScreenC = ? (72) VRAM:HI = #0000000000008002 (11) memory = ? (34)