├── .github └── workflows │ ├── build-openbios-builder.yml │ ├── main.yml │ └── release.yml ├── .gitignore ├── COPYING ├── Documentation ├── ChangeLog.arch ├── README.debugger ├── TODO.sparc └── kernel │ ├── AUTHORS │ ├── COPYING │ ├── Changelog.stepan │ ├── TODO │ ├── dictformat.txt │ ├── glossary.txt │ └── initializers.txt ├── Makefile ├── Makefile.target ├── README ├── VERSION ├── arch ├── amd64 │ ├── Kconfig │ ├── boot.c │ ├── build.xml │ ├── builtin.c │ ├── console.c │ ├── context.c │ ├── context.h │ ├── defconfig │ ├── init.fs │ ├── ldscript │ ├── lib.c │ ├── linux_load.c │ ├── multiboot.c │ ├── multiboot.h │ ├── openbios.c │ ├── openbios.h │ ├── plainboot.c │ ├── relocate.h │ ├── segment.c │ ├── segment.h │ ├── switch.S │ └── sys_info.c ├── build.xml ├── ia64 │ ├── Kconfig │ ├── build.xml │ ├── defconfig │ └── init.fs ├── ppc │ ├── Kconfig │ ├── Makefile │ ├── Makefile.asm │ ├── briq │ │ ├── briq.c │ │ ├── briq.fs │ │ ├── briq.h │ │ ├── init.c │ │ ├── kernel.c │ │ ├── main.c │ │ ├── methods.c │ │ ├── tree.c │ │ ├── tree.fs │ │ └── vfd.c │ ├── build.xml │ ├── defconfig │ ├── kernel.c │ ├── kernel.h │ ├── misc.S │ ├── mmutypes.h │ ├── mol │ │ ├── console.c │ │ ├── init.c │ │ ├── kernel.c │ │ ├── main.c │ │ ├── methods.c │ │ ├── mol.c │ │ ├── mol.fs │ │ ├── mol.h │ │ ├── osi-blk.c │ │ ├── osi-scsi.c │ │ ├── prom.c │ │ ├── prom.h │ │ ├── pseudodisk.c │ │ ├── tree.c │ │ └── tree.fs │ ├── ofmem.c │ ├── osi.h │ ├── osi_calls.h │ ├── pearpc │ │ ├── console.c │ │ ├── init.c │ │ ├── kernel.c │ │ ├── main.c │ │ ├── methods.c │ │ ├── pearpc.c │ │ ├── pearpc.fs │ │ ├── pearpc.h │ │ ├── tree.c │ │ ├── tree.fs │ │ └── vfd.c │ ├── ppc.fs │ ├── qemu │ │ ├── console.c │ │ ├── context.c │ │ ├── context.h │ │ ├── init.c │ │ ├── kernel.c │ │ ├── kernel.h │ │ ├── ldscript │ │ ├── main.c │ │ ├── methods.c │ │ ├── mmutypes.h │ │ ├── ofmem.c │ │ ├── qemu.c │ │ ├── qemu.fs │ │ ├── qemu.h │ │ ├── start.S │ │ ├── switch.S │ │ ├── tree.fs │ │ └── vfd.c │ ├── start.S │ └── timebase.S ├── ppc64 │ └── qemu │ │ └── ldscript ├── sparc32 │ ├── boot.c │ ├── boot.h │ ├── build.xml │ ├── builtin.c │ ├── call-romvec.S │ ├── console.c │ ├── context.c │ ├── context.h │ ├── cpu.fs │ ├── cpustate.h │ ├── crs.h │ ├── entry.S │ ├── init.fs │ ├── ldscript │ ├── lib.c │ ├── linux_load.c │ ├── multiboot.c │ ├── multiboot.h │ ├── ofmem_sparc32.c │ ├── openbios.c │ ├── openbios.h │ ├── openprom.h │ ├── plainboot.c │ ├── psr.h │ ├── romvec.c │ ├── romvec.h │ ├── switch.S │ ├── sys_info.c │ ├── tree.fs │ ├── udiv.S │ ├── vectors.S │ ├── wof.S │ └── wuf.S ├── sparc64 │ ├── boot.c │ ├── boot.h │ ├── build.xml │ ├── builtin.c │ ├── call-client.S │ ├── console.c │ ├── const.h │ ├── context.c │ ├── context.h │ ├── cpu.fs │ ├── cpustate.h │ ├── entry.S │ ├── init.fs │ ├── ldscript │ ├── lib.c │ ├── linux_load.c │ ├── lsu.h │ ├── multiboot.c │ ├── multiboot.h │ ├── ofmem_sparc64.c │ ├── openbios.c │ ├── openbios.h │ ├── openprom.h │ ├── plainboot.c │ ├── pstate.h │ ├── spitfire.h │ ├── switch.S │ ├── sys_info.c │ ├── tree.fs │ └── vectors.S ├── unix │ ├── Kconfig │ ├── Makefile │ ├── blk.c │ ├── blk.h │ ├── boot.c │ ├── build.xml │ ├── gui_qt │ │ ├── Makefile │ │ ├── gui-qt.cpp │ │ ├── gui-qt.h │ │ ├── gui-qt.pro │ │ ├── logo.xpm │ │ └── qt-main.cpp │ ├── plugins.c │ ├── plugins │ │ ├── Kconfig │ │ ├── Makefile │ │ ├── Rules.plugin │ │ ├── loader.c │ │ ├── plugin_pci │ │ │ ├── Makefile │ │ │ ├── Makefile.old │ │ │ └── plugin_pci.c │ │ └── plugin_qt │ │ │ ├── Makefile │ │ │ ├── logo.xpm │ │ │ ├── pciconfig.h │ │ │ ├── plugin_qt.cpp │ │ │ ├── plugin_qt.h │ │ │ ├── plugin_qt.pro │ │ │ ├── qt_main.cpp │ │ │ └── qt_rom.fs │ ├── tree.fs │ └── unix.c └── x86 │ ├── Kconfig │ ├── boot.c │ ├── boot.h │ ├── build.xml │ ├── builtin.c │ ├── console.c │ ├── context.c │ ├── context.h │ ├── defconfig │ ├── entry.S │ ├── exception.c │ ├── init.fs │ ├── ldscript │ ├── lib.c │ ├── linux_load.c │ ├── multiboot.c │ ├── multiboot.h │ ├── openbios.c │ ├── openbios.h │ ├── plainboot.c │ ├── relocate.h │ ├── segment.c │ ├── segment.h │ ├── sys_info.c │ └── xbox │ ├── console.c │ └── methods.c ├── build.xml ├── config ├── examples │ ├── amd64_config.xml │ ├── ppc64_config.xml │ ├── ppc_config.xml │ ├── sparc32_config.xml │ ├── sparc64_config.xml │ └── x86_config.xml ├── scripts │ ├── reldir │ └── switch-arch └── xml │ ├── config-c.xsl │ ├── config-forth.xsl │ ├── dictionary.xsl │ ├── fcode.xsl │ ├── makefile.xsl │ ├── object.xsl │ ├── rules.xml │ ├── util.xsl │ └── xinclude.xsl ├── docker └── Dockerfile.builder ├── drivers ├── Kconfig ├── adb_bus.c ├── adb_bus.h ├── adb_kbd.c ├── adb_kbd.h ├── adb_mouse.c ├── adb_mouse.h ├── build.xml ├── cgthree.fs ├── cuda.c ├── cuda.h ├── escc.c ├── escc.h ├── esp.c ├── esp.fs ├── esp.h ├── floppy.c ├── floppy.h ├── fw_cfg.c ├── hdreg.h ├── ide.c ├── ide.h ├── iommu.c ├── iommu.h ├── kbd.c ├── kbd.h ├── lsi.c ├── macio.c ├── macio.h ├── obio.c ├── obio.h ├── pc_kbd.c ├── pc_serial.c ├── pci.c ├── pci.fs ├── pci.h ├── pci_database.c ├── pci_database.h ├── pmu.c ├── pmu.h ├── sbus.c ├── sbus.fs ├── scsi.h ├── tcx.fs ├── timer.c ├── timer.h ├── usb.c ├── usb.h ├── usbhid.c ├── usbohci.c ├── usbohci.h ├── usbohci_private.h ├── usbohci_rh.c ├── vga.fs ├── vga.h ├── vga_load_regs.c ├── vga_set_mode.c ├── virtio.c └── virtio.h ├── forth ├── Kconfig ├── admin │ ├── README │ ├── banner.fs │ ├── build.xml │ ├── callback.fs │ ├── devices.fs │ ├── help.fs │ ├── iocontrol.fs │ ├── nvram.fs │ ├── power.fs │ ├── reset.fs │ ├── script.fs │ ├── security.fs │ ├── selftest.fs │ └── userboot.fs ├── bootstrap │ ├── bootstrap.fs │ ├── build.xml │ ├── builtin.fs │ ├── hayes.fs │ ├── interpreter.fs │ ├── memory.fs │ └── start.fs ├── build.xml ├── debugging │ ├── build.xml │ ├── client.fs │ ├── fcode.fs │ ├── firmware.fs │ └── see.fs ├── device │ ├── README.device │ ├── build.xml │ ├── builtin.fs │ ├── device.fs │ ├── display.fs │ ├── extra.fs │ ├── fcode.fs │ ├── feval.fs │ ├── font.fs │ ├── logo.fs │ ├── missing │ ├── other.fs │ ├── package.fs │ ├── pathres.fs │ ├── preof.fs │ ├── property.fs │ ├── romfont.bin │ ├── structures.fs │ ├── table.fs │ ├── terminal.fs │ └── tree.fs ├── lib │ ├── 64bit.fs │ ├── build.xml │ ├── creation.fs │ ├── lists.fs │ ├── locals.fs │ ├── preinclude.fs │ ├── preprocessor.fs │ ├── rstack.fs │ ├── split.fs │ ├── string.fs │ └── vocabulary.fs ├── packages │ ├── Kconfig │ ├── README │ ├── build.xml │ ├── deblocker.fs │ ├── disklabel.fs │ ├── obp-tftp.fs │ ├── packages.fs │ └── terminal-emulator.fs ├── system │ ├── build.xml │ ├── ciface.fs │ └── main.fs ├── testsuite │ ├── README │ ├── build.xml │ ├── fract.fs │ ├── framebuffer-test.fs │ ├── memory-testsuite.fs │ └── splitfunc-testsuite.fs └── util │ ├── apic.fs │ ├── build.xml │ ├── pci.fs │ └── util.fs ├── fs ├── build.xml ├── ext2 │ ├── build.xml │ ├── ext2.h │ ├── ext2_close.c │ ├── ext2_closedir.c │ ├── ext2_fs.c │ ├── ext2_fs.h │ ├── ext2_lseek.c │ ├── ext2_mount.c │ ├── ext2_open.c │ ├── ext2_opendir.c │ ├── ext2_read.c │ ├── ext2_readdir.c │ ├── ext2_utils.c │ ├── ext2_utils.h │ └── libext2.h ├── grubfs │ ├── Kconfig │ ├── build.xml │ ├── debug.h │ ├── defs.h │ ├── dir.h │ ├── disk_inode.h │ ├── disk_inode_ffs.h │ ├── fat.h │ ├── filesys.h │ ├── fs.h │ ├── fsys_affs.c │ ├── fsys_ext2fs.c │ ├── fsys_fat.c │ ├── fsys_ffs.c │ ├── fsys_iso9660.c │ ├── fsys_jfs.c │ ├── fsys_minix.c │ ├── fsys_ntfs.c │ ├── fsys_reiserfs.c │ ├── fsys_ufs.c │ ├── fsys_vstafs.c │ ├── fsys_xfs.c │ ├── glue.h │ ├── grubfs_fs.c │ ├── iso9660.h │ ├── jfs.h │ ├── shared.h │ ├── ufs_dinode.h │ ├── ufs_fs.h │ ├── vstafs.h │ └── xfs.h ├── hfs │ ├── block.c │ ├── btree.c │ ├── build.xml │ ├── data.c │ ├── file.c │ ├── hfs.c │ ├── hfs_fs.c │ ├── include │ │ ├── apple.h │ │ ├── block.h │ │ ├── btree.h │ │ ├── data.h │ │ ├── file.h │ │ ├── hfs.h │ │ ├── libhfs.h │ │ ├── low.h │ │ ├── medium.h │ │ ├── node.h │ │ ├── record.h │ │ └── volume.h │ ├── low.c │ ├── medium.c │ ├── node.c │ ├── record.c │ └── volume.c ├── hfs_mdb.h ├── hfsplus │ ├── build.xml │ ├── hfsp_blockiter.c │ ├── hfsp_btree.c │ ├── hfsp_fs.c │ ├── hfsp_record.c │ ├── hfsp_unicode.c │ ├── hfsp_volume.c │ ├── include │ │ ├── apple.h │ │ ├── blockiter.h │ │ ├── btree.h │ │ ├── hfs.h │ │ ├── hfsp.h │ │ ├── hfstime.h │ │ ├── libhfsp.h │ │ ├── record.h │ │ ├── swab.h │ │ ├── unicode.h │ │ └── volume.h │ └── libhfsp.c ├── ioglue.c ├── iso9660 │ ├── build.xml │ ├── iso9660.h │ ├── iso9660_close.c │ ├── iso9660_closedir.c │ ├── iso9660_fs.c │ ├── iso9660_fs.h │ ├── iso9660_lseek.c │ ├── iso9660_mount.c │ ├── iso9660_open.c │ ├── iso9660_opendir.c │ ├── iso9660_read.c │ ├── iso9660_readdir.c │ └── libiso9660.h └── os.h ├── include ├── arch │ ├── amd64 │ │ ├── elf.h │ │ ├── io.h │ │ ├── pci.h │ │ └── types.h │ ├── common │ │ ├── a.out.h │ │ ├── elf.h │ │ ├── elf_boot.h │ │ ├── fw_cfg.h │ │ ├── nvram.h │ │ └── xcoff.h │ ├── ia64 │ │ ├── elf.h │ │ ├── io.h │ │ └── types.h │ ├── ppc │ │ ├── asmdefs.h │ │ ├── elf.h │ │ ├── io.h │ │ ├── pci.h │ │ ├── processor.h │ │ ├── residual.h │ │ └── types.h │ ├── sparc32 │ │ ├── a.out.h │ │ ├── asi.h │ │ ├── crs.h │ │ ├── dma.h │ │ ├── elf.h │ │ ├── io.h │ │ ├── ofmem_sparc32.h │ │ ├── pgtsrmmu.h │ │ └── types.h │ ├── sparc64 │ │ ├── a.out.h │ │ ├── asi.h │ │ ├── elf.h │ │ ├── io.h │ │ ├── ofmem_sparc64.h │ │ ├── pci.h │ │ └── types.h │ ├── unix │ │ ├── plugin_pci.h │ │ └── plugins.h │ └── x86 │ │ ├── elf.h │ │ ├── io.h │ │ ├── pci.h │ │ └── types.h ├── config.h ├── drivers │ ├── drivers.h │ ├── pci.h │ ├── usb.h │ └── vga.h ├── fs │ └── fs.h ├── kernel │ ├── kernel.h │ └── stack.h ├── libc │ ├── byteorder.h │ ├── diskio.h │ ├── stdlib.h │ ├── string.h │ └── vsprintf.h ├── libopenbios │ ├── aout_load.h │ ├── bindings.h │ ├── bootcode_load.h │ ├── bootinfo_load.h │ ├── console.h │ ├── elf_load.h │ ├── fcode_load.h │ ├── fontdata.h │ ├── forth_load.h │ ├── initprogram.h │ ├── ipchecksum.h │ ├── load.h │ ├── of.h │ ├── ofmem.h │ ├── openbios.h │ ├── prep_load.h │ ├── sys_info.h │ ├── video.h │ └── xcoff_load.h ├── mconfig.h ├── packages │ ├── nvram.h │ └── video.h └── sysinclude.h ├── kernel ├── Kconfig ├── README ├── bootstrap.c ├── build.xml ├── cross.h ├── dict.c ├── forth.c ├── include │ └── dict.h └── stack.c ├── libc ├── build.xml ├── ctype.c ├── diskio.c ├── extra.c ├── misc.c ├── string.c └── vsprintf.c ├── libgcc ├── __divdi3.c ├── __divti3.c ├── __lshrdi3.c ├── __negti2.c ├── __udivdi3.c ├── __udivmoddi4.c ├── __udivmodti4.c ├── __udivti3.c ├── __umoddi3.c ├── __umodti3.c ├── ashldi3.c ├── ashrdi3.c ├── build.xml ├── crtsavres.S ├── libgcc.h └── multi3.c ├── libopenbios ├── Kconfig ├── aout_load.c ├── bindings.c ├── bootcode_load.c ├── bootinfo_load.c ├── build.xml ├── clib.fs ├── client.c ├── console.c ├── elf_info.c ├── elf_load.c ├── fcode_load.c ├── font_8x16.c ├── font_8x8.c ├── forth_load.c ├── helpers.fs ├── init.c ├── initprogram.c ├── ipchecksum.c ├── linuxbios.h ├── linuxbios_info.c ├── load.c ├── ofmem_common.c ├── prep_load.c ├── video_common.c └── xcoff_load.c ├── packages ├── bootinfo-loader.c ├── build.xml ├── cmdline.c ├── cmdline.fs ├── deblocker.c ├── disk-label.c ├── disk-label.fs ├── elf-loader.c ├── init.c ├── mac-parts.c ├── mac-parts.h ├── molvideo.c ├── nvram.c ├── packages.h ├── pc-parts.c ├── sun-parts.c └── xcoff-loader.c └── utils ├── README ├── devbios ├── COPYING ├── CREDITS ├── ChangeLog ├── Makefile ├── Makefile.24 ├── README.bios ├── ToDo ├── bios.h ├── bios_core.c ├── comp.c ├── filesystem.c ├── flashchips.c ├── flashchips.h ├── pcisets.c ├── pcisets.h ├── procfs.c ├── programming.c └── programming.h ├── dist ├── debian │ ├── changelog │ ├── control │ ├── packages │ └── rules └── openbios.spec ├── iso ├── README └── boot │ └── grub │ ├── README │ ├── menu.lst │ └── stage2_eltorito └── ofclient ├── Makefile ├── README ├── endian.h ├── of1275.c ├── of1275.h ├── of1275_io.c └── ofclient.c /.github/workflows/build-openbios-builder.yml: -------------------------------------------------------------------------------- 1 | name: Build openbios-builder container 2 | 3 | on: 4 | # Run manually from Actions tab 5 | workflow_dispatch: 6 | 7 | env: 8 | REGISTRY: ghcr.io 9 | IMAGE_NAME: ${{ github.repository }}-builder 10 | 11 | jobs: 12 | build-x86_64: 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | packages: write 17 | 18 | steps: 19 | - name: Checkout repository 20 | uses: actions/checkout@v2 21 | 22 | - name: Log in to the Container registry 23 | uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 24 | with: 25 | registry: ${{ env.REGISTRY }} 26 | username: ${{ github.actor }} 27 | password: ${{ secrets.GITHUB_TOKEN }} 28 | 29 | - name: Extract metadata (tags, labels) for Docker 30 | id: meta 31 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 32 | with: 33 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 34 | 35 | - name: Build and push Docker image 36 | uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc 37 | with: 38 | context: . 39 | file: docker/Dockerfile.builder 40 | push: true 41 | tags: ${{ steps.meta.outputs.tags }} 42 | labels: ${{ steps.meta.outputs.labels }} 43 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | obj-* 2 | .stgit-* 3 | config-host.mak 4 | -------------------------------------------------------------------------------- /Documentation/kernel/AUTHORS: -------------------------------------------------------------------------------- 1 | The OpenBIOS forth engine was written by 2 | 3 | Patrick Mauritz 4 | Stefan Reinauer 5 | 6 | # tag: list of authors 7 | -------------------------------------------------------------------------------- /Documentation/kernel/TODO: -------------------------------------------------------------------------------- 1 | TODO 2 | 3 | booting 4 | * support more arches than x86+amd64 5 | * compressed + rommable dictionary 6 | 7 | forth bootstrap 8 | * make prompt configurable 9 | * check state-variable when defining a new word. 10 | 11 | tag: TODO for the forth system 12 | -------------------------------------------------------------------------------- /Documentation/kernel/dictformat.txt: -------------------------------------------------------------------------------- 1 | # tag: contains a description of the dictionary format 2 | 3 | name | length of name in bytes + 0x80 | align with 0's | flags (bit 7 set) | LFA | CFA | PFA 4 | 5 | LFA == link field address (backlink) 6 | CFA == code field address ("word type") 7 | PFA == program field address (definitions) 8 | 9 | -------------------------------------------------------------------------------- /Documentation/kernel/glossary.txt: -------------------------------------------------------------------------------- 1 | # tag: glossary of openbios forth 2 | 3 | # dictionary 4 | LFA == link field address (backlink) 5 | CFA == code field address ("word type") 6 | PFA == program field address (definitions) 7 | 8 | # forth engine 9 | TIB == text input buffer 10 | 11 | inner interpreter: interprets dictionary, does threading 12 | outer interpreter: "user" interpreter, reads forth words from user. 13 | 14 | 15 | -------------------------------------------------------------------------------- /Documentation/kernel/initializers.txt: -------------------------------------------------------------------------------- 1 | 2 | Initializers are called when the forth kernel is started, to do some 3 | initialization stuff. 4 | Pro: If code needs initialization you can keep this in place with the code 5 | and don't need to patch the kernel itself to do so. 6 | 7 | There are 2 types of initializers. "Normal" and "Late" initializers. 8 | 9 | Since initializers are only called during startup, they don't need a name. 10 | 11 | Definition: 12 | initializer ( xt -- ) 13 | late-initializer ( xt -- ) 14 | 15 | Examples: 16 | :noname ; initializer 17 | 18 | :noname 19 | some-base initializations 20 | ; late-initializer 21 | 22 | Late initializers are run after all ordinary initializers have 23 | been executed. 24 | 25 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include config-host.mak 2 | 3 | all: requirements info build 4 | 5 | requirements: 6 | @which xsltproc &>/dev/null || ( echo ; echo "Please install libxslt2"; \ 7 | echo; exit 1 ) 8 | 9 | info: 10 | @echo "Building OpenBIOS for $(TARGETS)" 11 | 12 | clean: 13 | @echo "Cleaning up..." 14 | @for dir in $(ODIRS); do \ 15 | $(MAKE) -C $$dir clean; \ 16 | done 17 | 18 | build: start-build 19 | @for dir in $(ODIRS); do \ 20 | $(MAKE) -C $$dir > $$dir/build.log 2>&1 && echo "ok." || \ 21 | ( echo "error:"; tail -15 $$dir/build.log; exit 1 ) \ 22 | done 23 | 24 | SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGETS)) 25 | SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory) 26 | 27 | quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) 28 | 29 | build-verbose: start-build $(SUBDIR_RULES) 30 | 31 | subdir-%: 32 | $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C obj-$* V="$(V)" all,) 33 | 34 | start-build: 35 | @echo "Building..." 36 | 37 | run: 38 | @echo "Running..." 39 | @for dir in $(ODIRS); do \ 40 | $$dir/openbios-unix $$dir/openbios-unix.dict; \ 41 | done 42 | 43 | 44 | # The following two targets will only work on x86 so far. 45 | # 46 | $(ODIR)/openbios.iso: $(ODIR)/openbios.multiboot $(ODIR)/openbios-x86.dict 47 | @mkisofs -input-charset UTF-8 -r -b boot/grub/stage2_eltorito -no-emul-boot \ 48 | -boot-load-size 4 -boot-info-table -o $@ utils/iso $^ 49 | 50 | runiso: $(ODIR)/openbios.iso 51 | qemu -cdrom $^ 52 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.1 2 | -------------------------------------------------------------------------------- /arch/amd64/Kconfig: -------------------------------------------------------------------------------- 1 | mainmenu "OpenBIOS Configuration" 2 | 3 | config AMD64 4 | bool 5 | default y 6 | help 7 | Building for AMD64 hardware. 8 | 9 | config LITTLE_ENDIAN 10 | bool 11 | default y 12 | help 13 | AMD64 is little endian. 14 | 15 | 16 | menu "Kernel binaries (AMD64)" 17 | 18 | config IMAGE_ELF 19 | bool "ELF image (for LinuxBIOS)" 20 | default y 21 | help 22 | Build a simple elf image that can be used with LinuxBIOS 23 | This image will be called openbios.elf 24 | 25 | config IMAGE_ELF_EMBEDDED 26 | bool "ELF image with embedded dictionary" 27 | default y 28 | help 29 | Build an elf image with embedded dictionary. This image 30 | can easily be used with etherboot. 31 | The image filename is openbios.full 32 | 33 | config IMAGE_ELF_MULTIBOOT 34 | bool "Multiboot image" 35 | default y 36 | help 37 | Build a multiboot image for booting with grub 38 | 39 | endmenu 40 | 41 | menu "Build hosted UNIX Binary" 42 | source "arch/unix/Kconfig" 43 | endmenu 44 | 45 | source "kernel/Kconfig" 46 | source "forth/Kconfig" 47 | source "libopenbios/Kconfig" 48 | source "drivers/Kconfig" 49 | -------------------------------------------------------------------------------- /arch/amd64/boot.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | #undef BOOTSTRAP 5 | #include "config.h" 6 | #include "libopenbios/bindings.h" 7 | #include "libopenbios/elfload.h" 8 | #include "arch/common/nvram.h" 9 | #include "libc/diskio.h" 10 | #include "libopenbios/sys_info.h" 11 | 12 | int elf_load(struct sys_info *, const char *filename, const char *cmdline); 13 | int linux_load(struct sys_info *, const char *filename, const char *cmdline); 14 | 15 | void boot(void); 16 | 17 | void boot(void) 18 | { 19 | char *path=pop_fstr_copy(), *param; 20 | 21 | // char *param="root=/dev/hda2 console=ttyS0,115200n8 console=tty0"; 22 | 23 | if(!path) { 24 | printk("[x86] Booting default not supported.\n"); 25 | return; 26 | } 27 | 28 | param = strchr(path, ' '); 29 | if(param) { 30 | *param = '\0'; 31 | param++; 32 | } 33 | 34 | printk("[x86] Booting file '%s' with parameters '%s'\n",path, param); 35 | 36 | if (elf_load(&sys_info, path, param) == LOADER_NOT_SUPPORT) 37 | if (linux_load(&sys_info, path, param) == LOADER_NOT_SUPPORT) 38 | printk("Unsupported image format\n"); 39 | 40 | free(path); 41 | } 42 | -------------------------------------------------------------------------------- /arch/amd64/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /arch/amd64/builtin.c: -------------------------------------------------------------------------------- 1 | /* tag: openbios forth starter for builtin dictionary for amd64 2 | * 3 | * Copyright (C) 2003 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #include "config.h" 10 | #include 11 | #include "libopenbios/sys_info.h" 12 | 13 | /* 14 | * wrap an array around the hex'ed dictionary file 15 | */ 16 | 17 | #include "static-dict.h" 18 | 19 | void collect_multiboot_info(struct sys_info *info); 20 | void collect_multiboot_info(struct sys_info *info) 21 | { 22 | info->dict_start=(unsigned long *)forth_dictionary; 23 | info->dict_end=(unsigned long *)((ucell)forth_dictionary + 24 | sizeof(forth_dictionary)); 25 | } 26 | -------------------------------------------------------------------------------- /arch/amd64/context.h: -------------------------------------------------------------------------------- 1 | #ifndef AMD64_CONTEXT_H 2 | #define AMD64_CONTEXT_H 3 | 4 | struct context { 5 | /* Stack Segment, placed here because of the alignment issue... */ 6 | uint16_t ss; 7 | /* Used with sgdt/lgdt */ 8 | uint16_t gdt_limit; 9 | uint64_t gdt_base; 10 | /* General registers, accessed with pushal/popal */ 11 | uint32_t edi; 12 | uint32_t esi; 13 | uint32_t ebp; 14 | uint32_t esp; /* points just below eax */ 15 | uint32_t ebx; 16 | uint32_t edx; 17 | uint32_t ecx; 18 | uint32_t eax; 19 | #define ESP_LOC(ctx) (&(ctx)->gs) 20 | /* Segment registers */ 21 | uint32_t gs; 22 | uint32_t fs; 23 | uint32_t es; 24 | uint32_t ds; 25 | /* Flags */ 26 | uint32_t eflags; 27 | /* Code segment:offset */ 28 | uint32_t eip; 29 | uint32_t cs; 30 | /* Optional stack contents */ 31 | uint32_t return_addr; 32 | uint32_t param[0]; 33 | }; 34 | 35 | /* Create a new context in the given stack */ 36 | struct context * 37 | init_context(uint8_t *stack, uint32_t stack_size, int num_param); 38 | 39 | /* Switch context */ 40 | struct context *switch_to(struct context *); 41 | 42 | /* Holds physical address of boot context */ 43 | extern unsigned long __boot_ctx; 44 | 45 | /* This can always be safely used to refer to the boot context */ 46 | #define boot_ctx ((struct context *) phys_to_virt(__boot_ctx)) 47 | 48 | #endif /* AMD64_CONTEXT_H */ 49 | -------------------------------------------------------------------------------- /arch/amd64/defconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated make config: don't edit 3 | # 4 | CONFIG_AMD64=y 5 | CONFIG_LITTLE_ENDIAN=y 6 | 7 | # 8 | # Kernel binaries (AMD64) 9 | # 10 | # CONFIG_IMAGE_ELF is not set 11 | # CONFIG_IMAGE_ELF_EMBEDDED is not set 12 | # CONFIG_IMAGE_ELF_MULTIBOOT is not set 13 | 14 | # 15 | # Build hosted UNIX Binary 16 | # 17 | CONFIG_HOST_UNIX=y 18 | # CONFIG_PLUGIN_PCI is not set 19 | 20 | # 21 | # Kernel Debugging 22 | # 23 | # CONFIG_DEBUG is not set 24 | CONFIG_DEBUG_CONSOLE=y 25 | CONFIG_DEBUG_CONSOLE_SERIAL=y 26 | CONFIG_SERIAL_PORT=1 27 | CONFIG_SERIAL_SPEED=115200 28 | CONFIG_DEBUG_CONSOLE_VGA=y 29 | 30 | # 31 | # Module Configuration 32 | # 33 | CONFIG_CMDLINE=y 34 | CONFIG_DEBLOCKER=y 35 | 36 | # 37 | # Filesystem Configuration 38 | # 39 | CONFIG_DISK_LABEL=y 40 | CONFIG_PART_SUPPORT=y 41 | CONFIG_PC_PARTS=y 42 | CONFIG_FS=y 43 | CONFIG_GRUBFS=y 44 | CONFIG_FSYS_EXT2FS=y 45 | CONFIG_FSYS_FAT=y 46 | CONFIG_FSYS_JFS=y 47 | # CONFIG_FSYS_MINIX is not set 48 | CONFIG_FSYS_REISERFS=y 49 | CONFIG_FSYS_XFS=y 50 | CONFIG_FSYS_ISO9660=y 51 | # CONFIG_FSYS_FFS is not set 52 | # CONFIG_FSYS_VSTAFS is not set 53 | # CONFIG_DEBUG_FS is not set 54 | 55 | # 56 | # Miscellaneous 57 | # 58 | CONFIG_LINUXBIOS=y 59 | 60 | # 61 | # Drivers 62 | # 63 | CONFIG_DRIVER_PCI=y 64 | CONFIG_DRIVER_IDE=y 65 | # CONFIG_DEBUG_IDE is not set 66 | -------------------------------------------------------------------------------- /arch/amd64/lib.c: -------------------------------------------------------------------------------- 1 | /* lib.c 2 | * tag: simple function library 3 | * 4 | * Copyright (C) 2003 Stefan Reinauer 5 | * 6 | * See the file "COPYING" for further information about 7 | * the copyright and warranty status of this work. 8 | */ 9 | 10 | #include "config.h" 11 | #include "asm/types.h" 12 | #include 13 | #include "libc/stdlib.h" 14 | #include "libc/vsprintf.h" 15 | #include "kernel/kernel.h" 16 | 17 | /* Format a string and print it on the screen, just like the libc 18 | * function printf. 19 | */ 20 | int printk( const char *fmt, ... ) 21 | { 22 | char *p, buf[512]; 23 | va_list args; 24 | int i; 25 | 26 | va_start(args, fmt); 27 | i = vsnprintf(buf, sizeof(buf), fmt, args); 28 | va_end(args); 29 | 30 | for( p=buf; *p; p++ ) 31 | putchar(*p); 32 | return i; 33 | } 34 | 35 | // dumb quick memory allocator until we get a decent thing here. 36 | 37 | #define MEMSIZE 128*1024 38 | static char memory[MEMSIZE]; 39 | static void *memptr=memory; 40 | static int memsize=MEMSIZE; 41 | 42 | void *malloc(int size) 43 | { 44 | void *ret=(void *)0; 45 | if(memsize>=size) { 46 | memsize-=size; 47 | ret=memptr; 48 | memptr+=size; 49 | } 50 | return ret; 51 | } 52 | 53 | void free(void *ptr) 54 | { 55 | /* Nothing yet */ 56 | } 57 | -------------------------------------------------------------------------------- /arch/amd64/openbios.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/01/15 16:14:05 samuel> 3 | * Time-stamp: <2004/01/15 16:14:05 samuel> 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * Copyright (C) 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_OPENBIOS 18 | #define _H_OPENBIOS 19 | 20 | int openbios(void); 21 | 22 | /* console.c */ 23 | extern void cls(void); 24 | #ifdef CONFIG_DEBUG_CONSOLE 25 | extern int uart_init(int port, unsigned long speed); 26 | extern void video_init(void); 27 | #endif 28 | 29 | #endif /* _H_OPENBIOS */ 30 | -------------------------------------------------------------------------------- /arch/amd64/plainboot.c: -------------------------------------------------------------------------------- 1 | /* tag: openbios fixed address forth starter 2 | * 3 | * Copyright (C) 2003 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #include "config.h" 10 | #include "libopenbios/sys_info.h" 11 | #include "multiboot.h" 12 | 13 | #define FIXED_DICTSTART 0xfffe0000 14 | #define FIXED_DICTEND 0xfffeffff 15 | 16 | void collect_multiboot_info(struct sys_info *info); 17 | void collect_multiboot_info(struct sys_info *info) 18 | { 19 | info->dict_start=(unsigned long *)FIXED_DICTSTART; 20 | info->dict_end=(unsigned long *)FIXED_DICTEND; 21 | } 22 | -------------------------------------------------------------------------------- /arch/amd64/relocate.h: -------------------------------------------------------------------------------- 1 | void relocate(struct sys_info *); 2 | -------------------------------------------------------------------------------- /arch/amd64/segment.h: -------------------------------------------------------------------------------- 1 | 2 | /* Segment indexes. Must match the gdt definition in segment.c. */ 3 | enum { 4 | NULL_SEG, 5 | FLAT_CODE, 6 | FLAT_DATA, 7 | RELOC_CODE, 8 | RELOC_DATA, 9 | NUM_SEG, 10 | }; 11 | 12 | /* Values for segment selector register */ 13 | #define FLAT_CS (FLAT_CODE << 3) 14 | #define FLAT_DS (FLAT_DATA << 3) 15 | #define RELOC_CS (RELOC_CODE << 3) 16 | #define RELOC_DS (RELOC_DATA << 3) 17 | 18 | /* i386 segment descriptor */ 19 | struct segment_desc { 20 | unsigned short limit_0; 21 | unsigned short base_0; 22 | unsigned char base_16; 23 | unsigned char types; 24 | unsigned char flags; 25 | unsigned char base_24; 26 | }; 27 | 28 | extern struct segment_desc gdt[NUM_SEG]; 29 | 30 | #define GDT_LIMIT ((NUM_SEG << 3) - 1) 31 | -------------------------------------------------------------------------------- /arch/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /arch/ia64/Kconfig: -------------------------------------------------------------------------------- 1 | mainmenu "OpenBIOS Configuration" 2 | 3 | config IPF 4 | bool 5 | default y 6 | help 7 | Building for IPF hardware. 8 | 9 | config LITTLE_ENDIAN 10 | bool 11 | default y 12 | help 13 | IPF is little endian. 14 | 15 | menu "Build hosted UNIX Binary" 16 | source "arch/unix/Kconfig" 17 | endmenu 18 | 19 | source "kernel/Kconfig" 20 | source "forth/Kconfig" 21 | source "libopenbios/Kconfig" 22 | source "drivers/Kconfig" 23 | -------------------------------------------------------------------------------- /arch/ia64/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /arch/ia64/defconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated make config: don't edit 3 | # 4 | CONFIG_IPF=y 5 | CONFIG_LITTLE_ENDIAN=y 6 | 7 | # 8 | # Kernel binaries (x86) 9 | # 10 | # CONFIG_IMAGE_ELF is not set 11 | # CONFIG_IMAGE_ELF_EMBEDDED is not set 12 | # CONFIG_IMAGE_ELF_MULTIBOOT is not set 13 | 14 | # 15 | # Build hosted UNIX Binary 16 | # 17 | CONFIG_HOST_UNIX=y 18 | # CONFIG_PLUGIN_PCI is not set 19 | 20 | # 21 | # Kernel Debugging 22 | # 23 | # CONFIG_DEBUG is not set 24 | CONFIG_DEBUG_CONSOLE=y 25 | CONFIG_DEBUG_CONSOLE_SERIAL=y 26 | CONFIG_SERIAL_PORT=1 27 | CONFIG_SERIAL_SPEED=115200 28 | CONFIG_DEBUG_CONSOLE_VGA=y 29 | 30 | # 31 | # Module Configuration 32 | # 33 | CONFIG_CMDLINE=y 34 | CONFIG_DEBLOCKER=y 35 | 36 | # 37 | # Filesystem Configuration 38 | # 39 | CONFIG_DISK_LABEL=y 40 | CONFIG_PART_SUPPORT=y 41 | CONFIG_PC_PARTS=y 42 | CONFIG_FS=y 43 | CONFIG_GRUBFS=y 44 | CONFIG_FSYS_EXT2FS=y 45 | CONFIG_FSYS_FAT=y 46 | CONFIG_FSYS_JFS=y 47 | # CONFIG_FSYS_MINIX is not set 48 | CONFIG_FSYS_REISERFS=y 49 | CONFIG_FSYS_XFS=y 50 | CONFIG_FSYS_ISO9660=y 51 | # CONFIG_FSYS_FFS is not set 52 | # CONFIG_FSYS_VSTAFS is not set 53 | # CONFIG_DEBUG_FS is not set 54 | 55 | # 56 | # Miscellaneous 57 | # 58 | CONFIG_LINUXBIOS=y 59 | 60 | # 61 | # Drivers 62 | # 63 | CONFIG_DRIVER_PCI=y 64 | CONFIG_DRIVER_IDE=y 65 | # CONFIG_DEBUG_IDE is not set 66 | -------------------------------------------------------------------------------- /arch/ppc/Kconfig: -------------------------------------------------------------------------------- 1 | mainmenu "OpenBIOS Configuration" 2 | 3 | config PPC 4 | bool 5 | default y 6 | help 7 | Building for PPC hardware. 8 | 9 | config BIG_ENDIAN 10 | bool 11 | default y 12 | help 13 | PPC hardware is big endian (per default) 14 | 15 | choice 16 | prompt "Platform Type" 17 | default MOL 18 | 19 | config MOL 20 | bool "Mac-on-Linux" 21 | help 22 | Build an image for Mac-on-Linux 23 | 24 | config MPC107 25 | bool "MPC107 board (Crescendo)" 26 | help 27 | Build for Crescendo board. 28 | 29 | config BRIQ 30 | bool "Total Impact briQ" 31 | help 32 | Build an image for the Total Impact briQ 33 | 34 | config NO_ARCH 35 | bool "None" 36 | help 37 | Don't build any images. 38 | 39 | endchoice 40 | 41 | menu "Build hosted UNIX Binary" 42 | source "arch/unix/Kconfig" 43 | endmenu 44 | 45 | source "kernel/Kconfig" 46 | source "forth/Kconfig" 47 | source "libopenbios/Kconfig" 48 | source "drivers/Kconfig" 49 | -------------------------------------------------------------------------------- /arch/ppc/Makefile.asm: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | # 3 | # Makefile.asm - assembly support 4 | # 5 | # Copyright (C) 2004 Samuel Rydh (samuel@ibrium.se) 6 | # 7 | # This program is free software; you can redistribute it and/or 8 | # modify it under the terms of the GNU General Public License 9 | # version 2 10 | 11 | 12 | ################################################# 13 | # Rules for asm targets 14 | ################################################# 15 | 16 | ASMFLAGS = -D__ASSEMBLY__ -I$(top_srcdir) $(ALTIVEC) 17 | FILTERBIN = $(top_srcdir)/scripts/asfilter 18 | ASFILTER = $(shell if test -x $(FILTERBIN) ; then echo $(FILTERBIN) \ 19 | ; else echo "tr ';' '\n'" ; fi) 20 | INVOKE_M4 = | $(M4) -s $(M4_NO_GNU) | $(ASFILTER) 21 | 22 | $(ODIR)/%.o: %.S 23 | @printf " Compiling %-20s: " $(notdir $@) 24 | assembly= 25 | @install -d $(dir $@) 26 | @$(RM) $@ $@.s 27 | @$(CPP) $(ASMFLAGS) $(IDIRS) $< > /dev/null 28 | $(CPP) $(ASMFLAGS) $(IDIRS) $(DEPFLAGS) $< $(INVOKE_M4) > $@.s 29 | $(AS) $@.s $(AS_FLAGS) -o $@ 30 | @$(DEPEXTRA) 31 | @$(RM) $@.s 32 | @echo "ok" 33 | -------------------------------------------------------------------------------- /arch/ppc/briq/briq.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 17:50:12 stepan> 3 | * Time-stamp: <2004/08/28 17:50:12 stepan> 4 | * 5 | * 6 | * 7 | * Copyright (C) 2004 Stefan Reinauer 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * version 2 12 | * 13 | */ 14 | 15 | #ifndef _H_BRIQ 16 | #define _H_BRIQ 17 | 18 | /* vfd.c */ 19 | extern int vfd_draw_str( const char *str ); 20 | extern void vfd_close( void ); 21 | 22 | #include "kernel.h" 23 | 24 | #endif /* _H_BRIQ */ 25 | -------------------------------------------------------------------------------- /arch/ppc/briq/kernel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 18:03:25 stepan> 3 | * Time-stamp: <2004/08/28 18:03:25 stepan> 4 | * 5 | * 6 | * 7 | * Copyright (C) 2004 Stefan Reinauer 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * version 2 12 | * 13 | */ 14 | 15 | #include "briq-dict.h" 16 | #include "../kernel.c" 17 | -------------------------------------------------------------------------------- /arch/ppc/briq/tree.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 18:38:22 greg> 3 | * Time-stamp: <2004/08/28 18:38:22 greg> 4 | * 5 | * 6 | * 7 | * device tree setup 8 | * 9 | * Copyright (C) 2004 Greg Watson 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #include "config.h" 18 | #include "libopenbios/bindings.h" 19 | 20 | void devtree_init( void ) 21 | { 22 | fword("init-briq-tree"); 23 | } 24 | -------------------------------------------------------------------------------- /arch/ppc/briq/vfd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 17:29:43 greg> 3 | * Time-stamp: <2004/08/28 17:29:43 greg> 4 | * 5 | * 6 | * 7 | * Simple text console 8 | * 9 | * Copyright (C) 2004 Greg Watson 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #include "config.h" 18 | #include "libopenbios/bindings.h" 19 | #include "briq/briq.h" 20 | 21 | static int vfd_is_open; 22 | 23 | static int 24 | vfd_init( void ) 25 | { 26 | vfd_is_open = 1; 27 | return 0; 28 | } 29 | 30 | void 31 | vfd_close( void ) 32 | { 33 | } 34 | 35 | int 36 | vfd_draw_str( const char *str ) 37 | { 38 | if (!vfd_is_open) 39 | vfd_init(); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /arch/ppc/defconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated make config: don't edit 3 | # 4 | CONFIG_PPC=y 5 | CONFIG_MOL=y 6 | # CONFIG_MPC107 is not set 7 | # CONFIG_NO_ARCH is not set 8 | 9 | # 10 | # Build hosted UNIX Binary 11 | # 12 | CONFIG_HOST_UNIX=y 13 | # CONFIG_PLUGIN_PCI is not set 14 | 15 | # 16 | # Kernel Debugging 17 | # 18 | CONFIG_DEBUG=y 19 | CONFIG_DEBUG_BOOT=y 20 | # CONFIG_DEBUG_DSTACK is not set 21 | # CONFIG_DEBUG_RSTACK is not set 22 | # CONFIG_DEBUG_DICTIONARY is not set 23 | # CONFIG_DEBUG_INTERNAL is not set 24 | # CONFIG_DEBUG_INTERPRETER is not set 25 | CONFIG_DEBUG_CONSOLE=y 26 | CONFIG_DEBUG_CONSOLE_SERIAL=y 27 | CONFIG_SERIAL_PORT=1 28 | CONFIG_SERIAL_SPEED=115200 29 | CONFIG_DEBUG_CONSOLE_VGA=y 30 | 31 | # 32 | # Packages 33 | # 34 | # CONFIG_PKG_DEBLOCKER is not set 35 | # CONFIG_PKG_DISKLABEL is not set 36 | # CONFIG_PKG_OBP_TFTP is not set 37 | # CONFIG_PKG_TERMINAL_EMULATOR is not set 38 | 39 | # 40 | # Module Configuration 41 | # 42 | CONFIG_DEBLOCKER=y 43 | CONFIG_DISK_LABEL=y 44 | CONFIG_PART_SUPPORT=y 45 | CONFIG_MAC_PARTS=y 46 | CONFIG_FS=y 47 | CONFIG_HFS=y 48 | CONFIG_HFSP=y 49 | -------------------------------------------------------------------------------- /arch/ppc/kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 17:50:12 stepan> 3 | * Time-stamp: <2004/08/28 17:50:12 stepan> 4 | * 5 | * 6 | * 7 | * Copyright (C) 2004 Stefan Reinauer 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * version 2 12 | * 13 | */ 14 | 15 | #ifndef __KERNEL_H__ 16 | #define __KERNEL_H__ 17 | 18 | /* misc.c */ 19 | extern void fatal_error( const char *str ); 20 | extern void exit( int status ); 21 | 22 | /* start.S */ 23 | extern void flush_icache_range( char *start, char *stop ); 24 | extern char of_rtas_start[], of_rtas_end[]; 25 | 26 | /* methods.c */ 27 | extern void node_methods_init( void ); 28 | 29 | /* main.c */ 30 | extern void boot( void ); 31 | 32 | /* init.c */ 33 | extern void entry( void ); 34 | extern void arch_of_init( void ); 35 | extern int get_bool_res( const char *str ); 36 | 37 | /* tree.c */ 38 | extern void devtree_init( void ); 39 | 40 | 41 | #endif /* __KERNEL_H__ */ 42 | -------------------------------------------------------------------------------- /arch/ppc/mol/console.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2002/10/29 18:59:05 samuel> 3 | * Time-stamp: <2003/12/28 22:51:11 samuel> 4 | * 5 | * 6 | * 7 | * Simple text console 8 | * 9 | * Copyright (C) 2002, 2003, 2004 Samuel Rydh (samuel@ibrium.se) 10 | * Copyright (C) 2005 Stefan Reinauer 11 | * 12 | * This program is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU General Public License 14 | * as published by the Free Software Foundation 15 | * 16 | */ 17 | 18 | #include "config.h" 19 | #include "libopenbios/bindings.h" 20 | #include "libc/diskio.h" 21 | #include "osi_calls.h" 22 | #include "libopenbios/ofmem.h" 23 | #include "mol/mol.h" 24 | #include "boothelper_sh.h" 25 | #include "video_sh.h" 26 | 27 | #define openbios_GetFBInfo(x) OSI_GetFBInfo(x) 28 | 29 | #include "../../../packages/video.c" 30 | #include "../../../libopenbios/console_common.c" 31 | -------------------------------------------------------------------------------- /arch/ppc/mol/kernel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 18:03:25 stepan> 3 | * Time-stamp: <2004/08/28 18:03:25 stepan> 4 | * 5 | * 6 | * 7 | * Copyright (C) 2004 Stefan Reinauer 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * version 2 12 | * 13 | */ 14 | 15 | #include "mol-dict.h" 16 | #include "../kernel.c" 17 | -------------------------------------------------------------------------------- /arch/ppc/mol/mol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/12/20 00:20:12 samuel> 3 | * Time-stamp: <2004/03/27 01:52:50 samuel> 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_MOL 18 | #define _H_MOL 19 | 20 | /* video.c */ 21 | extern void init_video( void ); 22 | extern int video_get_res( int *w, int *h ); 23 | extern void draw_pixel( int x, int y, int colind ); 24 | extern void set_color( int index, unsigned long color ); 25 | 26 | /* console.c */ 27 | extern int console_draw_fstr(const char *str, int len); 28 | extern void console_close( void ); 29 | 30 | /* pseudodisk.c */ 31 | extern void pseudodisk_init( void ); 32 | 33 | /* osi-blk.c */ 34 | extern void osiblk_init( void ); 35 | 36 | /* osi-scsi.c */ 37 | extern void osiscsi_init( void ); 38 | 39 | /* pseudofs.c */ 40 | extern void pseudofs_init( void ); 41 | 42 | #include "../kernel.h" 43 | 44 | #endif /* _H_MOL */ 45 | -------------------------------------------------------------------------------- /arch/ppc/pearpc/console.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * 4 | * 5 | * Simple text console 6 | * 7 | * Copyright (C) 2005 Stefan Reinauer 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * as published by the Free Software Foundation 12 | * 13 | */ 14 | 15 | #include "config.h" 16 | #include "libopenbios/bindings.h" 17 | #include "libc/diskio.h" 18 | #include "libopenbios/ofmem.h" 19 | #include "pearpc/pearpc.h" 20 | 21 | 22 | typedef struct osi_fb_info { 23 | unsigned long mphys; 24 | int rb, w, h, depth; 25 | } osi_fb_info_t; 26 | 27 | 28 | int PearPC_GetFBInfo( osi_fb_info_t *fb ) 29 | { 30 | 31 | fb->w=1024; 32 | fb->h=768; 33 | fb->depth=15; 34 | fb->rb=2048; 35 | fb->mphys=0x84000000; 36 | 37 | return 0; 38 | } 39 | 40 | #define openbios_GetFBInfo(x) PearPC_GetFBInfo(x) 41 | 42 | #include "../../../packages/video.c" 43 | #include "../../../libopenbios/console_common.c" 44 | -------------------------------------------------------------------------------- /arch/ppc/pearpc/kernel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 18:03:25 stepan> 3 | * Time-stamp: <2004/08/28 18:03:25 stepan> 4 | * 5 | * 6 | * 7 | * Copyright (C) 2005 Stefan Reinauer 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * version 2 12 | * 13 | */ 14 | 15 | #include "pearpc-dict.h" 16 | #include "../kernel.c" 17 | -------------------------------------------------------------------------------- /arch/ppc/pearpc/pearpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 17:50:12 stepan> 3 | * Time-stamp: <2004/08/28 17:50:12 stepan> 4 | * 5 | * 6 | * 7 | * Copyright (C) 2005 Stefan Reinauer 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * version 2 12 | * 13 | */ 14 | 15 | #ifndef _H_PEARPC 16 | #define _H_PEARPC 17 | 18 | /* vfd.c */ 19 | extern int vfd_draw_str( const char *str ); 20 | extern void vfd_close( void ); 21 | 22 | extern int console_draw_fstr(const char *str, int len); 23 | 24 | #include "kernel.h" 25 | 26 | #endif /* _H_PEARPC */ 27 | -------------------------------------------------------------------------------- /arch/ppc/pearpc/tree.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 18:38:22 greg> 3 | * Time-stamp: <2004/08/28 18:38:22 greg> 4 | * 5 | * 6 | * 7 | * device tree setup 8 | * 9 | * Copyright (C) 2004 Greg Watson 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #include "config.h" 18 | #include "libopenbios/bindings.h" 19 | 20 | void devtree_init( void ) 21 | { 22 | fword("init-pearpc-tree"); 23 | } 24 | -------------------------------------------------------------------------------- /arch/ppc/pearpc/vfd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 17:29:43 greg> 3 | * Time-stamp: <2004/08/28 17:29:43 greg> 4 | * 5 | * 6 | * 7 | * Simple text console 8 | * 9 | * Copyright (C) 2004 Greg Watson 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #include "config.h" 18 | #include "libopenbios/bindings.h" 19 | #include "pearpc/pearpc.h" 20 | 21 | static int vfd_is_open; 22 | 23 | static int 24 | vfd_init( void ) 25 | { 26 | vfd_is_open = 1; 27 | return 0; 28 | } 29 | 30 | void 31 | vfd_close( void ) 32 | { 33 | } 34 | 35 | int 36 | vfd_draw_str( const char *str ) 37 | { 38 | if (!vfd_is_open) 39 | vfd_init(); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /arch/ppc/qemu/context.h: -------------------------------------------------------------------------------- 1 | #ifndef PPC_CONTEXT_H 2 | #define PPC_CONTEXT_H 3 | 4 | struct context { 5 | #define SP_LOC(ctx) (&(ctx)->sp) 6 | unsigned long _sp; 7 | unsigned long return_addr; 8 | unsigned long sp; 9 | unsigned long pc; 10 | /* General registers */ 11 | unsigned long regs[34]; 12 | #define REG_R3 3 13 | #define REG_R4 7 14 | #define REG_R5 8 15 | #define REG_R6 9 16 | #define REG_R7 10 17 | /* Flags */ 18 | /* Optional stack contents */ 19 | unsigned long param[0]; 20 | }; 21 | 22 | /* Create a new context in the given stack */ 23 | struct context * 24 | init_context(uint8_t *stack, uint32_t stack_size, int num_param); 25 | 26 | /* Switch context */ 27 | struct context *switch_to(struct context *); 28 | 29 | /* Holds physical address of boot context */ 30 | extern unsigned long __boot_ctx; 31 | 32 | /* This can always be safely used to refer to the boot context */ 33 | #define boot_ctx ((struct context *) phys_to_virt(__boot_ctx)) 34 | 35 | #endif /* PPC_CONTEXT_H */ 36 | -------------------------------------------------------------------------------- /arch/ppc/qemu/kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 17:50:12 stepan> 3 | * Time-stamp: <2004/08/28 17:50:12 stepan> 4 | * 5 | * 6 | * 7 | * Copyright (C) 2004 Stefan Reinauer 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * version 2 12 | * 13 | */ 14 | 15 | #ifndef __KERNEL_H__ 16 | #define __KERNEL_H__ 17 | 18 | /* misc.c */ 19 | extern void fatal_error( const char *str ); 20 | extern void exit( int status ) __attribute__ ((noreturn)); 21 | 22 | /* start.S */ 23 | extern void flush_icache_range( char *start, char *stop ); 24 | extern void flush_dcache_range( char *start, char *stop ); 25 | extern char of_rtas_start[], of_rtas_end[]; 26 | 27 | /* methods.c */ 28 | extern void node_methods_init( const char *cpuname ); 29 | 30 | /* main.c */ 31 | extern void boot( void ); 32 | 33 | /* init.c */ 34 | extern void entry( void ); 35 | extern void arch_of_init( void ); 36 | extern int get_bool_res( const char *str ); 37 | 38 | /* tree.c */ 39 | extern void devtree_init( void ); 40 | 41 | 42 | #endif /* __KERNEL_H__ */ 43 | -------------------------------------------------------------------------------- /arch/ppc/qemu/ldscript: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT(elf32-powerpc) 2 | OUTPUT_ARCH(powerpc:common) 3 | 4 | /* Initial load address 5 | */ 6 | BASE_ADDR = 0xfff00000; 7 | 8 | /* As NVRAM is at 0xfff04000, the .text needs to be after that 9 | */ 10 | TEXT_ADDR = 0xfff08000; 11 | 12 | /* Hard reset vector address 13 | */ 14 | HRESET_ADDR = 0xfffffffc; 15 | 16 | CSTACK_SIZE = 32768; /* client stack size */ 17 | 18 | SECTIONS 19 | { 20 | . = BASE_ADDR; 21 | 22 | _start = BASE_ADDR + 0x0100; 23 | .text.vectors ALIGN(4096): { 24 | *(.text.vectors) 25 | } 26 | 27 | . = TEXT_ADDR; 28 | /* Normal sections */ 29 | .text ALIGN(4096): { 30 | *(.text) 31 | *(.text.*) 32 | } 33 | 34 | .rodata ALIGN(4096): { 35 | _rodata = .; 36 | *(.rodata) 37 | *(.rodata.*) 38 | *(.note.ELFBoot) 39 | } 40 | .data ALIGN(4096): { 41 | _data = .; 42 | *(.data) 43 | *(.data.*) 44 | _edata = .; 45 | } 46 | 47 | .bss ALIGN(4096): { 48 | _bss = .; 49 | *(.sbss) 50 | *(.sbss.*) 51 | *(.bss) 52 | *(.bss.*) 53 | *(COMMON) 54 | _ebss = .; 55 | } 56 | 57 | . = HRESET_ADDR; 58 | 59 | .romentry : { *(.romentry) } 60 | 61 | . = ALIGN(4096); 62 | _end = .; 63 | 64 | /* We discard .note sections other than .note.ELFBoot, 65 | * because some versions of GCC generates useless ones. */ 66 | 67 | /DISCARD/ : { *(.comment*) *(.note.*) } 68 | } 69 | -------------------------------------------------------------------------------- /arch/ppc/qemu/qemu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 17:50:12 stepan> 3 | * Time-stamp: <2004/08/28 17:50:12 stepan> 4 | * 5 | * 6 | * 7 | * Copyright (C) 2005 Stefan Reinauer 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * version 2 12 | * 13 | */ 14 | 15 | #ifndef _H_QEMU 16 | #define _H_QEMU 17 | 18 | /* vfd.c */ 19 | extern int vfd_draw_str( const char *str ); 20 | extern void vfd_close( void ); 21 | 22 | #include "kernel.h" 23 | 24 | #endif /* _H_QEMU */ 25 | -------------------------------------------------------------------------------- /arch/ppc/qemu/vfd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/08/28 17:29:43 greg> 3 | * Time-stamp: <2004/08/28 17:29:43 greg> 4 | * 5 | * 6 | * 7 | * Simple text console 8 | * 9 | * Copyright (C) 2004 Greg Watson 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #include "config.h" 18 | #include "libopenbios/bindings.h" 19 | #include "qemu/qemu.h" 20 | 21 | static int vfd_is_open; 22 | 23 | static int 24 | vfd_init( void ) 25 | { 26 | vfd_is_open = 1; 27 | return 0; 28 | } 29 | 30 | void 31 | vfd_close( void ) 32 | { 33 | } 34 | 35 | int 36 | vfd_draw_str( const char *str ) 37 | { 38 | if (!vfd_is_open) 39 | vfd_init(); 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /arch/ppc/timebase.S: -------------------------------------------------------------------------------- 1 | #include "asm/asmdefs.h" 2 | #include "asm/processor.h" 3 | 4 | /* 5 | * unsigned long long _get_ticks(void); 6 | */ 7 | _GLOBAL(_get_ticks): 8 | 1: mftbu r3 9 | mftb r4 10 | mftbu r5 11 | cmpw 0,r3,r5 12 | bne 1b 13 | blr 14 | 15 | /* 16 | * Delay for a number of ticks 17 | */ 18 | _GLOBAL(_wait_ticks): 19 | mflr r8 /* save link register */ 20 | mr r7, r3 /* save tick count */ 21 | bl BRANCH_LABEL(_get_ticks) /* Get start time */ 22 | 23 | /* Calculate end time */ 24 | addc r7, r4, r7 /* Compute end time lower */ 25 | addze r6, r3 /* and end time upper */ 26 | 27 | 1: bl BRANCH_LABEL(_get_ticks) /* Get current time */ 28 | subfc r4, r4, r7 /* Subtract current time from end time */ 29 | subfe. r3, r3, r6 30 | bge 1b /* Loop until time expired */ 31 | 32 | mtlr r8 /* restore link register */ 33 | blr 34 | -------------------------------------------------------------------------------- /arch/sparc32/boot.h: -------------------------------------------------------------------------------- 1 | /* tag: openbios loader prototypes for sparc32 2 | * 3 | * Copyright (C) 2004 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #define INITRD_VIRT_ADDR 0x60000000 10 | #define IMAGE_VIRT_ADDR 0x4000 11 | 12 | // linux_load.c 13 | int linux_load(struct sys_info *info, const char *file, const char *cmdline); 14 | 15 | // boot.c 16 | extern const char *bootpath; 17 | extern void boot(void); 18 | extern void setup_romvec(void); 19 | 20 | // sys_info.c 21 | extern unsigned int qemu_mem_size; 22 | extern void collect_sys_info(struct sys_info *info); 23 | 24 | // romvec.c 25 | extern struct linux_arguments_v0 obp_arg; 26 | extern const void *romvec; 27 | extern const char *obp_stdin_path, *obp_stdout_path; 28 | extern char obp_stdin, obp_stdout; 29 | 30 | // openbios.c 31 | extern int qemu_machine_type; 32 | 33 | // arch/sparc32/lib.c 34 | struct linux_mlist_v0; 35 | extern struct linux_mlist_v0 *ptphys; 36 | extern struct linux_mlist_v0 *ptmap; 37 | extern struct linux_mlist_v0 *ptavail; 38 | 39 | void ob_init_mmu(uint32_t simm_size); 40 | void init_mmu_swift(void); 41 | -------------------------------------------------------------------------------- /arch/sparc32/builtin.c: -------------------------------------------------------------------------------- 1 | /* tag: openbios forth starter for builtin dictionary for sparc32 2 | * 3 | * Copyright (C) 2003 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #include "config.h" 10 | #include "asm/types.h" 11 | #include "libopenbios/sys_info.h" 12 | 13 | /* 14 | * wrap an array around the hex'ed dictionary file 15 | */ 16 | 17 | /* 256K for the dictionary */ 18 | #define DICTIONARY_SIZE (256 * 1024 / sizeof(ucell)) 19 | #define DICTIONARY_BASE ((ucell)((char *)&forth_dictionary)) 20 | 21 | static ucell forth_dictionary[DICTIONARY_SIZE] = { 22 | #include "static-dict.h" 23 | }; 24 | 25 | void collect_multiboot_info(struct sys_info *info); 26 | void collect_multiboot_info(struct sys_info *info) 27 | { 28 | info->dict_start=(unsigned long *)forth_dictionary; 29 | info->dict_end = (unsigned long *)FORTH_DICTIONARY_END; 30 | info->dict_last = (ucell *)((unsigned char *)forth_dictionary + 31 | FORTH_DICTIONARY_LAST); 32 | info->dict_limit = sizeof(forth_dictionary); 33 | } 34 | -------------------------------------------------------------------------------- /arch/sparc32/context.h: -------------------------------------------------------------------------------- 1 | #ifndef SPARC32_CONTEXT_H 2 | #define SPARC32_CONTEXT_H 3 | 4 | struct context { 5 | /* General registers */ 6 | uint32_t regs[148]; 7 | uint32_t pc; 8 | uint32_t npc; 9 | #define REG_O0 12 10 | #define REG_SP 18 11 | #define SP_LOC(ctx) (&(ctx)->regs[REG_SP]) 12 | /* Flags */ 13 | /* Optional stack contents */ 14 | uint32_t return_addr; 15 | uint32_t param[0]; 16 | }; 17 | 18 | /* Create a new context in the given stack */ 19 | struct context * 20 | init_context(uint8_t *stack, uint32_t stack_size, int num_param); 21 | 22 | /* Switch context */ 23 | struct context *switch_to(struct context *); 24 | 25 | /* Holds physical address of boot context */ 26 | extern unsigned long __boot_ctx; 27 | 28 | /* This can always be safely used to refer to the boot context */ 29 | #define boot_ctx ((struct context *) phys_to_virt(__boot_ctx)) 30 | 31 | #endif /* SPARC32_CONTEXT_H */ 32 | -------------------------------------------------------------------------------- /arch/sparc32/crs.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qemu/openbios/af97fd7af5e7c18f591a7b987291d3db4ffb28b5/arch/sparc32/crs.h -------------------------------------------------------------------------------- /arch/sparc32/openbios.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/01/15 16:14:05 samuel> 3 | * Time-stamp: <2004/01/15 16:14:05 samuel> 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * Copyright (C) 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_OPENBIOS 18 | #define _H_OPENBIOS 19 | 20 | int openbios(void); 21 | 22 | /* console.c */ 23 | extern unsigned char *vmem; 24 | #ifdef CONFIG_DEBUG_CONSOLE 25 | extern void video_init(void); 26 | #endif 27 | 28 | #endif /* _H_OPENBIOS */ 29 | -------------------------------------------------------------------------------- /arch/sparc32/plainboot.c: -------------------------------------------------------------------------------- 1 | /* tag: openbios fixed address forth starter 2 | * 3 | * Copyright (C) 2003 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #include "config.h" 10 | #include "libopenbios/sys_info.h" 11 | #include "multiboot.h" 12 | 13 | #define FIXED_DICTSTART 0xfffe0000 14 | #define FIXED_DICTEND 0xfffeffff 15 | 16 | void collect_multiboot_info(struct sys_info *info); 17 | void collect_multiboot_info(struct sys_info *info) 18 | { 19 | info->dict_start=(unsigned long *)FIXED_DICTSTART; 20 | info->dict_end=(unsigned long *)FIXED_DICTEND; 21 | } 22 | -------------------------------------------------------------------------------- /arch/sparc64/boot.h: -------------------------------------------------------------------------------- 1 | /* tag: openbios loader prototypes for sparc64 2 | * 3 | * Copyright (C) 2004 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #define INITRD_VIRT_ADDR 0x40c00000 10 | #define IMAGE_VIRT_ADDR 0x40000000 11 | 12 | // linux_load.c 13 | int linux_load(struct sys_info *info, const char *file, const char *cmdline); 14 | 15 | // boot.c 16 | extern uint64_t kernel_image; 17 | extern uint64_t kernel_size; 18 | extern uint64_t initrd_image; 19 | extern uint64_t initrd_size; 20 | extern uint64_t qemu_cmdline; 21 | extern uint64_t cmdline_size; 22 | extern char *boot_device; 23 | extern void boot(void); 24 | 25 | // sys_info.c 26 | extern uint64_t qemu_mem_size; 27 | extern void collect_sys_info(struct sys_info *info); 28 | 29 | // console.c 30 | void ob_su_init(uint64_t base, uint64_t offset, int intr); 31 | void cls(void); 32 | 33 | // lib.c 34 | void ob_mmu_init(const char *cpuname, uint64_t ram_size); 35 | void prom_debug_handler(void); 36 | -------------------------------------------------------------------------------- /arch/sparc64/builtin.c: -------------------------------------------------------------------------------- 1 | /* tag: openbios forth starter for builtin dictionary for sparc64 2 | * 3 | * Copyright (C) 2003 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #include "config.h" 10 | #include "asm/types.h" 11 | #include "libopenbios/sys_info.h" 12 | 13 | /* 14 | * wrap an array around the hex'ed dictionary file 15 | */ 16 | 17 | /* 512K for the dictionary */ 18 | #define DICTIONARY_SIZE (512 * 1024 / sizeof(ucell)) 19 | #define DICTIONARY_BASE ((ucell)((char *)&forth_dictionary)) 20 | 21 | static ucell forth_dictionary[DICTIONARY_SIZE] = { 22 | #include "static-dict.h" 23 | }; 24 | 25 | void collect_multiboot_info(struct sys_info *info); 26 | void collect_multiboot_info(struct sys_info *info) 27 | { 28 | info->dict_start=(unsigned long *)forth_dictionary; 29 | info->dict_end = (unsigned long *)FORTH_DICTIONARY_END; 30 | info->dict_last = (ucell *)((unsigned char *)forth_dictionary + 31 | FORTH_DICTIONARY_LAST); 32 | info->dict_limit = sizeof(forth_dictionary); 33 | } 34 | -------------------------------------------------------------------------------- /arch/sparc64/const.h: -------------------------------------------------------------------------------- 1 | /* const.h: Macros for dealing with constants. */ 2 | 3 | #ifndef _SPARC64_CONST_H 4 | #define _SPARC64_CONST_H 5 | 6 | /* Some constant macros are used in both assembler and 7 | * C code. Therefore we cannot annotate them always with 8 | * 'UL' and other type specificers unilaterally. We 9 | * use the following macros to deal with this. 10 | */ 11 | 12 | #ifdef __ASSEMBLY__ 13 | #define _AC(X,Y) X 14 | #else 15 | #define _AC(X,Y) (X##Y) 16 | #endif 17 | 18 | 19 | #endif /* !(_SPARC64_CONST_H) */ 20 | -------------------------------------------------------------------------------- /arch/sparc64/context.h: -------------------------------------------------------------------------------- 1 | #ifndef SPARC64_CONTEXT_H 2 | #define SPARC64_CONTEXT_H 3 | 4 | #define STACK_BIAS 2047 5 | 6 | struct context { 7 | /* General registers */ 8 | uint64_t regs[154]; 9 | uint64_t pc; 10 | uint64_t npc; 11 | #define REG_O0 14 12 | #define REG_SP 20 13 | #define SP_LOC(ctx) (&(ctx)->regs[REG_SP]) 14 | uint64_t tba; 15 | uint64_t _pad; 16 | uint64_t tregs[16]; 17 | /* Flags */ 18 | /* Optional stack contents */ 19 | uint64_t return_addr; 20 | uint64_t param[0]; 21 | }; 22 | 23 | /* Create a new context in the given stack */ 24 | struct context * 25 | init_context(uint8_t *stack, uint64_t stack_size, int num_param); 26 | 27 | /* Switch context */ 28 | struct context *switch_to(struct context *); 29 | 30 | /* Holds physical address of boot context */ 31 | extern unsigned long __boot_ctx; 32 | 33 | /* This can always be safely used to refer to the boot context */ 34 | #define boot_ctx ((struct context *) phys_to_virt(__boot_ctx)) 35 | 36 | #endif /* SPARC64_CONTEXT_H */ 37 | -------------------------------------------------------------------------------- /arch/sparc64/init.fs: -------------------------------------------------------------------------------- 1 | \ va>tte-data defer MMU virtual to physical address hook for Solaris 2 | \ We need to make sure this is in the global wordlist 3 | active-package 0 active-package! 4 | defer va>tte-data 5 | 0 to va>tte-data 6 | active-package! 7 | 8 | :noname 9 | ." Type 'help' for detailed information" cr 10 | \ ." boot secondary slave cdrom: " cr 11 | \ ." 0 > boot hd:2,\boot\vmlinuz root=/dev/hda2" cr 12 | ; DIAG-initializer 13 | 14 | : make-openable ( path ) 15 | find-dev if 16 | begin ?dup while 17 | \ install trivial open and close methods 18 | dup active-package! is-open 19 | parent 20 | repeat 21 | then 22 | ; 23 | 24 | : preopen ( chosen-str node-path ) 25 | 2dup make-openable 26 | 27 | " /chosen" find-device 28 | open-dev ?dup if 29 | encode-int 2swap property 30 | else 31 | 2drop 32 | then 33 | ; 34 | 35 | :noname 36 | set-defaults 37 | ; PREPOST-initializer 38 | 39 | \ preopen device nodes (and store the ihandles under /chosen) 40 | :noname 41 | " memory" " /memory" preopen 42 | 43 | ; SYSTEM-initializer 44 | 45 | \ use the tty interface if available 46 | : activate-tty-interface 47 | " /packages/terminal-emulator" find-dev if drop 48 | then 49 | ; 50 | 51 | device-end 52 | 53 | : rmap@ ( virt -- rmentry ) 54 | drop 0 55 | ; 56 | 57 | \ Load VGA FCode driver blob 58 | [IFDEF] CONFIG_DRIVER_VGA 59 | -1 value vga-driver-fcode 60 | " QEMU,VGA.bin" $encode-file to vga-driver-fcode 61 | [THEN] 62 | -------------------------------------------------------------------------------- /arch/sparc64/lsu.h: -------------------------------------------------------------------------------- 1 | /* $Id: lsu.h,v 1.2 1997/04/04 00:50:22 davem Exp $ */ 2 | #ifndef _SPARC64_LSU_H 3 | #define _SPARC64_LSU_H 4 | 5 | #include "const.h" 6 | 7 | /* LSU Control Register */ 8 | #define LSU_CONTROL_PM _AC(0x000001fe00000000,UL) /* Phys-watchpoint byte mask*/ 9 | #define LSU_CONTROL_VM _AC(0x00000001fe000000,UL) /* Virt-watchpoint byte mask*/ 10 | #define LSU_CONTROL_PR _AC(0x0000000001000000,UL) /* Phys-rd watchpoint enable*/ 11 | #define LSU_CONTROL_PW _AC(0x0000000000800000,UL) /* Phys-wr watchpoint enable*/ 12 | #define LSU_CONTROL_VR _AC(0x0000000000400000,UL) /* Virt-rd watchpoint enable*/ 13 | #define LSU_CONTROL_VW _AC(0x0000000000200000,UL) /* Virt-wr watchpoint enable*/ 14 | #define LSU_CONTROL_FM _AC(0x00000000000ffff0,UL) /* Parity mask enables. */ 15 | #define LSU_CONTROL_DM _AC(0x0000000000000008,UL) /* Data MMU enable. */ 16 | #define LSU_CONTROL_IM _AC(0x0000000000000004,UL) /* Instruction MMU enable. */ 17 | #define LSU_CONTROL_DC _AC(0x0000000000000002,UL) /* Data cache enable. */ 18 | #define LSU_CONTROL_IC _AC(0x0000000000000001,UL) /* Instruction cache enable.*/ 19 | 20 | #endif /* !(_SPARC64_LSU_H) */ 21 | -------------------------------------------------------------------------------- /arch/sparc64/openbios.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/01/15 16:14:05 samuel> 3 | * Time-stamp: <2004/01/15 16:14:05 samuel> 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * Copyright (C) 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_OPENBIOS 18 | #define _H_OPENBIOS 19 | 20 | int openbios(void); 21 | 22 | /* console.c */ 23 | #ifdef CONFIG_DEBUG_CONSOLE 24 | extern void video_init(void); 25 | #endif 26 | 27 | #endif /* _H_OPENBIOS */ 28 | -------------------------------------------------------------------------------- /arch/sparc64/plainboot.c: -------------------------------------------------------------------------------- 1 | /* tag: openbios fixed address forth starter 2 | * 3 | * Copyright (C) 2003 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #include "config.h" 10 | #include "libopenbios/sys_info.h" 11 | #include "multiboot.h" 12 | 13 | #define FIXED_DICTSTART 0xfffe0000 14 | #define FIXED_DICTEND 0xfffeffff 15 | 16 | void collect_multiboot_info(struct sys_info *info); 17 | void collect_multiboot_info(struct sys_info *info) 18 | { 19 | info->dict_start=(unsigned long *)FIXED_DICTSTART; 20 | info->dict_end=(unsigned long *)FIXED_DICTEND; 21 | } 22 | -------------------------------------------------------------------------------- /arch/unix/Kconfig: -------------------------------------------------------------------------------- 1 | 2 | config HOST_UNIX 3 | bool "Build Hosted Unix binary" 4 | default y 5 | help 6 | Build a version of the OpenBIOS kernel that runs in a 7 | Unix-like operating system. 8 | 9 | config UNIX_QT 10 | depends HOST_UNIX 11 | bool "QT frontend for Unix binary" 12 | default n 13 | help 14 | Enable this option if you wish to add a graphical user 15 | interface to the openbios hosted unix binary. This option 16 | needs the QT library installed. 17 | 18 | source "arch/unix/plugins/Kconfig" 19 | -------------------------------------------------------------------------------- /arch/unix/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | 3 | include ../../config/Makefile.top 4 | 5 | SUBDIRS-$(CONFIG_PLUGINS) = plugins 6 | SUBDIRS-$(CONFIG_UNIX_QT) = gui_qt 7 | 8 | DICTIONARIES = unix 9 | unix-SRC = tree.fs $(ARCHDICT_SRC) 10 | 11 | PROGRAMS = unix 12 | 13 | unix-OBJS = $(unix-y) 14 | unix-y += blk.o 15 | unix-y += boot.o 16 | unix-y += unix.o 17 | unix-y += $(KOBJS) 18 | unix-y += $(MODULE_LIBS) $(FS_LIBS) $(DRIVER_LIBS) $(LIBC_LIBS) 19 | unix-$(CONFIG_PLUGINS) += plugins.o 20 | 21 | unix-LDFLAGS = $(unix-LDFLAGS-$(CONFIG_PLUGINS)) 22 | unix-LDFLAGS-y = -rdynamic $(LIBDL_LDFLAGS) 23 | unix-LDFLAGS-n = 24 | unix-LDADD = 25 | 26 | INCLUDES = -I../../kernel -I../../kernel/include -DBOOTSTRAP 27 | 28 | include $(rules)/Rules.forth 29 | include $(rules)/Rules.make 30 | -------------------------------------------------------------------------------- /arch/unix/blk.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _H_BLK 3 | #define _H_BLK 4 | 5 | extern void blk_init( void ); 6 | extern int read_from_disk( int channel, int unit, int blk, unsigned long mphys, int size ); 7 | 8 | #endif /* _H_BLK */ 9 | -------------------------------------------------------------------------------- /arch/unix/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | $(call quiet-command,$(CC) $(CFLAGS) -rdynamic $(LIBDL_LDFLAGS) -o $@ $^," LINK $(TARGET_DIR)$@") 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /arch/unix/gui_qt/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile of QT user interface for OpenBIOS 3 | # 4 | # (C) 2004 Stefan Reinauer 5 | # 6 | # This program is free software; you can redistribute it and/or 7 | # modify it under the terms of the GNU General Public License 8 | # version 2 9 | # 10 | 11 | include ../../../config/Makefile.top 12 | 13 | XTARGETS = qt 14 | 15 | qt-OBJS = $(obj-y) 16 | obj-y += gui_qt.o 17 | 18 | QMAKE = qmake 19 | UIDIR = $(shell pwd ) 20 | TOPDIR = $(shell cd $(top_srcdir) ; pwd) 21 | ABSOINC = $(shell cd $(ARCHINCLUDES) 2> /dev/null ; pwd ) 22 | 23 | export UIDIR TOPDIR ABSOINC 24 | 25 | $(ODIR)/makefile.qmake: gui-qt.pro Makefile 26 | @echo "ODIR: $(ODIR)" 27 | @test -d $(ODIR) || $(INSTALL) -d $(ODIR) 28 | @test -d $(ODIR)/qbuild || $(INSTALL) -d $(ODIR)/qbuild 29 | @install -m 644 gui-qt.pro $(ODIR)/ 30 | cd $(ODIR) ; $(QMAKE) -o makefile.qmake 31 | 32 | $(ODIR)/libgui_qt.a: $(ODIR)/makefile.qmake $(wildcard *.cpp) 33 | cd $(ODIR) ; $(MAKE) -f makefile.qmake 34 | @ln -f $(ODIR)/qbuild/libgui_qt.a $@ 35 | 36 | clean-local: 37 | @rm -f $(ODIR)/makefile.qmake 38 | @rm -rf $(QBUILDDIR) 39 | 40 | INCLUDES = -I$(top_srcdir)/include -DBOOTSTRAP 41 | 42 | include $(rules)/Rules.make 43 | -------------------------------------------------------------------------------- /arch/unix/gui_qt/gui-qt.h: -------------------------------------------------------------------------------- 1 | /* tag: qt user interface fb class description 2 | * 3 | * Copyright (C) 2003-2004 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #ifndef __framebufferwidget_h 10 | #define __framebufferwidget_h 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | class FrameBufferWidget : public QWidget { 23 | Q_OBJECT 24 | public: 25 | FrameBufferWidget(QWidget *parent=0, const char *name=0); 26 | unsigned char *getFrameBuffer(void); 27 | 28 | public slots: 29 | void quit(); 30 | void about(); 31 | void aboutQt(); 32 | void update(); 33 | 34 | private: 35 | QImage buffer; 36 | QMenuBar *menu; 37 | QStatusBar *status; 38 | QTimer *updatetimer; 39 | void paintEvent ( QPaintEvent * ); 40 | protected: 41 | void keyPressEvent(QKeyEvent * e); 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /arch/unix/gui_qt/gui-qt.pro: -------------------------------------------------------------------------------- 1 | # tag: qmake project file for OpenBIOS QT user interface 2 | # 3 | # Copyright (C) 2003-2004 Stefan Reinauer 4 | # 5 | # See the file "COPYING" for further information about 6 | # the copyright and warranty status of this work. 7 | # 8 | 9 | TEMPLATE = lib 10 | CONFIG += qt thread warn_on release staticlib 11 | LIBS = 12 | INCLUDEPATH = qbuild $(ABSOINC) $(TOPDIR)/include 13 | DESTDIR = qbuild 14 | OBJECTS_DIR = qbuild 15 | MOC_DIR = qbuild 16 | TARGET = gui_qt 17 | HEADERS = $(UIDIR)/gui-qt.h 18 | SOURCES = $(UIDIR)/gui-qt.cpp $(UIDIR)/qt-main.cpp 19 | -------------------------------------------------------------------------------- /arch/unix/plugins/Kconfig: -------------------------------------------------------------------------------- 1 | config PLUGINS 2 | depends HOST_UNIX 3 | bool "Plugin system (obsolete)" 4 | default n 5 | 6 | config PLUGIN_PCI 7 | depends HOST_UNIX && PLUGINS 8 | bool "PCI Emulation" 9 | default n 10 | 11 | config PLUGIN_QT 12 | bool "QT Display Emulation" 13 | depends HOST_UNIX && PLUGINS && PLUGIN_PCI 14 | default n 15 | help 16 | This plugin needs qt installed. Disable if you don't have qt. 17 | -------------------------------------------------------------------------------- /arch/unix/plugins/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../../config/Makefile.top 3 | 4 | SUBDIRS-$(CONFIG_PLUGIN_PCI) += plugin_pci 5 | SUBDIRS-$(CONFIG_PLUGIN_QT) += plugin_qt 6 | 7 | PROGRAMS = # loader 8 | loader-OBJS = loader.o 9 | loader-LDFLAGS = -dynamic $(LIBDL_LDFLAGS) 10 | 11 | INCLUDES = -DBOOTSTRAP 12 | 13 | include $(rules)/Rules.make 14 | -------------------------------------------------------------------------------- /arch/unix/plugins/Rules.plugin: -------------------------------------------------------------------------------- 1 | # -*- makefile -*- 2 | 3 | INCLUDES = -I$(top_srcdir)/include -DBOOTSTRAP 4 | CFLAGS = -fPIC 5 | 6 | %.so: %.o 7 | $(CC) -shared $(CFLAGS) $(filter %.o,$^) -o $@ 8 | 9 | THISDIR := $(notdir $(shell pwd)) 10 | 11 | all-local: $(addprefix $(ODIR)/../,$(PLUGINS)) 12 | 13 | $(ODIR)/../%.so: $(ODIR)/%.so 14 | install -d ../$(ODIR) 15 | ln -f "../$(THISDIR)"/$< $@ 16 | -------------------------------------------------------------------------------- /arch/unix/plugins/plugin_pci/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../../../config/Makefile.top 3 | 4 | PLUGINS = plugin_pci.so 5 | 6 | include ../Rules.plugin 7 | include $(rules)/Rules.make 8 | -------------------------------------------------------------------------------- /arch/unix/plugins/plugin_pci/Makefile.old: -------------------------------------------------------------------------------- 1 | # tag: Makefile for OpenBIOS PCI plugin 2 | # 3 | # Copyright (C) 2003 Stefan Reinauer 4 | # 5 | # See the file "COPYING" for further information about 6 | # the copyright and warranty status of this work. 7 | # 8 | 9 | PLUGIN_SOURCES = plugin_pci.c 10 | PLUGIN_NAME = plugin_pci.so 11 | 12 | INCLUDES := -I$(TOPDIR)/include -I$(BUILDDIR) -I.. 13 | VPATH := $(VPATH):. 14 | 15 | all: $(PLUGIN_NAME) 16 | 17 | $(PLUGIN_NAME): $(PLUGIN_SOURCES) 18 | $(CC) -shared -Wall -Os -fPIC $(INCLUDES) $< -o $(BUILDDIR)/$@ 19 | 20 | clean: 21 | rm -f plugin_*.so 22 | -------------------------------------------------------------------------------- /arch/unix/plugins/plugin_qt/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include ../../../../config/Makefile.top 3 | 4 | PLUGINS = plugin_qt.so 5 | 6 | QMAKE = qmake 7 | PLUGINDIR = $(shell cd .. ; pwd ) 8 | TOPDIR = $(shell cd $(top_srcdir) ; pwd) 9 | ABSOINC = $(shell cd $(ARCHINCLUDES) 2> /dev/null ; pwd ) 10 | 11 | export PLUGINDIR TOPDIR ABSOINC 12 | 13 | qt_rom.fc: qt_rom.fs 14 | $(TOKE) -v qt_rom.fs 15 | 16 | fcode.h: qt_rom.fc 17 | @echo "static const u8 qt_fcode[] = {" > $@ 18 | @cat $< | hexdump -ve '1/0 "\t" 8/1 "0x%02x, " 1/0 "\n"' \ 19 | | sed 's/0x ,//g' >> $@ 20 | @echo "};" >> $@ 21 | 22 | $(ODIR)/makefile.qmake: plugin_qt.pro Makefile 23 | @test -d $(ODIR) || $(INSTALL) -d $(ODIR) 24 | @test -d $(ODIR)/qbuild || $(INSTALL) -d $(ODIR)/qbuild 25 | @cp plugin_qt.pro $(ODIR)/ 26 | cd $(ODIR) ; $(QMAKE) -o makefile.qmake 27 | 28 | $(ODIR)/plugin_qt.so: fcode.h $(ODIR)/makefile.qmake $(wildcard *.cpp) 29 | cd $(ODIR) ; $(MAKE) -f makefile.qmake 30 | @ln -f $(ODIR)/qbuild/plugin_qt.so $@ 31 | 32 | clean-local: 33 | @rm -f $(ODIR)/makefile.qmake 34 | @rm -rf $(QBUILDDIR) $(ODIR)/*.fc $(ODIR)/fcode.h 35 | 36 | include ../Rules.plugin 37 | include $(rules)/Rules.make 38 | -------------------------------------------------------------------------------- /arch/unix/plugins/plugin_qt/plugin_qt.h: -------------------------------------------------------------------------------- 1 | /* tag: qt plugin framebuffer class description 2 | * 3 | * Copyright (C) 2003 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #ifndef __framebufferwidget_h 10 | #define __framebufferwidget_h 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | class FrameBufferWidget : public QWidget { 23 | Q_OBJECT 24 | public: 25 | FrameBufferWidget(QWidget *parent=0, const char *name=0); 26 | unsigned char *getFrameBuffer(void); 27 | 28 | public slots: 29 | void quit(); 30 | void about(); 31 | void aboutQt(); 32 | void update(); 33 | 34 | private: 35 | QImage buffer; 36 | QMenuBar *menu; 37 | QStatusBar *status; 38 | QTimer *updatetimer; 39 | void paintEvent ( QPaintEvent * ); 40 | protected: 41 | void keyPressEvent(QKeyEvent * e); 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /arch/unix/plugins/plugin_qt/plugin_qt.pro: -------------------------------------------------------------------------------- 1 | # tag: qmake project file for OpenBIOS QT plugin 2 | # 3 | # Copyright (C) 2003 Stefan Reinauer 4 | # 5 | # See the file "COPYING" for further information about 6 | # the copyright and warranty status of this work. 7 | # 8 | 9 | TEMPLATE = app 10 | CONFIG += qt thread warn_on release 11 | LIBS = -shared 12 | INCLUDEPATH = qbuild $(ABSOINC) $(TOPDIR)/include $(PLUGINDIR)/plugin_pci 13 | DESTDIR = qbuild 14 | OBJECTS_DIR = qbuild 15 | MOC_DIR = qbuild 16 | TARGET = plugin_qt.so 17 | HEADERS = $(PLUGINDIR)/plugin_qt/plugin_qt.h 18 | SOURCES = $(PLUGINDIR)/plugin_qt/plugin_qt.cpp $(PLUGINDIR)/plugin_qt/qt_main.cpp 19 | -------------------------------------------------------------------------------- /arch/x86/Kconfig: -------------------------------------------------------------------------------- 1 | mainmenu "OpenBIOS Configuration" 2 | 3 | config X86 4 | bool 5 | default y 6 | help 7 | Building for X86 hardware. 8 | 9 | config LITTLE_ENDIAN 10 | bool 11 | default y 12 | help 13 | X86 is little endian 14 | 15 | menu "Kernel binaries (x86)" 16 | 17 | config IMAGE_ELF 18 | bool "ELF image (for LinuxBIOS)" 19 | default y 20 | help 21 | Build a simple elf image that can be used with LinuxBIOS 22 | This image will be called openbios.elf 23 | 24 | config IMAGE_ELF_EMBEDDED 25 | bool "ELF image with embedded dictionary" 26 | default y 27 | help 28 | Build an elf image with embedded dictionary. This image 29 | can easily be used with etherboot. 30 | The image filename is openbios.full 31 | 32 | config IMAGE_ELF_MULTIBOOT 33 | bool "Multiboot image" 34 | default y 35 | help 36 | Build a multiboot image for booting with grub 37 | 38 | endmenu 39 | 40 | menu "Build hosted UNIX Binary" 41 | source "arch/unix/Kconfig" 42 | endmenu 43 | 44 | source "kernel/Kconfig" 45 | source "forth/Kconfig" 46 | source "libopenbios/Kconfig" 47 | source "drivers/Kconfig" 48 | -------------------------------------------------------------------------------- /arch/x86/boot.c: -------------------------------------------------------------------------------- 1 | /* tag: openbios boot command for x86 2 | * 3 | * Copyright (C) 2003-2004 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #undef BOOTSTRAP 10 | #include "config.h" 11 | #include "libopenbios/bindings.h" 12 | #include "arch/common/nvram.h" 13 | #include "libc/diskio.h" 14 | #include "libopenbios/initprogram.h" 15 | #include "libopenbios/sys_info.h" 16 | #include "boot.h" 17 | 18 | 19 | void boot(void) 20 | { 21 | /* No platform-specific boot code */ 22 | return; 23 | } 24 | -------------------------------------------------------------------------------- /arch/x86/boot.h: -------------------------------------------------------------------------------- 1 | /* tag: openbios loader prototypes for x86 2 | * 3 | * Copyright (C) 2004 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | /* linux_load.c */ 10 | int linux_load(struct sys_info *info, const char *file, const char *cmdline); 11 | 12 | /* boot.c */ 13 | extern void boot(void); 14 | 15 | -------------------------------------------------------------------------------- /arch/x86/builtin.c: -------------------------------------------------------------------------------- 1 | /* tag: openbios forth starter for builtin dictionary 2 | * 3 | * Copyright (C) 2003 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #include "config.h" 10 | #include "libopenbios/sys_info.h" 11 | 12 | /* 13 | * wrap an array around the hex'ed dictionary file 14 | */ 15 | 16 | /* 256K for the dictionary */ 17 | #define DICTIONARY_SIZE (256 * 1024 / sizeof(ucell)) 18 | #define DICTIONARY_BASE ((ucell)((char *)&forth_dictionary)) 19 | 20 | static ucell forth_dictionary[DICTIONARY_SIZE] = { 21 | #include "static-dict.h" 22 | }; 23 | 24 | void collect_multiboot_info(struct sys_info *info); 25 | void collect_multiboot_info(struct sys_info *info) 26 | { 27 | info->dict_start=(unsigned long *)forth_dictionary; 28 | info->dict_end = (unsigned long *)FORTH_DICTIONARY_END; 29 | info->dict_last = (ucell *)((unsigned char *)forth_dictionary + 30 | FORTH_DICTIONARY_LAST); 31 | info->dict_limit = sizeof(forth_dictionary); 32 | } 33 | -------------------------------------------------------------------------------- /arch/x86/context.h: -------------------------------------------------------------------------------- 1 | #ifndef i386_CONTEXT_H 2 | #define i386_CONTEXT_H 3 | 4 | struct context { 5 | /* Stack Segment, placed here because of the alignment issue... */ 6 | uint16_t ss; 7 | /* Used with sgdt/lgdt */ 8 | uint16_t gdt_limit; 9 | uint32_t gdt_base; 10 | /* General registers, accessed with pushal/popal */ 11 | uint32_t edi; 12 | uint32_t esi; 13 | uint32_t ebp; 14 | uint32_t esp; /* points just below eax */ 15 | uint32_t ebx; 16 | uint32_t edx; 17 | uint32_t ecx; 18 | uint32_t eax; 19 | #define ESP_LOC(ctx) (&(ctx)->gs) 20 | /* Segment registers */ 21 | uint32_t gs; 22 | uint32_t fs; 23 | uint32_t es; 24 | uint32_t ds; 25 | /* Flags */ 26 | uint32_t eflags; 27 | /* Code segment:offset */ 28 | uint32_t eip; 29 | uint32_t cs; 30 | /* Optional stack contents */ 31 | uint32_t return_addr; 32 | uint32_t param[0]; 33 | }; 34 | 35 | /* Create a new context in the given stack */ 36 | struct context * 37 | init_context(uint8_t *stack, uint32_t stack_size, int num_param); 38 | 39 | /* Switch context */ 40 | struct context *switch_to(struct context *); 41 | 42 | /* Holds physical address of boot context */ 43 | extern unsigned long __boot_ctx; 44 | 45 | /* This can always be safely used to refer to the boot context */ 46 | #define boot_ctx ((struct context *) phys_to_virt(__boot_ctx)) 47 | 48 | #endif /* i386_CONTEXT_H */ 49 | -------------------------------------------------------------------------------- /arch/x86/defconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated make config: don't edit 3 | # 4 | CONFIG_X86=y 5 | CONFIG_LITTLE_ENDIAN=y 6 | 7 | # 8 | # Kernel binaries (x86) 9 | # 10 | CONFIG_IMAGE_ELF=y 11 | CONFIG_IMAGE_ELF_EMBEDDED=y 12 | CONFIG_IMAGE_ELF_MULTIBOOT=y 13 | 14 | # 15 | # Build hosted UNIX Binary 16 | # 17 | CONFIG_HOST_UNIX=y 18 | # CONFIG_PLUGIN_PCI is not set 19 | 20 | # 21 | # Kernel Debugging 22 | # 23 | # CONFIG_DEBUG is not set 24 | CONFIG_DEBUG_CONSOLE=y 25 | CONFIG_DEBUG_CONSOLE_SERIAL=y 26 | CONFIG_SERIAL_PORT=1 27 | CONFIG_SERIAL_SPEED=115200 28 | CONFIG_DEBUG_CONSOLE_VGA=y 29 | 30 | # 31 | # Module Configuration 32 | # 33 | CONFIG_CMDLINE=y 34 | CONFIG_DEBLOCKER=y 35 | 36 | # 37 | # Filesystem Configuration 38 | # 39 | CONFIG_DISK_LABEL=y 40 | CONFIG_PART_SUPPORT=y 41 | CONFIG_PC_PARTS=y 42 | CONFIG_FS=y 43 | CONFIG_GRUBFS=y 44 | CONFIG_FSYS_EXT2FS=y 45 | CONFIG_FSYS_FAT=y 46 | CONFIG_FSYS_JFS=y 47 | # CONFIG_FSYS_MINIX is not set 48 | CONFIG_FSYS_REISERFS=y 49 | CONFIG_FSYS_XFS=y 50 | CONFIG_FSYS_ISO9660=y 51 | # CONFIG_FSYS_FFS is not set 52 | # CONFIG_FSYS_VSTAFS is not set 53 | # CONFIG_DEBUG_FS is not set 54 | 55 | # 56 | # Miscellaneous 57 | # 58 | CONFIG_LINUXBIOS=y 59 | 60 | # 61 | # Drivers 62 | # 63 | CONFIG_DRIVER_PCI=y 64 | CONFIG_DRIVER_IDE=y 65 | # CONFIG_DEBUG_IDE is not set 66 | -------------------------------------------------------------------------------- /arch/x86/lib.c: -------------------------------------------------------------------------------- 1 | /* lib.c 2 | * tag: simple function library 3 | * 4 | * Copyright (C) 2003 Stefan Reinauer 5 | * 6 | * See the file "COPYING" for further information about 7 | * the copyright and warranty status of this work. 8 | */ 9 | 10 | #include "config.h" 11 | #include "asm/types.h" 12 | #include 13 | #include "libc/stdlib.h" 14 | #include "libc/vsprintf.h" 15 | #include "kernel/kernel.h" 16 | 17 | /* Format a string and print it on the screen, just like the libc 18 | * function printf. 19 | */ 20 | int printk( const char *fmt, ... ) 21 | { 22 | char *p, buf[512]; 23 | va_list args; 24 | int i; 25 | 26 | va_start(args, fmt); 27 | i = vsnprintf(buf, sizeof(buf), fmt, args); 28 | va_end(args); 29 | 30 | for( p=buf; *p; p++ ) 31 | putchar(*p); 32 | return i; 33 | } 34 | 35 | // dumb quick memory allocator until we get a decent thing here. 36 | 37 | #define MEMSIZE 128*1024 38 | static char memory[MEMSIZE]; 39 | static void *memptr=memory; 40 | static int memsize=MEMSIZE; 41 | 42 | void *malloc(int size) 43 | { 44 | void *ret=(void *)0; 45 | if(memsize>=size) { 46 | memsize-=size; 47 | ret=memptr; 48 | memptr = (void *)((unsigned long)memptr + size); 49 | } 50 | return ret; 51 | } 52 | 53 | void free(void *ptr) 54 | { 55 | /* Nothing yet */ 56 | } 57 | -------------------------------------------------------------------------------- /arch/x86/openbios.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/01/15 16:14:05 samuel> 3 | * Time-stamp: <2004/01/15 16:14:05 samuel> 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * Copyright (C) 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_OPENBIOS 18 | #define _H_OPENBIOS 19 | 20 | int openbios(void); 21 | 22 | /* entry.S */ 23 | void init_exceptions(void); 24 | 25 | /* console.c */ 26 | extern void cls(void); 27 | #ifdef CONFIG_DEBUG_CONSOLE 28 | extern int uart_init(int port, unsigned long speed); 29 | extern void video_init(void); 30 | #endif 31 | 32 | #endif /* _H_OPENBIOS */ 33 | -------------------------------------------------------------------------------- /arch/x86/plainboot.c: -------------------------------------------------------------------------------- 1 | /* tag: openbios fixed address forth starter 2 | * 3 | * Copyright (C) 2003 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #include "config.h" 10 | #include "libopenbios/sys_info.h" 11 | #include "multiboot.h" 12 | 13 | #define FIXED_DICTSTART 0xfffe0000 14 | #define FIXED_DICTEND 0xfffeffff 15 | 16 | void collect_multiboot_info(struct sys_info *info); 17 | void collect_multiboot_info(struct sys_info *info) 18 | { 19 | info->dict_start=(unsigned long *)FIXED_DICTSTART; 20 | info->dict_end=(unsigned long *)FIXED_DICTEND; 21 | } 22 | -------------------------------------------------------------------------------- /arch/x86/relocate.h: -------------------------------------------------------------------------------- 1 | void relocate(struct sys_info *); 2 | -------------------------------------------------------------------------------- /arch/x86/segment.h: -------------------------------------------------------------------------------- 1 | 2 | /* Segment indexes. Must match the gdt definition in segment.c. */ 3 | enum { 4 | NULL_SEG, 5 | FLAT_CODE, 6 | FLAT_DATA, 7 | RELOC_CODE, 8 | RELOC_DATA, 9 | NUM_SEG, 10 | }; 11 | 12 | /* Values for segment selector register */ 13 | #define FLAT_CS (FLAT_CODE << 3) 14 | #define FLAT_DS (FLAT_DATA << 3) 15 | #define RELOC_CS (RELOC_CODE << 3) 16 | #define RELOC_DS (RELOC_DATA << 3) 17 | 18 | /* i386 segment descriptor */ 19 | struct segment_desc { 20 | unsigned short limit_0; 21 | unsigned short base_0; 22 | unsigned char base_16; 23 | unsigned char types; 24 | unsigned char flags; 25 | unsigned char base_24; 26 | }; 27 | 28 | extern struct segment_desc gdt[NUM_SEG]; 29 | 30 | #define GDT_LIMIT ((NUM_SEG << 3) - 1) 31 | -------------------------------------------------------------------------------- /arch/x86/xbox/console.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Xbox framebuffer - Video + Console 3 | * 4 | * Copyright (C) 2005 Ed Schouten , 5 | * Stefan Reinauer 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 as published by 9 | * the Free Software Foundation 10 | */ 11 | 12 | 13 | #include "config.h" 14 | #include "libopenbios/bindings.h" 15 | #include "libc/diskio.h" 16 | 17 | typedef struct osi_fb_info { 18 | unsigned long mphys; 19 | int rb, w, h, depth; 20 | } osi_fb_info_t; 21 | 22 | #include "../../../packages/video.c" 23 | #include "../../../libopenbios/console_common.c" 24 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /config/scripts/reldir: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PREF="." 4 | for x in 0 1 2 3 4 5 6 7 ; do 5 | test -f $PREF/config/configure.in && break 6 | PREF="../$PREF" 7 | done 8 | ROOT=$( echo $(pwd) | sed "s,\(//*[^/][^/]*\)\{$x\}/*\$,," ) 9 | RELNAME=$( echo $(pwd) | sed "s,^$ROOT/*,,g" ) 10 | echo $RELNAME 11 | -------------------------------------------------------------------------------- /config/xml/makefile.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /config/xml/xinclude.xsl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /docker/Dockerfile.builder: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/openbios/fcode-utils:master AS cross 2 | 3 | RUN apt-get update && \ 4 | apt-get install -y wget xz-utils tar && \ 5 | wget https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/10.1.0/x86_64-gcc-10.1.0-nolibc-sparc64-linux.tar.xz && \ 6 | tar Jxf x86_64-gcc-10.1.0-nolibc-sparc64-linux.tar.xz && \ 7 | rm -f x86_64-gcc-10.1.0-nolibc-sparc64-linux.tar.xz && \ 8 | wget https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/10.1.0/x86_64-gcc-10.1.0-nolibc-powerpc-linux.tar.xz && \ 9 | tar Jxf x86_64-gcc-10.1.0-nolibc-powerpc-linux.tar.xz && \ 10 | rm -f x86_64-gcc-10.1.0-nolibc-powerpc-linux.tar.xz 11 | 12 | FROM ghcr.io/openbios/fcode-utils:master AS builder 13 | 14 | COPY --from=cross /gcc-10.1.0-nolibc /gcc-10.1.0-nolibc 15 | 16 | RUN apt-get update && \ 17 | apt-get install -y make xsltproc gcc gcc-multilib zip 18 | 19 | ENV PATH /gcc-10.1.0-nolibc/sparc64-linux/bin:/gcc-10.1.0-nolibc/powerpc-linux/bin:$PATH 20 | -------------------------------------------------------------------------------- /drivers/Kconfig: -------------------------------------------------------------------------------- 1 | 2 | 3 | menu "Drivers" 4 | 5 | config DRIVER_PCI 6 | bool "PCI driver" 7 | default y 8 | help 9 | Builtin PCI driver 10 | 11 | config DEBUG_PCI 12 | bool "Debug PCI driver" 13 | default n 14 | help 15 | Debug PCI driver 16 | 17 | config DRIVER_IDE 18 | depends X86 || AMD64 || PPC 19 | bool "Legacy IDE" 20 | default y 21 | help 22 | If you want to be able to boot from IDE, enable this option. 23 | 24 | config IDE_NUM_CHANNELS 25 | depends DRIVER_IDE 26 | int "Number of IDE channels to be probed" 27 | default 4 28 | help 29 | Number of IDE channels to be probed. This should be set to 30 | one or two if you build OpenBIOS for the Total Impact BRIQ. 31 | 32 | config DEBUG_IDE 33 | depends DRIVER_IDE 34 | bool "Debug IDE driver" 35 | default n 36 | help 37 | Debug IDE driver 38 | 39 | config DRIVER_USB 40 | bool "USB Support" 41 | default n 42 | help 43 | If you want to be able to use USB devices, enable this option. 44 | 45 | config DEBUG_USB 46 | depends DRIVER_USB 47 | bool "Debug USB driver" 48 | default n 49 | help 50 | Debug USB driver 51 | 52 | config USB_HID 53 | depends DRIVER_USB 54 | bool "USB driver for HID devices" 55 | default n 56 | help 57 | If you want to be able to use USB keyboard, enable this option. 58 | 59 | endmenu 60 | -------------------------------------------------------------------------------- /drivers/adb_kbd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Open Hack'Ware BIOS ADB keyboard support, ported to OpenBIOS 4 | * 5 | * Copyright (c) 2005 Jocelyn Mayer 6 | * Copyright (c) 2005 Stefan Reinauer 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License V2 10 | * as 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA 20 | */ 21 | 22 | void *adb_kbd_new (char *path, void *private); 23 | -------------------------------------------------------------------------------- /drivers/adb_mouse.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Open Hack'Ware BIOS ADB mouse support, ported to OpenBIOS 4 | * 5 | * Copyright (c) 2005 Jocelyn Mayer 6 | * Copyright (c) 2005 Stefan Reinauer 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License V2 10 | * as 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., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA 20 | */ 21 | 22 | void adb_mouse_new (char *path, void *private); 23 | -------------------------------------------------------------------------------- /drivers/cuda.h: -------------------------------------------------------------------------------- 1 | #include "adb_bus.h" 2 | 3 | struct cuda_t { 4 | phys_addr_t base; 5 | adb_bus_t *adb_bus; 6 | }; 7 | typedef struct cuda_t cuda_t; 8 | 9 | enum { 10 | CHARDEV_KBD = 0, 11 | CHARDEV_MOUSE, 12 | CHARDEV_SERIAL, 13 | CHARDEV_DISPLAY, 14 | CHARDEV_LAST, 15 | }; 16 | 17 | cuda_t *cuda_init (const char *path, phys_addr_t base); 18 | -------------------------------------------------------------------------------- /drivers/escc.h: -------------------------------------------------------------------------------- 1 | 2 | #define IO_ESCC_SIZE 0x00001000 3 | #define IO_ESCC_OFFSET 0x00013000 4 | #define IO_ESCC_LEGACY_SIZE 0x00001000 5 | #define IO_ESCC_LEGACY_OFFSET 0x00012000 6 | 7 | #define ZS_REGS 8 8 | 9 | void escc_init(const char *path, phys_addr_t addr); 10 | void ob_zs_init(phys_addr_t base, uint64_t offset, int intr, int slave, 11 | int keyboard); 12 | -------------------------------------------------------------------------------- /drivers/esp.fs: -------------------------------------------------------------------------------- 1 | \ ------------------------------------------------------------------------- 2 | \ SCSI encode/decode unit 3 | \ ------------------------------------------------------------------------- 4 | 5 | : decode-unit-scsi ( str len -- id lun ) 6 | 2 parse-nhex 7 | ; 8 | 9 | : encode-unit-scsi ( id lun -- str len) 10 | swap 11 | pocket tohexstr 12 | " ," pocket tmpstrcat >r 13 | rot pocket tohexstr r> tmpstrcat drop 14 | ; 15 | -------------------------------------------------------------------------------- /drivers/floppy.h: -------------------------------------------------------------------------------- 1 | #ifndef FLOPPY_SUBR_H 2 | #define FLOPPY_SUBR_H 3 | 4 | int floppy_init(void); 5 | int floppy_read(char *dest, unsigned long offset, unsigned long length); 6 | void floppy_fini(void); 7 | 8 | 9 | #endif /* FLOPPY_SUBR_H */ 10 | -------------------------------------------------------------------------------- /drivers/macio.h: -------------------------------------------------------------------------------- 1 | extern phandle_t pic_handle; 2 | 3 | void ob_macio_heathrow_init(const char *path, phys_addr_t addr); 4 | void ob_macio_keylargo_init(const char *path, phys_addr_t addr); 5 | -------------------------------------------------------------------------------- /drivers/pci.fs: -------------------------------------------------------------------------------- 1 | [IFDEF] CONFIG_DRIVER_PCI 2 | 3 | : pci-addr-encode ( addr.lo addr.mi addr.hi ) 4 | rot >r swap >r 5 | encode-int 6 | r> encode-int encode+ 7 | r> encode-int encode+ 8 | ; 9 | 10 | : pci-len-encode ( len.lo len.hi ) 11 | encode-int 12 | rot encode-int encode+ 13 | ; 14 | 15 | \ Get PCI physical address and size for configured BAR reg 16 | : pci-bar>pci-addr ( bar-reg -- addr.lo addr.mid addr.hi size -1 | 0 ) 17 | " assigned-addresses" active-package get-package-property 0= if 18 | begin 19 | decode-phys \ ( reg prop prop-len phys.lo phys.mid phys.hi ) 20 | dup ff and 6 pick = if 21 | >r >r >r rot drop 22 | decode-int drop decode-int 23 | -rot 2drop 24 | r> swap r> r> rot 25 | -1 exit 26 | else 27 | 3drop 28 | then 29 | \ Drop the size as we don't need it 30 | decode-int drop decode-int drop 31 | dup 0= 32 | until 33 | 3drop 34 | 0 exit 35 | else 36 | 0 37 | then 38 | ; 39 | 40 | [THEN] 41 | -------------------------------------------------------------------------------- /drivers/pmu.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMU_H__ 2 | #define __PMU_H__ 3 | 4 | #include "adb_bus.h" 5 | 6 | typedef struct pmu_t { 7 | phys_addr_t base; 8 | adb_bus_t *adb_bus; 9 | } pmu_t; 10 | 11 | pmu_t *pmu_init (const char *path, phys_addr_t base); 12 | 13 | int pmu_request(pmu_t *dev, uint8_t cmd, 14 | uint8_t in_len, uint8_t *in_data, 15 | uint8_t *out_len, uint8_t *out_data); 16 | 17 | #endif /* __PMU_H__ */ 18 | -------------------------------------------------------------------------------- /forth/Kconfig: -------------------------------------------------------------------------------- 1 | # 2 | # 3 | # 4 | 5 | #menu "Packages" 6 | # 7 | #source "forth/packages/Kconfig" 8 | # 9 | #endmenu 10 | -------------------------------------------------------------------------------- /forth/admin/README: -------------------------------------------------------------------------------- 1 | \ This directory contains code that implements 2 | \ the Administration command group 3 | \ (Chapter 7.4 in the IEEE 1275-1994) 4 | -------------------------------------------------------------------------------- /forth/admin/banner.fs: -------------------------------------------------------------------------------- 1 | \ 7.4.10 Banner 2 | 3 | defer builtin-logo 4 | defer builtin-banner 5 | 0 value suppress-banner? 6 | 7 | :noname 8 | 0 0 9 | ; to builtin-logo 10 | 11 | :noname 12 | builddate s" built on " version s" Welcome to OpenBIOS v" pocket 13 | tmpstrcat tmpstrcat tmpstrcat drop 14 | ; to builtin-banner 15 | 16 | : suppress-banner ( -- ) 17 | 1 to suppress-banner? 18 | ; 19 | 20 | : banner ( -- ) 21 | suppress-banner 22 | stdout @ ?dup 0= if exit then 23 | 24 | \ draw logo if stdout is a "display" node 25 | dup ihandle>phandle " device_type" rot get-package-property if 0 0 then 26 | " display" strcmp if 27 | drop 28 | else 29 | \ draw logo ( ihandle ) 30 | dup ihandle>phandle " draw-logo" rot find-method if 31 | ( ihandle xt ) 32 | swap >r >r 33 | 0 \ line # 34 | oem-logo? if oem-logo else builtin-logo then 35 | ( 0 addr logo-len ) 36 | 200 = if 37 | d# 64 d# 64 38 | r> r> call-package 39 | else 40 | r> r> 2drop 2drop 41 | then 42 | else 43 | drop 44 | then 45 | then 46 | 47 | oem-banner? if oem-banner else builtin-banner then 48 | type cr 49 | ; 50 | -------------------------------------------------------------------------------- /forth/admin/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /forth/admin/callback.fs: -------------------------------------------------------------------------------- 1 | \ 7.4.9 Client program callback 2 | 3 | : callback ( "service-name< >" "arguments" -- ) 4 | ; 5 | 6 | : $callback ( argn ... arg1 nargs addr len -- retn ... ret2 Nreturns-1 ) 7 | ; 8 | 9 | : sync ( -- ) 10 | ; 11 | -------------------------------------------------------------------------------- /forth/admin/help.fs: -------------------------------------------------------------------------------- 1 | \ tag: firmware help 2 | \ 3 | \ this code implements IEEE 1275-1994 ch. 7.4.1 4 | \ 5 | \ Copyright (C) 2003 Stefan Reinauer 6 | \ 7 | \ See the file "COPYING" for further information about 8 | \ the copyright and warranty status of this work. 9 | \ 10 | 11 | hex 12 | 13 | : (help-generic) 14 | ." Enter 'help command-name' or 'help category-name' for more help" cr 15 | ." (Use ONLY the first word of a category description)" cr 16 | ." Examples: help select -or- help line" cr cr 17 | ." Categories:" cr 18 | ." boot (Load and execute a client program)" cr 19 | ." diag (Diagnostic routines)" cr 20 | ; 21 | 22 | : (help-diag) 23 | ." test Run the selftest method for specified device" cr 24 | ." test-all Execute test for all devices using selftest method" cr 25 | ; 26 | 27 | : (help-boot) 28 | ." boot [:] [boot-arguments]" cr 29 | ." Examples:" cr 30 | ." boot Default boot (values specified in nvram variables)" cr 31 | ." boot disk1:a Boot from disk1 partition a" cr 32 | ." boot hd:1,\boot\vmlinuz root=/dev/hda1" cr 33 | ; 34 | 35 | : help ( "{name}" -- ) 36 | \ Provide information for category or specific command. 37 | linefeed parse cr 38 | dup 0= if 39 | (help-generic) 40 | 2drop 41 | else 42 | 2dup " diag" rot min comp not if 43 | (help-diag) 2drop exit 44 | then 45 | 2dup " boot" rot min comp not if 46 | (help-boot) 2drop exit 47 | then 48 | ." No help available for " type cr 49 | then 50 | ; 51 | 52 | -------------------------------------------------------------------------------- /forth/admin/power.fs: -------------------------------------------------------------------------------- 1 | \ Power 2 | 3 | defer power-off ( -- ) 4 | 5 | : no-power-off 6 | s" power-off is not available on this platform." type cr 7 | ; 8 | 9 | ' no-power-off to power-off 10 | -------------------------------------------------------------------------------- /forth/admin/reset.fs: -------------------------------------------------------------------------------- 1 | \ 7.4.7 Reset 2 | 3 | defer reset-all ( -- ) 4 | 5 | : no-reset-all 6 | s" reset-all is not available on this platform." type cr 7 | ; 8 | 9 | ' no-reset-all to reset-all 10 | 11 | \ OpenBOOT knows reset as well. 12 | : reset reset-all ; 13 | -------------------------------------------------------------------------------- /forth/admin/script.fs: -------------------------------------------------------------------------------- 1 | \ 7.4.4.2 The script 2 | 3 | : nvedit ( -- ) 4 | ; 5 | 6 | : nvstore ( -- ) 7 | ; 8 | 9 | : nvquit ( -- ) 10 | ; 11 | 12 | : nvrecover ( -- ) 13 | ; 14 | 15 | : nvrun ( -- ) 16 | ; 17 | -------------------------------------------------------------------------------- /forth/admin/security.fs: -------------------------------------------------------------------------------- 1 | \ 7.4.6 Security 2 | 3 | : password ( -- ) 4 | ; 5 | 6 | : security-password ( -- password-str password-len ) 7 | ; 8 | 9 | : security-#badlogins ( -- n ) 10 | ; 11 | -------------------------------------------------------------------------------- /forth/admin/selftest.fs: -------------------------------------------------------------------------------- 1 | \ tag: self-test 2 | \ 3 | \ this code implements IEEE 1275-1994 ch. 7.4.8 4 | \ 5 | \ Copyright (C) 2003 Stefan Reinauer 6 | \ 7 | \ See the file "COPYING" for further information about 8 | \ the copyright and warranty status of this work. 9 | \ 10 | 11 | \ 12 | \ 7.4.8 Self-test 13 | \ 14 | 15 | : $test ( devname-addr devname-len -- ) 16 | 2dup ." Testing device " type ." : " 17 | find-dev if 18 | s" self-test" rot find-method if 19 | execute 20 | else 21 | ." no self-test method." 22 | then 23 | else 24 | ." no such device." 25 | then 26 | cr 27 | ; 28 | 29 | : test ( "device-specifier"-- ) 30 | linefeed parse cr $test 31 | ; 32 | 33 | : test-sub-devs 34 | >dn.child @ 35 | begin dup while 36 | dup get-package-path $test 37 | dup recurse 38 | >dn.peer @ 39 | repeat 40 | drop 41 | ; 42 | 43 | : test-all ( "{device-specifier}" -- ) 44 | active-package 45 | cr " /" find-device 46 | linefeed parse find-device 47 | ?active-package test-sub-devs 48 | active-package! 49 | ; 50 | -------------------------------------------------------------------------------- /forth/admin/userboot.fs: -------------------------------------------------------------------------------- 1 | \ 7.4.3.5 User commands for booting 2 | 3 | : boot ( "{param-text}" -- ) 4 | linefeed parse 5 | 6 | \ Copy NVRAM parameters from boot-file to bootargs in case any parameters have 7 | \ been specified for the platform-specific boot code 8 | s" boot-file" $find drop execute 9 | encode-string 10 | " /chosen" (find-dev) if 11 | " bootargs" rot (property) 12 | then 13 | 14 | \ Execute platform-specific boot code, e.g. kernel 15 | s" platform-boot" $find if 16 | execute 17 | then 18 | 19 | (find-bootdevice) \ Setup bootargs 20 | $load \ load and go 21 | go 22 | ; 23 | 24 | 25 | \ : diagnostic-mode? ( -- diag? ) 26 | \ ; 27 | 28 | \ : diag-switch? ( -- diag? ) 29 | \ ; 30 | -------------------------------------------------------------------------------- /forth/bootstrap/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /forth/bootstrap/builtin.fs: -------------------------------------------------------------------------------- 1 | \ tag: initialize builtin functionality 2 | \ 3 | \ Copyright (C) 2003 Stefan Reinauer 4 | \ 5 | \ See the file "COPYING" for further information about 6 | \ the copyright and warranty status of this work. 7 | \ 8 | 9 | 10 | 11 | : init-builtin-terminal ( -- ) 12 | 13 | \ define key, key? and emit 14 | ['] (key) ['] key (to) 15 | ['] (key?) ['] key? (to) 16 | ['] (emit) ['] emit (to) 17 | 18 | \ 2 bytes band guard on each side 19 | 100 #ib ! 20 | #ib @ dup ( -- ibs ibs ) 21 | cell+ alloc-mem ( -- ibs addr ) 22 | dup -rot ( -- addr ibs addr ) 23 | 24 | /w + ['] ib (to) \ assign input buffer 25 | 0 fill \ erase tib 26 | 0 ['] source-id (to) \ builtin terminal has id 0 27 | 28 | ; 29 | -------------------------------------------------------------------------------- /forth/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /forth/debugging/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /forth/debugging/fcode.fs: -------------------------------------------------------------------------------- 1 | \ 7.7 FCode Debugging command group 2 | 3 | \ The user interface versions of these FCode functions allow 4 | \ the user to debug FCode programs by providing named commands 5 | \ corresponding to FCode functions. 6 | 7 | : headerless ( -- ) 8 | ; 9 | 10 | : headers ( -- ) 11 | ; 12 | 13 | : apply ( ... "method-name< >device-specifier< >" -- ??? ) 14 | ; 15 | -------------------------------------------------------------------------------- /forth/device/README.device: -------------------------------------------------------------------------------- 1 | The code you find here implements the IEEE 1275-1994 Open Firmware 2 | device interface. 3 | 4 | Chapter File Comment 5 | structures.fs generic structures used by 5.3 6 | 5.3.2 defined in user interface 7 | 5.3.3 fcode.fs complete, partly untested 8 | 5.3.4 package.fs incomplete 9 | 5.3.5 property.fs incomplete 10 | 5.3.6 display.fs incomplete 11 | 5.3.7 other.fs incomplete 12 | 13 | H2 and 14 | 5.3.1.1.1 preof.fs pre-IEEE-1275-1994 words 15 | split.fs 16 | pathres.fs path resolution 17 | 18 | table.fs fcode evaluator 19 | feval.fs (byte-load) 20 | 21 | -------------------------------------------------------------------------------- /forth/device/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /forth/device/builtin.fs: -------------------------------------------------------------------------------- 1 | \ tag: builtin devices 2 | \ 3 | \ this code implements IEEE 1275-1994 4 | \ 5 | \ Copyright (C) 2003 Stefan Reinauer 6 | \ 7 | \ See the file "COPYING" for further information about 8 | \ the copyright and warranty status of this work. 9 | \ 10 | 11 | \ nodes it's children: 12 | 13 | " /" find-device 14 | 15 | new-device 16 | " builtin" device-name 17 | : open true ; 18 | : close ; 19 | 20 | new-device 21 | " console" device-name 22 | : open true ; 23 | : close ; 24 | : write dup >r bounds ?do i c@ (emit) loop r> ; 25 | : read dup >r bounds ?do (key) i c! loop r> ; 26 | finish-device 27 | 28 | \ clean up afterwards 29 | finish-device 30 | 0 active-package! 31 | -------------------------------------------------------------------------------- /forth/device/font.fs: -------------------------------------------------------------------------------- 1 | \ tag: 8x16 bitmap font 2 | \ 3 | \ Terminus font 4 | \ 5 | \ The Terminus Font is developed by and is a property 6 | \ of Dimitar Toshkov Zhekov 7 | \ 8 | \ See the file "COPYING" for further information about 9 | \ the copyright and warranty status of this work. 10 | \ 11 | 12 | 0 value (romfont) 13 | 0 value (romfont-width) 14 | 0 value (romfont-height) 15 | 16 | \ encode-file romfont.bin 17 | \ drop value (romfont-8x16) 18 | -------------------------------------------------------------------------------- /forth/device/missing: -------------------------------------------------------------------------------- 1 | 5.3.3.1 2 | 3 | * (is-user-word) 4 | 5 | 5.3.4 Package access 6 | 7 | 5.3.6 Display 8 | * default-font 9 | * set-font 10 | * >font 11 | * is-install 12 | * is-remove 13 | * is-selftest 14 | 15 | 5.3.7 Other 16 | * cpeek 17 | * wpeek 18 | * lpeek 19 | * cpoke 20 | * wpoke 21 | * lpoke 22 | * rb@ 23 | * rw@ 24 | * rl@ 25 | * rb! 26 | * rw! 27 | * rl! 28 | * get-msecs 29 | * ms 30 | * alarm 31 | * user-abort 32 | * mac-address 33 | * display-status 34 | * memory-test-suite 35 | * mask 36 | * diagnostic-mode? 37 | * suspend-fcode 38 | * set-args 39 | -------------------------------------------------------------------------------- /forth/device/romfont.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qemu/openbios/af97fd7af5e7c18f591a7b987291d3db4ffb28b5/forth/device/romfont.bin -------------------------------------------------------------------------------- /forth/device/tree.fs: -------------------------------------------------------------------------------- 1 | \ tag: Device Tree 2 | \ 3 | \ this code implements IEEE 1275-1994 ch. 3.5 4 | \ 5 | \ Copyright (C) 2003 Stefan Reinauer 6 | \ 7 | \ See the file "COPYING" for further information about 8 | \ the copyright and warranty status of this work. 9 | \ 10 | 11 | 12 | \ root node 13 | new-device 14 | " OpenBiosTeam,OpenBIOS" device-name 15 | 1 encode-int " #address-cells" property 16 | : open true ; 17 | : close ; 18 | : decode-unit parse-hex ; 19 | : encode-unit ( addr -- str len ) 20 | pocket tohexstr 21 | ; 22 | 23 | new-device 24 | " aliases" device-name 25 | : open true ; 26 | : close ; 27 | finish-device 28 | 29 | new-device 30 | " openprom" device-name 31 | " BootROM" device-type 32 | " OpenFirmware 3" model 33 | 0 0 " relative-addressing" property 34 | 0 0 " supports-bootinfo" property 35 | 1 encode-int " boot-syntax" property 36 | 37 | : selftest 38 | ." OpenBIOS selftest... succeeded" cr 39 | true 40 | ; 41 | : open true ; 42 | : close ; 43 | 44 | finish-device 45 | 46 | new-device 47 | " options" device-name 48 | finish-device 49 | 50 | new-device 51 | " chosen" device-name 52 | 0 encode-int " stdin" property 53 | 0 encode-int " stdout" property 54 | \ " hda1:/boot/vmunix" encode-string " bootpath" property 55 | \ " -as" encode-string " bootargs" property 56 | finish-device 57 | 58 | \ END 59 | finish-device 60 | -------------------------------------------------------------------------------- /forth/lib/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /forth/lib/creation.fs: -------------------------------------------------------------------------------- 1 | \ tag: misc useful functions 2 | \ 3 | \ C bindings 4 | \ 5 | \ Copyright (C) 2003, 2004 Samuel Rydh 6 | \ 7 | \ See the file "COPYING" for further information about 8 | \ the copyright and warranty status of this work. 9 | \ 10 | 11 | \ return xt of the word just defined 12 | : last-xt ( -- xt ) 13 | latest @ na1+ 14 | ; 15 | 16 | \ ------------------------------------------------------------------------- 17 | \ word creation 18 | \ ------------------------------------------------------------------------- 19 | 20 | : $is-ibuf ( size name name-len -- xt ) 21 | instance $buffer: drop 22 | last-xt 23 | ; 24 | 25 | : is-ibuf ( size -- xt ) 26 | 0 0 $is-ibuf 27 | ; 28 | 29 | : is-ivariable ( size name len -- xt ) 30 | 4 -rot instance $buffer: drop 31 | last-xt 32 | ; 33 | 34 | : is-xt-func ( xt|0 wordstr len ) 35 | header 1 , 36 | ?dup if , then 37 | ['] (semis) , reveal 38 | ; 39 | 40 | : is-2xt-func ( xt1 xt2 wordstr len ) 41 | header 1 , 42 | swap , , 43 | ['] (semis) , reveal 44 | ; 45 | 46 | : is-func-begin ( wordstr len ) 47 | header 1 , 48 | ; 49 | 50 | : is-func-end ( wordstr len ) 51 | ['] (semis) , reveal 52 | ; 53 | -------------------------------------------------------------------------------- /forth/lib/lists.fs: -------------------------------------------------------------------------------- 1 | \ tag: misc useful functions 2 | \ 3 | \ Misc useful functions 4 | \ 5 | \ Copyright (C) 2003 Samuel Rydh 6 | \ 7 | \ See the file "COPYING" for further information about 8 | \ the copyright and warranty status of this work. 9 | \ 10 | 11 | \ ------------------------------------------------------------------------- 12 | \ statically allocated lists 13 | \ ------------------------------------------------------------------------- 14 | \ list-head should be a variable 15 | 16 | : list-add ( listhead -- ) 17 | here 0 , swap \ next, [data...] 18 | ( here listhead ) 19 | begin dup @ while @ repeat ! 20 | ; 21 | 22 | : list-get ( listptr -- nextlistptr dictptr true | false ) 23 | @ dup if 24 | dup na1+ true 25 | then 26 | ; 27 | -------------------------------------------------------------------------------- /forth/lib/preinclude.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ config and build date includes 3 | \ 4 | \ Copyright (C) 2005 Stefan Reinauer 5 | \ 6 | \ See the file "COPYING" for further information about 7 | \ the copyright and warranty status of this work. 8 | \ 9 | 10 | include config.fs 11 | include version.fs 12 | -------------------------------------------------------------------------------- /forth/lib/rstack.fs: -------------------------------------------------------------------------------- 1 | \ tag: pseudo r-stack implementation for openbios 2 | \ 3 | \ Copyright (C) 2016 Mark Cave-Ayland 4 | \ 5 | \ See the file "COPYING" for further information about 6 | \ the copyright and warranty status of this work. 7 | \ 8 | 9 | \ 10 | \ Pseudo r-stack implementation for interpret mode 11 | \ 12 | 13 | create prstack h# 20 cells allot 14 | variable #prstack 0 #prstack ! 15 | 16 | : prstack-push prstack #prstack @ cells + ! 1 #prstack +! ; 17 | : prstack-pop -1 #prstack +! prstack #prstack @ cells + @ ; 18 | 19 | : >r state @ if ['] >r , exit then r> swap prstack-push >r ; immediate 20 | : r> state @ if ['] r> , exit then r> prstack-pop swap >r ; immediate 21 | : r@ state @ if ['] r@ , exit then r> prstack-pop dup prstack-push swap >r ; immediate 22 | -------------------------------------------------------------------------------- /forth/lib/split.fs: -------------------------------------------------------------------------------- 1 | \ implements split-before, split-after and left-split 2 | \ as described in 4.3 (Path resolution) 3 | 4 | \ delimeter returned in R-string 5 | : split-before ( addr len delim -- addr-R len-R addr-L len-L ) 6 | 0 rot dup >r 0 ?do 7 | ( str char cnt R: len ) 8 | 2 pick over + c@ 2 pick = if leave then 9 | 1+ 10 | loop 11 | nip 12 | 2dup + r> 2 pick - 13 | 2swap 14 | ; 15 | 16 | \ delimeter returned in L-string 17 | : split-after ( addr len delim -- addr-R len-R addr-L len-L ) 18 | over 1- rot dup >r 0 ?do 19 | ( str char cnt R: len ) 20 | 2 pick over + c@ 2 pick = if leave then 21 | 1- 22 | loop 23 | nip 24 | dup 0 >= if 1+ else drop r@ then 25 | 2dup + r> 2 pick - 26 | 2swap 27 | ; 28 | 29 | \ delimiter not returned 30 | : left-split ( addr len delim -- addr-R len-R addr-L len-L ) 31 | 0 rot dup >r 0 ?do 32 | ( str char cnt R: len ) 33 | 2 pick i + c@ 2 pick = if leave then 34 | 1+ 35 | loop 36 | nip 37 | 2dup + 1+ r> 2 pick - 38 | dup if 1- then 39 | 2swap 40 | ; 41 | 42 | \ delimiter not returned [THIS FUNCTION IS NOT NEEDED] 43 | : right-split ( addr len delim -- addr-R len-R addr-L len-L ) 44 | dup >r 45 | split-after 46 | dup if 2dup + 1- 47 | c@ r@ = if 1- then then 48 | r> drop 49 | ; 50 | -------------------------------------------------------------------------------- /forth/packages/Kconfig: -------------------------------------------------------------------------------- 1 | 2 | config PKG_DEBLOCKER 3 | bool "Deblocker" 4 | default y 5 | 6 | config PKG_DISKLABEL 7 | bool "Disk Label" 8 | default y 9 | 10 | config PKG_OBP_TFTP 11 | bool "OBP-TFTP" 12 | default y 13 | 14 | config PKG_TERMINAL_EMULATOR 15 | bool "Terminal Emulator" 16 | default y 17 | -------------------------------------------------------------------------------- /forth/packages/README: -------------------------------------------------------------------------------- 1 | IEEE 1275-1994 support packages 2 | ------------------------------- 3 | 4 | These files create the sub nodes of the /packages node. The nodes 5 | do normally not need an open or close method since their methods are 6 | called statically. 7 | 8 | Currently there are the following support packages: 9 | * deblocker 10 | * obp-tftp 11 | * 12 | -------------------------------------------------------------------------------- /forth/packages/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /forth/packages/disklabel.fs: -------------------------------------------------------------------------------- 1 | \ tag: disklabel support package 2 | \ 3 | \ Copyright (C) 2003 Stefan Reinauer 4 | \ 5 | \ See the file "COPYING" for further information about 6 | \ the copyright and warranty status of this work. 7 | \ 8 | 9 | " /packages" find-device 10 | 11 | \ 12 | \ IEEE 1275 disklabel package 13 | \ 14 | 15 | new-device 16 | " disklabel" device-name 17 | \ now the methods... 18 | 19 | finish-device 20 | 21 | \ clean up afterwards 22 | device-end 23 | -------------------------------------------------------------------------------- /forth/packages/obp-tftp.fs: -------------------------------------------------------------------------------- 1 | \ tag: tftp support package 2 | \ 3 | \ Copyright (C) 2003 Stefan Reinauer 4 | \ 5 | \ See the file "COPYING" for further information about 6 | \ the copyright and warranty status of this work. 7 | \ 8 | 9 | " /packages" find-device 10 | 11 | \ 12 | \ IEEE 1275 obp-tftp package 13 | \ 14 | 15 | new-device 16 | " obp-tftp" device-name 17 | \ now the methods... 18 | 19 | finish-device 20 | 21 | \ clean up afterwards 22 | device-end 23 | -------------------------------------------------------------------------------- /forth/packages/packages.fs: -------------------------------------------------------------------------------- 1 | \ tag: /packages sub device tree 2 | \ 3 | \ Copyright (C) 2003 Stefan Reinauer 4 | \ 5 | \ See the file "COPYING" for further information about 6 | \ the copyright and warranty status of this work. 7 | \ 8 | 9 | " /" find-device 10 | 11 | new-device 12 | " packages" device-name 13 | : open true ; 14 | : close ; 15 | finish-device 16 | 17 | device-end 18 | -------------------------------------------------------------------------------- /forth/packages/terminal-emulator.fs: -------------------------------------------------------------------------------- 1 | \ tag: terminal emulator support package 2 | \ 3 | \ Copyright (C) 2003 Stefan Reinauer 4 | \ 5 | \ See the file "COPYING" for further information about 6 | \ the copyright and warranty status of this work. 7 | \ 8 | 9 | " /packages" find-device 10 | 11 | \ 12 | \ IEEE 1275 terminal-emulator package 13 | \ 14 | 15 | new-device 16 | " terminal-emulator" device-name 17 | \ now the methods... 18 | 19 | finish-device 20 | 21 | \ clean up afterwards 22 | 23 | device-end 24 | -------------------------------------------------------------------------------- /forth/system/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /forth/system/main.fs: -------------------------------------------------------------------------------- 1 | \ tag: misc useful functions 2 | \ 3 | \ Open Firmware Startup 4 | \ 5 | \ Copyright (C) 2003 Samuel Rydh 6 | \ 7 | \ See the file "COPYING" for further information about 8 | \ the copyright and warranty status of this work. 9 | \ 10 | 11 | variable PREPOST-list 12 | variable POST-list 13 | variable SYSTEM-list 14 | variable DIAG-list 15 | 16 | : PREPOST-initializer ( xt -- ) 17 | PREPOST-list list-add , 18 | ; 19 | 20 | : POST-initializer ( xt -- ) 21 | POST-list list-add , 22 | ; 23 | 24 | : SYSTEM-initializer ( xt -- ) 25 | SYSTEM-list list-add , 26 | ; 27 | 28 | : DIAG-initializer ( xt -- ) 29 | DIAG-list list-add , 30 | ; 31 | 32 | 33 | \ OpenFirmware entrypoint 34 | : initialize-of ( startmem endmem -- ) 35 | initialize-forth 36 | 37 | PREPOST-list begin list-get while @ execute repeat 38 | POST-list begin list-get while @ execute repeat 39 | SYSTEM-list begin list-get while @ execute repeat 40 | 41 | \ evaluate nvramrc script 42 | use-nvramrc? if 43 | nvramrc evaluate 44 | then 45 | 46 | \ probe-all etc. 47 | suppress-banner? 0= if 48 | probe-all 49 | install-console 50 | banner 51 | then 52 | 53 | DIAG-list begin list-get while @ execute repeat 54 | 55 | auto-boot? if 56 | boot-command evaluate 57 | then 58 | 59 | outer-interpreter 60 | ; 61 | -------------------------------------------------------------------------------- /forth/testsuite/README: -------------------------------------------------------------------------------- 1 | TESTSUITES 2 | ---------- 3 | 4 | This directory contains additional testsuites for some open 5 | firmware components. They are not built per default. 6 | 7 | 8 | tag: testsuites readme 9 | -------------------------------------------------------------------------------- /forth/testsuite/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /forth/testsuite/fract.fs: -------------------------------------------------------------------------------- 1 | \ tag: forth fractal example 2 | \ 3 | \ Copyright (C) 2002, 2003 Volker Poplawski 4 | \ Stefan Reinauer 5 | 6 | \ This example even fits in a signature ;-) 7 | 8 | \ hex 4666 dup negate do i 4000 dup 2* negate do 2a 0 dup 2dup 1e 0 do 9 | \ 2swap * d >>a 4 pick + -rot - j + dup dup * e >>a rot dup dup * e >>a 10 | \ rot swap 2dup + 10000 > if 3drop 2drop 20 0 dup 2dup leave then loop 11 | \ 2drop 2drop type 268 +loop cr drop 5de +loop 12 | 13 | 14 | : fract 15 | 4666 dup negate 16 | do 17 | i 4000 dup 2* negate 18 | do 19 | 2a 0 dup 2dup 1e 0 20 | do 21 | 2swap * d >>a 4 pick + 22 | -rot - j + 23 | dup dup * e >>a rot 24 | dup dup * e >>a rot 25 | swap 26 | 2dup + 10000 > if 27 | 3drop 2drop 20 0 dup 2dup leave 28 | then 29 | loop 30 | 2drop 2drop 31 | emit 32 | 268 +loop 33 | cr drop 34 | 5de +loop 35 | ; 36 | -------------------------------------------------------------------------------- /forth/testsuite/framebuffer-test.fs: -------------------------------------------------------------------------------- 1 | 2 | : test-screen 3 | 10 10 pci-l@ 4 | f0 0 do 5 | dup d# 1280 i * + 6 | 500 i fill 7 | loop 8 | ; 9 | 10 | test-screen 11 | -------------------------------------------------------------------------------- /forth/testsuite/splitfunc-testsuite.fs: -------------------------------------------------------------------------------- 1 | \ this is the splitfunc testsuite. 2 | \ 3 | \ run it with paflof < splitfunc-testsuite.fs 2>/dev/null 4 | 5 | \ implements split-before, split-after and left-split 6 | \ as described in 4.3 (Path resolution) 7 | 8 | s" splitfunc.fs" included 9 | 10 | : test-split 11 | s" var/log/messages" 2dup 12 | 13 | cr ." split-before test:" cr 14 | 2dup ." String: " type cr 15 | 2f split-before 16 | 2swap 17 | ." initial: " type cr ." remainder:" type cr 18 | cr 19 | ." split-after test:" cr 20 | 2f split-after cr 21 | 2swap 22 | ." initial: " type cr ." remainder:" type cr 23 | 24 | ." foobar test" cr 25 | 26 | s" foobar" 2dup 27 | 28 | 2f split-after cr 29 | 2swap 30 | ." initial: " type cr ." remainder:" type cr 31 | 32 | 2f split-after cr 33 | 2swap 34 | ." initial: " type cr ." remainder:" type cr 35 | ; 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /forth/util/apic.fs: -------------------------------------------------------------------------------- 1 | \ 2 | \ ioapic and local apic tester 3 | \ 4 | \ Copyright (C) 2003 Stefan Reinauer 5 | \ 6 | \ See the file "COPYING" for further information about 7 | \ the copyright and warranty status of this work. 8 | \ 9 | 10 | hex 11 | 12 | fee00000 constant lapic_base 13 | fec00000 constant ioapic_base 14 | 15 | : read_lapic ( regoffset -- value ) 16 | lapic_base + l@ 17 | ; 18 | 19 | : write_lapic ( value regoffset -- ) 20 | lapic_base + l! 21 | ; 22 | 23 | : read_ioapic ( regoffset -- low_value high_value ) 24 | 2* 10 + dup 25 | ioapic_base l! ioapic_base 4 cells + l@ 26 | swap 1+ 27 | ioapic_base l! ioapic_base 4 cells + l@ 28 | ; 29 | 30 | : write_ioapic ( low high regoffset -- ) 31 | 2* 10 + dup ( low high offs offs ) 32 | ioapic_base l! rot ioapic_base 4 cells + l! ( high offs ) 33 | 1+ 34 | ioapic_base l! ioapic_base 4 cells + l! ( high offs ) 35 | ; 36 | 37 | : test-lapic 38 | s" Dumping local apic:" type cr 39 | 3f0 0 do 40 | i dup ( lapic_base + ) s" 0x" type . s" = 0x" type read_lapic space . 41 | i 30 and 0= if cr then 42 | 10 +loop 43 | cr 44 | ; 45 | 46 | : test-ioapic 47 | s" Dumping io apic:" type cr 48 | 17 0 do 49 | i dup s" irq=" type . read_ioapic s" = 0x" type . s" ." type . 50 | i 1 and 0<> if 51 | cr 52 | then 53 | loop 54 | cr 55 | ; 56 | 57 | : dump-apics 58 | test-lapic 59 | test-ioapic 60 | ; 61 | 62 | \ tag: apic test utility 63 | -------------------------------------------------------------------------------- /forth/util/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /fs/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /fs/ext2/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /fs/ext2/ext2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2008-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #ifndef __EXT2_H__ 10 | #define __EXT2_H__ 11 | 12 | #include "ext2_fs.h" 13 | 14 | typedef struct ext2_VOLUME { 15 | int fd; 16 | struct ext2_super_block *super; 17 | unsigned int current; 18 | char *buffer; 19 | } ext2_VOLUME; 20 | 21 | typedef struct ext2_DIR { 22 | ext2_VOLUME *volume; 23 | struct ext2_inode *inode; 24 | off_t index; 25 | } ext2_DIR; 26 | 27 | typedef struct ext2_FILE { 28 | ext2_VOLUME *volume; 29 | struct ext2_inode *inode; 30 | off_t offset; 31 | char *path; 32 | } ext2_FILE; 33 | #endif /* __LIBEXT2_H__ */ 34 | -------------------------------------------------------------------------------- /fs/ext2/ext2_close.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2008-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libext2.h" 10 | 11 | void ext2_close(ext2_FILE *file) 12 | { 13 | if (file == NULL) 14 | return; 15 | free(file->inode); 16 | free(file->path); 17 | free(file); 18 | } 19 | -------------------------------------------------------------------------------- /fs/ext2/ext2_closedir.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2008-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libext2.h" 10 | #include "ext2.h" 11 | 12 | void ext2_closedir(ext2_DIR *dir) 13 | { 14 | if (dir == NULL) 15 | return; 16 | free(dir->inode); 17 | free(dir); 18 | } 19 | -------------------------------------------------------------------------------- /fs/ext2/ext2_lseek.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2008-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libext2.h" 10 | #include "ext2.h" 11 | 12 | int ext2_lseek(ext2_FILE *file, long offset, int whence) 13 | { 14 | long new_offset; 15 | 16 | switch(whence) 17 | { 18 | case SEEK_SET: 19 | new_offset = offset; 20 | break; 21 | case SEEK_CUR: 22 | new_offset = file->offset + offset; 23 | break; 24 | case SEEK_END: 25 | new_offset = file->inode->i_size + offset; 26 | break; 27 | default: 28 | return -1; 29 | } 30 | 31 | if ( (new_offset < 0) || 32 | (new_offset > file->inode->i_size) ) 33 | return -1; 34 | 35 | file->offset = new_offset; 36 | 37 | return new_offset; 38 | } 39 | -------------------------------------------------------------------------------- /fs/ext2/ext2_mount.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2008-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libext2.h" 10 | #include "ext2.h" 11 | #include "ext2_utils.h" 12 | 13 | #define SB_OFFSET (2) 14 | 15 | ext2_VOLUME* ext2_mount(int fd) 16 | { 17 | ext2_VOLUME *volume; 18 | struct ext2_super_block *super; 19 | char *buffer; 20 | 21 | super = (struct ext2_super_block*)malloc(sizeof(struct ext2_super_block)); 22 | if (super == NULL) 23 | return NULL; 24 | 25 | ext2_get_super(fd, super); 26 | if (super->s_magic != EXT2_SUPER_MAGIC) { 27 | free(super); 28 | return NULL; 29 | } 30 | 31 | buffer = (char*)malloc(EXT2_BLOCK_SIZE(super)); 32 | if (buffer == NULL) { 33 | free(super); 34 | return NULL; 35 | } 36 | 37 | volume = (ext2_VOLUME*)malloc(sizeof(ext2_VOLUME)); 38 | if (volume == NULL) { 39 | free(super); 40 | free(buffer); 41 | return NULL; 42 | } 43 | 44 | volume->buffer = buffer; 45 | volume->fd = fd; 46 | volume->super = super; 47 | 48 | volume->current = -1; 49 | ext2_read_block(volume, 0); 50 | 51 | return volume; 52 | } 53 | 54 | int ext2_umount(ext2_VOLUME* volume) 55 | { 56 | if (volume == NULL) 57 | return -1; 58 | free(volume->super); 59 | free(volume->buffer); 60 | free(volume); 61 | return 0; 62 | } 63 | -------------------------------------------------------------------------------- /fs/ext2/ext2_open.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2008-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libext2.h" 10 | #include "ext2.h" 11 | #include "ext2_utils.h" 12 | 13 | ext2_FILE* ext2_open(ext2_VOLUME *volume, const char* pathname) 14 | { 15 | ext2_FILE *file; 16 | struct ext2_inode *inode; 17 | int ino; 18 | int ret; 19 | 20 | ino = ext2_seek_name(volume, pathname); 21 | if (ino == 0) 22 | return NULL; 23 | 24 | inode = (struct ext2_inode*)malloc(sizeof(struct ext2_inode)); 25 | if (inode == NULL) 26 | return NULL; 27 | 28 | ret = ext2_get_inode(volume, ino, inode); 29 | if (ret == -1) { 30 | free(inode); 31 | return NULL; 32 | } 33 | if (S_ISLNK(inode->i_mode)) { 34 | static char buffer[1024]; 35 | int i, last = 0; 36 | strcpy(buffer, pathname); 37 | for (i = 0; buffer[i]; i++) 38 | if (buffer[i] == '\\') 39 | last = i; 40 | buffer[last] = '\\'; 41 | strcpy(buffer + last + 1, (char*)inode->i_block); 42 | ino = ext2_seek_name((ext2_VOLUME*)volume, buffer); 43 | if (ino == 0) { 44 | free(inode); 45 | return NULL; 46 | } 47 | ret = ext2_get_inode((ext2_VOLUME*)volume, ino, inode); 48 | if (ret == -1) { 49 | free(inode); 50 | return NULL; 51 | } 52 | } 53 | 54 | file = (ext2_FILE*)malloc(sizeof(ext2_FILE)); 55 | if (file == NULL) { 56 | free(inode); 57 | return NULL; 58 | } 59 | file->volume = volume; 60 | file->inode = inode; 61 | file->offset = 0; 62 | file->path = strdup(pathname); 63 | 64 | return file; 65 | } 66 | -------------------------------------------------------------------------------- /fs/ext2/ext2_opendir.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2008-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libext2.h" 10 | #include "ext2.h" 11 | #include "ext2_utils.h" 12 | 13 | ext2_DIR* ext2_opendir(ext2_VOLUME *volume, const char *name) 14 | { 15 | ext2_DIR* dir; 16 | int ino; 17 | struct ext2_inode *inode; 18 | int ret; 19 | 20 | ino = ext2_seek_name(volume, name); 21 | if (ino == 0) 22 | return NULL; 23 | 24 | inode = (struct ext2_inode*)malloc(sizeof(struct ext2_inode)); 25 | if (inode == NULL) 26 | return NULL; 27 | 28 | ret = ext2_get_inode(volume, ino, inode); 29 | if (ret == -1) { 30 | free(inode); 31 | return NULL; 32 | } 33 | 34 | if (!S_ISDIR(inode->i_mode)) { 35 | free(inode); 36 | return NULL; 37 | } 38 | 39 | dir = (ext2_DIR*)malloc(sizeof(ext2_DIR)); 40 | if (dir == NULL) { 41 | free(inode); 42 | return NULL; 43 | } 44 | dir->volume = (ext2_VOLUME*)volume; 45 | dir->inode = inode; 46 | dir->index = 0; 47 | 48 | return dir; 49 | } 50 | -------------------------------------------------------------------------------- /fs/ext2/ext2_read.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2008-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libext2.h" 10 | #include "ext2.h" 11 | #include "ext2_utils.h" 12 | 13 | size_t ext2_read(ext2_FILE *file, void *buf, size_t count) 14 | { 15 | int ret; 16 | 17 | ret = ext2_read_data(file->volume, file->inode, file->offset, 18 | buf, count); 19 | if (ret == -1) 20 | return -1; 21 | file->offset += ret; 22 | return ret; 23 | } 24 | -------------------------------------------------------------------------------- /fs/ext2/ext2_readdir.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2008-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libext2.h" 10 | #include "ext2_utils.h" 11 | 12 | static struct ext2_dir_entry_2 entry; 13 | 14 | struct ext2_dir_entry_2 *ext2_readdir(ext2_DIR *dir) 15 | { 16 | int ret; 17 | 18 | ret = ext2_dir_entry(dir->volume, dir->inode, dir->index, &entry); 19 | if (ret == -1) 20 | return NULL; 21 | dir->index = ret; 22 | 23 | entry.name[entry.name_len] = 0; 24 | return &entry; 25 | } 26 | -------------------------------------------------------------------------------- /fs/ext2/libext2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2008-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #ifndef __LIBEXT2_H__ 10 | #define __LIBEXT2_H__ 11 | 12 | #include "config.h" 13 | #include "ext2.h" 14 | 15 | extern ext2_VOLUME* ext2_mount(int fd); 16 | extern int ext2_umount(ext2_VOLUME *volume); 17 | extern ext2_DIR* ext2_opendir(ext2_VOLUME *, const char *name); 18 | extern struct ext2_dir_entry_2* ext2_readdir(ext2_DIR* dir); 19 | extern void ext2_closedir(ext2_DIR *dir); 20 | extern ext2_FILE* ext2_open(ext2_VOLUME *, const char* pathname); 21 | extern size_t ext2_read(ext2_FILE *file, void *buf, size_t count); 22 | extern void ext2_close(ext2_FILE *file); 23 | extern int ext2_lseek(ext2_FILE *file, long offset, int whence); 24 | 25 | #endif /* __LIBEXT2_H__ */ 26 | -------------------------------------------------------------------------------- /fs/grubfs/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /fs/grubfs/debug.h: -------------------------------------------------------------------------------- 1 | /* for grub compatibility */ 2 | -------------------------------------------------------------------------------- /fs/grubfs/glue.h: -------------------------------------------------------------------------------- 1 | #ifndef __GLUE_H 2 | #define __GLUE_H 3 | 4 | #include "asm/types.h" 5 | #include "config.h" 6 | #include "libc/byteorder.h" 7 | 8 | typedef uint64_t sector_t; 9 | 10 | int devopen(void); 11 | 12 | int devread(unsigned long sector, unsigned long byte_offset, 13 | unsigned long byte_len, void *buf); 14 | 15 | int file_open(const char *filename); 16 | int file_read(void *buf, unsigned long len); 17 | int file_seek(unsigned long offset); 18 | unsigned long file_size(void); 19 | void file_close(void); 20 | 21 | int mount_fs(void); 22 | 23 | extern int using_devsize; 24 | 25 | /* 26 | * some of the filesystem drivers don't correctly provide their 27 | * prototypes. we fix this here so we can leave them untouched. 28 | */ 29 | 30 | int ffs_mount (void); 31 | int ffs_read (char *buf, int len); 32 | int ffs_dir (char *dirname); 33 | int ffs_embed (int *start_sector, int needed_sectors); 34 | 35 | int vstafs_mount (void); 36 | int vstafs_dir (char *dirname); 37 | int vstafs_read (char *addr, int len); 38 | 39 | int ntfs_mount (void); 40 | int ntfs_dir (char *dirname); 41 | int ntfs_read (char *addr, int len); 42 | 43 | int affs_mount (void); 44 | int affs_dir (char *dirname); 45 | int affs_read (char *addr, int len); 46 | 47 | 48 | #endif /* FS_H */ 49 | -------------------------------------------------------------------------------- /fs/grubfs/shared.h: -------------------------------------------------------------------------------- 1 | /* Sorry, nothing is shared here ;) Just for GRUB compatibility. */ 2 | 3 | #include "glue.h" 4 | -------------------------------------------------------------------------------- /fs/hfs/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /fs/hfs/include/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., 51 Franklin Street - Fifth Floor, Boston, 18 | * MA 02110-1301, USA. 19 | * 20 | * $Id: btree.h,v 1.8 1998/11/02 22:08:55 rob Exp $ 21 | */ 22 | 23 | int bt_getnode(node *, btree *, unsigned long); 24 | int bt_putnode(node *); 25 | 26 | int bt_readhdr(btree *); 27 | int bt_writehdr(btree *); 28 | 29 | int bt_space(btree *, unsigned int); 30 | 31 | int bt_insert(btree *, const byte *, unsigned int); 32 | int bt_delete(btree *, const byte *); 33 | 34 | int bt_search(btree *, const byte *, node *); 35 | -------------------------------------------------------------------------------- /fs/hfs/include/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., 51 Franklin Street - Fifth Floor, Boston, 18 | * MA 02110-1301, USA. 19 | * 20 | * $Id: node.h,v 1.7 1998/11/02 22:09:06 rob Exp $ 21 | */ 22 | 23 | void n_init(node *, btree *, int, int); 24 | 25 | int n_new(node *); 26 | int n_free(node *); 27 | 28 | int n_search(node *, const byte *); 29 | 30 | void n_index(const node *, byte *, unsigned int *); 31 | 32 | void n_insertx(node *, const byte *, unsigned int); 33 | int n_insert(node *, byte *, unsigned int *); 34 | 35 | int n_delete(node *, byte *, int *); 36 | -------------------------------------------------------------------------------- /fs/hfsplus/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /fs/hfsplus/include/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., 51 Franklin Street - Fifth Floor, Boston, 23 | * MA 02110-1301, USA. 24 | * 25 | * $Id: hfs.h,v 1.1.1.1 2000/07/25 10:33:40 kkaempf Exp $ 26 | */ 27 | 28 | 29 | #define HFS_BLOCKSZ 512 30 | /* A sector for Apple is always 512 bytes */ 31 | #define HFS_BLOCKSZ_BITS 9 /* 1<<9 == 512 */ 32 | #define HFS_VOLHEAD_SIG 0x4244 /* 'BD' */ 33 | -------------------------------------------------------------------------------- /fs/hfsplus/include/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. And 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 | -------------------------------------------------------------------------------- /fs/hfsplus/libhfsp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * libhfsp - library for reading and writing Macintosh HFS volumes 3 | * Copyright (C) 1996-1998 Robert Leslie 4 | * 5 | * Thi file contains utitlity fucntions to manage the features of 6 | * the hfs+ library. 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., 51 Franklin Street - Fifth Floor, Boston, 21 | * MA 02110-1301, USA. 22 | * 23 | * $Id: libhfsp.c,v 1.1.1.1 2000/07/25 10:33:40 kkaempf Exp $ 24 | */ 25 | 26 | #include "config.h" 27 | #include "libhfsp.h" 28 | 29 | const char *hfsp_error = "no error"; /* static error string */ 30 | -------------------------------------------------------------------------------- /fs/iso9660/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /fs/iso9660/iso9660.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2005-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #ifndef __ISO9660_H__ 10 | #define __ISO9660_H__ 11 | 12 | #include "iso9660_fs.h" 13 | 14 | typedef struct iso9660_VOLUME { 15 | int ucs_level; 16 | struct iso_primary_descriptor *descriptor; 17 | int fd; 18 | } iso9660_VOLUME; 19 | 20 | typedef struct iso9660_DIR { 21 | iso9660_VOLUME *volume; 22 | int extent; 23 | int len; 24 | int index; 25 | unsigned char buffer[ISOFS_BLOCK_SIZE]; 26 | } iso9660_DIR; 27 | 28 | typedef struct iso9660_FILE { 29 | iso9660_VOLUME *volume; 30 | char *path; 31 | int base; /* first extent of the file */ 32 | int size; /* size of the file */ 33 | int offset; 34 | int current; 35 | unsigned char buffer[ISOFS_BLOCK_SIZE]; 36 | } iso9660_FILE; 37 | 38 | static inline int isonum_721(char *p) 39 | { 40 | return ((p[0] & 0xff) 41 | | ((p[1] & 0xff) << 8)); 42 | } 43 | 44 | static inline int isonum_723(char *p) 45 | { 46 | return (isonum_721(p)); 47 | } 48 | 49 | static inline int isonum_733(char *p) 50 | { 51 | return ((p[0] & 0xff) | ((p[1] & 0xff) << 8) | 52 | ((p[2] & 0xff) << 16) | ((p[3] & 0xff) << 24)); 53 | } 54 | 55 | extern struct iso_directory_record *iso9660_get_root_node(iso9660_VOLUME* volume); 56 | extern struct iso_directory_record* iso9660_get_node(iso9660_VOLUME *volume, struct iso_directory_record *dirnode, const char *path); 57 | 58 | #endif /* __ISO9660_H__ */ 59 | -------------------------------------------------------------------------------- /fs/iso9660/iso9660_close.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2005-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE bootloader, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libiso9660.h" 10 | 11 | void iso9660_close(iso9660_FILE *file) 12 | { 13 | free(file->path); 14 | free(file); 15 | } 16 | -------------------------------------------------------------------------------- /fs/iso9660/iso9660_closedir.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2005-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libiso9660.h" 10 | 11 | int iso9660_closedir(iso9660_DIR *dir) 12 | { 13 | if (dir == NULL) 14 | return -1; 15 | 16 | free(dir); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /fs/iso9660/iso9660_lseek.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2005-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libiso9660.h" 10 | 11 | int iso9660_lseek(iso9660_FILE *_file, long offset, int whence) 12 | { 13 | iso9660_FILE *file = (iso9660_FILE*)_file; 14 | long new_offset; 15 | 16 | switch(whence) 17 | { 18 | case SEEK_SET: 19 | new_offset = offset; 20 | break; 21 | case SEEK_CUR: 22 | new_offset = file->offset + offset; 23 | break; 24 | case SEEK_END: 25 | new_offset = file->size + offset; 26 | break; 27 | default: 28 | return -1; 29 | } 30 | 31 | if ( (new_offset < 0) || (new_offset > file->size) ) 32 | return -1; 33 | 34 | file->offset = new_offset; 35 | 36 | return new_offset; 37 | } 38 | -------------------------------------------------------------------------------- /fs/iso9660/iso9660_open.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2005-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libiso9660.h" 10 | 11 | iso9660_FILE* iso9660_open(iso9660_VOLUME *volume, const char* pathname) 12 | { 13 | struct iso_directory_record *root; 14 | struct iso_directory_record *idr; 15 | iso9660_FILE *file; 16 | 17 | root = iso9660_get_root_node(volume); 18 | if (root == NULL) 19 | return NULL; 20 | 21 | idr = iso9660_get_node(volume, root, pathname); 22 | if (idr == NULL) 23 | return NULL; 24 | 25 | file = (iso9660_FILE*)malloc(sizeof(iso9660_FILE)); 26 | if (file == NULL) 27 | return NULL; 28 | 29 | file->base = isonum_733((char *)idr->extent); 30 | file->size = isonum_733((char *)idr->size); 31 | file->offset = 0; 32 | file->current = -1; 33 | file->volume = volume; 34 | file->path = strdup(pathname); 35 | 36 | free(idr); 37 | 38 | return file; 39 | } 40 | -------------------------------------------------------------------------------- /fs/iso9660/iso9660_readdir.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2005-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #include "libiso9660.h" 10 | #include "libopenbios/bindings.h" 11 | #include "libc/diskio.h" 12 | 13 | #define offsetof(t,m) ((long)&(((t *)0)->m)) 14 | 15 | static void read_extent(iso9660_DIR *dir) 16 | { 17 | seek_io(dir->volume->fd, dir->extent * ISOFS_BLOCK_SIZE); 18 | read_io(dir->volume->fd, dir->buffer, ISOFS_BLOCK_SIZE); 19 | 20 | dir->len -= ISOFS_BLOCK_SIZE; 21 | dir->extent ++; 22 | dir->index = 0; 23 | } 24 | 25 | struct iso_directory_record *iso9660_readdir(iso9660_DIR *dir) 26 | { 27 | struct iso_directory_record *idr; 28 | 29 | if (dir->index > 30 | ISOFS_BLOCK_SIZE - offsetof(struct iso_directory_record, name[0])) 31 | { 32 | if (dir->len <= 0) 33 | return NULL; 34 | 35 | read_extent(dir); 36 | } 37 | 38 | idr = (struct iso_directory_record *) &dir->buffer[dir->index]; 39 | if (idr->length[0] == 0) { 40 | if (dir->len <= 0) 41 | return NULL; 42 | 43 | read_extent(dir); 44 | idr = (struct iso_directory_record *) &dir->buffer[dir->index]; 45 | } 46 | 47 | dir->index += dir->buffer[dir->index]; 48 | 49 | return idr; 50 | } 51 | -------------------------------------------------------------------------------- /fs/iso9660/libiso9660.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * (c) 2005-2009 Laurent Vivier 4 | * 5 | * This file has been copied from EMILE, http://emile.sf.net 6 | * 7 | */ 8 | 9 | #ifndef __LIBISO9660_H__ 10 | #define __LIBISO9660_H__ 11 | 12 | #include "config.h" 13 | #include "iso9660.h" 14 | 15 | extern iso9660_VOLUME* iso9660_mount(int fd); 16 | extern int iso9660_umount(iso9660_VOLUME *volume); 17 | extern int iso9660_probe(int fd, long long offs); 18 | extern iso9660_DIR* iso9660_opendir(iso9660_VOLUME *, const char *name); 19 | extern iso9660_FILE* iso9660_open(iso9660_VOLUME *, const char *pathname); 20 | extern int iso9660_closedir(iso9660_DIR *dir); 21 | extern struct iso_directory_record *iso9660_readdir(iso9660_DIR *dir); 22 | extern size_t iso9660_read(iso9660_FILE *file, char *buf, size_t count); 23 | extern void iso9660_close(iso9660_FILE *file); 24 | extern int iso9660_lseek(iso9660_FILE *file, long offset, int whence); 25 | extern void iso9660_name(iso9660_VOLUME *volume, struct iso_directory_record * idr, char *buffer); 26 | 27 | #endif /* __LIBISO9660_H__ */ 28 | -------------------------------------------------------------------------------- /include/arch/amd64/elf.h: -------------------------------------------------------------------------------- 1 | /* for now we're a 32bit architecture */ 2 | #define ARCH_ELF_CLASS ELFCLASS32 3 | #define ARCH_ELF_DATA ELFDATA2LSB 4 | #define ARCH_ELF_MACHINE_OK(x) ((x)==EM_386 || (x)==EM_486) 5 | typedef Elf32_Ehdr Elf_ehdr; 6 | typedef Elf32_Phdr Elf_phdr; 7 | -------------------------------------------------------------------------------- /include/arch/common/nvram.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/12/20 01:04:25 samuel> 3 | * Time-stamp: <2004/01/07 19:59:11 samuel> 4 | * 5 | * 6 | * 7 | * arch NVRAM interface 8 | * 9 | * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_NVRAM 18 | #define _H_NVRAM 19 | 20 | extern int arch_nvram_size( void ); 21 | extern void arch_nvram_get( char *buf ); 22 | extern void arch_nvram_put( char *buf ); 23 | 24 | #endif /* _H_NVRAM */ 25 | -------------------------------------------------------------------------------- /include/arch/ia64/elf.h: -------------------------------------------------------------------------------- 1 | #define ARCH_ELF_CLASS ELFCLASS64 2 | #define ARCH_ELF_DATA ELFDATA2LSB 3 | #define ARCH_ELF_MACHINE_OK(x) ((x)==EM_IA64) 4 | typedef Elf64_Ehdr Elf_ehdr; 5 | typedef Elf64_Phdr Elf_phdr; 6 | -------------------------------------------------------------------------------- /include/arch/ia64/types.h: -------------------------------------------------------------------------------- 1 | /* tag: data types for forth engine 2 | * 3 | * This file is autogenerated by types.sh. Do not edit! 4 | * 5 | * Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer 6 | * 7 | * See the file "COPYING" for further information about 8 | * the copyright and warranty status of this work. 9 | */ 10 | 11 | #ifndef __TYPES_H 12 | #define __TYPES_H 13 | 14 | #include 15 | 16 | /* endianness */ 17 | 18 | #include 19 | 20 | /* physical address */ 21 | 22 | typedef uint64_t phys_addr_t; 23 | 24 | #define FMT_plx "%016" PRIx64 25 | 26 | /* cell based types */ 27 | 28 | typedef int64_t cell; 29 | typedef uint64_t ucell; 30 | typedef __int128_t dcell; 31 | typedef __uint128_t ducell; 32 | 33 | typedef int64_t prom_arg_t; 34 | typedef uint64_t prom_uarg_t; 35 | 36 | #define PRIdPROMARG PRId64 37 | #define PRIuPROMARG PRIu64 38 | #define PRIxPROMARG PRIx64 39 | #define FMT_prom_arg "%" PRIdPROMARG 40 | #define FMT_prom_uarg "%" PRIuPROMARG 41 | #define FMT_prom_uargx "%016" PRIxPROMARG 42 | 43 | #define bitspercell (sizeof(cell)<<3) 44 | #define bitsperdcell (sizeof(dcell)<<3) 45 | 46 | #define BITS 64 47 | 48 | /* size named types */ 49 | 50 | typedef unsigned char u8; 51 | typedef unsigned short u16; 52 | typedef unsigned int u32; 53 | typedef unsigned long u64; 54 | 55 | typedef char s8; 56 | typedef short s16; 57 | typedef int s32; 58 | typedef long s64; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/arch/ppc/elf.h: -------------------------------------------------------------------------------- 1 | #define ARCH_ELF_CLASS ELFCLASS32 2 | #define ARCH_ELF_DATA ELFDATA2MSB 3 | #define ARCH_ELF_MACHINE_OK(x) ((x)==EM_PPC) 4 | typedef Elf32_Ehdr Elf_ehdr; 5 | typedef Elf32_Phdr Elf_phdr; 6 | -------------------------------------------------------------------------------- /include/arch/sparc32/crs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Parts of asm-sparc/contregs.h 3 | * 4 | * contregs.h: Addresses of registers in the ASI_CONTROL alternate address 5 | * space. These are for the mmu's context register, etc. 6 | * 7 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 8 | */ 9 | /* s=Swift, h=Ross_HyperSPARC, v=TI_Viking, t=Tsunami, r=Ross_Cypress */ 10 | #define AC_M_PCR 0x0000 /* shv Processor Control Reg */ 11 | #define AC_M_CTPR 0x0100 /* shv Context Table Pointer Reg */ 12 | #define AC_M_CXR 0x0200 /* shv Context Register */ 13 | #define AC_M_SFSR 0x0300 /* shv Synchronous Fault Status Reg */ 14 | #define AC_M_SFAR 0x0400 /* shv Synchronous Fault Address Reg */ 15 | -------------------------------------------------------------------------------- /include/arch/sparc32/elf.h: -------------------------------------------------------------------------------- 1 | #define ARCH_ELF_CLASS ELFCLASS32 2 | #define ARCH_ELF_DATA ELFDATA2MSB 3 | #define ARCH_ELF_MACHINE_OK(x) ((x)==EM_SPARC || (x)==EM_SPARC32PLUS) 4 | typedef Elf32_Ehdr Elf_ehdr; 5 | typedef Elf32_Phdr Elf_phdr; 6 | -------------------------------------------------------------------------------- /include/arch/sparc32/ofmem_sparc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | * OF Memory manager 5 | * 6 | * Copyright (C) 1999, 2002 Samuel Rydh (samuel@ibrium.se) 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation 11 | * 12 | */ 13 | 14 | #ifndef _H_OFMEM_SPARC32 15 | #define _H_OFMEM_SPARC32 16 | 17 | #include "libopenbios/ofmem.h" 18 | 19 | #define OF_CODE_START 0xffd00000 20 | #define OFMEM_VIRT_TOP 0xffff0000 21 | 22 | struct mem; 23 | extern struct mem cdvmem; 24 | 25 | extern unsigned long *l1; 26 | extern unsigned long find_pte(unsigned long va, int alloc); 27 | 28 | void mem_init(struct mem *t, char *begin, char *limit); 29 | void *mem_alloc(struct mem *t, int size, int align); 30 | 31 | #endif /* _H_OFMEM_SPARC32 */ -------------------------------------------------------------------------------- /include/arch/sparc64/elf.h: -------------------------------------------------------------------------------- 1 | #define ARCH_ELF_CLASS ELFCLASS64 2 | #define ARCH_ELF_DATA ELFDATA2MSB 3 | #define ARCH_ELF_MACHINE_OK(x) ((x)==EM_SPARCV9) 4 | typedef Elf64_Ehdr Elf_ehdr; 5 | typedef Elf64_Phdr Elf_phdr; 6 | -------------------------------------------------------------------------------- /include/arch/unix/plugin_pci.h: -------------------------------------------------------------------------------- 1 | /* tag: openbios pci plugin headers 2 | * 3 | * Copyright (C) 2003 Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #ifndef __PLUGINS_PCI_H 10 | #define __PLUGINS_PCI_H 11 | 12 | typedef struct pci_dev pci_dev_t; 13 | 14 | struct pci_dev { 15 | unsigned bus; 16 | unsigned dev; 17 | unsigned fn; 18 | 19 | u8 *config; 20 | pci_dev_t *next; 21 | }; 22 | 23 | int pci_register_device(unsigned bus, unsigned dev, unsigned fn, u8 *config); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/arch/unix/plugins.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PLUGINS_H 3 | #define __PLUGINS_H 4 | 5 | #include "asm/types.h" 6 | 7 | struct io_ops { 8 | u8 (*inb)(u32 reg); 9 | u16 (*inw)(u32 reg); 10 | u32 (*inl)(u32 reg); 11 | void (*outb)(u32 reg, u8 val); 12 | void (*outw)(u32 reg, u16 val); 13 | void (*outl)(u32 reg, u32 val); 14 | }; 15 | typedef struct io_ops io_ops_t; 16 | 17 | extern unsigned char *plugindir; 18 | 19 | #define PLUGIN_DEPENDENCIES(x...) const char *plugin_deps[]={ x, NULL }; 20 | #define PLUGIN_AUTHOR(author) const char *plugin_author=author; 21 | #define PLUGIN_LICENSE(license) const char *plugin_license=license; 22 | #define PLUGIN_DESCRIPTION(desc) const char *plugin_description=desc; 23 | 24 | int register_iorange(const char *name, io_ops_t *ops, 25 | unsigned int rstart, unsigned int rend); 26 | io_ops_t *find_iorange(u32 reg); 27 | 28 | int load_plugin(const char *plugin_name); 29 | int is_loaded(const char *plugin_name); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /include/arch/x86/elf.h: -------------------------------------------------------------------------------- 1 | #define ARCH_ELF_CLASS ELFCLASS32 2 | #define ARCH_ELF_DATA ELFDATA2LSB 3 | #define ARCH_ELF_MACHINE_OK(x) ((x)==EM_386 || (x)==EM_486) 4 | typedef Elf32_Ehdr Elf_ehdr; 5 | typedef Elf32_Phdr Elf_phdr; 6 | -------------------------------------------------------------------------------- /include/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/12/20 00:07:16 samuel> 3 | * Time-stamp: <2004/01/19 17:40:26 stepan> 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_CONFIG 18 | #define _H_CONFIG 19 | 20 | #include "autoconf.h" 21 | #include "mconfig.h" 22 | #include "asm/types.h" 23 | 24 | #define PROGRAM_NAME "OpenBIOS" 25 | 26 | #ifndef BOOTSTRAP 27 | 28 | #ifndef NULL 29 | #define NULL ((void*)0) 30 | #endif 31 | 32 | typedef unsigned int size_t; 33 | typedef unsigned int usize_t; 34 | typedef signed int ssize_t; 35 | typedef signed int off_t; 36 | 37 | typedef unsigned int time_t; 38 | 39 | #define UINT_MAX ((unsigned int)-1) 40 | 41 | #define ENOMEM 1 42 | #define EIO 2 43 | #define EINVAL 3 44 | #define ENOENT 4 45 | #define ENOTDIR 5 46 | #define EISDIR 6 47 | #define ENAMETOOLONG 7 48 | 49 | #define SEEK_CUR 1 50 | #define SEEK_SET 2 51 | #define SEEK_END 3 52 | 53 | #endif /* BOOTSTRAP */ 54 | 55 | #include "sysinclude.h" 56 | 57 | #ifndef MIN 58 | #define MIN(x,y) (((x) < (y)) ? (x) : (y)) 59 | #define MAX(x,y) (((x) > (y)) ? (x) : (y)) 60 | #endif 61 | 62 | /* errno is a macro on some systems, which might cause nasty problems. 63 | * We try to cope with this here. 64 | */ 65 | #undef errno 66 | #define errno errno_int 67 | 68 | #endif /* _H_CONFIG */ 69 | -------------------------------------------------------------------------------- /include/drivers/usb.h: -------------------------------------------------------------------------------- 1 | #ifndef USB_H 2 | #define USB_H 3 | 4 | int ob_usb_ohci_init(const char *path, uint32_t addr); 5 | void ob_usb_hid_add_keyboard(const char *path); 6 | int usb_exit(void); 7 | 8 | #endif /* USB_H */ 9 | -------------------------------------------------------------------------------- /include/drivers/vga.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_VGA_H 2 | #define VIDEO_VGA_H 3 | 4 | /* drivers/vga_load_regs.c */ 5 | void vga_load_regs(void); 6 | 7 | /* drivers/vga_set_mode.c */ 8 | void vga_set_gmode (void); 9 | void vga_set_amode (void); 10 | void vga_font_load(unsigned char *vidmem, const unsigned char *font, int height, int num_chars); 11 | 12 | /* drivers/vga_vbe.c */ 13 | void vga_set_color(int i, unsigned int r, unsigned int g, unsigned int b); 14 | void vga_vbe_set_mode(int width, int height, int depth); 15 | void vga_vbe_init(const char *path, unsigned long fb, uint32_t fb_size, 16 | unsigned long rom, uint32_t rom_size); 17 | 18 | extern volatile uint32_t *dac; 19 | 20 | #endif /* VIDEO_VGA_H */ 21 | -------------------------------------------------------------------------------- /include/kernel/kernel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/12/19 00:20:11 samuel> 3 | * Time-stamp: <2004/01/07 19:19:14 samuel> 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) 10 | * Stefan Reinauer 11 | * 12 | * This program is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU General Public License 14 | * version 2 15 | * 16 | */ 17 | 18 | #ifndef _H_KERNEL 19 | #define _H_KERNEL 20 | 21 | #include "kernel/stack.h" 22 | #include "asm/io.h" 23 | 24 | /* Interrupt status */ 25 | #define FORTH_INTSTAT_CLR 0x0 26 | #define FORTH_INTSTAT_STOP 0x1 27 | #define FORTH_INTSTAT_DBG 0x2 28 | 29 | extern volatile int interruptforth; 30 | extern int enterforth( xt_t xt ); 31 | extern void panic(const char *error) __attribute__ ((noreturn)); 32 | 33 | extern xt_t findword(const char *s1); 34 | extern void modules_init( void ); 35 | extern void init_trampoline(ucell *t); 36 | extern void forth_init(void); 37 | 38 | /* arch kernel hooks */ 39 | extern void exception(cell no); 40 | 41 | #ifdef FCOMPILER 42 | extern void include_file( const char *str ); 43 | extern void encode_file( const char *str ); 44 | extern int get_inputbyte( void ); 45 | extern void put_outputbyte( int c ); 46 | #endif 47 | 48 | #ifndef BOOTSTRAP 49 | #undef putchar 50 | #undef getchar 51 | 52 | extern int putchar( int ch ); 53 | extern int getchar( void ); 54 | #endif 55 | 56 | extern int availchar( void ); 57 | 58 | #endif /* _H_KERNEL */ 59 | -------------------------------------------------------------------------------- /include/libc/diskio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/12/20 00:57:01 samuel> 3 | * Time-stamp: <2004/01/07 19:32:29 samuel> 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_DISKIO 18 | #define _H_DISKIO 19 | 20 | extern int open_ih( ihandle_t ih ); 21 | extern int open_io( const char *spec ); 22 | extern int close_io( int fd ); 23 | extern int read_io( int fd, void *buf, size_t cnt ); 24 | extern int seek_io( int fd, long long offs ); 25 | extern long long tell( int fd ); 26 | extern int reopen( int fd, const char *filename ); 27 | extern int reopen_nwrom( int fd ); 28 | extern ihandle_t get_ih_from_fd( int fd ); 29 | const char *get_file_path( int fd ); 30 | const char *get_fstype( int fd ); 31 | const char *get_volume_name( int fd ); 32 | 33 | #endif /* _H_DISKIO */ 34 | -------------------------------------------------------------------------------- /include/libc/stdlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/12/19 18:52:20 samuel> 3 | * Time-stamp: <2003/12/19 18:52:21 samuel> 4 | * 5 | * 6 | * 7 | * 8 | * Copyright (C) 2003 Samuel Rydh (samuel@ibrium.se) 9 | * 10 | * This program is free software; you can redistribute it and/or 11 | * modify it under the terms of the GNU General Public License 12 | * version 2 13 | * 14 | */ 15 | 16 | #ifndef _H_STDLIB 17 | #define _H_STDLIB 18 | 19 | extern void *malloc( int size ); 20 | extern void free( void *ptr ); 21 | extern void *realloc( void *ptr, size_t size ); 22 | 23 | /* should perhaps go somewhere else... */ 24 | extern void qsort( void *base, size_t nmemb, size_t size, int (*compar)(const void*, const void*)); 25 | 26 | #endif /* _H_STDLIB */ 27 | -------------------------------------------------------------------------------- /include/libc/vsprintf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/12/20 01:51:22 samuel> 3 | * Time-stamp: <2004/01/07 19:02:17 samuel> 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_VSPRINTF 18 | #define _H_VSPRINTF 19 | 20 | #include 21 | #include "config.h" 22 | 23 | int vsprintf(char *buf, const char *fmt, va_list args) 24 | __attribute__((__format__(__printf__, 2, 0))); 25 | int sprintf(char * buf, const char *fmt, ...) 26 | __attribute__((__format__(__printf__, 2, 3))); 27 | int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) 28 | __attribute__((__format__(__printf__, 3, 0))); 29 | int snprintf(char * buf, size_t size, const char *fmt, ...) 30 | __attribute__((__format__(__printf__, 3, 4))); 31 | 32 | int forth_printf(const char *fmt, ...) 33 | __attribute__((__format__(__printf__, 1, 2))); 34 | 35 | #endif /* _H_VSPRINTF */ 36 | -------------------------------------------------------------------------------- /include/libopenbios/aout_load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2010/03/22 18:00:00 mcayland> 3 | * Time-stamp: <2010/03/22 18:00:00 mcayland> 4 | * 5 | * 6 | * 7 | * a.out loader 8 | * 9 | * Copyright (C) 2010 Mark Cave-Ayland (mark.cave-ayland@siriusit.co.uk) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #ifndef _H_AOUTLOAD 18 | #define _H_AOUTLOAD 19 | 20 | #include "arch/common/a.out.h" 21 | #include "libopenbios/sys_info.h" 22 | 23 | extern int is_aout(struct exec *ehdr); 24 | extern int aout_load(struct sys_info *info, ihandle_t dev); 25 | extern void aout_init_program(void); 26 | 27 | #endif /* _H_AOUTLOAD */ 28 | -------------------------------------------------------------------------------- /include/libopenbios/bootcode_load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2010/03/22 18:00:00 mcayland> 3 | * Time-stamp: <2010/03/22 18:00:00 mcayland> 4 | * 5 | * 6 | * 7 | * Raw bootcode (%BOOT) loader 8 | * 9 | * Copyright (C) 2013 Mark Cave-Ayland (mark.cave-ayland@ilande.co.uk) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #ifndef _H_BOOTCODELOAD 18 | #define _H_BOOTCODELOAD 19 | 20 | extern int bootcode_load(ihandle_t dev); 21 | int is_bootcode(char *addr); 22 | void bootcode_init_program(void); 23 | 24 | #endif /* _H__H_BOOTCODELOAD */ 25 | -------------------------------------------------------------------------------- /include/libopenbios/bootinfo_load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2010/03/22 18:00:00 mcayland> 3 | * Time-stamp: <2010/03/22 18:00:00 mcayland> 4 | * 5 | * 6 | * 7 | * CHRP boot info loader 8 | * 9 | * Copyright (C) 2010 Mark Cave-Ayland (mark.cave-ayland@siriusit.co.uk) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #ifndef _H_BOOTINFOLOAD 18 | #define _H_BOOTINFOLOAD 19 | 20 | #include "libopenbios/sys_info.h" 21 | 22 | extern int is_bootinfo(char *bootinfo); 23 | extern int bootinfo_load(struct sys_info *info, const char *filename); 24 | extern void bootinfo_init_program(void); 25 | 26 | #endif /* _H_BOOTINFOLOAD */ 27 | -------------------------------------------------------------------------------- /include/libopenbios/console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | * Shared console routines 5 | * 6 | * Copyright (C) 2013 Mark Cave-Ayland (mark.cave-ayland@ilande.co.uk) 7 | * 8 | * This program is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU General Public License 10 | * as published by the Free Software Foundation 11 | * 12 | */ 13 | 14 | #ifndef _H_CONSOLE 15 | #define _H_CONSOLE 16 | 17 | struct _console_ops { 18 | int (*putchar)(int c); 19 | int (*availchar)(void); 20 | int (*getchar)(void); 21 | }; 22 | 23 | void init_console(struct _console_ops ops); 24 | 25 | #endif /* _H_CONSOLE */ 26 | -------------------------------------------------------------------------------- /include/libopenbios/elf_load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2001/05/05 16:44:17 samuel> 3 | * Time-stamp: <2003/10/22 23:18:42 samuel> 4 | * 5 | * 6 | * 7 | * Elf loader 8 | * 9 | * Copyright (C) 2001, 2003 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #ifndef _H_ELFLOAD 18 | #define _H_ELFLOAD 19 | 20 | #include "arch/common/elf.h" 21 | #include "asm/elf.h" 22 | #include "libopenbios/sys_info.h" 23 | 24 | extern int elf_load(struct sys_info *info, ihandle_t dev, const char *cmdline, void **boot_notes); 25 | extern void elf_init_program(void); 26 | extern int is_elf(Elf_ehdr *ehdr); 27 | extern int find_elf(Elf_ehdr *ehdr); 28 | 29 | extern Elf_phdr * elf_readhdrs(int offset, Elf_ehdr *ehdr); 30 | 31 | #endif /* _H_ELFLOAD */ 32 | -------------------------------------------------------------------------------- /include/libopenbios/fcode_load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2010/03/22 18:00:00 mcayland> 3 | * Time-stamp: <2010/03/22 18:00:00 mcayland> 4 | * 5 | * 6 | * 7 | * Fcode loader 8 | * 9 | * Copyright (C) 2010 Mark Cave-Ayland (mark.cave-ayland@siriusit.co.uk) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #ifndef _H_FCODELOAD 18 | #define _H_FCODELOAD 19 | 20 | extern int is_fcode(unsigned char *fcode); 21 | extern int fcode_load(ihandle_t dev); 22 | extern void fcode_init_program(void); 23 | 24 | #endif /* _H_FCODELOAD */ 25 | -------------------------------------------------------------------------------- /include/libopenbios/fontdata.h: -------------------------------------------------------------------------------- 1 | /* Font definitions */ 2 | 3 | #ifndef OPENBIOS_FONTDATA_H 4 | #define OPENBIOS_FONTDATA_H 5 | 6 | #define FONTDATAMAX_8X8 2048 7 | #define FONT_WIDTH_8X8 8 8 | #define FONT_HEIGHT_8X8 8 9 | 10 | extern const unsigned char fontdata_8x8[FONTDATAMAX_8X8]; 11 | 12 | #define FONTDATAMAX_8X16 4096 13 | #define FONT_WIDTH_8X16 8 14 | #define FONT_HEIGHT_8X16 16 15 | 16 | extern const unsigned char fontdata_8x16[FONTDATAMAX_8X16]; 17 | 18 | #if defined(CONFIG_FONT_8X8) 19 | #define fontdata fontdata_8x8 20 | #define FONT_HEIGHT FONT_HEIGHT_8X8 21 | #define FONT_WIDTH FONT_WIDTH_8X8 22 | #elif defined(CONFIG_FONT_8X16) 23 | #define fontdata fontdata_8x16 24 | #define FONT_HEIGHT FONT_HEIGHT_8X16 25 | #define FONT_WIDTH FONT_WIDTH_8X16 26 | #endif 27 | 28 | #endif /* OPENBIOS_FONTDATA_H */ 29 | -------------------------------------------------------------------------------- /include/libopenbios/forth_load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2010/03/22 18:00:00 mcayland> 3 | * Time-stamp: <2010/03/22 18:00:00 mcayland> 4 | * 5 | * 6 | * 7 | * Forth loader 8 | * 9 | * Copyright (C) 2010 Mark Cave-Ayland (mark.cave-ayland@siriusit.co.uk) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #ifndef _H_FORTHLOAD 18 | #define _H_FORTHLOAD 19 | 20 | extern int is_forth(char *forth); 21 | extern int forth_load(ihandle_t dev); 22 | extern void forth_init_program(void); 23 | 24 | #endif /* _H_FORTHLOAD */ 25 | -------------------------------------------------------------------------------- /include/libopenbios/initprogram.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2010/04/02 13:00:00 mcayland> 3 | * Time-stamp: <2010/04/02 13:00:00 mcayland> 4 | * 5 | * 6 | * 7 | * C implementation of (init-program) word 8 | * 9 | * Copyright (C) 2010 Mark Cave-Ayland (mark.cave-ayland@siriusit.co.uk) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_INITPROGRAM 18 | #define _H_INITPROGRAM 19 | 20 | extern struct context * volatile __context; 21 | extern unsigned int start_elf(void); 22 | 23 | extern int arch_init_program(void); 24 | extern void init_program(void); 25 | 26 | void init_fcode_context(void); 27 | void init_forth_context(void); 28 | 29 | void go(void); 30 | 31 | #endif /* _H_INITPROGRAM */ 32 | -------------------------------------------------------------------------------- /include/libopenbios/ipchecksum.h: -------------------------------------------------------------------------------- 1 | #ifndef IPCHECKSUM_H 2 | #define IPCHECKSUM_H 3 | 4 | unsigned short ipchksum(const void *data, unsigned long length); 5 | unsigned short add_ipchksums(unsigned long offset, unsigned short sum, unsigned short new); 6 | 7 | #endif /* IPCHECKSUM_H */ 8 | -------------------------------------------------------------------------------- /include/libopenbios/load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2010/06/25 20:00:00 mcayland> 3 | * Time-stamp: <2010/06/25 20:00:00 mcayland> 4 | * 5 | * 6 | * 7 | * C implementation of load 8 | * 9 | * Copyright (C) 2010 Mark Cave-Ayland (mark.cave-ayland@siriusit.co.uk) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_LOAD 18 | #define _H_LOAD 19 | 20 | extern void load(ihandle_t dev); 21 | 22 | #endif /* _H_LOAD */ 23 | -------------------------------------------------------------------------------- /include/libopenbios/of.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2004/01/07 19:19:18 samuel> 3 | * Time-stamp: <2004/01/07 19:19:48 samuel> 4 | * 5 | * 6 | * 7 | * OpenFirmware related defines 8 | * 9 | * Copyright (C) 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_OF 18 | #define _H_OF 19 | 20 | extern int of_client_interface( int *params ); 21 | 22 | #endif /* _H_OF */ 23 | -------------------------------------------------------------------------------- /include/libopenbios/openbios.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2010/04/02 12:00:00 mcayland> 3 | * Time-stamp: <2010/04/02 12:00:00 mcayland> 4 | * 5 | * 6 | * 7 | * General OpenBIOS initialization 8 | * 9 | * Copyright (C) 2010 Mark Cave-Ayland (mark.cave-ayland@siriusit.co.uk) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_LIBOPENBIOS 18 | #define _H_LIBOPENBIOS 19 | 20 | extern void openbios_init( void ); 21 | 22 | #endif /* _H_LIBOPENBIOS */ 23 | -------------------------------------------------------------------------------- /include/libopenbios/prep_load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2010/03/22 18:00:00 mcayland> 3 | * Time-stamp: <2010/03/22 18:00:00 mcayland> 4 | * 5 | * 6 | * 7 | * PReP boot partition loader 8 | * 9 | * Copyright (C) 2018 Mark Cave-Ayland (mark.cave-ayland@ilande.co.uk) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #ifndef _H_PREPLOAD 18 | #define _H_PREPLOAD 19 | 20 | extern int prep_load(ihandle_t dev); 21 | int is_prep(char *addr); 22 | void prep_init_program(void); 23 | 24 | #endif /* _H_PREPLOAD */ 25 | -------------------------------------------------------------------------------- /include/libopenbios/sys_info.h: -------------------------------------------------------------------------------- 1 | #ifndef SYS_INFO_H 2 | #define SYS_INFO_H 3 | 4 | /* Information collected from firmware/bootloader */ 5 | 6 | struct sys_info { 7 | /* Values passed by bootloader */ 8 | unsigned long boot_type; 9 | unsigned long boot_data; 10 | unsigned long boot_arg; 11 | 12 | const char *firmware; /* "PCBIOS", "LinuxBIOS", etc. */ 13 | const char *command_line; /* command line given to us */ 14 | 15 | /* memory map */ 16 | int n_memranges; 17 | struct memrange { 18 | unsigned long long base; 19 | unsigned long long size; 20 | } *memrange; 21 | unsigned long *dict_start; 22 | unsigned long *dict_end; 23 | cell dict_limit; 24 | ucell *dict_last; 25 | }; 26 | 27 | extern void *elf_boot_notes; 28 | extern struct sys_info sys_info; 29 | 30 | void collect_elfboot_info(struct sys_info *info); 31 | void collect_linuxbios_info(struct sys_info *info); 32 | 33 | /* Our name and version. I want to see single instance of these in the image */ 34 | extern const char *program_name, *program_version; 35 | 36 | #define LOADER_NOT_SUPPORT 0xbadf11e 37 | 38 | #endif /* SYS_INFO_H */ 39 | -------------------------------------------------------------------------------- /include/libopenbios/video.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef CONFIG_VGA_WIDTH 3 | #define VGA_DEFAULT_WIDTH CONFIG_VGA_WIDTH 4 | #else 5 | #define VGA_DEFAULT_WIDTH 800 6 | #endif 7 | 8 | #ifdef CONFIG_VGA_HEIGHT 9 | #define VGA_DEFAULT_HEIGHT CONFIG_VGA_HEIGHT 10 | #else 11 | #define VGA_DEFAULT_HEIGHT 600 12 | #endif 13 | 14 | #ifdef CONFIG_VGA_DEPTH 15 | #define VGA_DEFAULT_DEPTH CONFIG_VGA_DEPTH 16 | #else 17 | #define VGA_DEFAULT_DEPTH 8 18 | #endif 19 | 20 | #define VGA_DEFAULT_LINEBYTES (VGA_DEFAULT_WIDTH*((VGA_DEFAULT_DEPTH+7)/8)) 21 | 22 | void setup_video(void); 23 | unsigned long video_get_color(int col_ind); 24 | void video_mask_blit(void); 25 | void video_invert_rect(void); 26 | void video_fill_rect(void); 27 | 28 | extern struct video_info { 29 | volatile ihandle_t *ih; 30 | volatile ucell *mvirt; 31 | volatile ucell *rb, *w, *h, *depth; 32 | 33 | volatile ucell *pal; /* 256 elements */ 34 | } video; 35 | 36 | #define VIDEO_DICT_VALUE(x) (*(ucell *)(x)) 37 | -------------------------------------------------------------------------------- /include/libopenbios/xcoff_load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2010/03/22 18:00:00 mcayland> 3 | * Time-stamp: <2010/03/22 18:00:00 mcayland> 4 | * 5 | * 6 | * 7 | * XCOFF loader 8 | * 9 | * Copyright (C) 2010 Mark Cave-Ayland (mark.cave-ayland@siriusit.co.uk) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * as published by the Free Software Foundation 14 | * 15 | */ 16 | 17 | #ifndef _H_XCOFFLOAD 18 | #define _H_XCOFFLOAD 19 | 20 | #include "arch/common/xcoff.h" 21 | #include "libopenbios/sys_info.h" 22 | 23 | extern int is_xcoff(COFF_filehdr_t *fhdr); 24 | extern int xcoff_load(ihandle_t dev); 25 | extern void xcoff_init_program(void); 26 | 27 | #endif /* _H_XCOFFLOAD */ 28 | -------------------------------------------------------------------------------- /include/packages/nvram.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/12/20 01:04:25 samuel> 3 | * Time-stamp: <2004/01/07 19:59:11 samuel> 4 | * 5 | * 6 | * 7 | * arch NVRAM interface 8 | * 9 | * Copyright (C) 2003, 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_NVRAM_PACKAGE 18 | #define _H_NVRAM_PACKAGE 19 | 20 | #include "kernel/stack.h" 21 | 22 | extern void nvconf_init( void ); 23 | extern phandle_t nvram_init( const char *path ); 24 | extern void update_nvram( void ); 25 | 26 | #endif /* _H_NVRAM_PACKAGE */ 27 | -------------------------------------------------------------------------------- /include/packages/video.h: -------------------------------------------------------------------------------- 1 | #ifndef VIDEO_SUBR_H 2 | #define VIDEO_SUBR_H 3 | 4 | /* packages/video.c */ 5 | void molvideo_init(void); 6 | 7 | #endif /* VIDEO_SUBR_H */ 8 | -------------------------------------------------------------------------------- /include/sysinclude.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYSINCLUDE_H 2 | #define __SYSINCLUDE_H 3 | 4 | #ifdef BOOTSTRAP 5 | #include "asm/types.h" 6 | #include 7 | #include 8 | #include 9 | #else /* BOOTSTRAP */ 10 | #include "libc/stdlib.h" 11 | #include "libc/string.h" 12 | #endif /* BOOTSTRAP */ 13 | 14 | extern int printk( const char *fmt, ... ) \ 15 | __attribute__ ((format (printf, 1, 2))); 16 | #ifdef BOOTSTRAP 17 | #define printk printf 18 | #endif 19 | 20 | #endif /* __SYSINCLUDE_H */ 21 | -------------------------------------------------------------------------------- /kernel/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /kernel/include/dict.h: -------------------------------------------------------------------------------- 1 | /* tag: dict management headers 2 | * 3 | * Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | #ifndef __DICT_H 10 | #define __DICT_H 11 | 12 | #define DICTID "OpenBIOS" 13 | 14 | #define DOSEMIS 0 15 | #define DOCOL 1 16 | #define DOLIT 2 17 | #define DOCON 3 18 | #define DOVAR 4 19 | #define DODFR 5 20 | #define DODOES 6 21 | 22 | #define MAXNFALEN 128 23 | 24 | /* The header is 28/32 bytes on 32/64bit platforms */ 25 | 26 | typedef struct dictionary_header { 27 | char signature[8]; 28 | u8 version; 29 | u8 cellsize; 30 | u8 endianess; 31 | u8 compression; 32 | u8 relocation; 33 | u8 reserved[3]; 34 | u32 checksum; 35 | u32 length; 36 | ucell last; 37 | } __attribute__((packed)) dictionary_header_t; 38 | 39 | ucell lfa2nfa(ucell ilfa); 40 | ucell load_dictionary(const char *data, ucell len); 41 | void dump_header(dictionary_header_t *header); 42 | ucell fstrlen(ucell fstr); 43 | void fstrncpy(char *dest, ucell src, unsigned int maxlen); 44 | ucell findsemis(ucell xt); 45 | ucell findxtfromcell_wordlist(ucell incell, ucell wordlist); 46 | ucell findxtfromcell(ucell incell); 47 | 48 | /* program counter */ 49 | extern ucell PC; 50 | 51 | extern unsigned char *dict; 52 | extern cell dicthead; 53 | extern cell dictlimit; 54 | extern ucell *last; 55 | #ifdef FCOMPILER 56 | extern ucell *trampoline; 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /kernel/stack.c: -------------------------------------------------------------------------------- 1 | /* tag: defines the stacks, program counter and ways to access those 2 | * 3 | * Copyright (C) 2003 Patrick Mauritz, Stefan Reinauer 4 | * 5 | * See the file "COPYING" for further information about 6 | * the copyright and warranty status of this work. 7 | */ 8 | 9 | 10 | #include "config.h" 11 | #include "kernel/stack.h" 12 | #include "cross.h" 13 | 14 | #define dstacksize 512 15 | int dstackcnt = 0; 16 | cell dstack[dstacksize]; 17 | 18 | #define rstacksize 512 19 | int rstackcnt = 0; 20 | cell rstack[rstacksize]; 21 | 22 | /* Rstack value saved before entering forth interpreter in debugger */ 23 | int dbgrstackcnt = 0; 24 | 25 | #if defined(CONFIG_DEBUG_DSTACK) || defined(FCOMPILER) 26 | void printdstack(void) 27 | { 28 | int i; 29 | printk("dstack:"); 30 | for (i = 0; i <= dstackcnt; i++) { 31 | printk(" 0x%" FMT_CELL_x , dstack[i]); 32 | } 33 | printk("\n"); 34 | } 35 | #endif 36 | #if defined(CONFIG_DEBUG_RSTACK) || defined(FCOMPILER) 37 | void printrstack(void) 38 | { 39 | int i; 40 | printk("rstack:"); 41 | for (i = 0; i <= rstackcnt; i++) { 42 | printk(" 0x%" FMT_CELL_x , rstack[i]); 43 | } 44 | printk("\n"); 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /libc/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /libc/ctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | * linux/lib/ctype.c 3 | * 4 | * Copyright (C) 1991, 1992 Linus Torvalds 5 | */ 6 | 7 | #include "config.h" 8 | #include "libc/string.h" 9 | 10 | const unsigned char _ctype[] = { 11 | _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ 12 | _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ 13 | _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ 14 | _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ 15 | _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ 16 | _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ 17 | _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ 18 | _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ 19 | _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ 20 | _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ 21 | _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ 22 | _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ 23 | _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ 24 | _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ 25 | _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ 26 | _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ 27 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ 28 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ 29 | _S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */ 30 | _P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */ 31 | _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */ 32 | _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ 33 | _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ 34 | _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ 35 | -------------------------------------------------------------------------------- /libc/extra.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/10/18 13:52:32 samuel> 3 | * Time-stamp: <2003/10/18 13:54:24 samuel> 4 | * 5 | * 6 | * 7 | * Libc extras 8 | * 9 | * Copyright (C) 2003 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #include "config.h" 18 | #include "libc/string.h" 19 | #include "libc/vsprintf.h" 20 | #include "libopenbios/bindings.h" 21 | 22 | /* strncpy without 0-pad */ 23 | char * 24 | strncpy_nopad( char *dest, const char *src, size_t n ) 25 | { 26 | int len = MIN( n, strlen(src)+1 ); 27 | return memcpy( dest, src, len ); 28 | } 29 | 30 | /* printf */ 31 | 32 | int forth_printf( const char *fmt, ... ) 33 | { 34 | char buf[512]; 35 | va_list args; 36 | int i; 37 | 38 | va_start(args, fmt); 39 | i = vsnprintf(buf, sizeof(buf), fmt, args); 40 | va_end(args); 41 | 42 | PUSH(pointer2cell(buf)); 43 | PUSH(i); 44 | fword("type"); 45 | 46 | return i; 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /libgcc/__divdi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__divdi3.c 3 | */ 4 | 5 | #include "libgcc.h" 6 | 7 | int64_t __divdi3(int64_t num, int64_t den) 8 | { 9 | int minus = 0; 10 | int64_t v; 11 | 12 | if ( num < 0 ) { 13 | num = -num; 14 | minus = 1; 15 | } 16 | if ( den < 0 ) { 17 | den = -den; 18 | minus ^= 1; 19 | } 20 | 21 | v = __udivmoddi4(num, den, NULL); 22 | if ( minus ) 23 | v = -v; 24 | 25 | return v; 26 | } 27 | -------------------------------------------------------------------------------- /libgcc/__divti3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__divti3.c 3 | */ 4 | 5 | #include "libgcc.h" 6 | 7 | __int128_t __divti3(__int128_t num, __int128_t den) 8 | { 9 | int minus = 0; 10 | __int128_t v; 11 | 12 | if ( num < 0 ) { 13 | num = -num; 14 | minus = 1; 15 | } 16 | if ( den < 0 ) { 17 | den = -den; 18 | minus ^= 1; 19 | } 20 | 21 | v = __udivmodti4(num, den, NULL); 22 | if ( minus ) 23 | v = -v; 24 | 25 | return v; 26 | } 27 | -------------------------------------------------------------------------------- /libgcc/__negti2.c: -------------------------------------------------------------------------------- 1 | /* Extracted from gcc-3.4.1/gcc/config/mips/_tilibi.c */ 2 | /* A few TImode functions needed for TFmode emulated arithmetic. 3 | Copyright 2002, 2003 Free Software Foundation, Inc. 4 | Contributed by Alexandre Oliva 5 | 6 | This file is part of GCC. 7 | 8 | GCC 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, or (at your option) 11 | any later version. 12 | 13 | GCC 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 GCC; see the file COPYING. If not, write to 20 | the Free Software Foundation, 59 Temple Place - Suite 330, 21 | Boston, MA 02111-1307, USA. */ 22 | 23 | #include "libgcc.h" 24 | 25 | #if defined(__sparc__) || defined(__ppc__) 26 | #define LIBGCC2_WORDS_BIG_ENDIAN 27 | #endif 28 | 29 | typedef union 30 | { 31 | struct TIstruct { 32 | #if defined(LIBGCC2_WORDS_BIG_ENDIAN) 33 | DItype high, low; 34 | #else 35 | DItype low, high; 36 | #endif 37 | } s; 38 | TItype ll; 39 | } TIunion; 40 | 41 | TItype 42 | __negti2 (TItype u) 43 | { 44 | TIunion w; 45 | TIunion uu; 46 | 47 | uu.ll = u; 48 | 49 | w.s.low = -uu.s.low; 50 | w.s.high = -uu.s.high - ((UDItype) w.s.low > 0); 51 | 52 | return w.ll; 53 | } 54 | -------------------------------------------------------------------------------- /libgcc/__udivdi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__divdi3.c 3 | */ 4 | 5 | #include "libgcc.h" 6 | 7 | uint64_t __udivdi3(uint64_t num, uint64_t den) 8 | { 9 | return __udivmoddi4(num, den, NULL); 10 | } 11 | -------------------------------------------------------------------------------- /libgcc/__udivmoddi4.c: -------------------------------------------------------------------------------- 1 | #include "libgcc.h" 2 | 3 | uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p) 4 | { 5 | uint64_t quot = 0, qbit = 1; 6 | 7 | if ( den == 0 ) { 8 | __divide_error(); 9 | return 0; /* If trap returns... */ 10 | } 11 | 12 | /* Left-justify denominator and count shift */ 13 | while ( (int64_t)den >= 0 ) { 14 | den <<= 1; 15 | qbit <<= 1; 16 | } 17 | 18 | while ( qbit ) { 19 | if ( den <= num ) { 20 | num -= den; 21 | quot += qbit; 22 | } 23 | den >>= 1; 24 | qbit >>= 1; 25 | } 26 | 27 | if ( rem_p ) 28 | *rem_p = num; 29 | 30 | return quot; 31 | } 32 | -------------------------------------------------------------------------------- /libgcc/__udivmodti4.c: -------------------------------------------------------------------------------- 1 | #include "libgcc.h" 2 | 3 | __uint128_t __udivmodti4(__uint128_t num, __uint128_t den, __uint128_t *rem_p) 4 | { 5 | __uint128_t quot = 0, qbit = 1; 6 | 7 | if ( den == 0 ) { 8 | __divide_error(); 9 | return 0; /* If trap returns... */ 10 | } 11 | 12 | /* Left-justify denominator and count shift */ 13 | while ( (__int128_t)den >= 0 ) { 14 | den <<= 1; 15 | qbit <<= 1; 16 | } 17 | 18 | while ( qbit ) { 19 | if ( den <= num ) { 20 | num -= den; 21 | quot += qbit; 22 | } 23 | den >>= 1; 24 | qbit >>= 1; 25 | } 26 | 27 | if ( rem_p ) 28 | *rem_p = num; 29 | 30 | return quot; 31 | } 32 | -------------------------------------------------------------------------------- /libgcc/__udivti3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__divdi3.c 3 | */ 4 | 5 | #include "libgcc.h" 6 | 7 | __uint128_t __udivti3(__uint128_t num, __uint128_t den) 8 | { 9 | return __udivmodti4(num, den, NULL); 10 | } 11 | -------------------------------------------------------------------------------- /libgcc/__umoddi3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__umoddi3.c 3 | */ 4 | 5 | #include "libgcc.h" 6 | 7 | uint64_t __umoddi3(uint64_t num, uint64_t den) 8 | { 9 | uint64_t v; 10 | 11 | (void) __udivmoddi4(num, den, &v); 12 | return v; 13 | } 14 | -------------------------------------------------------------------------------- /libgcc/__umodti3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arch/i386/libgcc/__umoddi3.c 3 | */ 4 | 5 | #include "libgcc.h" 6 | 7 | __uint128_t __umodti3(__uint128_t num, __uint128_t den) 8 | { 9 | __uint128_t v; 10 | 11 | (void) __udivmodti4(num, den, &v); 12 | return v; 13 | } 14 | -------------------------------------------------------------------------------- /libgcc/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /libgcc/libgcc.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBGCC_H 2 | #define _LIBGCC_H 3 | 4 | #include "asm/types.h" 5 | 6 | #ifndef NULL 7 | #define NULL ((void *)0) 8 | #endif 9 | 10 | typedef int SItype __attribute__ ((mode (SI))); 11 | typedef unsigned int USItype __attribute__ ((mode (SI))); 12 | typedef int DItype __attribute__ ((mode (DI))); 13 | typedef unsigned int UDItype __attribute__ ((mode (DI))); 14 | typedef int word_type __attribute__ ((mode (__word__))); 15 | 16 | uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem); 17 | 18 | int64_t __divdi3(int64_t num, int64_t den); 19 | uint64_t __udivdi3(uint64_t num, uint64_t den); 20 | 21 | uint64_t __umoddi3(uint64_t num, uint64_t den); 22 | 23 | DItype __ashldi3 (DItype u, word_type b); 24 | DItype __lshrdi3 (DItype u, word_type b); 25 | DItype __ashrdi3 (DItype u, word_type b); 26 | 27 | // Must be implemented outside: 28 | void __divide_error(void); 29 | 30 | #if defined(__arch64__) || defined(__LP64__) 31 | typedef int TItype __attribute__ ((mode (TI))); 32 | 33 | __uint128_t __udivmodti4(__uint128_t num, __uint128_t den, __uint128_t *rem); 34 | 35 | __int128_t __divti3(__int128_t num, __int128_t den); 36 | __uint128_t __udivti3(__uint128_t num, __uint128_t den); 37 | 38 | __uint128_t __umodti3(__uint128_t num, __uint128_t den); 39 | 40 | TItype __multi3 (TItype u, TItype v); 41 | TItype __negti2 (TItype u); 42 | 43 | #endif 44 | 45 | #endif /* _LIBGCC_H */ 46 | -------------------------------------------------------------------------------- /libopenbios/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /libopenbios/clib.fs: -------------------------------------------------------------------------------- 1 | \ tag: C helpers 2 | \ 3 | \ Misc C helpers 4 | \ 5 | \ Copyright (C) 2003, 2004 Samuel Rydh 6 | \ 7 | \ See the file "COPYING" for further information about 8 | \ the copyright and warranty status of this work. 9 | \ 10 | 11 | \ should perhaps be moved somewhere else 12 | : set-property ( buf len propname propname-len phandle -- ) 13 | >r 2swap encode-bytes 2swap r> encode-property 14 | ; 15 | 16 | \ install C function 17 | : is-cfunc ( funcaddr word word-len -- ) 18 | $create , does> @ call 19 | ; 20 | 21 | \ install a nameless C function 22 | : is-noname-cfunc ( funcaddr -- xt ) 23 | 0 0 is-cfunc last-xt 24 | ; 25 | 26 | \ is-xt-cfunc installs a function which does the following: 27 | \ - xt is executes 28 | \ - funcarg is pushed 29 | \ - funcaddr is called 30 | 31 | : is-xt-cfunc ( xt|0 funcarg funcaddr word word-len -- ) 32 | is-func-begin 33 | rot ?dup if , then 34 | swap ['] (lit) , , ['] (lit) , , ['] call , 35 | is-func-end 36 | ; 37 | -------------------------------------------------------------------------------- /libopenbios/font_8x16.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qemu/openbios/af97fd7af5e7c18f591a7b987291d3db4ffb28b5/libopenbios/font_8x16.c -------------------------------------------------------------------------------- /libopenbios/font_8x8.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qemu/openbios/af97fd7af5e7c18f591a7b987291d3db4ffb28b5/libopenbios/font_8x8.c -------------------------------------------------------------------------------- /libopenbios/helpers.fs: -------------------------------------------------------------------------------- 1 | \ tag: helper functions 2 | \ 3 | \ deblocker / filesystem support 4 | \ 5 | \ Copyright (C) 2003 Samuel Rydh 6 | \ 7 | \ See the file "COPYING" for further information about 8 | \ the copyright and warranty status of this work. 9 | \ 10 | 11 | 12 | \ create device node and any missing parents. 13 | \ The new node becomes the active package 14 | 15 | : create-node ( nodepath -- ) 16 | recursive 17 | ascii / right-split 18 | 2dup find-dev if 19 | active-package! 20 | 2drop 21 | else 22 | ( nodename path ) 23 | dup if 24 | create-node 25 | else 26 | device-tree @ active-package! 27 | 2drop 28 | then 29 | then 30 | new-device 31 | device-name 32 | active-package 33 | finish-device 34 | active-package! 35 | ; 36 | -------------------------------------------------------------------------------- /libopenbios/ipchecksum.c: -------------------------------------------------------------------------------- 1 | /* Taken from Etherboot */ 2 | 3 | #include "libopenbios/ipchecksum.h" 4 | 5 | unsigned short ipchksum(const void *data, unsigned long length) 6 | { 7 | unsigned long sum; 8 | unsigned long i; 9 | const unsigned char *ptr; 10 | union { 11 | unsigned char byte[2]; 12 | unsigned short word; 13 | } u; 14 | 15 | /* In the most straight forward way possible, 16 | * compute an ip style checksum. 17 | */ 18 | sum = 0; 19 | ptr = data; 20 | for(i = 0; i < length; i++) { 21 | unsigned long value; 22 | value = ptr[i]; 23 | if (i & 1) { 24 | value <<= 8; 25 | } 26 | /* Add the new value */ 27 | sum += value; 28 | /* Wrap around the carry */ 29 | if (sum > 0xFFFF) { 30 | sum = (sum + (sum >> 16)) & 0xFFFF; 31 | } 32 | } 33 | u.byte[0] = (unsigned char) sum; 34 | u.byte[1] = (unsigned char) (sum >> 8); 35 | return (unsigned short) ~u.word; 36 | } 37 | 38 | unsigned short add_ipchksums(unsigned long offset, unsigned short sum, unsigned short new) 39 | { 40 | unsigned long checksum; 41 | sum = ~sum & 0xFFFF; 42 | new = ~new & 0xFFFF; 43 | if (offset & 1) { 44 | /* byte swap the sum if it came from an odd offset 45 | * since the computation is endian independant this 46 | * works. 47 | */ 48 | new = (new << 8) | (new >> 8); 49 | } 50 | checksum = sum + new; 51 | if (checksum > 0xFFFF) { 52 | checksum -= 0xFFFF; 53 | } 54 | return (~checksum) & 0xFFFF; 55 | } 56 | -------------------------------------------------------------------------------- /packages/bootinfo-loader.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | * 5 | * bootinfo file loader 6 | * 7 | * Copyright (C) 2009 Laurent Vivier (Laurent@vivier.eu) 8 | * 9 | * This program is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU General Public License 11 | * version 2 12 | * 13 | */ 14 | 15 | #include "config.h" 16 | #include "libopenbios/bindings.h" 17 | #include "libopenbios/bootinfo_load.h" 18 | #include "packages.h" 19 | 20 | DECLARE_NODE(bootinfo_loader, INSTALL_OPEN, 0, "+/packages/bootinfo-loader" ); 21 | 22 | NODE_METHODS( bootinfo_loader ) = { 23 | { "init-program", bootinfo_init_program }, 24 | }; 25 | 26 | void bootinfo_loader_init( void ) 27 | { 28 | REGISTER_NODE( bootinfo_loader ); 29 | } 30 | -------------------------------------------------------------------------------- /packages/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /packages/cmdline.fs: -------------------------------------------------------------------------------- 1 | \ tag: Utility functions 2 | \ 3 | \ deblocker / filesystem support 4 | \ 5 | \ Copyright (C) 2003, 2004 Samuel Rydh 6 | \ 7 | \ See the file "COPYING" for further information about 8 | \ the copyright and warranty status of this work. 9 | \ 10 | 11 | \ ------------------------------------------------------------- 12 | \ command line editor (/packages/cmdline) 13 | \ ------------------------------------------------------------- 14 | 15 | [IFDEF] CONFIG_CMDLINE 16 | 17 | dev /packages 18 | new-device 19 | " cmdline" device-name 20 | 21 | :noname 22 | " " [active-package], open-package 23 | ?dup if 24 | " cmdline" rot $call-method 25 | else 26 | ." cmdline is missing!" cr 27 | then 28 | \ cmdline must close itself upon return 29 | ; 30 | 31 | :noname 32 | [ ['] (lit) , swap , ] to outer-interpreter 33 | ; SYSTEM-initializer 34 | 35 | external 36 | : prepare 0 to my-self ; 37 | 38 | finish-device 39 | 40 | [THEN] 41 | device-end 42 | -------------------------------------------------------------------------------- /packages/elf-loader.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | * 5 | * ELF file loader 6 | * 7 | * Copyright (C) 2009 Laurent Vivier (Laurent@vivier.eu) 8 | * 9 | * Some parts Copyright (C) 2002, 2003, 2004 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #include "config.h" 18 | #include "libopenbios/bindings.h" 19 | #include "libopenbios/elf_load.h" 20 | #include "packages.h" 21 | 22 | DECLARE_NODE(elf_loader, INSTALL_OPEN, 0, "+/packages/elf-loader" ); 23 | 24 | NODE_METHODS( elf_loader ) = { 25 | { "init-program", elf_init_program }, 26 | }; 27 | 28 | void elf_loader_init( void ) 29 | { 30 | REGISTER_NODE( elf_loader ); 31 | } 32 | -------------------------------------------------------------------------------- /packages/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/12/23 00:28:05 samuel> 3 | * Time-stamp: <2003/12/28 19:43:41 samuel> 4 | * 5 | * 6 | * 7 | * Module intialization 8 | * 9 | * Copyright (C) 2003 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #include "config.h" 18 | #include "kernel/kernel.h" 19 | #include "packages.h" 20 | 21 | void 22 | modules_init( void ) 23 | { 24 | #ifdef CONFIG_CMDLINE 25 | cmdline_init(); 26 | #endif 27 | #ifdef CONFIG_DEBLOCKER 28 | deblocker_init(); 29 | #endif 30 | #ifdef CONFIG_DISK_LABEL 31 | disklabel_init(); 32 | #endif 33 | #ifdef CONFIG_HFSP 34 | hfsp_init(); 35 | #endif 36 | #ifdef CONFIG_HFS 37 | hfs_init(); 38 | #endif 39 | #ifdef CONFIG_EXT2 40 | ext2_init(); 41 | #endif 42 | #ifdef CONFIG_ISO9660 43 | iso9660_init(); 44 | #endif 45 | #ifdef CONFIG_GRUBFS 46 | grubfs_init(); 47 | #endif 48 | #ifdef CONFIG_MAC_PARTS 49 | macparts_init(); 50 | #endif 51 | #ifdef CONFIG_PC_PARTS 52 | pcparts_init(); 53 | #endif 54 | #ifdef CONFIG_SUN_PARTS 55 | sunparts_init(); 56 | #endif 57 | #ifdef CONFIG_LOADER_XCOFF 58 | xcoff_loader_init(); 59 | #endif 60 | #ifdef CONFIG_LOADER_ELF 61 | elf_loader_init(); 62 | #endif 63 | #ifdef CONFIG_LOADER_BOOTINFO 64 | bootinfo_loader_init(); 65 | #endif 66 | 67 | } 68 | -------------------------------------------------------------------------------- /packages/packages.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Creation Date: <2003/12/23 00:32:12 samuel> 3 | * Time-stamp: <2003/12/28 14:47:02 samuel> 4 | * 5 | * 6 | * 7 | * Package initialization 8 | * 9 | * Copyright (C) 2003 Samuel Rydh (samuel@ibrium.se) 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #ifndef _H_MODULES 18 | #define _H_MODULES 19 | 20 | extern void deblocker_init( void ); 21 | extern void disklabel_init( void ); 22 | extern void files_init( void ); 23 | extern void iso9660_init( void ); 24 | extern void hfsp_init( void ); 25 | extern void hfs_init( void ); 26 | extern void ext2_init( void ); 27 | extern void grubfs_init( void ); 28 | extern void macparts_init( void ); 29 | extern void pcparts_init( void ); 30 | extern void sunparts_init( void ); 31 | extern void cmdline_init( void ); 32 | extern void elf_loader_init( void ); 33 | extern void xcoff_loader_init( void ); 34 | extern void bootinfo_loader_init( void ); 35 | 36 | #endif /* _H_MODULES */ 37 | -------------------------------------------------------------------------------- /packages/xcoff-loader.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * 4 | * 5 | * XCOFF file loader 6 | * 7 | * Copyright (C) 2009 Laurent Vivier (Laurent@vivier.eu) 8 | * 9 | * from original XCOFF loader by Steven Noonan 10 | * 11 | * This program is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU General Public License 13 | * version 2 14 | * 15 | */ 16 | 17 | #include "config.h" 18 | #include "libopenbios/bindings.h" 19 | #include "libopenbios/xcoff_load.h" 20 | #include "packages.h" 21 | 22 | DECLARE_NODE(xcoff_loader, INSTALL_OPEN, 0, "+/packages/xcoff-loader" ); 23 | 24 | NODE_METHODS( xcoff_loader ) = { 25 | { "init-program", xcoff_init_program }, 26 | }; 27 | 28 | void xcoff_loader_init( void ) 29 | { 30 | REGISTER_NODE( xcoff_loader ); 31 | } 32 | -------------------------------------------------------------------------------- /utils/devbios/CREDITS: -------------------------------------------------------------------------------- 1 | 2 | Thanks to Michael Gibson from eSeSiX for donating a cs5530 3 | based thin client for porting /dev/bios. 4 | 5 | -------------------------------------------------------------------------------- /utils/devbios/Makefile: -------------------------------------------------------------------------------- 1 | # comment this if you don't want debugging information 2 | CFLAGS += -DDEBUG 3 | 4 | TARGET = bios.o 5 | OBJS = bios_core.o flashchips.o pcisets.o \ 6 | filesystem.o procfs.o programming.o 7 | 8 | obj-m := $(TARGET) 9 | bios-objs := $(OBJS) 10 | 11 | all: module comp 12 | 13 | clean: 14 | -rm -f $(TARGET) $(OBJS) comp *.o bios.ko 15 | -rm -rf .*.cmd .tmp_versions 16 | module: 17 | make -C /usr/src/linux SUBDIRS=`pwd` modules 18 | 19 | comp: comp.c 20 | $(CC) comp.c -O2 -o comp 21 | strip comp 22 | 23 | -------------------------------------------------------------------------------- /utils/devbios/ToDo: -------------------------------------------------------------------------------- 1 | ToDo-/Buglist 2003/06/04 (0.4pre6) 2 | ---------------------------------- 3 | 4 | Memory Stuff 5 | * devbios does not find any flash chip on some systems even though 6 | they are supported. One of the reasons this might happen is that 7 | the flash memory area is hidden using the CPUs mtrrs. If you have 8 | a Pentium II/III/IV or AMD K6/K7 board, you might try 9 | echo "base=0xffe00000 size=0x200000 type=uncachable" >| /proc/mtrr 10 | before loading the module. 11 | 12 | Misc Stuff 13 | * port this driver to fit into the linux kernel's 14 | mtd device drivers. 15 | * join with ctflasher code 16 | * port to *BSD (if anybody wants that) 17 | * disable NMI watchdog while flashing, if active 18 | 19 | PCI Stuff 20 | * unshadow functions do not work on certain 440BX/GX chipsets? 21 | when loading the module, no system flashchip is detected. 22 | * change unshadow functions not to touch low bios area to 23 | be apm and pci bios safe. 24 | 25 | Module stuff 26 | * /proc/sys/kernel/bios-writable 27 | 28 | Flashchip Stuff 29 | * Finnish FWH support. 30 | * Implement writing for Macronix and AMD. 31 | (Catalyst have Intel and AMD compatible chips) 32 | * Implement write protection checking some flash chips have. 33 | * Test/complete existing support 34 | -------------------------------------------------------------------------------- /utils/devbios/bios.h: -------------------------------------------------------------------------------- 1 | /* 2 | * OpenBIOS - free your system! 3 | * ( firmware/flash device driver for Linux ) 4 | * 5 | * bios.h - compile time configuration and globals 6 | * 7 | * This program is part of a free implementation of the IEEE 1275-1994 8 | * Standard for Boot (Initialization Configuration) Firmware. 9 | * 10 | * Copyright (C) 1998-2004 Stefan Reinauer 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; version 2 of the License. 15 | * 16 | * This program is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA 24 | * 25 | */ 26 | 27 | #include 28 | 29 | #define BIOS_MAJOR 104 30 | #define BIOS_MAXDEV 8 31 | #define BIOS_VERSION "0.4rc1" 32 | 33 | // #define UTC_BIOS 34 | 35 | extern int write; 36 | extern unsigned char *bios; 37 | extern spinlock_t bios_lock; 38 | 39 | -------------------------------------------------------------------------------- /utils/devbios/comp.c: -------------------------------------------------------------------------------- 1 | /* Simple utility to compare 2 files. 2 | * Diff or cmp are not sufficient, when 3 | * comparing bioses :-) 4 | * 5 | * Copyright (c) 1998-2000 by Stefan Reinauer 6 | */ 7 | 8 | 9 | #include 10 | 11 | int main (int argc, char *argv[]) 12 | { 13 | FILE *eins,*zwei; 14 | int a,b,i=0,flag=0; 15 | 16 | if(argv[1]==NULL||argv[2]==NULL) { 17 | printf ("Usage: %s file1 file2\n %s compares two files.\n",argv[0],argv[0]); 18 | return 0; 19 | } 20 | eins=fopen(argv[1],"r"); 21 | zwei=fopen(argv[2],"r"); 22 | 23 | if (eins==NULL) { 24 | printf ("File %s not found or unreadable.\n",argv[1]); 25 | return 0; 26 | } 27 | if (zwei==NULL) { 28 | printf ("File %s not found or unreadable.\n",argv[2]); 29 | fclose (eins); 30 | return 0; 31 | } 32 | 33 | while (!feof(eins)) { 34 | a=fgetc(eins); 35 | b=fgetc(zwei); 36 | if (flag==0 && (a==-1||b==-1) && (a!=-1||b!=-1)) { 37 | printf ("One file ended. Printing the rest of the other.\n"); 38 | flag=1; 39 | } 40 | if(a!=b) printf ("0x%06x: 0x%02x -> 0x%02x\n",i,a,b); 41 | i++; 42 | } 43 | 44 | fclose(eins); 45 | fclose(zwei); 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /utils/dist/debian/changelog: -------------------------------------------------------------------------------- 1 | openbios (0.1-1) unstable; urgency=low 2 | 3 | * Initial Debian version. 4 | 5 | -- Patrick Mauritz Mon, 22 Jul 2002 23:24:56 +0200 6 | 7 | -------------------------------------------------------------------------------- /utils/dist/debian/control: -------------------------------------------------------------------------------- 1 | Source: openbios 2 | Maintainer: Patrick Mauritz 3 | Section: devel 4 | Priority: optional 5 | Standards-Version: 3.5.2 6 | Build-Depends: grep-dctrl, yada (>= 0.9.9) 7 | 8 | Package: openbios 9 | Architecture: any 10 | Depends: ${openbios:Depends} 11 | Description: OpenBIOS - OpenFirmware development tools 12 | It contains: 13 | - toke: tokenizer for fcode programs 14 | - detok: decompiler for fcode programs 15 | - paflof: (yet) incomplete forth environment which will be 16 | _the_ core of OpenBIOS 17 | -------------------------------------------------------------------------------- /utils/iso/README: -------------------------------------------------------------------------------- 1 | The files in this directory are packed into the ISO image created with 2 | 3 | $ make runiso 4 | 5 | 6 | -------------------------------------------------------------------------------- /utils/iso/boot/grub/README: -------------------------------------------------------------------------------- 1 | stage2_eltorito is part of grub and therefore (C) by the FSF. 2 | -------------------------------------------------------------------------------- /utils/iso/boot/grub/menu.lst: -------------------------------------------------------------------------------- 1 | timeout 0 2 | default 0 3 | hiddenmenu 4 | title openbios 5 | kernel (cd)/openbios.multiboot 6 | module (cd)/openbios-x86.dict 7 | boot 8 | -------------------------------------------------------------------------------- /utils/iso/boot/grub/stage2_eltorito: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qemu/openbios/af97fd7af5e7c18f591a7b987291d3db4ffb28b5/utils/iso/boot/grub/stage2_eltorito -------------------------------------------------------------------------------- /utils/ofclient/Makefile: -------------------------------------------------------------------------------- 1 | PROGRAM := ofclient 2 | OBJECTS := of1275.o of1275_io.o ofclient.o 3 | CC := gcc 4 | CFLAGS := -m32 -fpic -fno-builtin-strlen -Os 5 | LDFLAGS := -melf_i386 -s -N -Ttext 0x200000 -e _start 6 | 7 | $(PROGRAM): $(OBJECTS) 8 | $(LD) $(LDFLAGS) -Map $(PROGRAM).map -o $(PROGRAM) $(OBJECTS) 9 | 10 | clean: 11 | rm -f $(OBJECTS) 12 | 13 | distclean: clean 14 | rm -f $(PROGRAM) $(PROGRAM).map 15 | -------------------------------------------------------------------------------- /utils/ofclient/README: -------------------------------------------------------------------------------- 1 | This is an example program using the openfirmware client 2 | interface on x86. The same program can be compiled on ppc. 3 | 4 | 5 | -------------------------------------------------------------------------------- /utils/ofclient/endian.h: -------------------------------------------------------------------------------- 1 | 2 | #define __bswap32(x) \ 3 | ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ 4 | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) 5 | 6 | static int little_endian(void) 7 | { 8 | static short one=1; 9 | return *(char *)&one==1; 10 | } 11 | 12 | static unsigned int ntohl(unsigned int netlong) 13 | { 14 | if(little_endian()) 15 | return __bswap32(netlong); 16 | 17 | return netlong; 18 | } 19 | -------------------------------------------------------------------------------- /utils/ofclient/of1275_io.c: -------------------------------------------------------------------------------- 1 | #include "of1275.h" 2 | 3 | static int of_write_initialized = 0; 4 | static int stdout_ihandle = 0; 5 | static int of_read_initialized = 0; 6 | static int stdin_ihandle = 0; 7 | 8 | int write(int fd, char *buf, int len) 9 | { 10 | int actual; 11 | 12 | if (fd != 1 && fd != 2) { 13 | // printk("write: bad id %x\n", fd); 14 | exit(1); 15 | } 16 | 17 | if (!of_write_initialized) { 18 | stdout_ihandle = 19 | of_find_integer_property("/chosen", "stdout"); 20 | // printk("stdout_ihandle: %x\n",stdout_ihandle); 21 | of_write_initialized = 1; 22 | } 23 | 24 | of1275_write(stdout_ihandle, buf, len, &actual); 25 | return actual; 26 | } 27 | 28 | int read(int fd, char *buf, int len) 29 | { 30 | int actual; 31 | 32 | if (fd != 0) { 33 | // printk("write: bad id %x\n", fd); 34 | exit(1); 35 | } 36 | 37 | if (!of_read_initialized) { 38 | stdin_ihandle = 39 | of_find_integer_property("/chosen", "stdin"); 40 | of_read_initialized = 1; 41 | } 42 | 43 | of1275_read(stdin_ihandle, buf, len, &actual); 44 | return actual; 45 | } 46 | 47 | exit(int status) 48 | { 49 | of1275_exit(status); 50 | while (1); 51 | } 52 | -------------------------------------------------------------------------------- /utils/ofclient/ofclient.c: -------------------------------------------------------------------------------- 1 | #include "of1275.h" 2 | 3 | int write(int fd, char *buf, int len); 4 | 5 | int main(void) 6 | { 7 | write(1, "Hello world!\n", 13 ); 8 | return 0; 9 | } 10 | --------------------------------------------------------------------------------