├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── ChangeLog.altivec ├── Makefile.am ├── README ├── TODO ├── autogen.sh ├── configure.ac ├── doc ├── .gitignore ├── Makefile.am ├── beos-missing-headers.diff └── ppc.1 ├── ppccfg.example ├── scripts ├── .gitignore ├── Makefile.am ├── ifppc_down ├── ifppc_down.beos ├── ifppc_down.setuid.cc ├── ifppc_up ├── ifppc_up.beos ├── ifppc_up.setuid.cc └── settings ├── sdl.m4 ├── src ├── .gitignore ├── Makefile.am ├── configparser.cc ├── configparser.h ├── cpu │ ├── .gitignore │ ├── Makefile.am │ ├── common.h │ ├── cpu.h │ ├── cpu_generic │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── ppc_alu.cc │ │ ├── ppc_alu.h │ │ ├── ppc_cpu.cc │ │ ├── ppc_cpu.h │ │ ├── ppc_dec.cc │ │ ├── ppc_dec.h │ │ ├── ppc_exc.cc │ │ ├── ppc_exc.h │ │ ├── ppc_fpu.cc │ │ ├── ppc_fpu.h │ │ ├── ppc_mmu.cc │ │ ├── ppc_mmu.h │ │ ├── ppc_opc.cc │ │ ├── ppc_opc.h │ │ ├── ppc_tools.h │ │ ├── ppc_vec.cc │ │ └── ppc_vec.h │ ├── cpu_jitc_x86 │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── jitc.cc │ │ ├── jitc.h │ │ ├── jitc_asm.h │ │ ├── jitc_debug.cc │ │ ├── jitc_debug.h │ │ ├── jitc_mmu.S │ │ ├── jitc_tools.S │ │ ├── jitc_types.h │ │ ├── ppc_alu.cc │ │ ├── ppc_alu.h │ │ ├── ppc_cpu.cc │ │ ├── ppc_cpu.h │ │ ├── ppc_dec.cc │ │ ├── ppc_dec.h │ │ ├── ppc_esc.cc │ │ ├── ppc_esc.h │ │ ├── ppc_exc.cc │ │ ├── ppc_exc.h │ │ ├── ppc_fpu.cc │ │ ├── ppc_fpu.h │ │ ├── ppc_mmu.cc │ │ ├── ppc_mmu.h │ │ ├── ppc_opc.cc │ │ ├── ppc_opc.h │ │ ├── ppc_tools.h │ │ ├── ppc_vec.cc │ │ ├── ppc_vec.h │ │ ├── x86asm.cc │ │ └── x86asm.h │ ├── cpu_jitc_x86_64 │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── jitc.cc │ │ ├── jitc.h │ │ ├── jitc_asm.h │ │ ├── jitc_common.h │ │ ├── jitc_debug.cc │ │ ├── jitc_debug.h │ │ ├── jitc_mmu.S │ │ ├── jitc_tools.S │ │ ├── jitc_types.h │ │ ├── ppc_alu.cc │ │ ├── ppc_alu.h │ │ ├── ppc_cpu.cc │ │ ├── ppc_cpu.h │ │ ├── ppc_dec.cc │ │ ├── ppc_dec.h │ │ ├── ppc_esc.cc │ │ ├── ppc_esc.h │ │ ├── ppc_exc.cc │ │ ├── ppc_exc.h │ │ ├── ppc_fpu.cc │ │ ├── ppc_fpu.h │ │ ├── ppc_mmu.cc │ │ ├── ppc_mmu.h │ │ ├── ppc_opc.cc │ │ ├── ppc_opc.h │ │ ├── ppc_tools.h │ │ ├── ppc_vec.cc │ │ ├── ppc_vec.h │ │ ├── x86_64asm.cc │ │ └── x86_64asm.h │ ├── debug.h │ └── mem.h ├── debug │ ├── .gitignore │ ├── Makefile.am │ ├── asm.cc │ ├── asm.h │ ├── debugger.cc │ ├── debugger.h │ ├── debugparse.y │ ├── debugtype.h │ ├── lex.h │ ├── lex.l │ ├── parsehelper.c │ ├── parsehelper.h │ ├── ppcdis.cc │ ├── ppcdis.h │ ├── ppcopc.cc │ ├── ppcopc.h │ ├── stdfuncs.cc │ ├── stdfuncs.h │ ├── tracers.h │ ├── x86dis.cc │ ├── x86dis.h │ ├── x86opc.cc │ └── x86opc.h ├── info.h ├── io │ ├── .gitignore │ ├── 3c90x │ │ ├── .gitignore │ │ ├── 3c90x.cc │ │ ├── 3c90x.h │ │ └── Makefile.am │ ├── Makefile.am │ ├── cuda │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── cuda.cc │ │ └── cuda.h │ ├── graphic │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── gcard.cc │ │ └── gcard.h │ ├── ide │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── ata.cc │ │ ├── ata.h │ │ ├── cd.cc │ │ ├── cd.h │ │ ├── ide.cc │ │ ├── ide.h │ │ ├── idedevice.cc │ │ ├── idedevice.h │ │ └── scsicmds.h │ ├── io.cc │ ├── io.h │ ├── macio │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── macio.cc │ │ └── macio.h │ ├── nvram │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── nvram.cc │ │ └── nvram.h │ ├── pci │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── pci.cc │ │ └── pci.h │ ├── pic │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── pic.cc │ │ └── pic.h │ ├── prom │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── fcode.cc │ │ ├── fcode.h │ │ ├── forth.cc │ │ ├── forth.h │ │ ├── forthtable.cc │ │ ├── forthtable.h │ │ ├── fs │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── fs.cc │ │ │ ├── fs.h │ │ │ ├── hfs.cc │ │ │ ├── hfs.h │ │ │ ├── hfs │ │ │ │ ├── .gitignore │ │ │ │ ├── Makefile.am │ │ │ │ ├── apple.h │ │ │ │ ├── block.c │ │ │ │ ├── block.h │ │ │ │ ├── btree.c │ │ │ │ ├── btree.h │ │ │ │ ├── data.c │ │ │ │ ├── data.h │ │ │ │ ├── file.c │ │ │ │ ├── file.h │ │ │ │ ├── hfs.c │ │ │ │ ├── hfs.h │ │ │ │ ├── libhfs.h │ │ │ │ ├── low.c │ │ │ │ ├── low.h │ │ │ │ ├── medium.c │ │ │ │ ├── medium.h │ │ │ │ ├── node.c │ │ │ │ ├── node.h │ │ │ │ ├── os.cc │ │ │ │ ├── os.h │ │ │ │ ├── record.c │ │ │ │ ├── record.h │ │ │ │ ├── version.c │ │ │ │ ├── version.h │ │ │ │ ├── volume.c │ │ │ │ └── volume.h │ │ │ ├── hfsglue.h │ │ │ ├── hfsplus.cc │ │ │ ├── hfsplus.h │ │ │ ├── hfsplus │ │ │ │ ├── .gitignore │ │ │ │ ├── Makefile.am │ │ │ │ ├── apple.h │ │ │ │ ├── blockiter.c │ │ │ │ ├── blockiter.h │ │ │ │ ├── btree.c │ │ │ │ ├── btree.h │ │ │ │ ├── hfs.h │ │ │ │ ├── hfsp.h │ │ │ │ ├── hfstime.c │ │ │ │ ├── hfstime.h │ │ │ │ ├── libhfsp.c │ │ │ │ ├── libhfsp.h │ │ │ │ ├── os.cc │ │ │ │ ├── os.h │ │ │ │ ├── partitions.c │ │ │ │ ├── partitions.h │ │ │ │ ├── record.c │ │ │ │ ├── record.h │ │ │ │ ├── swab.h │ │ │ │ ├── unicode.c │ │ │ │ ├── unicode.h │ │ │ │ ├── volume.c │ │ │ │ └── volume.h │ │ │ ├── hfsplusglue.h │ │ │ ├── hfsstruct.h │ │ │ ├── part.cc │ │ │ └── part.h │ │ ├── prom.cc │ │ ├── prom.h │ │ ├── promboot.cc │ │ ├── promboot.h │ │ ├── promdt.cc │ │ ├── promdt.h │ │ ├── prommem.cc │ │ ├── prommem.h │ │ ├── promosi.cc │ │ └── promosi.h │ ├── rtl8139 │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── rtl8139.cc │ │ └── rtl8139.h │ ├── serial │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── serial.cc │ │ └── serial.h │ └── usb │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── usb.cc │ │ └── usb.h ├── main.cc ├── ppc_button_changecd.c ├── ppc_button_changecd.h ├── ppc_font.c ├── ppc_font.h ├── ppc_img.c ├── ppc_img.h ├── system │ ├── .gitignore │ ├── Makefile.am │ ├── arch │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── generic │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── sysendian.h │ │ │ ├── sysfeatures.h │ │ │ └── sysvaccel.cc │ │ ├── sysendian.h │ │ ├── sysfeatures.h │ │ ├── x86 │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── sysendian.h │ │ │ ├── sysfeatures.h │ │ │ ├── sysvaccel.cc │ │ │ └── vaccel.S │ │ └── x86_64 │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── sysendian.h │ │ │ ├── sysfeatures.h │ │ │ ├── sysvaccel.cc │ │ │ └── vaccel.S │ ├── device.cc │ ├── device.h │ ├── display.cc │ ├── display.h │ ├── event.h │ ├── file.cc │ ├── file.h │ ├── fileofs.h │ ├── font.cc │ ├── font.h │ ├── gif.cc │ ├── gif.h │ ├── keyboard.cc │ ├── keyboard.h │ ├── mouse.cc │ ├── mouse.h │ ├── osapi │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── beos │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── syscdrom.cc │ │ │ ├── sysclipboard.cc │ │ │ ├── sysfile.cc │ │ │ ├── sysinit.cc │ │ │ ├── systhread.cc │ │ │ ├── systimer.cc │ │ │ └── types.h │ │ ├── posix │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── syscdrom.cc │ │ │ ├── sysclipboard.cc │ │ │ ├── sysethtun.cc │ │ │ ├── sysfile.cc │ │ │ ├── sysinit.cc │ │ │ ├── systhread.cc │ │ │ ├── systimer.cc │ │ │ ├── sysvm.cc │ │ │ └── types.h │ │ └── win32 │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── aspi-win32.h │ │ │ ├── scsipt.h │ │ │ ├── scsitypes.h │ │ │ ├── syscdrom.cc │ │ │ ├── sysclipboard.cc │ │ │ ├── sysethtun.cc │ │ │ ├── sysfile.cc │ │ │ ├── sysinit.cc │ │ │ ├── systhread.cc │ │ │ ├── systimer.cc │ │ │ ├── tap_constants.h │ │ │ └── types.h │ ├── sys.cc │ ├── sys.h │ ├── syscdrom.h │ ├── sysclk.h │ ├── sysethtun.h │ ├── sysexcept.cc │ ├── sysexcept.h │ ├── sysfeatures.h │ ├── systhread.h │ ├── systimer.h │ ├── sysvaccel.h │ ├── sysvm.h │ ├── types.h │ ├── ui │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── beos │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── gui.cc │ │ │ ├── pearpc-res.h │ │ │ ├── pearpc-res.rdef │ │ │ ├── sysbeos.cc │ │ │ ├── sysbeos.h │ │ │ ├── sysdisplay.cc │ │ │ ├── syskeyboard.cc │ │ │ └── sysmouse.cc │ │ ├── gtk │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ └── gui.cc │ │ ├── gui.h │ │ ├── qt │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ └── gui.cc │ │ ├── sdl │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── gui.cc │ │ │ ├── sysdisplay.cc │ │ │ ├── syskeyboard.cc │ │ │ ├── sysmouse.cc │ │ │ ├── syssdl.cc │ │ │ └── syssdl.h │ │ ├── win32 │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── gui.cc │ │ │ ├── ppc.ico │ │ │ ├── resources.h │ │ │ ├── resources.rc │ │ │ ├── sysdisplay.cc │ │ │ ├── syskeyboard.cc │ │ │ ├── sysmouse.cc │ │ │ ├── syswin.cc │ │ │ └── syswin.h │ │ └── x11 │ │ │ ├── .gitignore │ │ │ ├── Makefile.am │ │ │ ├── gui.cc │ │ │ ├── sysdisplay.cc │ │ │ ├── syskeyboard.cc │ │ │ ├── sysmouse.cc │ │ │ ├── sysx11.cc │ │ │ └── sysx11.h │ ├── vt100.cc │ └── vt100.h └── tools │ ├── .gitignore │ ├── Makefile.am │ ├── atom.cc │ ├── atom.h │ ├── configfile.cc │ ├── configfile.h │ ├── crc32.cc │ ├── crc32.h │ ├── crc32defs.h │ ├── crc32table.h │ ├── cstream.h │ ├── data.cc │ ├── data.h │ ├── debug.cc │ ├── debug.h │ ├── endianess.cc │ ├── endianess.h │ ├── except.cc │ ├── except.h │ ├── snprintf.cc │ ├── snprintf.h │ ├── store.cc │ ├── store.h │ ├── str.cc │ ├── str.h │ ├── stream.cc │ ├── stream.h │ ├── strtools.cc │ ├── strtools.h │ ├── thread.cc │ └── thread.h └── video.x /.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | aclocal.m4 5 | autom4te.cache 6 | config.h 7 | config.h.in 8 | config.cache 9 | config.log 10 | config.status 11 | configure 12 | stamp-h1 13 | stamp-h 14 | stamp-h.in 15 | config.guess 16 | config.sub 17 | depcomp 18 | install-sh 19 | missing 20 | ylwrap -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | AUTHORS 3 | =========== 4 | 5 | 6 | Main developer: Sebastian Biallas 7 | Some major parts by: Stefan Weyergraf 8 | AltiVec and other core updates by: Daniel Foesch 9 | 10 | Contributions by (in alphabetical order): 11 | * Anders F. Bjoerklund 12 | * Roman Bogorodskiy 13 | * Eric Estabrooks 14 | * Daniel Foesch 15 | * Jens von der Heydt 16 | * John Kelley 17 | * Matt Jobson 18 | * Keith Rothman 19 | * Alexander Stockinger 20 | * Kimball Thurston 21 | 22 | Contains code stolen (i.e. copied with respect to the GPL) from: 23 | 24 | * HT Editor 25 | * Linux 26 | * Bochs 27 | * MOL 28 | * Yaboot 29 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | EXTRA_DIST = TODO ChangeLog README COPYING AUTHORS ppccfg.example video.x sdl.m4 4 | SUBDIRS = doc src scripts 5 | 6 | dist2: distdir 7 | -chmod -R a+r $(distdir) 8 | BZIP2=$(BZIP2_ENV) $(AMTAR) chojf $(distdir).tar.bz2 $(distdir) 9 | -rm -rf $(distdir) 10 | 11 | dist-all2: dist2 12 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | PearPC 3 | ================ 4 | 5 | 6 | This is the EXPERIMENTAL release PearPC 0.6pre. 7 | Please read the documentation online at 8 | 9 | http://pearpc.sf.net 10 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | - jitc 2 | - do not map ctr 3 | 00000b90 4200fffc bdnz 0xb8c 4 | 10c3af540 448b9424a4010000 mov r10d, [rsp+1a4] 5 | 10c3af548 41ffca dec r10d 6 | 10c3af54b 0f8400000000 jz 10c3af551 7 | - flags 8 | 00000b94 70a50003 andi. r5, r5, 3 9 | 10c3af571 8b6c2424 mov ebp, [rsp+24] 10 | 10c3af575 83e503 and ebp, 3 11 | 00000b98 2c050000 cmpwi cr0, r5, 0 12 | 10c3af578 e85388e5f7 call ppc_flush_flags_asm 13 | 10c3af57d 83fd00 cmp ebp, 0 14 | 10c3af580 e88b88e5f7 call ppc_flush_flags_signed_0_asm 15 | - pc 16 | 00000b9c 4d820020 beqlr cr0 17 | 10c3af585 f684249301000020 test byte ptr [rsp+193], 20 18 | 10c3af58d 8b8424a0010000 mov eax, [rsp+1a0] 19 | 10c3af594 0f8400000000 jz 10c3af59a 20 | 10c3af5aa 83e0fc and eax, 0fffffffc <-- no need for that 21 | 10c3af5ad e95e8ee5f7 jmp ppc_new_pc_asm 22 | 23 | - set_msr0 24 | EXPORT(ppc_opc_icbi_asm): 25 | add %eax, 1 # FIXME: WTF??? 26 | 27 | 28 | - why do 2.6 Linux-kernels not display console? 29 | - OpenBSD doesn't start. why? 30 | - NetBSD doesn't start. why? 31 | - MOL doesn't start in Mandrake? (testing needed) 32 | - network: "scripts" directory configurable 33 | - usability: intercept focus change and send key-release events. 34 | - usability: intercept close window. ask if user really wants to terminate the session. 35 | - gfx: adapt startup logo (name is now PearPC, not PPC) 36 | - configuration: jitc entries 37 | - documentation: dma and who uses it. 38 | - jitc_x86: jmpFixup / Resolve(here) crash? 39 | - PVR testing. understand numbering. 40 | - create specialized example config files for Mandrake, Darwin, Mac OS X. 41 | - configuration: possibility to configure HDs read-only. 42 | - usability: locked CDs can't be changed. GUI should reflect this. 43 | - usability: don't complain if CD is not available at startup. (CDs are _removable_ media) 44 | - usability: try to eject CD if "Change CD" is clicked 45 | - usability: make Win32 CDROM drives work 46 | - hardware: full USB support 47 | - rtl8139 doesn't implement write-frame-prefixes 48 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # script to prepare PearPC sources 3 | aclocal -I . \ 4 | && autoheader \ 5 | && automake --add-missing \ 6 | && autoconf \ 7 | || exit 1 8 | 9 | echo PearPC sources are now prepared. To build here, run: 10 | echo " ./configure" 11 | echo " make" 12 | -------------------------------------------------------------------------------- /doc/.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | Makefile.in 3 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | man_MANS = ppc.1 4 | 5 | EXTRA_DIST = $(man_MANS) 6 | -------------------------------------------------------------------------------- /scripts/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | ifppc_down.setuid 5 | ifppc_up.setuid 6 | -------------------------------------------------------------------------------- /scripts/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | EXTRA_DIST = ifppc_up.setuid.cc ifppc_down.setuid.cc ifppc_up ifppc_down ifppc_up.beos ifppc_down.beos 4 | 5 | if USE_OSAPI_POSIX 6 | noinst_PROGRAMS = ifppc_down.setuid ifppc_up.setuid 7 | ifppc_up_setuid_SOURCES = ifppc_up.setuid.cc 8 | ifppc_down_setuid_SOURCES = ifppc_down.setuid.cc 9 | endif 10 | -------------------------------------------------------------------------------- /scripts/ifppc_down: -------------------------------------------------------------------------------- 1 | # 2 | # BE CAREFUL. THIS SCRIPT IS INVOKED BY A SETUID ROOT BINARY! 3 | # IT SHOULD BE OWNED BY ROOT. 4 | # ONLY ROOT SHOULD HAVE WRITE-ACCESS TO THIS FILE. 5 | # 6 | 7 | . ./scripts/settings 8 | 9 | if [ $BRIDGE == 1 ]; then 10 | rm $PPC_INTERFACE.active 11 | brctl delif $BRIDGE_INTERFACE $PPC_INTERFACE 12 | if [ `ls -l *.active | wc -l` == 0 ]; then 13 | # If this is the last ppc interface, down the whole bridge 14 | ifconfig $BRIDGE_INTERFACE down 15 | brctl delbr $BRIDGE_INTERFACE 16 | ifconfig $HOST_INTERFACE $HOST_IP netmask $HOST_NETMASK up 17 | route add -net default gw $HOST_DEFAULT_ROUTER 18 | fi 19 | else 20 | /sbin/ifconfig $PPC_INTERFACE down 21 | fi 22 | -------------------------------------------------------------------------------- /scripts/ifppc_down.beos: -------------------------------------------------------------------------------- 1 | # 2 | # BE CAREFUL. THIS SCRIPT IS INVOKED BY A SETUID ROOT BINARY! 3 | # IT SHOULD BE OWNED BY ROOT. 4 | # ONLY ROOT SHOULD HAVE WRITE-ACCESS TO THIS FILE. 5 | # 6 | /bin/ifconfig --del $PPC_INTERFACE >/dev/null 7 | -------------------------------------------------------------------------------- /scripts/ifppc_down.setuid.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int canonicalize(char *buf, int bufsize, char *cwd, char *fn) 9 | { 10 | int cwdsize = strlen(cwd); 11 | int fnsize = strlen(fn); 12 | if (fn[0] == '/') { 13 | if (fnsize +1 > bufsize) return ERANGE; 14 | strcpy(buf, fn); 15 | return 0; 16 | } 17 | if (cwdsize + 1 + fnsize + 1 > bufsize) return ERANGE; 18 | strcpy(buf, cwd); 19 | strcat(buf, "/"); 20 | strcat(buf, fn); 21 | return 0; 22 | } 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | setuid(0); 27 | const char *relfilename = "ifppc_down"; 28 | int relfilenamesize = strlen(relfilename); 29 | char cwdbuf[2048]; 30 | if (!getcwd(cwdbuf, sizeof cwdbuf)) { 31 | printf("CWD name too long (>%d bytes). move to a higher level directory.\n", (int)sizeof cwdbuf); 32 | return 1; 33 | } 34 | char filename[2048+128]; 35 | if (canonicalize(filename, sizeof filename, cwdbuf, argv[0])) { 36 | printf("unable to determine absolute executable filename. " 37 | "probably absolute filename too long (>%d bytes). " 38 | "move to a higher level directory.\n", (int) sizeof cwdbuf); 39 | return 1; 40 | } 41 | char *bs = strrchr(filename, '/'); 42 | if (!bs) { 43 | printf("???\n"); 44 | return 1; 45 | } 46 | int pathsize = bs-filename; 47 | if (pathsize + 1 + relfilenamesize + 1 > sizeof filename) { 48 | printf("absolute pathname too long (>%d bytes). " 49 | "move to a higher level directory.\n", (int) sizeof cwdbuf); 50 | return 1; 51 | } 52 | strcpy(bs+1, relfilename); 53 | printf("filename = %s\n", filename); 54 | struct stat s; 55 | if (stat(filename, &s)) { 56 | printf("can't stat file '%s': %s\n", filename, strerror(errno)); 57 | return 1; 58 | } 59 | if (s.st_uid != 0) { 60 | printf("script '%s' must be owned by root (UID %d instead)\n", filename, s.st_uid); 61 | return 1; 62 | } 63 | if (s.st_mode & S_IWGRP) { 64 | printf("script '%s' must not be group-writable\n", filename); 65 | return 1; 66 | } 67 | if (s.st_mode & S_IWOTH) { 68 | printf("script '%s' must not be world-writable\n", filename); 69 | return 1; 70 | } 71 | execl("/bin/sh", "/bin/sh", filename, (char*)NULL); 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /scripts/ifppc_up: -------------------------------------------------------------------------------- 1 | # 2 | # BE CAREFUL. THIS SCRIPT IS INVOKED BY A SETUID ROOT BINARY! 3 | # IT SHOULD BE OWNED BY ROOT. 4 | # ONLY ROOT SHOULD HAVE WRITE-ACCESS TO THIS FILE. 5 | # 6 | echo UID=$UID 7 | 8 | . ./scripts/settings 9 | 10 | #if [ $BRIDGE ]; then 11 | # touch $PPC_INTERFACE.active 12 | # ifconfig $BRIDGE_INTERFACE 1>/dev/null 2>&1 13 | # if [ $? != 0 ]; then 14 | # ifconfig $HOST_INTERFACE 0.0.0.0 15 | # ifconfig $PPC_INTERFACE 0.0.0.0 16 | # brctl addbr $BRIDGE_INTERFACE 17 | # brctl addif $BRIDGE_INTERFACE $HOST_INTERFACE 18 | # brctl addif $BRIDGE_INTERFACE $PPC_INTERFACE 19 | # ifconfig $BRIDGE_INTERFACE $HOST_IP netmask $HOST_NETMASK up 20 | # route add -net default gw $HOST_DEFAULT_ROUTER 21 | # else 22 | # ifconfig $PPC_INTERFACE 0.0.0.0 23 | # brctl addif $BRIDGE_INTERFACE $PPC_INTERFACE 24 | # fi 25 | #else 26 | PPC_NETMASK="255.255.255.0" 27 | PPC_HOST_IP="192.168.1.80" 28 | PPC_CLIENT_IP="192.168.1.1" 29 | /sbin/ifconfig $PPC_INTERFACE $PPC_HOST_IP netmask $PPC_NETMASK up &&\ 30 | /sbin/iptables -t nat -s $PPC_CLIENT_IP -A POSTROUTING -j MASQUERADE &&\ 31 | echo 1 > /proc/sys/net/ipv4/ip_forward 32 | #fi 33 | -------------------------------------------------------------------------------- /scripts/ifppc_up.beos: -------------------------------------------------------------------------------- 1 | # 2 | # BE CAREFUL. THIS SCRIPT IS INVOKED BY A SETUID ROOT BINARY! 3 | # IT SHOULD BE OWNED BY ROOT. 4 | # ONLY ROOT SHOULD HAVE WRITE-ACCESS TO THIS FILE. 5 | # 6 | echo UID=$UID 7 | PPC_NETMASK="255.255.255.0" 8 | PPC_HOST_IP="192.168.1.80" 9 | PPC_CLIENT_IP="192.168.1.81" 10 | /bin/ifconfig $PPC_INTERFACE $PPC_HOST_IP nm $PPC_NETMASK up >/dev/null 11 | -------------------------------------------------------------------------------- /scripts/ifppc_up.setuid.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int canonicalize(char *buf, int bufsize, char *cwd, char *fn) 9 | { 10 | int cwdsize = strlen(cwd); 11 | int fnsize = strlen(fn); 12 | if (fn[0] == '/') { 13 | if (fnsize +1 > bufsize) return ERANGE; 14 | strcpy(buf, fn); 15 | return 0; 16 | } 17 | if (cwdsize + 1 + fnsize + 1 > bufsize) return ERANGE; 18 | strcpy(buf, cwd); 19 | strcat(buf, "/"); 20 | strcat(buf, fn); 21 | return 0; 22 | } 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | setuid(0); 27 | const char *relfilename = "ifppc_up"; 28 | int relfilenamesize = strlen(relfilename); 29 | char cwdbuf[2048]; 30 | if (!getcwd(cwdbuf, sizeof cwdbuf)) { 31 | printf("CWD name too long (>%d bytes). move to a higher level directory.\n", (int)sizeof cwdbuf); 32 | return 1; 33 | } 34 | char filename[2048+128]; 35 | if (canonicalize(filename, sizeof filename, cwdbuf, argv[0])) { 36 | printf("unable to determine absolute executable filename. " 37 | "probably absolute filename too long (>%d bytes). " 38 | "move to a higher level directory.\n", (int)sizeof cwdbuf); 39 | return 1; 40 | } 41 | char *bs = strrchr(filename, '/'); 42 | if (!bs) { 43 | printf("???\n"); 44 | return 1; 45 | } 46 | int pathsize = bs-filename; 47 | if (pathsize + 1 + relfilenamesize + 1 > sizeof filename) { 48 | printf("absolute pathname too long (>%d bytes). " 49 | "move to a higher level directory.\n", (int)sizeof cwdbuf); 50 | return 1; 51 | } 52 | strcpy(bs+1, relfilename); 53 | // printf("filename = %s, uid=%d, euid=%d\n", filename, getuid(), geteuid()); 54 | struct stat s; 55 | if (stat(filename, &s)) { 56 | printf("can't stat file '%s': %s\n", filename, strerror(errno)); 57 | return 1; 58 | } 59 | if (s.st_uid != 0) { 60 | printf("script '%s' must be owned by root (UID %d instead)\n", filename, s.st_uid); 61 | return 1; 62 | } 63 | if (s.st_mode & S_IWGRP) { 64 | printf("script '%s' must not be group-writable\n", filename); 65 | return 1; 66 | } 67 | if (s.st_mode & S_IWOTH) { 68 | printf("script '%s' must not be world-writable\n", filename); 69 | return 1; 70 | } 71 | execl("/bin/sh", "/bin/sh", filename, (char*)NULL); 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /scripts/settings: -------------------------------------------------------------------------------- 1 | BRIDGE=1 2 | BRIDGE_INTERFACE=br1 3 | HOST_INTERFACE=eth0 4 | HOST_IP=192.168.88.120 5 | HOST_NETMASK=255.255.255.0 6 | HOST_DEFAULT_ROUTER=192.168.88.1 7 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | ppc 5 | *.o 6 | *.a 7 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | bin_PROGRAMS = ppc 4 | 5 | SUBDIRS = cpu debug io system tools 6 | 7 | AM_CPPFLAGS = 8 | 9 | if USE_UI_WIN32 10 | ppc_RES = system/ui/@UI_DIR@/resources.o 11 | else 12 | ppc_RES = 13 | endif 14 | 15 | ppc_LDADD = io/graphic/libgraphic.a \ 16 | io/ide/libide.a system/ui/@UI_DIR@/libui.a \ 17 | io/libio.a io/prom/libprom.a \ 18 | io/prom/fs/libfs.a io/prom/fs/hfs/libhfs.a io/prom/fs/hfsplus/libhfsplus.a \ 19 | io/pic/libpic.a io/pci/libpci.a io/macio/libmacio.a io/nvram/libnvram.a \ 20 | io/cuda/libcuda.a io/3c90x/lib3c90x.a io/rtl8139/librtl8139.a io/usb/libusb.a \ 21 | io/serial/libserial.a cpu/@CPU_DIR@/libcpu.a debug/libdebug.a \ 22 | tools/libtools.a system/libsystem.a \ 23 | system/arch/@ARCH_DIR@/libsarch.a \ 24 | system/osapi/@OSAPI_DIR@/libsosapi.a $(ppc_RES) @PPC_LDADD@ 25 | 26 | ppc_LDFLAGS = @PPC_LDFLAGS@ 27 | 28 | ppc_SOURCES = main.cc info.h ppc_img.c ppc_img.h \ 29 | ppc_font.c ppc_font.h ppc_button_changecd.c ppc_button_changecd.h \ 30 | configparser.cc configparser.h 31 | 32 | dist2: distdir 33 | $(AMTAR) chof - $(distdir) | BZIP2=$(BZIP2_ENV) bzip2 -c >$(distdir).tar.bz2 34 | $(am__remove_distdir) 35 | 36 | dist-all2: dist2 37 | -------------------------------------------------------------------------------- /src/cpu/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/cpu/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | if USE_CPU_GENERIC 4 | THE_ARCH_DIR=cpu_generic 5 | endif 6 | 7 | if USE_CPU_JITC_X86 8 | THE_ARCH_DIR=cpu_jitc_x86 9 | endif 10 | 11 | if USE_CPU_JITC_X86_64 12 | THE_ARCH_DIR=cpu_jitc_x86_64 13 | endif 14 | 15 | EXTRA_DIST = cpu.h debug.h mem.h common.h 16 | 17 | SUBDIRS = $(THE_ARCH_DIR) 18 | EXTRA_SUBDIRS = cpu_jitc_generic cpu_jitc_x86 cpu_jitc_x86_64 19 | 20 | AM_CPPFLAGS = -I .. 21 | -------------------------------------------------------------------------------- /src/cpu/cpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * cpu.h 4 | * 5 | * Copyright (C) 2003, 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __CPU_H__ 22 | #define __CPU_H__ 23 | 24 | #include "system/types.h" 25 | 26 | uint64 ppc_get_clock_frequency(int cpu); 27 | uint64 ppc_get_bus_frequency(int cpu); 28 | uint64 ppc_get_timebase_frequency(int cpu); 29 | 30 | bool ppc_cpu_init(); 31 | void ppc_cpu_init_config(); 32 | 33 | void ppc_cpu_stop(); 34 | void ppc_cpu_wakeup(); 35 | 36 | void ppc_machine_check_exception(); 37 | 38 | void ppc_cpu_raise_ext_exception(); 39 | void ppc_cpu_cancel_ext_exception(); 40 | 41 | /* 42 | * May only be called from within a CPU thread. 43 | */ 44 | 45 | void ppc_cpu_run(); 46 | uint32 ppc_cpu_get_gpr(int cpu, int i); 47 | void ppc_cpu_set_gpr(int cpu, int i, uint32 newvalue); 48 | void ppc_cpu_set_msr(int cpu, uint32 newvalue); 49 | void ppc_cpu_set_pc(int cpu, uint32 newvalue); 50 | uint32 ppc_cpu_get_pc(int cpu); 51 | uint32 ppc_cpu_get_pvr(int cpu); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/cpu/cpu_generic/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | *.o 5 | *.a 6 | -------------------------------------------------------------------------------- /src/cpu/cpu_generic/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libcpu.a 4 | 5 | libcpu_a_SOURCES = ppc_alu.cc ppc_alu.h ppc_cpu.cc ppc_cpu.h \ 6 | ppc_dec.cc ppc_dec.h ppc_exc.cc ppc_exc.h ppc_fpu.cc ppc_fpu.h \ 7 | ppc_mmu.cc ppc_mmu.h ppc_opc.cc ppc_opc.h ppc_tools.h ppc_vec.h ppc_vec.cc 8 | 9 | AM_CPPFLAGS = -I../.. 10 | -------------------------------------------------------------------------------- /src/cpu/cpu_generic/ppc_opc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * ppc_opc.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PPC_OPC_H__ 22 | #define __PPC_OPC_H__ 23 | 24 | #include "system/types.h" 25 | 26 | static inline void ppc_update_cr0(uint32 r) 27 | { 28 | gCPU.cr &= 0x0fffffff; 29 | if (!r) { 30 | gCPU.cr |= CR_CR0_EQ; 31 | } else if (r & 0x80000000) { 32 | gCPU.cr |= CR_CR0_LT; 33 | } else { 34 | gCPU.cr |= CR_CR0_GT; 35 | } 36 | if (gCPU.xer & XER_SO) gCPU.cr |= CR_CR0_SO; 37 | } 38 | 39 | void ppc_opc_bx(); 40 | void ppc_opc_bcx(); 41 | void ppc_opc_bcctrx(); 42 | void ppc_opc_bclrx(); 43 | 44 | void ppc_opc_dcba(); 45 | void ppc_opc_dcbf(); 46 | void ppc_opc_dcbi(); 47 | void ppc_opc_dcbst(); 48 | void ppc_opc_dcbt(); 49 | void ppc_opc_dcbtst(); 50 | 51 | void ppc_opc_eciwx(); 52 | void ppc_opc_ecowx(); 53 | void ppc_opc_eieio(); 54 | 55 | void ppc_opc_icbi(); 56 | void ppc_opc_isync(); 57 | 58 | void ppc_opc_mcrf(); 59 | void ppc_opc_mcrfs(); 60 | void ppc_opc_mcrxr(); 61 | void ppc_opc_mfcr(); 62 | void ppc_opc_mffsx(); 63 | void ppc_opc_mfmsr(); 64 | void ppc_opc_mfspr(); 65 | void ppc_opc_mfsr(); 66 | void ppc_opc_mfsrin(); 67 | void ppc_opc_mftb(); 68 | void ppc_opc_mtcrf(); 69 | void ppc_opc_mtfsb0x(); 70 | void ppc_opc_mtfsb1x(); 71 | void ppc_opc_mtfsfx(); 72 | void ppc_opc_mtfsfix(); 73 | void ppc_opc_mtmsr(); 74 | void ppc_opc_mtspr(); 75 | void ppc_opc_mtsr(); 76 | void ppc_opc_mtsrin(); 77 | 78 | void ppc_opc_rfi(); 79 | void ppc_opc_sc(); 80 | void ppc_opc_sync(); 81 | void ppc_opc_tlbia(); 82 | void ppc_opc_tlbie(); 83 | void ppc_opc_tlbsync(); 84 | void ppc_opc_tw(); 85 | void ppc_opc_twi(); 86 | 87 | 88 | #endif 89 | 90 | -------------------------------------------------------------------------------- /src/cpu/cpu_generic/ppc_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * ppc_tools.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PPC_TOOLS_H__ 22 | #define __PPC_TOOLS_H__ 23 | 24 | #include "system/types.h" 25 | 26 | static inline FUNCTION_CONST bool ppc_carry_3(uint32 a, uint32 b, uint32 c) 27 | { 28 | if ((a+b) < a) { 29 | return true; 30 | } 31 | if ((a+b+c) < c) { 32 | return true; 33 | } 34 | return false; 35 | } 36 | 37 | static inline FUNCTION_CONST uint32 ppc_word_rotl(uint32 data, int n) 38 | { 39 | n &= 0x1f; 40 | return (data << n) | (data >> (32-n)); 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | SUFFIXES = .asm .o 4 | 5 | noinst_LIBRARIES = libcpu.a 6 | 7 | libcpu_a_SOURCES = ppc_alu.cc ppc_alu.h ppc_cpu.cc ppc_cpu.h \ 8 | ppc_dec.cc ppc_dec.h ppc_esc.cc ppc_esc.h ppc_exc.cc ppc_exc.h \ 9 | ppc_fpu.cc ppc_fpu.h ppc_mmu.cc ppc_mmu.h ppc_opc.cc ppc_opc.h \ 10 | ppc_vec.h ppc_vec.cc ppc_tools.h jitc.cc jitc.h jitc_debug.cc jitc_debug.h \ 11 | jitc_types.h jitc_mmu.S jitc_tools.S x86asm.cc x86asm.h jitc_asm.h 12 | 13 | AM_CPPFLAGS = -I ../.. 14 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86/jitc_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * jitc_debug.h 4 | * 5 | * Copyright (C) 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __JITC_DEBUG_H__ 22 | #define __JITC_DEBUG_H__ 23 | 24 | //#define JITC_DEBUG 25 | 26 | static inline UNUSED uint64 jitcDebugGetTicks() 27 | { 28 | uint32 s0, s1; 29 | asm("rdtsc" : "=a" (s0), "=d" (s1)); 30 | return ((uint64)s1)<<32 | s0; 31 | } 32 | 33 | #ifdef JITC_DEBUG 34 | 35 | void jitcDebugLogNewInstruction(); 36 | void jitcDebugLogEmit(const byte *insn, int size); 37 | void jitcDebugLogAdd(const char *fmt, ...); 38 | 39 | void jitcDebugInit(); 40 | void jitcDebugDone(); 41 | 42 | #else 43 | 44 | static inline UNUSED void jitcDebugLogNewInstruction() 45 | { 46 | } 47 | static inline UNUSED void jitcDebugLogEmit(const byte *insn, int size) 48 | { 49 | } 50 | static inline UNUSED void jitcDebugLogAdd(const char *fmt, ...) 51 | { 52 | } 53 | static inline UNUSED void jitcDebugInit() 54 | { 55 | } 56 | static inline UNUSED void jitcDebugDone() 57 | { 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86/jitc_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * jitc_types.h 4 | * 5 | * Copyright (C) 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __JITC_TYPES_H__ 22 | #define __JITC_TYPES_H__ 23 | 24 | #include "system/types.h" 25 | 26 | /* 27 | * This refers to (code) addresses in the host computer 28 | * They have to be in the translation cache. 29 | */ 30 | typedef byte *NativeAddress; 31 | 32 | /* 33 | * This is the return type of opcode generation functions 34 | */ 35 | enum JITCFlow { 36 | flowContinue, 37 | flowEndBlock, 38 | flowEndBlockUnreachable, 39 | }; 40 | 41 | typedef void (*ppc_opc_function)(); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86/ppc_esc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * ppc_dec.h 4 | * 5 | * Copyright (C) 2003, 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PPC_ESC_H__ 22 | #define __PPC_ESC_H__ 23 | 24 | #include "system/types.h" 25 | 26 | #define PPC_OPC_ESCAPE_VM 0x0069BABE 27 | 28 | #define PPC_ESCAPE_IF_VERSION 0 29 | 30 | // values for r3 31 | #define PPC_INTERN_VERSION 0 32 | 33 | #define PPC_INTERN_MEMSET 1 34 | #define PPC_INTERN_MEMCPY 2 35 | #define PPC_INTERN_BZERO 3 36 | #define PPC_INTERN_BZERO_PHYS 4 37 | #define PPC_INTERN_BCOPY 5 38 | #define PPC_INTERN_BCOPY_PHYS 6 39 | #define PPC_INTERN_BCOPY_PHYSVIR 7 40 | #define PPC_INTERN_COPY_PAGE 8 41 | 42 | 43 | void FASTCALL ppc_escape_vm(uint32 func, uint32 *esp, uint32 client_pc); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86/ppc_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * ppc_tools.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PPC_TOOLS_H__ 22 | #define __PPC_TOOLS_H__ 23 | 24 | #include "system/arch/sysendian.h" 25 | 26 | static inline __attribute__((const)) bool ppc_carry_3(uint32 a, uint32 b, uint32 c) 27 | { 28 | register uint8 t; 29 | asm ( 30 | "addl %2, %1\n\t" 31 | "setc %0\n\t" 32 | "addl %3, %1\n\t" 33 | "adcb $0, %0" 34 | : "=&q" (t), "+&r" (a) 35 | : "g" (b), "g" (c) 36 | ); 37 | return t; 38 | } 39 | /* 40 | equivalent C-construction: 41 | static inline __attribute__((const)) bool ppc_carry_3(uint32 a, uint32 b, uint32 c) 42 | { 43 | if ((a+b) < a) { 44 | return true; 45 | } 46 | if ((a+b+c) < c) { 47 | return true; 48 | } 49 | return false; 50 | } 51 | */ 52 | 53 | static inline __attribute__((const)) uint32 ppc_word_rotl(uint32 data, int n) 54 | { 55 | n &= 0x1f; 56 | return (data << n) | (data >> (32-n)); 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86_64/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86_64/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | SUFFIXES = .asm .o 4 | 5 | noinst_LIBRARIES = libcpu.a 6 | 7 | libcpu_a_SOURCES = ppc_alu.cc ppc_alu.h ppc_cpu.cc ppc_cpu.h \ 8 | ppc_dec.cc ppc_dec.h ppc_esc.cc ppc_esc.h ppc_exc.cc ppc_exc.h \ 9 | ppc_fpu.cc ppc_fpu.h ppc_mmu.cc ppc_mmu.h ppc_opc.cc ppc_opc.h \ 10 | ppc_vec.h ppc_vec.cc ppc_tools.h jitc.cc jitc.h jitc_debug.cc jitc_debug.h \ 11 | jitc_types.h jitc_mmu.S jitc_tools.S x86_64asm.cc x86_64asm.h jitc_asm.h \ 12 | jitc_common.h 13 | 14 | AM_CPPFLAGS = -I ../.. 15 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86_64/jitc_debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * jitc_debug.h 4 | * 5 | * Copyright (C) 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __JITC_DEBUG_H__ 22 | #define __JITC_DEBUG_H__ 23 | 24 | #define JITC_DEBUG 25 | 26 | static inline UNUSED uint64 jitcDebugGetTicks() 27 | { 28 | uint32 s0, s1; 29 | asm("rdtsc" : "=a" (s0), "=d" (s1)); 30 | return ((uint64)s1)<<32 | s0; 31 | } 32 | 33 | #ifdef JITC_DEBUG 34 | 35 | void jitcDebugLogNewInstruction(JITC &jitc); 36 | void jitcDebugLogEmit(JITC &jitc, const byte *insn, int size); 37 | void jitcDebugLogAdd(const char *fmt, ...); 38 | 39 | void jitcDebugInit(); 40 | void jitcDebugDone(); 41 | 42 | #else 43 | 44 | static inline UNUSED void jitcDebugLogNewInstruction(JITC &jitc) 45 | { 46 | } 47 | static inline UNUSED void jitcDebugLogEmit(JITC &jitc, const byte *insn, int size) 48 | { 49 | } 50 | static inline UNUSED void jitcDebugLogAdd(const char *fmt, ...) 51 | { 52 | } 53 | static inline UNUSED void jitcDebugInit() 54 | { 55 | } 56 | static inline UNUSED void jitcDebugDone() 57 | { 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86_64/jitc_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * jitc_types.h 4 | * 5 | * Copyright (C) 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __JITC_TYPES_H__ 22 | #define __JITC_TYPES_H__ 23 | 24 | #include "system/types.h" 25 | 26 | /* 27 | * This refers to (code) addresses in the host computer 28 | * They have to be in the translation cache. 29 | */ 30 | typedef byte *NativeAddress; 31 | 32 | /* 33 | * This is the return type of opcode generation functions 34 | */ 35 | enum JITCFlow { 36 | flowContinue, 37 | flowEndBlock, 38 | flowEndBlockUnreachable, 39 | }; 40 | 41 | struct PPC_CPU_State; 42 | struct JITC; 43 | 44 | typedef JITCFlow (*ppc_opc_gen_function)(JITC &aJITC); 45 | typedef void (*ppc_opc_function)(PPC_CPU_State &aCPU); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86_64/ppc_esc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * ppc_dec.h 4 | * 5 | * Copyright (C) 2003, 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PPC_ESC_H__ 22 | #define __PPC_ESC_H__ 23 | 24 | #include "system/types.h" 25 | 26 | #define PPC_OPC_ESCAPE_VM 0x0069BABE 27 | 28 | #define PPC_ESCAPE_IF_VERSION 0 29 | 30 | // values for r3 31 | #define PPC_INTERN_VERSION 0 32 | 33 | #define PPC_INTERN_MEMSET 1 34 | #define PPC_INTERN_MEMCPY 2 35 | #define PPC_INTERN_BZERO 3 36 | #define PPC_INTERN_BZERO_PHYS 4 37 | #define PPC_INTERN_BCOPY 5 38 | #define PPC_INTERN_BCOPY_PHYS 6 39 | #define PPC_INTERN_BCOPY_PHYSVIR 7 40 | #define PPC_INTERN_COPY_PAGE 8 41 | 42 | 43 | void FASTCALL ppc_escape_vm(PPC_CPU_State &aCPU, uint32 func, uint64 *rsp, uint32 client_pc); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/cpu/cpu_jitc_x86_64/ppc_tools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * ppc_tools.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PPC_TOOLS_H__ 22 | #define __PPC_TOOLS_H__ 23 | 24 | #include "system/arch/sysendian.h" 25 | 26 | static inline __attribute__((const)) bool ppc_carry_3(uint32 a, uint32 b, uint32 c) 27 | { 28 | uint8 t; 29 | asm ( 30 | "addl %2, %1\n\t" 31 | "setc %0\n\t" 32 | "addl %3, %1\n\t" 33 | "adcb $0, %0" 34 | : "=&q" (t), "+&r" (a) 35 | : "g" (b), "g" (c) 36 | ); 37 | return t; 38 | } 39 | /* 40 | equivalent C-construction: 41 | static inline __attribute__((const)) bool ppc_carry_3(uint32 a, uint32 b, uint32 c) 42 | { 43 | if ((a+b) < a) { 44 | return true; 45 | } 46 | if ((a+b+c) < c) { 47 | return true; 48 | } 49 | return false; 50 | } 51 | */ 52 | 53 | static inline __attribute__((const)) uint32 ppc_word_rotl(uint32 data, int n) 54 | { 55 | n &= 0x1f; 56 | return (data << n) | (data >> (32-n)); 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/cpu/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * debug.h 4 | * 5 | * Copyright (C) 2003, 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __DEBUG_H__ 22 | #define __DEBUG_H__ 23 | 24 | #include "system/types.h" 25 | 26 | /* 27 | * Debugger Interface 28 | */ 29 | void ppc_set_singlestep_v(bool v, const char *file, int line, const char *infoformat, ...); 30 | void ppc_set_singlestep_nonverbose(bool v); 31 | 32 | #define SINGLESTEP(info...) ppc_set_singlestep_v(true, __FILE__, __LINE__, info) 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/cpu/mem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * mem.h 4 | * 5 | * Copyright (C) 2003, 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __MEM_H__ 22 | #define __MEM_H__ 23 | 24 | #include "system/types.h" 25 | 26 | bool FASTCALL ppc_init_physical_memory(uint size); 27 | 28 | uint32 ppc_get_memory_size(); 29 | 30 | bool ppc_dma_write(uint32 dest, const void *src, uint32 size); 31 | bool ppc_dma_read(void *dest, uint32 src, uint32 size); 32 | bool ppc_dma_set(uint32 dest, int c, uint32 size); 33 | 34 | void ppc_cpu_map_framebuffer(uint32 pa, uint32 ea); 35 | 36 | /* 37 | * These functions will be removed once we switch to openbios. 38 | */ 39 | 40 | bool DEPRECATED ppc_prom_set_sdr1(uint32 newval, bool quiesce); 41 | bool DEPRECATED ppc_prom_effective_to_physical(uint32 &result, uint32 ea); 42 | bool DEPRECATED ppc_prom_page_create(uint32 ea, uint32 pa); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /src/debug/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | debugparse.c 5 | debugparse.h 6 | lex.c 7 | *.o 8 | *.a 9 | -------------------------------------------------------------------------------- /src/debug/Makefile.am: -------------------------------------------------------------------------------- 1 | YFLAGS=-d 2 | 3 | LFLAGS= 4 | 5 | AUTOMAKE_OPTIONS = foreign 6 | 7 | noinst_LIBRARIES = libdebug.a 8 | 9 | libdebug_a_SOURCES = asm.cc asm.h ppcdis.cc ppcdis.h ppcopc.cc ppcopc.h tracers.h \ 10 | debugparse.y debugtype.h lex.l lex.h parsehelper.c parsehelper.h debugger.cc debugger.h \ 11 | stdfuncs.cc stdfuncs.h debugparse.h x86opc.cc x86opc.h x86dis.cc x86dis.h 12 | 13 | AM_CPPFLAGS = -I .. 14 | -------------------------------------------------------------------------------- /src/debug/lex.h: -------------------------------------------------------------------------------- 1 | #ifndef __LEX_H__ 2 | #define __LEX_H__ 3 | 4 | void *lex_current_buffer(); 5 | int lex_current_buffer_pos(); 6 | void lex_switch_buffer(void *buffer); 7 | void lex_delete_buffer(void *buffer); 8 | void *lex_scan_string_buffer(const char *str); 9 | 10 | int yylex(); 11 | 12 | #endif /* __LEX_H__ */ 13 | -------------------------------------------------------------------------------- /src/debug/parsehelper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * parsehelper.h 4 | * 5 | * Copyright (C) 2003 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PARSEHELPER_H__ 22 | #define __PARSEHELPER_H__ 23 | 24 | /*#define EVAL_DEBUG*/ 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif /* __cplusplus */ 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "debugtype.h" 37 | 38 | #include "lex.h" 39 | 40 | /* 41 | * 42 | */ 43 | 44 | #define MAX_FUNCNAME_LEN 16 45 | #define MAX_SYMBOLNAME_LEN 32 46 | #define MAX_ERRSTR_LEN 128 47 | 48 | /* 49 | * ERROR HANDLING 50 | */ 51 | void clear_eval_error(); 52 | int get_eval_error(char **str, int *pos); 53 | void set_eval_error(char *errmsg); 54 | 55 | /* 56 | * SCALARLIST 57 | */ 58 | void scalarlist_set(struct eval_scalarlist *l, struct eval_scalar *s); 59 | void scalarlist_concat(struct eval_scalarlist *l, struct eval_scalarlist *a, struct eval_scalarlist *b); 60 | void scalarlist_destroy(struct eval_scalarlist *l); 61 | void scalarlist_destroy_flat(struct eval_scalarlist *l); 62 | 63 | /* 64 | * 65 | */ 66 | void create_command(struct eval_command *result, eval_commandtype type, int args, ...); 67 | void create_func_call(struct eval_scalar *result, const char *name, int args, ...); 68 | void create_func_call_list(struct eval_scalar *result, const char *name, struct eval_scalarlist *args); 69 | 70 | /* 71 | * SCALAR 72 | */ 73 | void scalar_destroy(struct eval_scalar *s); 74 | 75 | int eval_parse(struct eval_command *r, const char *str); 76 | 77 | #ifdef __cplusplus 78 | } 79 | #endif /* __cplusplus */ 80 | 81 | #endif /* __PARSEHELPER_H__ */ 82 | -------------------------------------------------------------------------------- /src/debug/ppcdis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * ppcdis.h 4 | * 5 | * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PPC_DIS_H__ 22 | #define __PPC_DIS_H__ 23 | 24 | #include "system/types.h" 25 | #include "asm.h" 26 | #include "ppcopc.h" 27 | 28 | struct ppcdis_operand { 29 | int flags; 30 | const powerpc_operand *op; 31 | union { 32 | int reg; // general register 33 | int freg; // float register 34 | int creg; // condition register 35 | int vreg; // vector register 36 | uint64 imm; 37 | struct { 38 | uint64 disp; 39 | int gr; 40 | } mem; 41 | struct { 42 | uint64 mem; 43 | } abs; 44 | struct { 45 | uint64 mem; 46 | } rel; 47 | }; 48 | }; 49 | 50 | struct ppcdis_insn { 51 | bool valid; 52 | int size; 53 | const char * name; 54 | uint32 data; 55 | int ops; 56 | ppcdis_operand op[8]; 57 | }; 58 | 59 | #define PPC_MODE_32 0 60 | #define PPC_MODE_64 1 61 | 62 | class PPCDisassembler: public Disassembler { 63 | protected: 64 | char insnstr[256]; 65 | ppcdis_insn insn; 66 | int mode; 67 | public: 68 | PPCDisassembler(int mode); 69 | 70 | virtual dis_insn *decode(const byte *code, int maxlen, CPU_ADDR addr); 71 | virtual dis_insn *duplicateInsn(dis_insn *disasm_insn); 72 | virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align); 73 | virtual byte getSize(dis_insn *disasm_insn); 74 | virtual const char *getName(); 75 | virtual const char *str(dis_insn *disasm_insn, int style); 76 | virtual const char *strf(dis_insn *disasm_insn, int style, const char *format); 77 | virtual bool validInsn(dis_insn *disasm_insn); 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/debug/stdfuncs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * stdfuncs.h 4 | * 5 | * Copyright (C) 2003 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __STDFUNCS_H__ 22 | #define __STDFUNCS_H__ 23 | 24 | #include "debugger.h" 25 | 26 | #define FUNCTION_MAX_DECL_PARAMS 8 27 | 28 | typedef Function *(*FunctionCreator)(); 29 | 30 | struct FunctionDesc { 31 | const char *name; 32 | int declparam_count; 33 | EvalType declparam[FUNCTION_MAX_DECL_PARAMS]; 34 | FunctionCreator creator; 35 | }; 36 | 37 | extern FunctionDesc gStdEvalFunctions[]; 38 | 39 | #endif /* __STDFUNCS_H__ */ 40 | -------------------------------------------------------------------------------- /src/info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * info.h 4 | * 5 | * Copyright (C) 2003-2005 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __INFO_H__ 22 | #define __INFO_H__ 23 | 24 | #define APPNAME "PearPC" 25 | #define APPVERSION "0.6pre" 26 | // this will show up in the win32 version resource: 27 | #define APPVERSION_IN_NUMBERS 0,0,6,0 28 | 29 | #define EMULATOR_MODEL "PowerPC (" APPNAME " " APPVERSION ")" 30 | #define COPYRIGHT "(c) 2003-2015 Sebastian Biallas " 31 | 32 | //#define PPC_CPU_ENABLE_SINGLESTEP 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /src/io/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/3c90x/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/3c90x/3c90x.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * 3c90x.h 4 | * 5 | * Copyright (C) 2003 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __IO_3C90X_H__ 22 | #define __IO_3C90X_H__ 23 | 24 | extern bool _3c90x_installed; 25 | void _3c90x_init(); 26 | void _3c90x_done(); 27 | void _3c90x_init_config(); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/io/3c90x/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = lib3c90x.a 4 | 5 | lib3c90x_a_SOURCES = 3c90x.cc 3c90x.h 6 | 7 | AM_CPPFLAGS = -I ../.. 8 | 9 | -------------------------------------------------------------------------------- /src/io/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | 4 | noinst_LIBRARIES = libio.a 5 | libio_a_SOURCES = io.cc io.h 6 | 7 | SUBDIRS = 3c90x rtl8139 prom graphic pic cuda pci ide macio nvram usb serial 8 | 9 | AM_CPPFLAGS = -I .. 10 | -------------------------------------------------------------------------------- /src/io/cuda/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/cuda/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libcuda.a 4 | 5 | libcuda_a_SOURCES = cuda.cc cuda.h 6 | 7 | AM_CPPFLAGS = -I ../.. 8 | -------------------------------------------------------------------------------- /src/io/cuda/cuda.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * cuda.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __IO_CUDA_H__ 22 | #define __IO_CUDA_H__ 23 | 24 | #include "system/types.h" 25 | 26 | #define IO_CUDA_PA_START 0x80816000 27 | #define IO_CUDA_PA_END 0x80817E00 28 | 29 | void cuda_write(uint32 addr, uint32 data, int size); 30 | void cuda_read(uint32 addr, uint32 &data, int size); 31 | bool cuda_interrupt(); 32 | 33 | void cuda_init(); 34 | void cuda_pre_init(); 35 | void cuda_done(); 36 | void cuda_init_config(); 37 | 38 | bool cuda_prom_get_key(uint32 &key); 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /src/io/graphic/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/graphic/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libgraphic.a 4 | 5 | libgraphic_a_SOURCES = gcard.cc gcard.h 6 | 7 | AM_CPPFLAGS = -I ../.. 8 | -------------------------------------------------------------------------------- /src/io/ide/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/ide/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libide.a 4 | 5 | libide_a_SOURCES = ide.cc ide.h idedevice.cc idedevice.h ata.cc ata.h cd.cc \ 6 | cd.h scsicmds.h 7 | 8 | AM_CPPFLAGS = -I ../.. 9 | -------------------------------------------------------------------------------- /src/io/ide/ata.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * ata.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __ATA_H__ 22 | #define __ATA_H__ 23 | 24 | #include "system/file.h" 25 | #include "idedevice.h" 26 | 27 | // Flags for IDEDevice::mMode 28 | #define ATA_DEVICE_MODE_PLAIN 0 // just a 512 byte sector 29 | #define ATA_DEVICE_MODE_ECC 1 // add 4 byte ECC 30 | 31 | class ATADevice: public IDEDevice { 32 | public: 33 | int mCyl; 34 | int mHeads; 35 | int mSpt; 36 | uint blocks; 37 | 38 | ATADevice(const char *name); 39 | virtual ~ATADevice(); 40 | void init(int aHeads, int aCyl, int mSpt); 41 | virtual uint getBlockSize(); 42 | virtual uint getBlockCount(); 43 | }; 44 | 45 | class ATADeviceFile: public ATADevice { 46 | SYS_FILE *mFile; 47 | public: 48 | ATADeviceFile(const char *name, const char *filename); 49 | virtual ~ATADeviceFile(); 50 | 51 | virtual bool seek(uint64 blockno); 52 | virtual void flush(); 53 | virtual int readBlock(byte *buf); 54 | virtual int writeBlock(byte *buf); 55 | 56 | virtual bool promSeek(uint64 pos); 57 | virtual uint promRead(byte *buf, uint size); 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /src/io/ide/ide.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * ide.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __IO_IDE_H__ 22 | #define __IO_IDE_H__ 23 | 24 | #include "system/types.h" 25 | #include "system/display.h" 26 | #include "idedevice.h" 27 | #include "cd.h" 28 | 29 | /* 30 | * IDE is handled by PCI and therefore has no base address 31 | */ 32 | 33 | enum IDEProtocol { 34 | IDE_ATA, 35 | IDE_ATAPI, 36 | }; 37 | 38 | struct IDEConfig { 39 | bool installed; 40 | IDEProtocol protocol; 41 | bool lba; 42 | union { 43 | struct { 44 | int cyl; 45 | int heads; 46 | int spt; 47 | } hd; 48 | struct { 49 | Sense sense; 50 | struct { 51 | uint8 command; 52 | int drq_bytes; 53 | int total_remain; 54 | } atapi; 55 | int next_lba; 56 | int remain; 57 | bool dma; 58 | } cdrom; 59 | }; 60 | int bps; 61 | IDEDevice *device; 62 | }; 63 | 64 | IDEConfig *ide_get_config(int disk); 65 | 66 | void ide_init(); 67 | void ide_done(); 68 | void ide_init_config(); 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /src/io/ide/idedevice.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * idedevice.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __IDEDEVICE_H__ 22 | #define __IDEDEVICE_H__ 23 | 24 | #include "system/systhread.h" 25 | #include "tools/data.h" 26 | #include "tools/stream.h" 27 | 28 | // The maximum size of a CD sector 29 | #define IDE_MAX_BLOCK_SIZE 2352 30 | 31 | class IDEDevice: public Object { 32 | protected: 33 | int mMode; // this is implementation specific 34 | bool mAcquired; 35 | sys_mutex mMutex; 36 | char *mName; 37 | /* only needed for deblocking read/write */ 38 | uint8 mSector[IDE_MAX_BLOCK_SIZE]; 39 | int mSectorFirst; // first valid byte 40 | int mSectorSize; 41 | char *mError; 42 | 43 | /* only for prom */ 44 | public: 45 | IDEDevice(const char *name); 46 | virtual ~IDEDevice(); 47 | bool acquire(); 48 | bool release(); 49 | virtual void setError(const char *error); 50 | virtual char * getError(); 51 | virtual uint getBlockSize() = 0; 52 | virtual uint getBlockCount() = 0; 53 | virtual bool seek(uint64 blockno) = 0; 54 | virtual void flush() = 0; 55 | void setMode(int aMode, int aSectorSize); 56 | /* these are deblocking read/writes */ 57 | virtual int read(byte *buf, int size); 58 | virtual int write(byte *buf, int size); 59 | /* these will always fetch a whole sector */ 60 | virtual int readBlock(byte *buf) = 0; 61 | virtual int writeBlock(byte *buf) = 0; 62 | /* only for prom */ 63 | virtual File * promGetRawFile(); 64 | virtual bool promSeek(uint64 pos) = 0; 65 | virtual uint promRead(byte *buf, uint size) = 0; 66 | 67 | virtual int toString(char *buf, int buflen) const; 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /src/io/macio/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/macio/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libmacio.a 4 | 5 | libmacio_a_SOURCES = macio.cc macio.h 6 | 7 | AM_CPPFLAGS = -I ../.. 8 | -------------------------------------------------------------------------------- /src/io/macio/macio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * macio.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __IO_MACIO_H__ 22 | #define __IO_MACIO_H__ 23 | 24 | #include "io/pci/pci.h" 25 | 26 | class PCI_MacIO: public PCI_Device { 27 | public: 28 | PCI_MacIO(); 29 | virtual bool readDeviceMem(uint r, uint32 address, uint32 &data, uint size); 30 | virtual bool writeDeviceMem(uint r, uint32 address, uint32 data, uint size); 31 | }; 32 | 33 | void macio_init(); 34 | void macio_done(); 35 | void macio_init_config(); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /src/io/nvram/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/nvram/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libnvram.a 4 | 5 | libnvram_a_SOURCES = nvram.cc nvram.h 6 | 7 | AM_CPPFLAGS = -I ../.. 8 | -------------------------------------------------------------------------------- /src/io/nvram/nvram.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * nvram.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __IO_NVRAM_H__ 22 | #define __IO_NVRAM_H__ 23 | 24 | #include "system/types.h" 25 | 26 | #define IO_NVRAM_PA_START 0x80860000 27 | #define IO_NVRAM_PA_END 0x80880000 28 | 29 | void nvram_write(uint32 addr, uint32 data, int size); 30 | void nvram_read(uint32 addr, uint32 &data, int size); 31 | 32 | void nvram_init(); 33 | void nvram_init_config(); 34 | void nvram_done(); 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /src/io/pci/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/pci/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libpci.a 4 | 5 | libpci_a_SOURCES = pci.cc pci.h 6 | 7 | AM_CPPFLAGS = -I ../.. 8 | -------------------------------------------------------------------------------- /src/io/pic/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/pic/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libpic.a 4 | 5 | libpic_a_SOURCES = pic.cc pic.h 6 | 7 | AM_CPPFLAGS = -I ../.. 8 | -------------------------------------------------------------------------------- /src/io/pic/pic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * pic.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __IO_PIC_H__ 22 | #define __IO_PIC_H__ 23 | 24 | #include "system/types.h" 25 | #include "system/display.h" 26 | 27 | #define IO_PIC_PA_START 0x80800000 28 | #define IO_PIC_PA_END 0x80800040 29 | 30 | /* 31 | * interrupts < 32 and in this mask are level'd (20 <= irq <= 28) 32 | * all other are of edge type 33 | */ 34 | #define IO_PIC_LEVEL_TYPE 0x1ff00000 35 | 36 | #define IO_PIC_IRQ_ETHERNET0 5 37 | #define IO_PIC_IRQ_ETHERNET1 7 38 | #define IO_PIC_IRQ_CUDA 18 39 | #define IO_PIC_IRQ_NMI_XMON 20 40 | #define IO_PIC_IRQ_GCARD 23 41 | #define IO_PIC_IRQ_IDE0 26 42 | #define IO_PIC_IRQ_USB 28 43 | 44 | void pic_write(uint32 addr, uint32 data, int size); 45 | void pic_read(uint32 addr, uint32 &data, int size); 46 | 47 | void pic_raise_interrupt(int intr); 48 | void pic_cancel_interrupt(int intr); 49 | 50 | void pic_init(); 51 | void pic_done(); 52 | void pic_init_config(); 53 | 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /src/io/prom/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/prom/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libprom.a 4 | 5 | SUBDIRS = fs 6 | 7 | libprom_a_SOURCES = prom.cc prom.h prommem.cc prommem.h fcode.cc fcode.h forth.cc \ 8 | forth.h forthtable.h forthtable.cc promboot.cc promboot.h promosi.cc promosi.h \ 9 | promdt.cc promdt.h 10 | 11 | AM_CPPFLAGS = -I ../.. 12 | -------------------------------------------------------------------------------- /src/io/prom/forthtable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * forthtable.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __FORTHTABLE_H__ 22 | #define __FORTHTABLE_H__ 23 | 24 | #include "tools/data.h" 25 | #include "forth.h" 26 | 27 | void forth_build_vocabulary(Container &dict, ForthVM &vm); 28 | void forth_disassemble(ForthVM &vm); 29 | #endif 30 | -------------------------------------------------------------------------------- /src/io/prom/fs/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/prom/fs/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libfs.a 4 | 5 | SUBDIRS = hfs hfsplus 6 | 7 | libfs_a_SOURCES = part.cc part.h hfs.cc hfs.h hfsglue.h hfsplus.cc hfsplus.h \ 8 | hfsplusglue.h hfsstruct.h fs.cc fs.h 9 | 10 | AM_CPPFLAGS = -I ../../.. 11 | -------------------------------------------------------------------------------- /src/io/prom/fs/fs.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * fs.cc 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include "fs.h" 22 | 23 | FileSystem::FileSystem(File *device) 24 | { 25 | mDevice = device; 26 | } 27 | -------------------------------------------------------------------------------- /src/io/prom/fs/fs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * fs.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __FS_H__ 22 | #define __FS_H__ 23 | 24 | #include "tools/data.h" 25 | #include "tools/stream.h" 26 | 27 | class FileSystem: public Object { 28 | protected: 29 | File *mDevice; 30 | public: 31 | FileSystem(File *device); 32 | /* new */ 33 | virtual File * open(const String &filename) = 0; 34 | virtual bool getBlessedPath(String &blessed) = 0; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * hfs.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __HFS_H__ 22 | #define __HFS_H__ 23 | 24 | #include "fs.h" 25 | #include "hfsglue.h" 26 | #include "part.h" 27 | 28 | bool tryBootHFS(File *aDevice, uint aDeviceBlocksize, FileOfs start, PartitionEntry *partEnt); 29 | 30 | /***/ 31 | class HFSFileSystem: public FileSystem { 32 | protected: 33 | hfs_devicehandle_s dh; 34 | void *hfshandle; 35 | 36 | public: 37 | HFSFileSystem(File *device, int partnum /* 1-based */); 38 | virtual ~HFSFileSystem(); 39 | /* extends FileSystem */ 40 | virtual File * open(const String &filename); 41 | virtual bool getBlessedPath(String &blessed); 42 | /* new */ 43 | virtual File * openBootFile(); 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libhfs.a 4 | 5 | libhfs_a_SOURCES = apple.h block.c block.h btree.c btree.h data.c data.h \ 6 | file.c file.h hfs.c hfs.h libhfs.h low.c low.h medium.c medium.h \ 7 | node.c node.h os.cc os.h record.c record.h version.c version.h volume.c volume.h 8 | 9 | AM_CPPFLAGS = -I ../../../.. 10 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/block.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | int b_init(hfsvol *); 22 | int b_flush(hfsvol *); 23 | int b_finish(hfsvol *); 24 | 25 | int b_readpb(hfsvol *, unsigned long, block *, unsigned int); 26 | int b_writepb(hfsvol *, unsigned long, const block *, unsigned int); 27 | 28 | int b_readlb(hfsvol *, unsigned long, block *); 29 | int b_writelb(hfsvol *, unsigned long, const block *); 30 | 31 | int b_readab(hfsvol *, unsigned int, unsigned int, block *); 32 | int b_writeab(hfsvol *, unsigned int, unsigned int, const block *); 33 | 34 | unsigned long b_size(hfsvol *); 35 | 36 | # ifdef DEBUG 37 | void b_showstats(const bcache *); 38 | void b_dumpcache(const bcache *); 39 | # endif 40 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/btree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | int bt_getnode(node *, btree *, unsigned long); 22 | int bt_putnode(node *); 23 | 24 | int bt_readhdr(btree *); 25 | int bt_writehdr(btree *); 26 | 27 | int bt_space(btree *, unsigned int); 28 | 29 | int bt_insert(btree *, const byte *, unsigned int); 30 | int bt_delete(btree *, const byte *); 31 | 32 | int bt_search(btree *, const byte *, node *); 33 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | enum { 22 | fkData = 0x00, 23 | fkRsrc = 0xff 24 | }; 25 | 26 | void f_init(hfsfile *, hfsvol *, long, const char *); 27 | void f_selectfork(hfsfile *, int); 28 | void f_getptrs(hfsfile *, ExtDataRec **, unsigned long **, unsigned long **); 29 | 30 | int f_doblock(hfsfile *, unsigned long, block *, 31 | int (*)(hfsvol *, unsigned int, unsigned int, block *)); 32 | 33 | # define f_getblock(file, num, bp) \ 34 | f_doblock((file), (num), (bp), b_readab) 35 | # define f_putblock(file, num, bp) \ 36 | f_doblock((file), (num), (bp), \ 37 | (int (*)(hfsvol *, unsigned int, unsigned int, block *)) \ 38 | b_writeab) 39 | 40 | int f_addextent(hfsfile *, ExtDescriptor *); 41 | long f_alloc(hfsfile *); 42 | 43 | int f_trunc(hfsfile *); 44 | int f_flush(hfsfile *); 45 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/low.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | # define HFS_DDR_SIGWORD 0x4552 22 | 23 | # define HFS_PM_SIGWORD 0x504d 24 | # define HFS_PM_SIGWORD_OLD 0x5453 25 | 26 | # define HFS_BB_SIGWORD 0x4c4b 27 | 28 | # define HFS_BOOTCODE1LEN (HFS_BLOCKSZ - 148) 29 | # define HFS_BOOTCODE2LEN HFS_BLOCKSZ 30 | 31 | # define HFS_BOOTCODELEN (HFS_BOOTCODE1LEN + HFS_BOOTCODE2LEN) 32 | 33 | int l_getddr(hfsvol *, Block0 *); 34 | int l_putddr(hfsvol *, const Block0 *); 35 | 36 | int l_getpmentry(hfsvol *, ApplePartition *, unsigned long); 37 | int l_putpmentry(hfsvol *, const ApplePartition *, unsigned long); 38 | 39 | int l_getbb(hfsvol *, BootBlkHdr *, byte *); 40 | int l_putbb(hfsvol *, const BootBlkHdr *, const byte *); 41 | 42 | int l_getmdb(hfsvol *, MDB *, int); 43 | int l_putmdb(hfsvol *, const MDB *, int); 44 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/medium.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | /* 22 | * Partition Types: 23 | * 24 | * "Apple_partition_map" partition map 25 | * "Apple_Driver" device driver 26 | * "Apple_Driver43" SCSI Manager 4.3 device driver 27 | * "Apple_MFS" Macintosh 64K ROM filesystem 28 | * "Apple_HFS" Macintosh hierarchical filesystem 29 | * "Apple_Unix_SVR2" Unix filesystem 30 | * "Apple_PRODOS" ProDOS filesystem 31 | * "Apple_Free" unused 32 | * "Apple_Scratch" empty 33 | */ 34 | 35 | int m_zeroddr(hfsvol *); 36 | 37 | int m_zeropm(hfsvol *, unsigned int); 38 | int m_findpmentry(hfsvol *, const char *, ApplePartition *, unsigned long *); 39 | int m_mkpart(hfsvol *, const char *, const char *, unsigned long); 40 | 41 | int m_zerobb(hfsvol *); 42 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | void n_init(node *, btree *, int, int); 22 | 23 | int n_new(node *); 24 | int n_free(node *); 25 | 26 | int n_search(node *, const byte *); 27 | 28 | void n_index(const node *, byte *, unsigned int *); 29 | 30 | void n_insertx(node *, const byte *, unsigned int); 31 | int n_insert(node *, byte *, unsigned int *); 32 | 33 | int n_delete(node *, byte *, int *); 34 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/os.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | int hfs_os_open(void **, const void *, int); 22 | int hfs_os_close(void **); 23 | 24 | int hfs_os_same(void **, const void *); 25 | 26 | unsigned long hfs_os_seek(void **, unsigned long); 27 | unsigned long hfs_os_read(void **, void *, unsigned long); 28 | unsigned long hfs_os_write(void **, const void *, unsigned long); 29 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/record.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | void r_packcatkey(const CatKeyRec *, byte *, unsigned int *); 22 | void r_unpackcatkey(const byte *, CatKeyRec *); 23 | 24 | void r_packextkey(const ExtKeyRec *, byte *, unsigned int *); 25 | void r_unpackextkey(const byte *, ExtKeyRec *); 26 | 27 | int r_comparecatkeys(const CatKeyRec *, const CatKeyRec *); 28 | int r_compareextkeys(const ExtKeyRec *, const ExtKeyRec *); 29 | 30 | void r_packcatdata(const CatDataRec *, byte *, unsigned int *); 31 | void r_unpackcatdata(const byte *, CatDataRec *); 32 | 33 | void r_packextdata(const ExtDataRec *, byte *, unsigned int *); 34 | void r_unpackextdata(const byte *, ExtDataRec *); 35 | 36 | void r_makecatkey(CatKeyRec *, unsigned long, const char *); 37 | void r_makeextkey(ExtKeyRec *, int, unsigned long, unsigned int); 38 | 39 | void r_packcatrec(const CatKeyRec *, const CatDataRec *, 40 | byte *, unsigned int *); 41 | void r_packextrec(const ExtKeyRec *, const ExtDataRec *, 42 | byte *, unsigned int *); 43 | 44 | void r_packdirent(CatDataRec *, const hfsdirent *); 45 | void r_unpackdirent(unsigned long, const char *, 46 | const CatDataRec *, hfsdirent *); 47 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | # include "version.h" 22 | 23 | const char libhfs_version[] = "libhfs version 3.2.6"; 24 | const char libhfs_copyright[] = "Copyright (C) 1996-1998 Robert Leslie"; 25 | const char libhfs_author[] = "Robert Leslie "; 26 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | extern const char libhfs_rcsid[]; 22 | 23 | extern const char libhfs_version[]; 24 | extern const char libhfs_copyright[]; 25 | extern const char libhfs_author[]; 26 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfs/volume.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | void v_init(hfsvol *, int); 22 | 23 | int v_open(hfsvol *, const void *, int); 24 | int v_flush(hfsvol *); 25 | int v_close(hfsvol *); 26 | 27 | int v_same(hfsvol *, const char *); 28 | int v_geometry(hfsvol *, int); 29 | 30 | int v_readmdb(hfsvol *); 31 | int v_writemdb(hfsvol *); 32 | 33 | int v_readvbm(hfsvol *); 34 | int v_writevbm(hfsvol *); 35 | 36 | int v_mount(hfsvol *); 37 | int v_dirty(hfsvol *); 38 | 39 | int v_catsearch(hfsvol *, unsigned long, const char *, 40 | CatDataRec *, char *, node *); 41 | int v_extsearch(hfsfile *, unsigned int, ExtDataRec *, node *); 42 | 43 | int v_getthread(hfsvol *, unsigned long, CatDataRec *, node *, int); 44 | 45 | # define v_getdthread(vol, id, thread, np) \ 46 | v_getthread(vol, id, thread, np, cdrThdRec) 47 | # define v_getfthread(vol, id, thread, np) \ 48 | v_getthread(vol, id, thread, np, cdrFThdRec) 49 | 50 | int v_putcatrec(const CatDataRec *, node *); 51 | int v_putextrec(const ExtDataRec *, node *); 52 | 53 | int v_allocblocks(hfsvol *, ExtDescriptor *); 54 | int v_freeblocks(hfsvol *, const ExtDescriptor *); 55 | 56 | int v_resolve(hfsvol **, const char *, CatDataRec *, unsigned long *, char *, node *); 57 | 58 | int v_adjvalence(hfsvol *, unsigned long, int, int); 59 | int v_mkdir(hfsvol *, unsigned long, const char *); 60 | 61 | int v_scavenge(hfsvol *); 62 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsglue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * hfsglue.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | #ifndef __HFSGLUE_H__ 21 | #define __HFSGLUE_H__ 22 | 23 | #include "tools/stream.h" 24 | 25 | struct hfs_devicehandle_s { 26 | File * mDevice; 27 | FileOfs mStart; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplus.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * hfsplus.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __HFSPLUS_H__ 22 | #define __HFSPLUS_H__ 23 | 24 | #include "hfsplusglue.h" 25 | #include "part.h" 26 | 27 | #define HFSPlusSigWord MAGIC16("H+") 28 | #define HFSXSigWord MAGIC16("HX") 29 | 30 | bool tryBootHFSPlus(File *aDevice, uint aDeviceBlocksize, FileOfs start, PartitionEntry *partEnt); 31 | 32 | /***/ 33 | class HFSPlusFileSystem: public FileSystem { 34 | protected: 35 | hfsplus_devicehandle_s dh; 36 | void *hfsplushandle; 37 | public: 38 | HFSPlusFileSystem(File *device, int partnum /* 1-based */); 39 | virtual ~HFSPlusFileSystem(); 40 | /* extends FileSystem */ 41 | virtual File * open(const String &filename); 42 | virtual bool getBlessedPath(String &blessed); 43 | /* new */ 44 | virtual File * openBootFile(); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplus/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplus/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libhfsplus.a 4 | 5 | libhfsplus_a_SOURCES = apple.h blockiter.c blockiter.h btree.c btree.h \ 6 | hfs.h hfsp.h hfstime.c hfstime.h \ 7 | libhfsp.c libhfsp.h os.cc os.h partitions.c partitions.h record.c record.h \ 8 | swab.h unicode.c unicode.h volume.c volume.h 9 | 10 | AM_CPPFLAGS = -I ../../../.. 11 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplus/hfs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfsp - library for reading and writing Macintosh HFS+ volumes 3 | * 4 | * This file includes definitions for access to old HFS structures. 5 | * 6 | * Copyright (C) 2000 Klaus Halfmann 7 | * Original code 1996-1998 by Robert Leslie 8 | * other work 2000 from Brad Boyer (flar@pants.nu) 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | 27 | #define HFS_BLOCKSZ 512 28 | /* A sector for Apple is always 512 bytes */ 29 | #define HFS_BLOCKSZ_BITS 9 /* 1<<9 == 512 */ 30 | #define HFS_VOLHEAD_SIG 0x4244 /* 'BD' */ 31 | 32 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplus/hfstime.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 2000 Klaus Halfmann ^ 4 | * Original 1996-1998 Robert Leslie 5 | * other work 2000 from Brad Boyer (flar@pants.nu) 6 | * 7 | * The HFS+ dates are stored as UInt32 containing the number of seconds since 8 | * midnight, January 1, 1904, GMT. This is slightly different from HFS, 9 | * where the value represents local time. A notable exception is the 10 | * creationdate !. Linux uses times in GMT starting at January 1, 1970 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program; if not, write to the Free Software 24 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 | * 26 | */ 27 | 28 | # ifdef HAVE_CONFIG_H 29 | # include "config.h" 30 | # endif 31 | 32 | #include "apple.h" 33 | #include "hfstime.h" 34 | 35 | /* return the given apple time as printable UNIX time */ 36 | char* get_atime(UInt32 atime) 37 | { 38 | time_t t = atime; 39 | t -= HFSPTIMEDIFF; 40 | return ctime(&t); 41 | } 42 | 43 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplus/hfstime.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * 4 | * Copyright (C) 2000 Klaus Halfmann 5 | * Original 1996-1998 Robert Leslie 6 | * other work 2000 from Brad Boyer (flar@pants.nu) 7 | * 8 | * The HFS+ dates are stored as UInt32 containing the number of seconds since 9 | * midnight, January 1, 1904, GMT. This is slightly different from HFS, 10 | * where the value represents local time. A notable exception is the 11 | * creationdate !. Linux uses times in GMT starting at January 1, 1970 12 | * 13 | * This program is free software; you can redistribute it and/or modify 14 | * it under the terms of the GNU General Public License as published by 15 | * the Free Software Foundation; either version 2 of the License, or 16 | * (at your option) any later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | * GNU General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU General Public License 24 | * along with this program; if not, write to the Free Software 25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 26 | * 27 | */ 28 | 29 | #include 30 | 31 | /* The number of seconds between 1.1.1904 and 1.1.1970 */ 32 | #define HFSPTIMEDIFF 2082844800U 33 | 34 | /* return the given apple time as UNIX time */ 35 | extern char* get_atime(UInt32 atime); 36 | 37 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplus/libhfsp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfsp - library for reading and writing Macintosh HFS+ volumes 3 | * 4 | * Copyright (C) 2000-2001 Klaus Halfmann 5 | * Original 1996-1998 Robert Leslie 6 | * 7 | * Thi file contains utitlity functions to manage the features of 8 | * the hfs+ library. 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 | * 24 | */ 25 | 26 | # ifdef HAVE_CONFIG_H 27 | # include "config.h" 28 | # endif 29 | 30 | # include "libhfsp.h" 31 | 32 | const char *hfsp_error = "no error"; /* static error string */ 33 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplus/os.h: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfs - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | * 19 | */ 20 | 21 | /* 22 | * NAME: os->open() 23 | * DESCRIPTION: open and lock a new descriptor from the given path and mode 24 | */ 25 | int hfsp_os_open(void **priv, const void *devicehandle, int mode); 26 | 27 | /* 28 | * NAME: os->close() 29 | * DESCRIPTION: close an open descriptor 30 | */ 31 | int hfsp_os_close(void **priv); 32 | 33 | /* 34 | * NAME: os->same() 35 | * DESCRIPTION: return 1 iff path is same as the open descriptor 36 | */ 37 | int hfsp_os_same(void **priv, const char *path); 38 | 39 | 40 | /** Offset that is silently used by os_seek. 41 | * Needed to transparaently support things like partitions */ 42 | /*extern APPLEUInt64 os_offset;*/ 43 | uint64 hfsp_get_offset(void **priv); 44 | void hfsp_set_offset(void **priv, uint64 ofs); 45 | 46 | /* 47 | * NAME: os->seek() 48 | * DESCRIPTION: set a descriptor's seek pointer (offset in blocks) 49 | */ 50 | uint64 hfsp_os_seek(void **priv, uint64 offset, int blksize_bits); 51 | 52 | /* 53 | * NAME: os->read() 54 | * DESCRIPTION: read blocks from an open descriptor 55 | */ 56 | unsigned long hfsp_os_read(void **priv, void *buf, unsigned long len, int blksize_bits); 57 | 58 | /* 59 | * NAME: os->write() 60 | * DESCRIPTION: write blocks to an open descriptor 61 | */ 62 | unsigned long hfsp_os_write(void **priv, const void *buf, unsigned long len, int blksize_bits); 63 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplus/partitions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * hfsutils - tools for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 2000 Klaus Halfmann 4 | * 5 | * Structures and Functions for accessing the mac partition map 6 | * Copyright (C) 2002 Michael Schulze 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | * 22 | */ 23 | 24 | #ifndef APPLE_H 25 | #include "apple.h" 26 | #endif 27 | 28 | typedef struct { 29 | int numparts; /* number of partitions found */ 30 | ApplePartition *parray; /* only used for mem mngmnt */ 31 | ApplePartition **partitions; /* partition descriptions */ 32 | } partition_map; 33 | 34 | /* 35 | * Returns the number of partitions in the given partition map or 0 if no partitions were found 36 | * @param map Partition map to get the information from. 37 | */ 38 | int partition_getnparts( partition_map *map); 39 | 40 | /* 41 | * Returns the startblock of the th partition of the given type from the given 42 | * Partition Map. 43 | * 44 | * @param map Partition map to get the information from 45 | * @param type type of the desired partition 46 | * @param num number of the desired partition (starting with 1) 47 | * 48 | * @return the start block of the partition or 0 if no such partition could be found 49 | */ 50 | UInt32 partition_getStartBlock( partition_map *map, const char *type, int num); 51 | 52 | /* 53 | * Returns the partition map of the given device 54 | */ 55 | int partition_getPartitionMap( partition_map *map, void *fd); 56 | 57 | /* 58 | * cleanup and free allocated memory. 59 | */ 60 | void partition_release( partition_map *map); 61 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplus/unicode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * linux/fs/hfsplus/unicode.c 3 | * 4 | * Copyright (C) 1999-2000 Brad Boyer (flar@pants.nu) 5 | * This file may be distributed under the terms of the GNU Public License. 6 | * 7 | * The routines found here convert hfs-unicode string into ascii Strings 8 | * and vice versa. Tehy allow the correct comparison between Strings. 9 | */ 10 | 11 | /* convert the asci string astr into a unicode string given by ustr. 12 | * 13 | * returns actual length of convertet string. 14 | */ 15 | 16 | int unicode_asc2uni(hfsp_unistr255 *ustr, const char *astr); 17 | 18 | /* Convert an unicode string ustr to a ascii string astr of given maximum len 19 | * 20 | * returns actual length of convertet string. 21 | */ 22 | 23 | int unicode_uni2asc(char *astr, const hfsp_unistr255 *ustr, int maxlen); 24 | 25 | /* similar to strcmp for unicode, pascal strings */ 26 | 27 | SInt32 fast_unicode_compare (const hfsp_unistr255 *ustr1, 28 | const hfsp_unistr255 *ustr2); 29 | -------------------------------------------------------------------------------- /src/io/prom/fs/hfsplusglue.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * hfsplusglue.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | #ifndef __HFSPLUSGLUE_H__ 21 | #define __HFSPLUSGLUE_H__ 22 | 23 | #include "tools/stream.h" 24 | 25 | struct hfsplus_devicehandle_s { 26 | File * mDevice; 27 | FileOfs mStart; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/io/prom/prom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * prom.cc 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PROM_H__ 22 | #define __PROM_H__ 23 | 24 | #include "system/types.h" 25 | #include "tools/stream.h" 26 | 27 | enum PromBootMethod { 28 | prombmAuto, 29 | prombmSelect, 30 | prombmForce, 31 | }; 32 | 33 | extern PromBootMethod gPromBootMethod; 34 | extern String gPromBootPath; 35 | 36 | void prom_init(); 37 | void prom_init_config(); 38 | void prom_done(); 39 | void prom_quiesce(); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/io/prom/promboot.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * promboot.cc 4 | * 5 | * Copyright (C) 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PROMBOOT_H__ 22 | #define __PROMBOOT_H__ 23 | 24 | #include "system/types.h" 25 | #include "tools/stream.h" 26 | 27 | bool prom_user_boot_partition(File *&file, uint32 &size, bool &direct, uint32 &loadAddr, uint32 &entryAddr); 28 | 29 | bool mapped_load_elf(File &f); 30 | bool mapped_load_xcoff(File &f, uint disp_ofs); 31 | bool mapped_load_chrp(File &f); 32 | bool mapped_load_direct(File &f, uint vaddr, uint pc); 33 | 34 | bool prom_load_boot_file(); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/io/prom/prommem.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * prommem.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __IO_PROMMEM_H__ 22 | #define __IO_PROMMEM_H__ 23 | 24 | #include "system/types.h" 25 | 26 | #define PROM_MEM_SIZE (2*1024*1024) 27 | 28 | bool prom_get_string(String &result, uint32 ea); 29 | bool prom_claim_page(uint32 phys); 30 | bool prom_claim_pages(uint32 phys, uint32 size); 31 | uint32 prom_allocate_mem(uint32 size, uint32 align=0, uint32 virt=0); 32 | bool prom_free_mem(uint32 virt); 33 | 34 | uint32 prom_mem_malloc(uint32 s); 35 | void prom_mem_free(uint32 p); 36 | uint32 prom_mem_phys_to_virt(uint32 pa); 37 | uint32 prom_mem_virt_to_phys(uint32 va); 38 | void prom_mem_set(uint32 pa, int c, int size); 39 | 40 | bool prom_mem_init(); 41 | bool prom_mem_done(); 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /src/io/prom/promosi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * promosi.cc 4 | * 5 | * Copyright (C) 2003, 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __PROMOSI_H__ 22 | #define __PROMOSI_H__ 23 | 24 | #include "system/types.h" 25 | #define PROM_MAGIC_OPCODE 0x00345678 26 | 27 | extern uint32 gPromOSIEntry; 28 | 29 | struct prom_args { 30 | uint32 service; 31 | uint32 nargs; 32 | uint32 nret; 33 | uint32 args[10]; 34 | }; 35 | 36 | void call_prom_osi(); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/io/rtl8139/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/rtl8139/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = librtl8139.a 4 | 5 | librtl8139_a_SOURCES = rtl8139.cc rtl8139.h 6 | 7 | AM_CPPFLAGS = -I ../.. 8 | -------------------------------------------------------------------------------- /src/io/rtl8139/rtl8139.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * rtl8139.h 4 | * 5 | * Copyright (C) 2003 Stefan Weyergraf 6 | * Copyright (C) 2004 Eric Estabrooks (estabroo@battlefoundry.net) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef __IO_RTL8139_H__ 23 | #define __IO_RTL8139_H__ 24 | 25 | extern bool rtl8139_installed; 26 | 27 | void rtl8139_init(); 28 | void rtl8139_done(); 29 | void rtl8139_init_config(); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/io/serial/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/serial/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libserial.a 4 | 5 | libserial_a_SOURCES = serial.cc serial.h 6 | 7 | AM_CPPFLAGS = -I ../.. 8 | -------------------------------------------------------------------------------- /src/io/serial/serial.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * usb.h 4 | * 5 | * Copyright (C) 2005 Daniel Foesch (dfoesch@cs.nmsu.edu) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __IO_SERIAL_H__ 22 | #define __IO_SERIAL_H__ 23 | 24 | void serial_init(); 25 | void serial_done(); 26 | void serial_init_config(); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /src/io/usb/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/io/usb/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libusb.a 4 | 5 | libusb_a_SOURCES = usb.cc usb.h 6 | 7 | AM_CPPFLAGS = -I ../.. 8 | -------------------------------------------------------------------------------- /src/io/usb/usb.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * usb.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __IO_USB_H__ 22 | #define __IO_USB_H__ 23 | 24 | void usb_init(); 25 | void usb_done(); 26 | void usb_init_config(); 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /src/ppc_button_changecd.h: -------------------------------------------------------------------------------- 1 | #ifndef __PPC_BUTTON_CHANGECD_H 2 | #define __PPC_BUTTON_CHANGECD_H 3 | 4 | extern 5 | #ifdef __cplusplus 6 | "C" 7 | #endif 8 | char ppc_button_changecd[2911]; 9 | 10 | #endif /* __PPC_BUTTON_CHANGECD_H */ 11 | -------------------------------------------------------------------------------- /src/ppc_font.h: -------------------------------------------------------------------------------- 1 | #ifndef __PPC_FONT_H 2 | #define __PPC_FONT_H 3 | 4 | extern 5 | #ifdef __cplusplus 6 | "C" 7 | #endif 8 | char ppc_font[7953]; 9 | 10 | #endif /* __PPC_FONT_H */ 11 | -------------------------------------------------------------------------------- /src/ppc_img.h: -------------------------------------------------------------------------------- 1 | #ifndef __PPC_IMG_H 2 | #define __PPC_IMG_H 3 | 4 | extern 5 | #ifdef __cplusplus 6 | "C" 7 | #endif 8 | char ppc_img[19442]; 9 | 10 | #endif /* __PPC_IMG_H */ 11 | -------------------------------------------------------------------------------- /src/system/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libsystem.a 4 | libsystem_a_SOURCES = display.cc display.h fileofs.h \ 5 | sysexcept.cc sysexcept.h sys.cc sys.h types.h file.cc file.h \ 6 | vt100.cc vt100.h font.cc font.h gif.cc gif.h systhread.h systimer.h \ 7 | sysethtun.h sysfeatures.h keyboard.cc keyboard.h mouse.cc mouse.h \ 8 | event.h device.cc device.h sysclk.h sysvaccel.h syscdrom.h \ 9 | sysvm.h 10 | 11 | SUBDIRS = arch osapi ui 12 | 13 | AM_CPPFLAGS = -I .. 14 | -------------------------------------------------------------------------------- /src/system/arch/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/arch/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | if USE_ARCH_GENERIC 4 | THE_ARCH_DIR=generic 5 | endif 6 | 7 | if USE_ARCH_X86 8 | THE_ARCH_DIR=x86 9 | endif 10 | 11 | if USE_ARCH_X86_64 12 | THE_ARCH_DIR=x86_64 13 | endif 14 | 15 | EXTRA_DIST = sysfeatures.h sysendian.h 16 | 17 | SUBDIRS = $(THE_ARCH_DIR) 18 | EXTRA_SUBDIRS = generic x86 x86_64 19 | 20 | AM_CPPFLAGS = -I ../.. 21 | -------------------------------------------------------------------------------- /src/system/arch/generic/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/arch/generic/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libsarch.a 4 | libsarch_a_SOURCES = sysfeatures.h sysvaccel.cc sysendian.h 5 | 6 | AM_CPPFLAGS = -I ../../.. 7 | -------------------------------------------------------------------------------- /src/system/arch/generic/sysfeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * features.h - arch/generic variant 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTEM_ARCH_SPECIFIC_FEATURES_H__ 22 | #define __SYSTEM_ARCH_SPECIFIC_FEATURES_H__ 23 | 24 | // PPC_FEATURE_PROVIDED_BY_ARCH 25 | #if !defined(PPC_VIDEO_CONVERT_ACCEL_FEATURE) || (PPC_VIDEO_CONVERT_ACCEL_FEATURE < PPC_FEATURE_PROVIDED_BY_ARCH) 26 | # undef PPC_VIDEO_CONVERT_ACCEL_FEATURE 27 | # define PPC_VIDEO_CONVERT_ACCEL_FEATURE PPC_FEATURE_PROVIDED_BY_ARCH 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/system/arch/sysendian.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * sysendian.h 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTEM_ARCH_SYSENDIAN_H__ 22 | #define __SYSTEM_ARCH_SYSENDIAN_H__ 23 | 24 | #include "config.h" 25 | 26 | #include SYSTEM_ARCH_SPECIFIC_ENDIAN_DIR 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/system/arch/sysfeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * sysfeatures.h 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTEM_ARCH_SYSFEATURES_H__ 22 | #define __SYSTEM_ARCH_SYSFEATURES_H__ 23 | 24 | #include "config.h" 25 | 26 | #include SYSTEM_ARCH_SPECIFIC_FEATURES_DIR 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/system/arch/x86/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/arch/x86/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | SUFFIXES = .asm .o 4 | 5 | noinst_LIBRARIES = libsarch.a 6 | libsarch_a_SOURCES = sysfeatures.h sysvaccel.cc vaccel.S sysendian.h 7 | 8 | AM_CPPFLAGS = -I ../../.. 9 | -------------------------------------------------------------------------------- /src/system/arch/x86/sysendian.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * sysendian.h 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTEM_ARCH_SPECIFIC_SYSENDIAN_H__ 22 | #define __SYSTEM_ARCH_SPECIFIC_SYSENDIAN_H__ 23 | 24 | #include "system/types.h" 25 | 26 | static inline FUNCTION_CONST uint32 ppc_bswap_word(uint32 data) 27 | { 28 | asm ( 29 | "bswap %0": "=r" (data) : "0" (data) 30 | ); 31 | return data; 32 | } 33 | 34 | static inline FUNCTION_CONST uint16 ppc_bswap_half(uint16 data) 35 | { 36 | asm ( 37 | "xchgb %b0,%h0": "=q" (data): "0" (data) 38 | ); 39 | return data; 40 | } 41 | 42 | static inline FUNCTION_CONST uint64 ppc_bswap_dword(uint64 data) 43 | { 44 | return (((uint64)ppc_bswap_word(data)) << 32) | (uint64)ppc_bswap_word(data >> 32); 45 | } 46 | 47 | # define ppc_dword_from_BE(data) (ppc_bswap_dword(data)) 48 | # define ppc_word_from_BE(data) (ppc_bswap_word(data)) 49 | # define ppc_half_from_BE(data) (ppc_bswap_half(data)) 50 | 51 | # define ppc_dword_from_LE(data) ((uint64)(data)) 52 | # define ppc_word_from_LE(data) ((uint32)(data)) 53 | # define ppc_half_from_LE(data) ((uint16)(data)) 54 | 55 | # define ppc_dword_to_LE(data) ppc_dword_from_LE(data) 56 | # define ppc_word_to_LE(data) ppc_word_from_LE(data) 57 | # define ppc_half_to_LE(data) ppc_half_from_LE(data) 58 | 59 | # define ppc_dword_to_BE(data) ppc_dword_from_BE(data) 60 | # define ppc_word_to_BE(data) ppc_word_from_BE(data) 61 | # define ppc_half_to_BE(data) ppc_half_from_BE(data) 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/system/arch/x86/sysfeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * features.h - arch/x86 variant 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTEM_ARCH_SPECIFIC_FEATURES_H__ 22 | #define __SYSTEM_ARCH_SPECIFIC_FEATURES_H__ 23 | 24 | // PPC_FEATURE_PROVIDED_BY_ARCH 25 | #if !defined(PPC_VIDEO_CONVERT_ACCEL_FEATURE) || (PPC_VIDEO_CONVERT_ACCEL_FEATURE < PPC_FEATURE_PROVIDED_BY_ARCH) 26 | # undef PPC_VIDEO_CONVERT_ACCEL_FEATURE 27 | # define PPC_VIDEO_CONVERT_ACCEL_FEATURE PPC_FEATURE_PROVIDED_BY_ARCH 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/system/arch/x86_64/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/arch/x86_64/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | SUFFIXES = .asm .o 4 | 5 | noinst_LIBRARIES = libsarch.a 6 | libsarch_a_SOURCES = sysfeatures.h sysvaccel.cc sysendian.h 7 | 8 | AM_CPPFLAGS = -I ../../.. 9 | -------------------------------------------------------------------------------- /src/system/arch/x86_64/sysendian.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * sysendian.h 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTEM_ARCH_SPECIFIC_SYSENDIAN_H__ 22 | #define __SYSTEM_ARCH_SPECIFIC_SYSENDIAN_H__ 23 | 24 | #include "system/types.h" 25 | 26 | static inline FORCE_INLINE FUNCTION_CONST uint32 ppc_bswap_word(uint32 data) 27 | { 28 | asm ( 29 | "bswapl %0": "=r" (data) : "0" (data) 30 | ); 31 | return data; 32 | } 33 | 34 | static inline FORCE_INLINE FUNCTION_CONST uint16 ppc_bswap_half(uint16 data) 35 | { 36 | asm ( 37 | "rolw $8, %0": "=r" (data): "0" (data) 38 | ); 39 | return data; 40 | } 41 | 42 | static inline FORCE_INLINE FUNCTION_CONST uint64 ppc_bswap_dword(uint64 data) 43 | { 44 | asm ( 45 | "bswapq %0": "=r" (data) : "0" (data) 46 | ); 47 | return data; 48 | } 49 | 50 | # define ppc_dword_from_BE(data) (ppc_bswap_dword(data)) 51 | # define ppc_word_from_BE(data) (ppc_bswap_word(data)) 52 | # define ppc_half_from_BE(data) (ppc_bswap_half(data)) 53 | 54 | # define ppc_dword_from_LE(data) ((uint64)(data)) 55 | # define ppc_word_from_LE(data) ((uint32)(data)) 56 | # define ppc_half_from_LE(data) ((uint16)(data)) 57 | 58 | # define ppc_dword_to_LE(data) ppc_dword_from_LE(data) 59 | # define ppc_word_to_LE(data) ppc_word_from_LE(data) 60 | # define ppc_half_to_LE(data) ppc_half_from_LE(data) 61 | 62 | # define ppc_dword_to_BE(data) ppc_dword_from_BE(data) 63 | # define ppc_word_to_BE(data) ppc_word_from_BE(data) 64 | # define ppc_half_to_BE(data) ppc_half_from_BE(data) 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /src/system/arch/x86_64/sysfeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * features.h - arch/x86 variant 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTEM_ARCH_SPECIFIC_FEATURES_H__ 22 | #define __SYSTEM_ARCH_SPECIFIC_FEATURES_H__ 23 | 24 | // PPC_FEATURE_PROVIDED_BY_ARCH 25 | #if !defined(PPC_VIDEO_CONVERT_ACCEL_FEATURE) || (PPC_VIDEO_CONVERT_ACCEL_FEATURE < PPC_FEATURE_PROVIDED_BY_ARCH) 26 | # undef PPC_VIDEO_CONVERT_ACCEL_FEATURE 27 | # define PPC_VIDEO_CONVERT_ACCEL_FEATURE PPC_FEATURE_PROVIDED_BY_ARCH 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/system/device.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * device.cc 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * Copyright (C) 2003,2004 Sebastian Biallas (sb@biallas.net) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | 24 | #include 25 | 26 | #include "device.h" 27 | 28 | SystemDevice::SystemDevice() 29 | { 30 | mAttachedEventHandler = NULL; 31 | } 32 | 33 | bool SystemDevice::handleEvent(const SystemEvent &ev) 34 | { 35 | return mAttachedEventHandler ? mAttachedEventHandler(ev) : false; 36 | } 37 | 38 | void SystemDevice::attachEventHandler(SystemEventHandler cevh) 39 | { 40 | if (mAttachedEventHandler) { 41 | ht_printf("INTERNAL ERROR: only 1 attached event handler allowed.\n"); 42 | exit(1); 43 | } 44 | mAttachedEventHandler = cevh; 45 | } 46 | -------------------------------------------------------------------------------- /src/system/device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * device.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTEM_DEVICE_H__ 22 | #define __SYSTEM_DEVICE_H__ 23 | 24 | #include "tools/data.h" 25 | #include "system/event.h" 26 | 27 | class SystemDevice: public Object { 28 | protected: 29 | SystemEventHandler mAttachedEventHandler; 30 | public: 31 | SystemDevice(); 32 | 33 | /** 34 | * @returns true if the event has been handled, false otherwise 35 | */ 36 | virtual bool handleEvent(const SystemEvent &ev); 37 | 38 | virtual void attachEventHandler(SystemEventHandler cevh); 39 | }; 40 | 41 | #endif /* __SYSTEM_DEVICE_H__ */ 42 | -------------------------------------------------------------------------------- /src/system/event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * event.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTEM_EVENT_H__ 22 | #define __SYSTEM_EVENT_H__ 23 | 24 | #include "system/types.h" 25 | #include "tools/data.h" 26 | 27 | enum SystemEventType { 28 | sysevNone = 0, 29 | sysevKey, 30 | sysevMouse 31 | }; 32 | 33 | enum SystemMouseEventType { 34 | sme_buttonPressed, 35 | sme_buttonReleased, 36 | sme_motionNotify 37 | }; 38 | 39 | struct SystemEvent { 40 | SystemEventType type; 41 | union { 42 | struct { 43 | SystemMouseEventType type; 44 | int x; 45 | int y; 46 | int relx; 47 | int rely; 48 | bool button1; // left mouse button 49 | bool button2; // right mouse button 50 | bool button3; // middle mouse button 51 | int dbutton; // mouse button that changed since last sysevMouse (0 if none) 52 | } mouse; 53 | struct { 54 | uint keycode; 55 | bool pressed; 56 | char chr; 57 | } key; 58 | }; 59 | }; 60 | 61 | class SystemEventObject: public Object { 62 | public: 63 | SystemEvent mEv; 64 | 65 | SystemEventObject(const SystemEvent &ev) : mEv(ev) {} 66 | }; 67 | 68 | typedef bool (*SystemEventHandler)(const SystemEvent &ev); 69 | 70 | #endif /* __SYSTEM_EVENT_H__ */ 71 | -------------------------------------------------------------------------------- /src/system/fileofs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * fileofs.h 4 | * 5 | * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) 6 | * Copyright (C) 1999-2002 Stefan Weyergraf 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef __FILEOFS_H__ 23 | #define __FILEOFS_H__ 24 | 25 | typedef uint64 FileOfs; /// A file offset 26 | 27 | #define PUT_FILEOFS(st, d) (st).putQWordHex(d, 8, #d) 28 | #define GET_FILEOFS(st, d) d=(st).getQwordHex(8, #d) 29 | 30 | #endif /* __FILEOFS_H__ */ 31 | 32 | -------------------------------------------------------------------------------- /src/system/font.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * font.h 4 | * 5 | * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | #ifndef __FONT_H__ 21 | #define __FONT_H__ 22 | 23 | #include "tools/data.h" 24 | #include "display.h" 25 | 26 | class Font: public Object { 27 | int mCharWidth; 28 | int mCharHeight; 29 | int mRealWidth; 30 | int mRealHeight; 31 | int mPadX; 32 | int mPadY; 33 | int mBytes; 34 | byte *mData; 35 | public: 36 | Font(); 37 | bool loadFromFile(File &file); 38 | void setPadding(int px, int py); 39 | ~Font(); 40 | 41 | void drawChar(int x, int y, byte c, uint fgcolor, uint bgcolor, byte *tobuf, int bufwidth, int bufheight, int bufcolorbytes); 42 | void drawFixedChar(int x, int y, int dx, int dy, byte c, uint fgcolor, uint bgcolor, byte *tobuf, int bufwidth, int bufheight, int bufcolorbytes); 43 | 44 | void drawChar2(SystemDisplay *toDisplay, int x, int y, byte c, RGBA fgcolor, RGBA bgcolor); 45 | void drawFixedChar2(SystemDisplay *toDisplay, int x, int y, int dx, int dy, byte c, RGBA fgcolor, RGBA bgcolor); 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /src/system/gif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * gif.h 4 | * 5 | * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | #ifndef __GIF_H__ 21 | #define __GIF_H__ 22 | 23 | #include "tools/data.h" 24 | #include "system/display.h" 25 | 26 | class Gif: public Object { 27 | byte *pic; 28 | byte mPal[768]; 29 | public: 30 | int mWidth, mHeight; 31 | Gif(); 32 | Gif(Stream &str); 33 | ~Gif(); 34 | bool loadFromByteStream(Stream &str); 35 | void draw(SystemDisplay *display, int x, int y); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/system/mouse.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * mouse.cc 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * Copyright (C) 2003,2004 Sebastian Biallas (sb@biallas.net) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include "tools/snprintf.h" 23 | #include "mouse.h" 24 | #include "display.h" 25 | 26 | SystemMouse *gMouse = NULL; 27 | 28 | bool SystemMouse::handleEvent(const SystemEvent &ev) 29 | { 30 | if (ev.type != sysevMouse) return false; 31 | if (gDisplay->isMouseGrabbed()) { 32 | return SystemDevice::handleEvent(ev); 33 | } else { 34 | if (ev.mouse.type == sme_buttonReleased) { 35 | gDisplay->setMouseGrab(true); 36 | return true; 37 | } 38 | return false; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/system/mouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * mouse.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTEM_MOUSE_H__ 22 | #define __SYSTEM_MOUSE_H__ 23 | 24 | #include "system/types.h" 25 | 26 | #include "system/device.h" 27 | #include "system/event.h" 28 | 29 | #include "tools/data.h" 30 | 31 | /* system-dependent (implementation in ui / $MYUI / *.cc) */ 32 | class SystemMouse: public SystemDevice { 33 | public: 34 | virtual bool handleEvent(const SystemEvent &ev); 35 | }; 36 | 37 | /* system-independent (implementation in keyboard.cc) */ 38 | extern SystemMouse *gMouse; 39 | 40 | #endif /* __SYSTEM_KEYBOARD_H__ */ 41 | -------------------------------------------------------------------------------- /src/system/osapi/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/osapi/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | if USE_OSAPI_BEOS 4 | THE_OSAPI_DIR=beos 5 | endif 6 | 7 | if USE_OSAPI_POSIX 8 | THE_OSAPI_DIR=posix 9 | endif 10 | 11 | if USE_OSAPI_WIN32 12 | THE_OSAPI_DIR=win32 13 | endif 14 | 15 | SUBDIRS = $(THE_OSAPI_DIR) 16 | EXTRA_SUBDIRS = beos posix win32 17 | 18 | AM_CPPFLAGS = -I ../.. 19 | -------------------------------------------------------------------------------- /src/system/osapi/beos/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/osapi/beos/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libsosapi.a 4 | 5 | libsosapi_a_SOURCES = sysclipboard.cc sysfile.cc \ 6 | syscdrom.cc sysethtun.cc sysinit.cc systhread.cc systimer.cc types.h 7 | 8 | AM_CPPFLAGS = -I ../../.. 9 | 10 | sysethtun.cc: 11 | ln -s ../posix/$@ $@ 12 | -------------------------------------------------------------------------------- /src/system/osapi/beos/sysclipboard.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * clipboard.cc - BeOS-specific clipboard functions 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * Copyright (C) 2004 Francois Revol (revol@free.fr) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | #include "system/sys.h" 28 | 29 | bool sys_write_data_to_native_clipboard(const void *data, int size) 30 | { 31 | BMessage *clip; 32 | be_clipboard->Lock(); 33 | be_clipboard->Clear(); 34 | clip = be_clipboard->Data(); 35 | clip->AddData("text/plain", B_MIME_TYPE, data, size); 36 | be_clipboard->Commit(); 37 | be_clipboard->Unlock(); 38 | return true; 39 | } 40 | 41 | int sys_get_native_clipboard_data_size() 42 | { 43 | return false; 44 | } 45 | 46 | bool sys_read_data_from_native_clipboard(void *data, int max_size) 47 | { 48 | BMessage *clip; 49 | const void *cdata; 50 | ssize_t csize; 51 | be_clipboard->Lock(); 52 | clip = be_clipboard->Data(); 53 | if (clip->FindData("text/plain", B_MIME_TYPE, &cdata, &csize) < B_OK) { 54 | be_clipboard->Unlock(); 55 | return false; 56 | } 57 | be_clipboard->Unlock(); 58 | memcpy(data, cdata, MIN(max_size, csize)); 59 | return true; 60 | } 61 | -------------------------------------------------------------------------------- /src/system/osapi/beos/sysinit.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * sysinit.cc - BeOS-specific initialization 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * Copyright (C) 2004 Francois Revol (revol@free.fr) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include "system/sys.h" 30 | 31 | int32 bapp_thread(void *) 32 | { 33 | be_app->Lock(); 34 | be_app->Run(); 35 | } 36 | 37 | bool initOSAPI() 38 | { 39 | thread_id bapp_tid; 40 | setuid(getuid()); 41 | new BApplication("application/x-vnd.PearPC"); 42 | if (!be_app) 43 | return false; 44 | bapp_tid = spawn_thread(bapp_thread, "BApplication(PearPC)", B_NORMAL_PRIORITY, NULL); 45 | if (bapp_tid < B_OK) 46 | return false; 47 | if (resume_thread(bapp_tid) < B_OK) 48 | return false; 49 | be_app->Unlock(); 50 | return true; 51 | } 52 | 53 | void doneOSAPI() 54 | { 55 | be_app->Lock(); 56 | be_app->Quit(); 57 | delete be_app; 58 | } 59 | -------------------------------------------------------------------------------- /src/system/osapi/beos/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * types.h 4 | * 5 | * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) 6 | * Copyright (C) 1999-2002 Stefan Weyergraf 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef __BEOS_TYPES_H__ 23 | #define __BEOS_TYPES_H__ 24 | 25 | /* included everywhere else anyway, and colides... */ 26 | #include 27 | 28 | typedef signed int sint; 29 | 30 | typedef int8 sint8; 31 | typedef int16 sint16; 32 | typedef int32 sint32; 33 | typedef int64 sint64; 34 | 35 | typedef uint8 byte; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/system/osapi/posix/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/osapi/posix/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libsosapi.a 4 | 5 | libsosapi_a_SOURCES = sysclipboard.cc sysfile.cc \ 6 | sysinit.cc sysethtun.cc systhread.cc systimer.cc syscdrom.cc types.h \ 7 | sysvm.cc 8 | 9 | AM_CPPFLAGS = -I ../../.. 10 | -------------------------------------------------------------------------------- /src/system/osapi/posix/syscdrom.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * syscdrom.cc 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include "errno.h" 24 | 25 | #include "io/ide/cd.h" 26 | #include "debug/tracers.h" 27 | 28 | /// Creates a native CDROM device 29 | /// @param device_name The PearPC internal device name for the drive 30 | /// @param image_name The image / device name to identify the real hardware 31 | /// @return On success a pointer to a CDROMDevice is returned, else NULL 32 | /// @author Alexander Stockinger 33 | /// @date 07/19/2004 34 | CDROMDevice* createNativeCDROMDevice(const char* device_name, const char* image_name) 35 | { 36 | IO_IDE_ERR("No native CDROMs supported on POSIX\n"); 37 | // No native CDROM devices on this platform 38 | return NULL; 39 | } 40 | -------------------------------------------------------------------------------- /src/system/osapi/posix/sysclipboard.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * clipboard.cc - POSIX-specific (windows-)clipboard functions 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include "system/sys.h" 22 | 23 | static bool open_clipboard() 24 | { 25 | return false; 26 | } 27 | 28 | static void close_clipboard() 29 | { 30 | } 31 | 32 | bool sys_write_data_to_native_clipboard(const void *data, int size) 33 | { 34 | return false; 35 | } 36 | 37 | int sys_get_native_clipboard_data_size() 38 | { 39 | return false; 40 | } 41 | 42 | bool sys_read_data_from_native_clipboard(void *data, int max_size) 43 | { 44 | return false; 45 | } 46 | -------------------------------------------------------------------------------- /src/system/osapi/posix/sysinit.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * sysinit.cc - POSIX-specific initialization 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include "system/sys.h" 26 | 27 | bool initOSAPI() 28 | { 29 | setuid(getuid()); 30 | return true; 31 | } 32 | 33 | void doneOSAPI() 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /src/system/osapi/posix/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * types.h 4 | * 5 | * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) 6 | * Copyright (C) 1999-2002 Stefan Weyergraf 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef __POSIX_TYPES_H__ 23 | #define __POSIX_TYPES_H__ 24 | 25 | #ifdef HAVE_STDINT_H 26 | #include 27 | #else 28 | #include 29 | #endif /* HAVE_STDINT_H */ 30 | #include 31 | 32 | typedef uint8_t uint8; 33 | typedef uint16_t uint16; 34 | typedef uint32_t uint32; 35 | typedef uint64_t uint64; 36 | 37 | typedef int8_t sint8; 38 | typedef int16_t sint16; 39 | typedef int32_t sint32; 40 | typedef int64_t sint64; 41 | 42 | typedef signed int sint; 43 | 44 | typedef uint8 byte; 45 | 46 | /* FreeBSD versions after importing gcc34 has broken offsetof() */ 47 | #ifdef __FreeBSD__ 48 | #include 49 | #if __FreeBSD_version >= 502126 50 | #undef offsetof 51 | #define offsetof(TYPE, MEMBER) \ 52 | (__offsetof__ (reinterpret_cast \ 53 | (&reinterpret_cast \ 54 | (static_cast (0)->MEMBER)))) 55 | #endif /* __FreeBSD_version >= 502126 */ 56 | #endif /* __FreeBSD__ */ 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/system/osapi/win32/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/osapi/win32/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libsosapi.a 4 | 5 | libsosapi_a_SOURCES = sysclipboard.cc sysfile.cc systhread.cc \ 6 | sysethtun.cc systimer.cc sysinit.cc types.h tap_constants.h \ 7 | syscdrom.cc scsipt.h aspi-win32.h scsitypes.h 8 | 9 | AM_CPPFLAGS = -I ../../.. 10 | -------------------------------------------------------------------------------- /src/system/osapi/win32/scsitypes.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // This file was copied from bochs IA-32 emulator 4 | // Original comment: 5 | // 6 | // > This file was copied from ... ? 7 | // 8 | 9 | //*************************************************************************** 10 | // %%% PERIPHERAL DEVICE TYPE DEFINITIONS %%% 11 | //*************************************************************************** 12 | #define DTYPE_DASD 0x00 // Disk Device 13 | #define DTYPE_SEQD 0x01 // Tape Device 14 | #define DTYPE_PRNT 0x02 // Printer 15 | #define DTYPE_PROC 0x03 // Processor 16 | #define DTYPE_WORM 0x04 // Write-once read-multiple 17 | #define DTYPE_CROM 0x05 // CD-ROM device 18 | #define DTYPE_CDROM 0x05 // CD-ROM device 19 | #define DTYPE_SCAN 0x06 // Scanner device 20 | #define DTYPE_OPTI 0x07 // Optical memory device 21 | #define DTYPE_JUKE 0x08 // Medium Changer device 22 | #define DTYPE_COMM 0x09 // Communications device 23 | #define DTYPE_RESL 0x0A // Reserved (low) 24 | #define DTYPE_RESH 0x1E // Reserved (high) 25 | #define DTYPE_UNKNOWN 0x1F // Unknown or no device type 26 | -------------------------------------------------------------------------------- /src/system/osapi/win32/sysclipboard.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * clipboard.cc - Win32-specific (windows-)clipboard functions 4 | * 5 | * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) 6 | * Copyright (C) 1999-2002 Stefan Weyergraf 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #define WIN32_LEAN_AND_MEAN 23 | #include 24 | 25 | #define MIN(a,b) (((a)<(b))?(a):(b)) 26 | bool sys_write_data_to_native_clipboard(const void *data, int size) 27 | { 28 | // FIXME: 29 | if (!OpenClipboard(0)) return false; 30 | HGLOBAL hdata; 31 | hdata = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, size); 32 | if (hdata) { 33 | void *ptr = GlobalLock(hdata); 34 | memmove(ptr, data, size); 35 | GlobalUnlock(hdata); 36 | if (SetClipboardData(CF_OEMTEXT, hdata)) { 37 | CloseClipboard(); 38 | return true; 39 | } 40 | } 41 | CloseClipboard(); 42 | return false; 43 | } 44 | 45 | int sys_get_native_clipboard_data_size() 46 | { 47 | return 0; 48 | } 49 | 50 | bool sys_read_data_from_native_clipboard(void *data, int max_size) 51 | { 52 | if (!OpenClipboard(0)) return false; 53 | HANDLE hdata = GetClipboardData(CF_OEMTEXT); 54 | if (!hdata) { 55 | CloseClipboard(); 56 | return false; 57 | } 58 | int size = GlobalSize(hdata); 59 | void *ptr = GlobalLock(hdata); 60 | memmove(data, ptr, MIN(size, max_size)); 61 | GlobalUnlock(hdata); 62 | CloseClipboard(); 63 | return true; 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/system/osapi/win32/sysinit.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * sysinit.cc 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include 22 | 23 | #include "system/sys.h" 24 | 25 | #define WIN32_LEAN_AND_MEAN 26 | #include 27 | 28 | bool initOSAPI() 29 | { 30 | #if 0 31 | HMODULE h = GetModuleHandle(NULL); 32 | GetModuleFileName(h, gAppFilename, sizeof gAppFilename); 33 | #endif 34 | return true; 35 | } 36 | 37 | void doneOSAPI() 38 | { 39 | } 40 | -------------------------------------------------------------------------------- /src/system/osapi/win32/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * types.h 4 | * 5 | * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) 6 | * Copyright (C) 1999-2002 Stefan Weyergraf 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #ifndef __WIN32_TYPES_H__ 23 | #define __WIN32_TYPES_H__ 24 | 25 | // >> FIXME: only works on x86 26 | typedef unsigned char uint8; 27 | typedef unsigned short uint16; 28 | typedef unsigned int uint32; 29 | typedef unsigned long long uint64; 30 | 31 | typedef signed char sint8; 32 | typedef signed short sint16; 33 | typedef signed int sint32; 34 | typedef signed long long sint64; 35 | // << 36 | 37 | typedef unsigned int uint; 38 | typedef signed int sint; 39 | 40 | typedef uint8 byte; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/system/sys.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * sys.cc 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | char gAppFilename[260]; 22 | 23 | -------------------------------------------------------------------------------- /src/system/sys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * sys.h 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYS_H__ 22 | #define __SYS_H__ 23 | 24 | extern char gAppFilename[260]; 25 | 26 | /* system-dependent (implementation in $MYSYSTEM/ *.cc) */ 27 | /* Note: all functions only take absolute dir/filenames! */ 28 | #define SYSCAP_IPC 1 29 | #define SYSCAP_NBIPC 2 30 | #define SYSCAP_NATIVE_CLIPBOARD 4 31 | int sys_get_caps(); 32 | 33 | int sys_ht_mode(int mode); 34 | 35 | #define SYS_DRIVER_DESC_LEN 128 36 | void sys_get_driver_desc(char *buf); 37 | 38 | // return time slice to system 39 | void sys_suspend(); 40 | 41 | bool sys_native_clipboard_read(void *buf, int bufsize); 42 | bool sys_native_clipboard_write(const void *buf, int bufsize); 43 | int sys_native_clipboard_get_size(); 44 | 45 | bool initOSAPI(); 46 | void doneOSAPI(); 47 | 48 | #endif /* __SYS_H__ */ 49 | -------------------------------------------------------------------------------- /src/system/syscdrom.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * PearPC 4 | * syscdrom.h 5 | * 6 | * Abstraction for ethernet tunnel devices 7 | * 8 | * Copyright (C) 2003,2004 Stefan Weyergraf (stefan@weyergraf.de) 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License version 2 as 12 | * published by the Free Software Foundation. 13 | * 14 | * This program is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this program; if not, write to the Free Software 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 | */ 23 | 24 | #ifndef __SYSCDROM_H__ 25 | #define __SYSCDROM_H__ 26 | 27 | #include "system/types.h" 28 | 29 | /* system-dependent (implementation in $MYSYSTEM/ *.cc) */ 30 | extern CDROMDevice *createNativeCDROMDevice(const char *device_name, 31 | const char *image_name); 32 | 33 | #endif /* __SYSETHTUN_H__ */ 34 | -------------------------------------------------------------------------------- /src/system/sysclk.h: -------------------------------------------------------------------------------- 1 | /// @file sysclk.h 2 | /// @author Kimball Thurston 3 | /// 4 | 5 | // 6 | // Copyright (c) 2004 Kimball Thurston 7 | // 8 | // This program is free software; you can redistribute it and/or modify 9 | // it under the terms of the GNU General Public License version 2 as 10 | // published by the Free Software Foundation. 11 | // 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU General Public License 18 | // along with this program; if not, write to the Free Software 19 | // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | // 21 | 22 | #ifndef _SYSCLK_H_ 23 | #define _SYSCLK_H_ 24 | 25 | #include "types.h" 26 | /** 27 | * Retrieves the host global high-resolution ticks. This is expected to be a 28 | * counter that is very fast to query, and has very good resolution. 29 | * 30 | * On x86 architecture, this is probably best implemented as retrieving the time 31 | * stamp counter (rdtsc).*/ 32 | uint64 sys_get_hiresclk_ticks(); 33 | 34 | /* 35 | * Find the number of high resolution ticks per second. 36 | */ 37 | uint64 sys_get_hiresclk_ticks_per_second(); 38 | 39 | #endif /* _SYSCLK_H_ */ 40 | -------------------------------------------------------------------------------- /src/system/sysexcept.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * sysexcept.cc 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include 22 | 23 | #include "sysexcept.h" 24 | 25 | sys_exception::sys_exception(char *s) 26 | { 27 | strncpy(str, s, (sizeof str)-1); 28 | } 29 | 30 | const char *sys_exception::what() const throw() 31 | { 32 | return str; 33 | } 34 | -------------------------------------------------------------------------------- /src/system/sysexcept.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * sysexcept.h 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSEXCEPT_H__ 22 | #define __SYSEXCEPT_H__ 23 | 24 | #define SYS_EXCEPTION_STR_MAX 256 25 | 26 | #include 27 | 28 | class sys_exception: public std::exception { 29 | private: 30 | char str[SYS_EXCEPTION_STR_MAX]; 31 | public: 32 | sys_exception(char *s); 33 | virtual const char * what() const throw(); 34 | }; 35 | 36 | #endif /* __SYSEXCEPT_H__ */ 37 | -------------------------------------------------------------------------------- /src/system/sysfeatures.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * sysfeatures.h 4 | * 5 | * Stupid GCC: we can't name this file features.h... 6 | * 7 | * Copyright (C) 2004 Stefan Weyergraf 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License version 2 as 11 | * published by the Free Software Foundation. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | */ 22 | 23 | #ifndef __SYSTEM_SYSFEATURES_H__ 24 | #define __SYSTEM_SYSFEATURES_H__ 25 | 26 | /* We've got the following features: 27 | * PPC_VIDEO_CONVERT_ACCEL_FEATURE see sysvaccel.h 28 | */ 29 | 30 | // provider priorities 31 | #define PPC_FEATURE_NOT_PROVIDED 0 32 | //#define PPC_FEATURE_PROVIDED_BY_OSAPI 1 33 | #define PPC_FEATURE_PROVIDED_BY_ARCH 2 34 | 35 | #include "arch/sysfeatures.h" 36 | //#include "osapi/sysfeatures.h" 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /src/system/systhread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * systhread.h 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSTHREAD_H__ 22 | #define __SYSTHREAD_H__ 23 | 24 | #include "types.h" 25 | 26 | typedef void * sys_mutex; 27 | typedef void * sys_semaphore; 28 | typedef void * sys_thread; 29 | 30 | typedef void * (*sys_thread_function)(void *); 31 | 32 | /* system-dependent (implementation in $MYSYSTEM/systhread.cc) */ 33 | /* all return 0 on success */ 34 | int sys_create_mutex(sys_mutex *m); 35 | int sys_create_semaphore(sys_semaphore *s); 36 | int sys_create_thread(sys_thread *t, int flags, sys_thread_function start_routine, void *arg); 37 | 38 | void sys_destroy_mutex(sys_mutex m); 39 | void sys_destroy_semaphore(sys_semaphore s); 40 | void sys_destroy_thread(sys_semaphore s); 41 | 42 | int sys_lock_mutex(sys_mutex m); 43 | int sys_trylock_mutex(sys_mutex m); 44 | void sys_unlock_mutex(sys_mutex m); 45 | 46 | void sys_signal_semaphore(sys_semaphore s); 47 | void sys_signal_all_semaphore(sys_semaphore s); 48 | void sys_wait_semaphore(sys_semaphore s); 49 | void sys_wait_semaphore_bounded(sys_semaphore s, int ms); 50 | 51 | void sys_lock_semaphore(sys_semaphore s); 52 | void sys_unlock_semaphore(sys_semaphore s); 53 | 54 | void sys_exit_thread(void *ret); 55 | void * sys_join_thread(sys_thread t); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/system/sysvaccel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * sysvaccel.h 4 | * 5 | * Abstraction for video conversion function acceleration 6 | * 7 | * Copyright (C) 2004 Stefan Weyergraf 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License version 2 as 11 | * published by the Free Software Foundation. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | */ 22 | 23 | #ifndef __SYSVACCEL_H__ 24 | #define __SYSVACCEL_H__ 25 | 26 | #include "system/display.h" 27 | 28 | void sys_convert_display( 29 | const DisplayCharacteristics &aSrcChar, 30 | const DisplayCharacteristics &aDestChar, 31 | const void *aSrcBuf, 32 | void *aDestBuf, 33 | int firstLine, 34 | int lastLine); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/system/sysvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * sysvm.h 4 | * 5 | * Copyright (C) 2004 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef _SYSVM_H_ 22 | #define _SYSVM_H_ 23 | 24 | #include 25 | #include "system/types.h" 26 | 27 | bool sys_support_vm(); 28 | 29 | void *sys_alloc_read_write_execute(size_t size); 30 | void sys_free_read_write_execute(void *p); 31 | 32 | void *sys_malloc32(size_t size); 33 | void sys_free32(void *p, size_t size); 34 | 35 | #define SYSVM_PROT_NOACCESS 0 36 | #define SYSVM_PROT_READ 1 37 | #define SYSVM_PROT_WRITE 2 38 | 39 | void sys_mprotect(void *va, size_t size, int protection); 40 | void *sys_mmap_anon(size_t size); 41 | void *sys_mcommit(void *va, size_t size); 42 | void sys_mfree(void *va, size_t size); 43 | 44 | typedef void *sys_mapping_area; 45 | 46 | bool sys_alloc_mapping_area(sys_mapping_area *area, size_t size); 47 | void *sys_mapping_area_ptr(sys_mapping_area area); 48 | void *sys_map_area(sys_mapping_area area, size_t ofs, size_t size, int protection, void *hint); 49 | void sys_unmap_area(void *base, size_t size); 50 | void sys_free_mapping_area(sys_mapping_area area); 51 | 52 | #endif /* _SYSVM_H_ */ 53 | -------------------------------------------------------------------------------- /src/system/ui/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/ui/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | if USE_UI_BEOS 4 | THE_UI_DIR=beos 5 | endif 6 | 7 | if USE_UI_QT 8 | THE_UI_DIR=qt 9 | endif 10 | 11 | if USE_UI_GTK 12 | THE_UI_DIR=gtk 13 | endif 14 | 15 | if USE_UI_WIN32 16 | THE_UI_DIR=win32 17 | endif 18 | 19 | if USE_UI_SDL 20 | THE_UI_DIR=sdl 21 | endif 22 | 23 | if USE_UI_X11 24 | THE_UI_DIR=x11 25 | endif 26 | 27 | EXTRA_DIST = gui.h 28 | 29 | SUBDIRS = $(THE_UI_DIR) 30 | EXTRA_SUBDIRS = beos qt gtk win32 sdl x11 31 | 32 | AM_CPPFLAGS = -I ../.. 33 | -------------------------------------------------------------------------------- /src/system/ui/beos/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/ui/beos/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libui.a 4 | 5 | libui_a_SOURCES = gui.cc sysdisplay.cc sysbeos.cc \ 6 | sysmouse.cc syskeyboard.cc sysbeos.h 7 | 8 | EXTRA_DIST = pearpc-res.h pearpc-res.rdef 9 | 10 | AM_CPPFLAGS = -I ../../.. 11 | #@BEOS_CFLAGS@ 12 | -------------------------------------------------------------------------------- /src/system/ui/beos/gui.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * gui.cc 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * Copyright (C) 2004 Francois Revol (revol@free.fr) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include "tools/data.h" 26 | #include "system/ui/gui.h" 27 | 28 | /* 29 | class MyFilePanel : public BFilePanel { 30 | public: 31 | MyFilePanel( 32 | }; 33 | */ 34 | 35 | void sys_gui_init() 36 | { 37 | // BApplication is created in sysinit (needed for display & clipboard) 38 | //new BApplication("application/x-vnd.PearPC"); // no, BeOS doesn't look like a copy of Qt, it's Qt which is a copy of the BeAPI :p 39 | } 40 | 41 | bool sys_gui_open_file_dialog(String &ret, const String &title, const String &filespec, const String &filespecname, const String &home, bool existing) 42 | { 43 | /* String f; 44 | f.assignFormat("%y (%y)", &filespecname, &filespec); 45 | QFileDialog* fd = new QFileDialog(home.contentChar(), f.contentChar(), NULL, title.contentChar(), FALSE); 46 | fd->setCaption(title.contentChar()); 47 | if (existing) { 48 | fd->setMode(QFileDialog::ExistingFile); 49 | } else { 50 | fd->setMode(QFileDialog::AnyFile); 51 | } 52 | 53 | QString fileName; 54 | if (fd->exec() == QDialog::Accepted) { 55 | fileName = fd->selectedFile(); 56 | ret = (const char *)fileName; 57 | delete fd; 58 | return true; 59 | } else { 60 | delete fd; 61 | return false; 62 | } 63 | */ 64 | return false; 65 | } 66 | 67 | int sys_gui_messagebox(const String &title, const String &text, int buttons) 68 | { 69 | BAlert *alert; 70 | } 71 | -------------------------------------------------------------------------------- /src/system/ui/beos/pearpc-res.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** /BeOS 5 System/home/devel/pearpc/pearpc/src/system/ui/beos/pearpc-res.h 3 | ** 4 | ** Automatically generated by BResourceParser on 5 | ** Friday, August 13, 2004 at 12:05:26. 6 | ** 7 | */ 8 | 9 | -------------------------------------------------------------------------------- /src/system/ui/beos/syskeyboard.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * syskeyboard.cc - keyboard access functions for BeOS 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) 6 | * Copyright (C) 1999-2004 Sebastian Biallas (sb@biallas.net) 7 | * Copyright (C) 2004 Francois Revol (revol@free.fr) 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License version 2 as 11 | * published by the Free Software Foundation. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | */ 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include "system/display.h" 28 | #include "system/keyboard.h" 29 | 30 | #define DPRINTF(a...) 31 | //#define DPRINTF(a...) ht_printf(a) 32 | 33 | class BeOSSystemKeyboard: public SystemKeyboard { 34 | public: 35 | virtual int getKeybLEDs() 36 | { 37 | int r = 0; 38 | uint32 mods = modifiers(); 39 | if (mods & B_CAPS_LOCK) r |= KEYB_LED_NUM; 40 | if (mods & B_CAPS_LOCK) r |= KEYB_LED_CAPS; 41 | if (mods & B_SCROLL_LOCK) r |= KEYB_LED_SCROLL; 42 | return r; 43 | } 44 | 45 | virtual void setKeybLEDs(int leds) 46 | { 47 | uint32 mods = 0; 48 | if (leds & KEYB_LED_NUM) mods |= B_CAPS_LOCK; 49 | if (leds & KEYB_LED_CAPS) mods |= B_CAPS_LOCK; 50 | if (leds & KEYB_LED_SCROLL) mods |= B_SCROLL_LOCK; 51 | // XXX: warning: set_keyboard_locks() doesn't work correctly 52 | set_keyboard_locks(mods); 53 | } 54 | 55 | virtual bool handleEvent(const SystemEvent &ev) 56 | { 57 | return SystemKeyboard::handleEvent(ev); 58 | } 59 | }; 60 | 61 | SystemKeyboard *allocSystemKeyboard() 62 | { 63 | if (gKeyboard) return NULL; 64 | return new BeOSSystemKeyboard(); 65 | } 66 | -------------------------------------------------------------------------------- /src/system/ui/beos/sysmouse.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * sysmouse.cc - mouse access functions for BeOS 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) 6 | * Copyright (C) 1999-2004 Sebastian Biallas (sb@biallas.net) 7 | * Copyright (C) 2004 Francois Revol (revol@free.fr) 8 | * 9 | * This program is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License version 2 as 11 | * published by the Free Software Foundation. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 21 | */ 22 | 23 | #include 24 | 25 | #include "system/display.h" 26 | #include "system/mouse.h" 27 | 28 | #define DPRINTF(a...) 29 | //#define DPRINTF(a...) ht_printf(a) 30 | 31 | class BeOSSystemMouse: public SystemMouse { 32 | public: 33 | 34 | virtual bool handleEvent(const SystemEvent &ev) 35 | { 36 | return SystemMouse::handleEvent(ev); 37 | } 38 | }; 39 | 40 | SystemMouse *allocSystemMouse() 41 | { 42 | if (gMouse) return NULL; 43 | return new BeOSSystemMouse(); 44 | } 45 | -------------------------------------------------------------------------------- /src/system/ui/gtk/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/ui/gtk/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libui.a 4 | 5 | libui_a_SOURCES = gui.cc 6 | 7 | AM_CPPFLAGS = -I ../../.. -I/usr/include/gtk-2.0 -I/usr/include/glib-2.0 \ 8 | -I/usr/lib/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/lib/gtk-2.0/include \ 9 | -I/usr/include/atk-1.0 10 | -------------------------------------------------------------------------------- /src/system/ui/gui.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * gui.h 4 | * 5 | * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | #ifndef __GUI_H__ 21 | #define __GUI_H__ 22 | 23 | #include "tools/data.h" 24 | #include "tools/str.h" 25 | 26 | void sys_gui_init(); 27 | bool sys_gui_open_file_dialog(String &ret, const String &title, const String &filespec, const String &filespecname, const String &home, bool existing); 28 | 29 | #define MB_INFO 0 30 | #define MB_QUESTION 1 31 | #define MB_WARN 2 32 | #define MB_ERR 3 33 | 34 | #define MB_YES 0x100 35 | #define MB_NO 0x200 36 | #define MB_OK 0x300 37 | #define MB_CANCEL 0x400 38 | 39 | int sys_gui_messagebox(const String &title, const String &text, int buttons); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/system/ui/qt/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/ui/qt/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libui.a 4 | 5 | libui_a_SOURCES = gui.cc 6 | 7 | AM_CPPFLAGS = -I ../../.. @QT_CFLAGS@ 8 | -------------------------------------------------------------------------------- /src/system/ui/qt/gui.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * gui.cc 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include "tools/data.h" 24 | #include "system/ui/gui.h" 25 | 26 | static QApplication *gApp; 27 | 28 | void sys_gui_init() 29 | { 30 | int c=0; 31 | gApp = new QApplication(c, 0, TRUE); 32 | } 33 | 34 | bool sys_gui_open_file_dialog(String &ret, const String &title, const String &filespec, const String &filespecname, const String &home, bool existing) 35 | { 36 | String f; 37 | f.assignFormat("%y (%y)", &filespecname, &filespec); 38 | QFileDialog* fd = new QFileDialog(home.contentChar(), f.contentChar(), NULL, title.contentChar(), FALSE); 39 | fd->setCaption(title.contentChar()); 40 | if (existing) { 41 | fd->setMode(QFileDialog::ExistingFile); 42 | } else { 43 | fd->setMode(QFileDialog::AnyFile); 44 | } 45 | 46 | QString fileName; 47 | if (fd->exec() == QDialog::Accepted) { 48 | fileName = fd->selectedFile(); 49 | ret = (const char *)fileName; 50 | delete fd; 51 | return true; 52 | } else { 53 | delete fd; 54 | return false; 55 | } 56 | } 57 | 58 | int sys_gui_messagebox(const String &title, const String &text, int buttons) 59 | { 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/system/ui/sdl/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/ui/sdl/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libui.a 4 | 5 | libui_a_SOURCES = gui.cc sysdisplay.cc syskeyboard.cc sysmouse.cc syssdl.cc syssdl.h 6 | 7 | AM_CPPFLAGS = -I ../../.. 8 | -------------------------------------------------------------------------------- /src/system/ui/sdl/gui.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * gui.cc 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include "tools/data.h" 22 | #include "system/ui/gui.h" 23 | 24 | void sys_gui_init() 25 | { 26 | } 27 | 28 | bool sys_gui_open_file_dialog(String &ret, const String &title, const String &filespec, const String &filespecname, const String &home, bool existing) 29 | { 30 | return false; 31 | } 32 | 33 | int sys_gui_messagebox(const String &title, const String &text, int buttons) 34 | { 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /src/system/ui/sdl/syskeyboard.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * keyboard.cc - keyboardaccess functions for POSIX 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf 6 | * Copyright (C) 1999-2004 Sebastian Biallas (sb@biallas.net) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | 24 | #include 25 | 26 | #include "system/display.h" 27 | #include "system/keyboard.h" 28 | 29 | class SDLSystemKeyboard: public SystemKeyboard { 30 | public: 31 | virtual int getKeybLEDs() 32 | { 33 | int r = 0; 34 | SDLMod keyMods = SDL_GetModState(); 35 | if (keyMods & KMOD_NUM) 36 | r |= KEYB_LED_NUM; 37 | if (keyMods & KMOD_CAPS) 38 | r |= KEYB_LED_CAPS; 39 | /* 40 | if (keyMods & SDLK_SCROLLOCK) 41 | r |= KEYB_LED_SCROLL;*/ 42 | return r; 43 | } 44 | 45 | void setKeybLEDs(int leds) 46 | { 47 | #if 0 48 | int r = getKeybLEDs() ^ leds; 49 | SDLMod keyMods = SDL_GetModState(); 50 | 51 | if (r & KEYB_LED_NUM && leds & KEYB_LED_NUM) 52 | (int)keyMods |= KMOD_NUM; 53 | else 54 | (int)keyMods &= KMOD_NUM; 55 | 56 | if (r & KEYB_LED_CAPS && leds & KEYB_LED_CAPS) 57 | (int)keyMods |= KMOD_CAPS; 58 | else 59 | (int)keyMods &= KMOD_CAPS; 60 | /* 61 | if (r & KEYB_LED_SCROLL && leds & KEYB_LED_SCROLL) 62 | keyMods |= SDLK_SCROLLOCK; 63 | else 64 | keyMods &= SDLK_SCROLLOCK; 65 | */ 66 | SDL_SetModState(keyMods); 67 | #endif 68 | } 69 | 70 | virtual bool handleEvent(const SystemEvent &ev) 71 | { 72 | return SystemKeyboard::handleEvent(ev); 73 | } 74 | }; 75 | 76 | SystemKeyboard *allocSystemKeyboard() 77 | { 78 | if (gKeyboard) return NULL; 79 | return new SDLSystemKeyboard(); 80 | } 81 | -------------------------------------------------------------------------------- /src/system/ui/sdl/sysmouse.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * mouse.cc - mouse access functions for SDL 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf 6 | * Copyright (C) 1999-2004 Sebastian Biallas (sb@biallas.net) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | 24 | #include "system/systhread.h" 25 | #include "syssdl.h" 26 | 27 | #include "system/display.h" 28 | #include "system/mouse.h" 29 | 30 | class SDLSystemMouse: public SystemMouse { 31 | public: 32 | 33 | virtual bool handleEvent(const SystemEvent &ev) 34 | { 35 | return SystemMouse::handleEvent(ev); 36 | } 37 | }; 38 | 39 | SystemMouse *allocSystemMouse() 40 | { 41 | if (gMouse) return NULL; 42 | return new SDLSystemMouse(); 43 | } 44 | -------------------------------------------------------------------------------- /src/system/ui/sdl/syssdl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * syssdl.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSSDL_H__ 22 | #define __SYSSDL_H__ 23 | 24 | #include 25 | 26 | #include "system/display.h" 27 | #include "system/systhread.h" 28 | 29 | extern SDL_Surface * gSDLScreen; 30 | 31 | class SDLSystemDisplay: public SystemDisplay { 32 | protected: 33 | DisplayCharacteristics mSDLChar; 34 | byte * mSDLFrameBuffer; 35 | bool mChangingScreen; 36 | SDL_Surface * mSDLClientScreen; 37 | sys_mutex mRedrawMutex; 38 | SDL_Cursor * mVisibleCursor; 39 | SDL_Cursor * mInvisibleCursor; 40 | 41 | uint bitsPerPixelToXBitmapPad(uint bitsPerPixel); 42 | void dumpDisplayChar(const DisplayCharacteristics &chr); 43 | public: 44 | char * mTitle; 45 | DisplayCharacteristics mSDLChartemp; 46 | SDL_cond *mWaitcondition; 47 | bool mChangeResRet; 48 | uint32 mEventThreadID; 49 | 50 | SDLSystemDisplay(const char *title, const DisplayCharacteristics &chr, int redraw_ms); 51 | 52 | void finishMenu(); 53 | virtual void updateTitle(); 54 | virtual int toString(char *buf, int buflen) const; 55 | void toggleFullScreen(); 56 | virtual void displayShow(); 57 | virtual void convertCharacteristicsToHost(DisplayCharacteristics &aHostChar, const DisplayCharacteristics &aClientChar); 58 | virtual bool changeResolution(const DisplayCharacteristics &aCharacteristics); 59 | virtual bool changeResolutionREAL(const DisplayCharacteristics &aCharacteristics); 60 | virtual void getHostCharacteristics(Container &modes); 61 | virtual void setMouseGrab(bool enable); 62 | virtual void initCursor(); 63 | }; 64 | 65 | 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/system/ui/win32/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/ui/win32/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | SUFFIXES = .rc .o 4 | 5 | noinst_LIBRARIES = libui.a 6 | 7 | libui_a_SOURCES = gui.cc sysdisplay.cc syswin.cc syswin.h syskeyboard.cc \ 8 | sysmouse.cc resources.h resources.rc 9 | 10 | EXTRA_DIST = ppc.ico 11 | 12 | INCLUDE_PATH = ../../.. 13 | AM_CPPFLAGS = -I $(INCLUDE_PATH) 14 | 15 | .rc.o: 16 | windres -F pe-i386 --include-dir=$(INCLUDE_PATH) -i $< -o $@ 17 | -------------------------------------------------------------------------------- /src/system/ui/win32/ppc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastianbiallas/pearpc/7eb63de8a92b86e1b7438019ddcf935005112501/src/system/ui/win32/ppc.ico -------------------------------------------------------------------------------- /src/system/ui/win32/resources.h: -------------------------------------------------------------------------------- 1 | #define IDI_PEAR_PC 101 2 | -------------------------------------------------------------------------------- /src/system/ui/win32/resources.rc: -------------------------------------------------------------------------------- 1 | #include "info.h" 2 | #include "resources.h" 3 | 4 | #if 1 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // 7 | // Version 8 | // 9 | 10 | VS_VERSION_INFO VERSIONINFO 11 | FILEVERSION APPVERSION_IN_NUMBERS 12 | PRODUCTVERSION APPVERSION_IN_NUMBERS 13 | FILEFLAGSMASK 0x3fL 14 | FILEOS 0x40004L 15 | FILETYPE 0x1L 16 | FILESUBTYPE 0x0L 17 | BEGIN 18 | BLOCK "StringFileInfo" 19 | BEGIN 20 | BLOCK "040704b0" 21 | BEGIN 22 | VALUE "Comments", "\0" 23 | VALUE "CompanyName", "\0" 24 | VALUE "FileDescription", APPNAME"\0" 25 | VALUE "FileVersion", APPVERSION"\0" 26 | VALUE "InternalName", APPNAME"\0" 27 | VALUE "LegalCopyright", COPYRIGHT"\0" 28 | VALUE "LegalTrademarks", "\0" 29 | VALUE "OriginalFilename", "ppc.exe\0" 30 | VALUE "PrivateBuild", "\0" 31 | VALUE "ProductName", APPNAME"\0" 32 | VALUE "ProductVersion", APPVERSION"\0" 33 | VALUE "SpecialBuild", "\0" 34 | END 35 | END 36 | BLOCK "VarFileInfo" 37 | BEGIN 38 | VALUE "Translation", 0x407, 1200 39 | END 40 | END 41 | #endif 42 | 43 | ///////////////////////////////////////////////////////////////////////////// 44 | // 45 | // Icon 46 | // 47 | 48 | // Icon with lowest ID value placed first to ensure application icon 49 | // remains consistent on all systems. 50 | IDI_PEAR_PC ICON DISCARDABLE "ppc.ico" 51 | -------------------------------------------------------------------------------- /src/system/ui/win32/sysmouse.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * mouse.cc - mouse access functions for Windows 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf 6 | * Copyright (C) 1999-2004 Sebastian Biallas (sb@biallas.net) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | 24 | #define WIN32_LEAN_AND_MEAN 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #undef FASTCALL 31 | 32 | #include "system/systhread.h" 33 | #include "syswin.h" 34 | 35 | #include "system/display.h" 36 | #include "system/mouse.h" 37 | 38 | class WinSystemMouse: public SystemMouse { 39 | public: 40 | 41 | virtual bool handleEvent(const SystemEvent &ev) 42 | { 43 | return SystemMouse::handleEvent(ev); 44 | } 45 | }; 46 | 47 | SystemMouse *allocSystemMouse() 48 | { 49 | if (gMouse) return NULL; 50 | return new WinSystemMouse(); 51 | } 52 | -------------------------------------------------------------------------------- /src/system/ui/win32/syswin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * syswin.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSWIN_H__ 22 | #define __SYSWIN_H__ 23 | 24 | #include "system/systhread.h" 25 | #include "system/display.h" 26 | 27 | extern HWND gHWNDMain; 28 | extern CRITICAL_SECTION gDrawCS; 29 | extern int gMenuHeight; 30 | extern BITMAPINFO gMenuBitmapInfo; 31 | extern byte *menuData; 32 | 33 | class Win32Display: public SystemDisplay 34 | { 35 | char mCurTitle[200]; 36 | char *mTitle; 37 | HCURSOR mInvisibleCursor; 38 | HCURSOR mVisibleCursor; 39 | 40 | public: 41 | DisplayCharacteristics mWinChar; 42 | 43 | Win32Display(const char *name, const DisplayCharacteristics &chr, int redraw_ms); 44 | virtual ~Win32Display(); 45 | virtual void getHostCharacteristics(Container &modes); 46 | virtual void convertCharacteristicsToHost(DisplayCharacteristics &aHostChar, const DisplayCharacteristics &aClientChar); 47 | virtual bool changeResolution(const DisplayCharacteristics &aHostChar); 48 | virtual int toString(char *buf, int buflen) const; 49 | virtual void finishMenu(); 50 | virtual void updateTitle(); 51 | virtual void setMouseGrab(bool enable); 52 | virtual void displayShow(); 53 | void initCursor(); 54 | void showCursor(bool visible); 55 | void createBitmap(); 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/system/ui/x11/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/system/ui/x11/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libui.a 4 | 5 | libui_a_SOURCES = gui.cc sysdisplay.cc syskeyboard.cc sysmouse.cc sysx11.cc sysx11.h 6 | 7 | AM_CPPFLAGS = -I ../../.. @X_CFLAGS@ 8 | -------------------------------------------------------------------------------- /src/system/ui/x11/gui.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * gui.cc 4 | * 5 | * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include "tools/data.h" 22 | #include "system/ui/gui.h" 23 | 24 | void sys_gui_init() 25 | { 26 | } 27 | 28 | bool sys_gui_open_file_dialog(String &ret, const String &title, const String &filespec, const String &filespecname, const String &home, bool existing) 29 | { 30 | return false; 31 | } 32 | 33 | int sys_gui_messagebox(const String &title, const String &text, int buttons) 34 | { 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /src/system/ui/x11/syskeyboard.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * keyboard.cc - keyboard access functions for X11 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf 6 | * Copyright (C) 1999-2004 Sebastian Biallas (sb@biallas.net) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | 24 | #include "system/systhread.h" 25 | #include "sysx11.h" 26 | 27 | #include "system/display.h" 28 | #include "system/keyboard.h" 29 | 30 | class X11SystemKeyboard: public SystemKeyboard { 31 | public: 32 | virtual int getKeybLEDs() 33 | { 34 | return 0; 35 | } 36 | 37 | virtual void setKeybLEDs(int leds) 38 | { 39 | } 40 | 41 | virtual bool handleEvent(const SystemEvent &ev) 42 | { 43 | return SystemKeyboard::handleEvent(ev); 44 | } 45 | }; 46 | 47 | SystemKeyboard *allocSystemKeyboard() 48 | { 49 | if (gKeyboard) return NULL; 50 | return new X11SystemKeyboard(); 51 | } 52 | -------------------------------------------------------------------------------- /src/system/ui/x11/sysmouse.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * mouse.cc - mouse access functions for X11 4 | * 5 | * Copyright (C) 1999-2004 Stefan Weyergraf 6 | * Copyright (C) 1999-2004 Sebastian Biallas (sb@biallas.net) 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License version 2 as 10 | * published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 | */ 21 | 22 | #include 23 | 24 | #include "system/systhread.h" 25 | #include "sysx11.h" 26 | 27 | #include "system/display.h" 28 | #include "system/mouse.h" 29 | 30 | class X11SystemMouse: public SystemMouse { 31 | public: 32 | 33 | virtual bool handleEvent(const SystemEvent &ev) 34 | { 35 | return SystemMouse::handleEvent(ev); 36 | } 37 | }; 38 | 39 | SystemMouse *allocSystemMouse() 40 | { 41 | if (gMouse) return NULL; 42 | return new X11SystemMouse(); 43 | } 44 | -------------------------------------------------------------------------------- /src/system/ui/x11/sysx11.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PearPC 3 | * sysx11.h 4 | * 5 | * Copyright (C) 2004 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SYSX11_H__ 22 | #define __SYSX11_H__ 23 | 24 | #include 25 | 26 | #include "system/systhread.h" 27 | 28 | extern sys_mutex gX11Mutex; 29 | extern Display * gX11Display; 30 | extern Window gX11Window; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/tools/.gitignore: -------------------------------------------------------------------------------- 1 | .deps 2 | Makefile 3 | Makefile.in 4 | -------------------------------------------------------------------------------- /src/tools/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LIBRARIES = libtools.a 4 | 5 | libtools_a_SOURCES = atom.cc atom.h data.cc data.h debug.cc debug.h \ 6 | endianess.cc endianess.h except.cc except.h snprintf.cc snprintf.h \ 7 | str.cc str.h stream.cc stream.h strtools.cc strtools.h \ 8 | thread.cc thread.h cstream.h crc32.cc crc32.h \ 9 | crc32defs.h crc32table.h 10 | 11 | AM_CPPFLAGS = -I .. 12 | -------------------------------------------------------------------------------- /src/tools/atom.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * atom.cc 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #include "atom.h" 22 | #include "data.h" 23 | 24 | #include 25 | 26 | //static 27 | AVLTree atoms(true); 28 | 29 | class Atom: public Object { 30 | public: 31 | uint id; 32 | void *value; 33 | 34 | Atom(uint i, void *v) 35 | { 36 | id = i; 37 | value = v; 38 | } 39 | 40 | int compareTo(const Object *obj) const 41 | { 42 | Atom *a = (Atom*)obj; 43 | return id - a->id; 44 | } 45 | }; 46 | 47 | void *getAtomValue(uint id) 48 | { 49 | if (id != invalid_atom_id) { 50 | Atom a(id, NULL); 51 | Atom *f = (Atom*)atoms.get(atoms.find(&a)); 52 | if (f) return f->value; 53 | } 54 | return NULL; 55 | } 56 | 57 | uint getAtomId(void *value) 58 | { 59 | if (value) { 60 | foreach(Atom, a, atoms, 61 | if (a->value == value) return a->id; 62 | ); 63 | } 64 | return invalid_atom_id; 65 | } 66 | 67 | #include "debug.h" 68 | bool registerAtom(uint id, void *value) 69 | { 70 | ASSERT(value); 71 | atoms.insert(new Atom(id, value)); 72 | return true; 73 | } 74 | 75 | bool unregisterAtom(uint id) 76 | { 77 | Atom a(id, NULL); 78 | atoms.delObj(&a); 79 | return true; 80 | } 81 | 82 | /* 83 | * Module Init/Done 84 | */ 85 | 86 | bool initAtom() 87 | { 88 | return true; 89 | } 90 | 91 | void doneAtom() 92 | { 93 | } 94 | -------------------------------------------------------------------------------- /src/tools/atom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * atom.h 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __ATOM_H__ 22 | #define __ATOM_H__ 23 | 24 | #include "system/types.h" 25 | 26 | #define invalid_atom_id 0 27 | 28 | void *getAtomValue(uint id); 29 | uint getAtomId(void *value); 30 | bool registerAtom(uint id, void *data); 31 | bool unregisterAtom(uint id); 32 | 33 | /* 34 | * Module Init/Done 35 | */ 36 | 37 | bool initAtom(); 38 | void doneAtom(); 39 | 40 | #endif /* !__ATOM_H__ */ 41 | 42 | -------------------------------------------------------------------------------- /src/tools/crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Function for computing CRC32 for the purpose of adding to Ethernet packets. 3 | * 4 | */ 5 | 6 | #ifndef _CRC32_H_ 7 | #define _CRC32_H_ 8 | 9 | #include 10 | #include "system/types.h" 11 | 12 | uint32 ether_crc(size_t len, const byte *p); 13 | 14 | #endif /* _CRC32_H_ */ 15 | -------------------------------------------------------------------------------- /src/tools/crc32defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * There are multiple 16-bit CRC polynomials in common use, but this is 3 | * *the* standard CRC-32 polynomial, first popularized by Ethernet. 4 | * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0 5 | */ 6 | #define CRCPOLY_LE 0xedb88320 7 | #define CRCPOLY_BE 0x04c11db7 8 | 9 | /* How many bits at a time to use. Requires a table of 4< 8 || CRC_LE_BITS < 1 || CRC_LE_BITS & CRC_LE_BITS-1 23 | # error CRC_LE_BITS must be a power of 2 between 1 and 8 24 | #endif 25 | 26 | /* 27 | * Big-endian CRC computation. Used with serial bit streams sent 28 | * msbit-first. Be sure to use cpu_to_be32() to append the computed CRC. 29 | */ 30 | #if CRC_BE_BITS > 8 || CRC_BE_BITS < 1 || CRC_BE_BITS & CRC_BE_BITS-1 31 | # error CRC_BE_BITS must be a power of 2 between 1 and 8 32 | #endif 33 | -------------------------------------------------------------------------------- /src/tools/cstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * cstream.cc 4 | * 5 | * Copyright (C) 1999-2002 Sebastian Biallas (sb@web-productions.de) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | #ifndef __CSTREAM_H__ 21 | #define __CSTREAM_H__ 22 | 23 | #include "stream.h" 24 | 25 | /* 26 | * NEVER use CompressedStream for both reading and writing! 27 | */ 28 | 29 | #define COMPRESSED_STREAM_DEFAULT_GRANULARITY 10240 30 | 31 | class CompressedStream: public StreamLayer { 32 | protected: 33 | byte *buffer; 34 | uint buffersize; 35 | uint bufferpos; 36 | 37 | bool flush_compressed(); 38 | bool flush_uncompressed(); 39 | public: 40 | CompressedStream(Stream *stream, bool own_stream, uint granularity = COMPRESSED_STREAM_DEFAULT_GRANULARITY); 41 | virtual ~CompressedStream(); 42 | /* extends StreamLayer */ 43 | virtual uint read(void *buf, uint size); 44 | virtual uint write(const void *buf, uint size); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/tools/debug.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "debug.h" 6 | #include "system/types.h" 7 | 8 | extern "C" void NORETURN ht_assert_failed(const char *file, int line, const char *assertion) 9 | { 10 | fprintf(stderr, "in file %s, line %d: assertion failed: %s\n", file, line, assertion); 11 | #ifndef WIN32 12 | #if 1 13 | fprintf(stderr, "sending SIGTRAP..."); 14 | raise(SIGTRAP); 15 | #endif 16 | #endif 17 | exit(1); 18 | } 19 | 20 | void debugDumpMem(void *buf, int len) 21 | { 22 | byte *p = (byte*)buf; 23 | while (len) { 24 | uint w = 16; 25 | uint m = w; 26 | if (m>len) m = len; 27 | for (uint i=0; i 0x80)) ? '.' : *p); 37 | p++; 38 | } 39 | printf("\n"); 40 | len -= m; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/tools/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * debug.h 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __DEBUG_H__ 22 | #define __DEBUG_H__ 23 | 24 | #include "system/types.h" 25 | 26 | #ifdef __cplusplus 27 | extern "C" 28 | #endif 29 | void NORETURN ht_assert_failed(const char *file, int line, const char *assertion); 30 | 31 | #define ASSERT(a) if (!(a)) ht_assert_failed(__FILE__, __LINE__, (#a)); 32 | #define HERE __FILE__, __LINE__ 33 | 34 | void debugDumpMem(void *buf, int len); 35 | 36 | #endif /* !__DEBUG_H__ */ 37 | -------------------------------------------------------------------------------- /src/tools/endianess.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * endianess.h 4 | * 5 | * Copyright (C) 1999-2002 Stefan Weyergraf 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __ENDIANESS_H__ 22 | #define __ENDIANESS_H__ 23 | 24 | #include "system/types.h" 25 | 26 | // This is _NOT_ a bitmask! 27 | #define STRUCT_ENDIAN_8 1 28 | #define STRUCT_ENDIAN_16 2 29 | #define STRUCT_ENDIAN_32 4 30 | #define STRUCT_ENDIAN_64 8 31 | 32 | // This is a bitmask. 33 | #define STRUCT_ENDIAN_HOST 128 34 | 35 | typedef enum { 36 | big_endian, 37 | little_endian 38 | } Endianess; 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | void createForeignInt(void *buf, int i, int size, Endianess to_endianess); 45 | void createForeignInt64(void *buf, uint64 i, int size, Endianess to_endianess); 46 | int createHostInt(const void *buf, int size, Endianess from_endianess); 47 | uint64 createHostInt64(const void *buf, int size, Endianess from_endianess); 48 | void createHostStructx(void *buf, uint bufsize, const uint8 *table, Endianess from_endianess); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif /* __ENDIANESS_H__ */ 55 | -------------------------------------------------------------------------------- /src/tools/snprintf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HT Editor 3 | * snprintf.h 4 | * 5 | * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | */ 20 | 21 | #ifndef __SNPRINTF_H__ 22 | #define __SNPRINTF_H__ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | int ht_asprintf(char **ptr, const char *format, ...); 29 | int ht_vasprintf(char **ptr, const char *format, va_list ap); 30 | 31 | int ht_snprintf(char *str, size_t count, const char *fmt, ...); 32 | int ht_vsnprintf(char *str, size_t count, const char *fmt, va_list args); 33 | 34 | int ht_fprintf(FILE *file, const char *fmt, ...); 35 | int ht_vfprintf(FILE *file, const char *fmt, va_list args); 36 | 37 | int ht_printf(const char *fmt, ...); 38 | int ht_vprintf(const char *fmt, va_list args); 39 | #endif 40 | -------------------------------------------------------------------------------- /video.x: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sebastianbiallas/pearpc/7eb63de8a92b86e1b7438019ddcf935005112501/video.x --------------------------------------------------------------------------------