Author: wmb Date: Sat Aug 6 00:33:55 2011 New Revision: 2422 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2422
Log: Initial checkin of platform files for "Alex" ChromeBook.
Added: cpu/x86/pc/alex/addrs.fth cpu/x86/pc/alex/build/ cpu/x86/pc/alex/config.fth cpu/x86/pc/alex/devices.fth cpu/x86/pc/alex/fw.bth cpu/x86/pc/alex/ofw.bth cpu/x86/pc/alex/pcinode.fth cpu/x86/pc/alex/probemem.fth cpu/x86/pc/alex/reset.bth cpu/x86/pc/alex/start.bth cpu/x86/pc/alex/usb.fth
Added: cpu/x86/pc/alex/addrs.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/alex/addrs.fth Sat Aug 6 00:33:55 2011 (r2422) @@ -0,0 +1,56 @@ +\ See license at end of file +purpose: Establish address and I/O configuration definitions + +\ Dropin-base is where the set of dropin modules, the verbatim +\ image of what is stored in ROM or on disk, ends up in memory. +\ If OFW is in FLASH, dropin-base can just be the FLASH address. +\ If OFW is pulled in from disk, dropin-base is where the very +\ early startup code - the first few instructions in the image - +\ copies it to get it out of the way of things like OS load areas. + +h# 198.0000 constant dropin-base \ Location of payload in RAM +dropin-base h# 20 + constant ResetBase \ Location of "reset" dropin in RAM +h# 8.0000 constant dropin-size + +\needs fw-pa h# 7f00.0000 constant fw-pa \ OFW dictionary location +\needs /fw-ram h# 20.0000 constant /fw-ram + +\needs heap-base h# 7f20.0000 constant heap-base \ Dynamic allocation heap +\needs heap-size h# 20.0000 constant heap-size + +\needs dma-base h# 7ee0.0000 constant dma-base \ DMA heap +\needs dma-size h# 20.0000 constant dma-size + +\ Where OFW initially loads an OS that is is going to boot + +h# 100.0000 constant def-load-base \ Convenient for initrd + +fload ${BP}/cpu/x86/pc/virtaddr.fth + +[ifdef] virtual-mode +h# 3 constant pte-control \ Page table entry attributes +[then] + +\ LICENSE_BEGIN +\ Copyright (c) 2006 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/x86/pc/alex/config.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/alex/config.fth Sat Aug 6 00:33:55 2011 (r2422) @@ -0,0 +1,64 @@ +purpose: Configuration setting for OFW as a Coreboot payload on Samsung "Alex" Chromebook +\ See license at end of file + +h# e0401000 constant mem-uart-base + +create coreboot-loaded +create coreboot-qemu +create debug-startup + +create serial-console + +\ In virtual mode, OFW runs with the MMU on. The advantages are +\ that OFW can automatically locate itself out of the way, at the +\ top of physical memory, it can dynamically allocate exactly as +\ much physical memory as it needs, and it can remain alive after +\ the OS starts. The disadvantage is that it is more confusing - +\ you always have to be aware of the distinction between virtual +\ and physical addresses. + +\ If you use virtual mode for Linux, you can debug past +\ the point where Linux starts using the MMU. It is not strictly +\ necessary to use virtual mode if you just want to boot Linux +\ and then have OFW disappear. + +\ create virtual-mode + +\ linux-support includes a bzImage file-format handler +\ and ext2 filesystem support + +create linux-support + +\ create pseudo-nvram +create resident-packages +create addresses-assigned \ Don't reassign PCI addresses +create no-floppy-node +create no-lpt-node +create no-com1-node +create no-com2-node + +fload ${BP}/cpu/x86/pc/alex/addrs.fth + +\ LICENSE_BEGIN +\ Copyright (c) 2011 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/x86/pc/alex/devices.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/alex/devices.fth Sat Aug 6 00:33:55 2011 (r2422) @@ -0,0 +1,199 @@ +\ See license at end of file +purpose: Load device drivers according to configuration definitions + +fload ${BP}/cpu/x86/pc/isaio.fth + +fload ${BP}/dev/pci/configm1.fth \ Generic PCI configuration access + +0 0 " " " /" begin-package + fload ${BP}/cpu/x86/pc/mappci.fth \ Map PCI to root + fload ${BP}/dev/pcibus.fth \ Generic PCI bus package + + 0 0 " addresses-preassigned" property +[then] + + fload ${BP}/cpu/x86/pc/alex/pcinode.fth \ System-specific words for PCI +end-package +stand-init: PCI host bridge + " /pci" " init" execute-device-method drop +; + +fload ${BP}/dev/pciprobe.fth \ Generic PCI probing + +[ifdef] use-timestamp-counter +\ Use the CPU chip's Time Stamp Counter for timing; it does just what we want +fload ${BP}/cpu/x86/tsc.fth +[then] + +0 0 " " " /" begin-package + fload ${BP}/cpu/x86/pc/isabus.fth \ ISA Bus Bridge under root node +end-package + +[ifndef] use-timestamp-counter +fload ${BP}/cpu/x86/pc/getms.fth +[then] + +dev /interrupt-controller +h# 20 to vector-base0 +h# 28 to vector-base1 +device-end + +fload ${BP}/ofw/fs/cbfs.fth \ Coreboot ROM filesystem + +\ Create the top-level device node to access the entire boot FLASH device +0 0 " ffc00000" " /" begin-package + " flash" device-name + + h# 40.0000 value /device + h# 40.0000 constant /device-phys + my-address my-space /device-phys reg + fload ${BP}/dev/flashpkg.fth + fload ${BP}/dev/flashwrite.fth +end-package + +devalias cbfs /flash//cbfs-file-system + +0 [if] +\ This really should be a subrange of /flash +0 0 dropin-base <# u#s u#> " /" begin-package + " dropinram" device-name + + dropin-size + dup value /device + constant /device-phys + my-address my-space /device-phys reg + fload ${BP}/dev/flashpkg.fth +end-package + +devalias dropins /dropinram +[else] +patch /l /di-header first-header +patch /l /di-header first-header +devalias dropins cbfs:fallback\payload +[then] + +\ Create a pseudo-device that presents the dropin modules as a filesystem. +fload ${BP}/ofw/fs/dropinfs.fth + +\ This devalias lets us say, for example, "dir rom:" +devalias rom /dropin-fs + +fload ${BP}/cpu/x86/forthint.fth \ Low-level interrupt handling code +fload ${BP}/dev/isa/irq.fth \ ISA interrupt dispatcher +fload ${BP}/cpu/x86/pc/isatick.fth \ Use ISA timer as the alarm tick timer + +[ifdef] resident-packages +support-package: 16550 +fload ${BP}/dev/16550pkg/16550.fth \ Serial port support package +end-support-package +[then] + +fload ${BP}/dev/pci/isaall.fth +devalias mouse /isa/8042/mouse + +[ifdef] use-timestamp-counter +fload ${BP}/cpu/x86/pc/tsccal1.fth +[then] + +0 0 hex mem-uart-base (u.) " /" begin-package + 4 encode-int 0 encode-int encode+ " interrupts" property + fload ${BP}/dev/16550pkg/ns16550p.fth + d# 64,000,000 " clock-frequency" integer-property + fload ${BP}/dev/16550pkg/isa-int.fth +end-package +devalias com1 /serial:115200 +: com1 ( -- adr len ) " com1" ; ' com1 to fallback-device + +0 0 " i70" " /isa" begin-package \ Real-time clock node + fload ${BP}/dev/ds1385r.fth + 8 encode-int 0 encode-int encode+ " interrupts" property + 2 encode-int " device#" property +end-package +stand-init: RTC + " /rtc" open-dev clock-node ! +; + +fload ${BP}/cpu/x86/pc/cpunode.fth + +fload ${BP}/ofw/core/countdwn.fth \ Startup countdown +fload ${BP}/forth/lib/pattern.fth \ Text string pattern matching +fload ${BP}/forth/lib/tofile.fth \ to-file and append-to-file +\ XXX remove the OS file commands from tools.dic +fload ${BP}/ofw/core/filecmds.fth \ File commands: dir, del, ren, etc. + +0 0 " 2,0" " /pci" begin-package + " display" name + fload ${BP}/dev/intel/graphics/pineview.fth +end-package +devalias screen /pci/display@2,0 \ Explicit, because it's not probed + +\ Create the alias unless it already exists +: $?devalias ( alias$ value$ -- ) + 2over not-alias? if $devalias exit then ( alias$ value$ alias$ ) + 2drop 4drop +; + +: report-pci-fb ( -- ) + " /pci/display" locate-device 0= if ( phandle ) + " open" rot find-method if ( xt ) + drop + " screen" " /pci/display" $devalias + then + then +; + +: report-disk ( -- ) + " /pci-ide" locate-device 0= if + drop + " disk" " /pci-ide/ide@0/disk@0" $devalias + " c" " /pci-ide/ide@0/disk@0" $devalias + " d" " /pci-ide/ide@0/disk@1" $devalias + " e" " /pci-ide/ide@1/disk@0" $devalias + " f" " /pci-ide/ide@1/disk@1" $devalias + exit + then + " /ide" locate-device 0= if + drop + " disk" " /ide@1f0/disk@0" $devalias + " c" " /ide@1f0/disk@0" $devalias + " d" " /ide@170/disk@1" $devalias + " e" " /ide@1f0/disk@0" $devalias + " f" " /ide@170/disk@2" $devalias + exit + then +; + +fload ${BP}/cpu/x86/inoutstr.fth \ Multiple I/O port read/write +fload ${BP}/dev/isa/diaguart.fth \ ISA COM port driver +fload ${BP}/forth/lib/sysuart.fth \ Use UART for key and emit + +0 value keyboard-ih +0 value screen-ih + +fload ${BP}/ofw/core/muxdev.fth \ I/O collection/distribution device + +fload ${BP}/cpu/x86/pc/reset.fth \ reset-all + +\ LICENSE_BEGIN +\ Copyright (c) 2011 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/x86/pc/alex/fw.bth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/alex/fw.bth Sat Aug 6 00:33:55 2011 (r2422) @@ -0,0 +1,324 @@ +\ See license at end of file +purpose: Build Open Firmware core + +dictionary: ${BP}/cpu/x86/build/basefw.dic +command: &x86forth &dictionary &this +in: builton.fth +build-now + +" fw.tag" r/w create-file drop tag-file ! + +hex +\ ' $report-name is include-hook + +fload ${BP}/cpu/x86/pc/alex/config.fth + +: headerless ; : headers ; : headerless0 ; + +' (quit) to quit + +: \Tags [compile] \ ; immediate +: \NotTags [compile] \ ; immediate + +: RAMbase ( -- adr ) fw-virt-base ; +: RAMtop ( -- adr ) RAMbase /fw-ram + ; + +h# 00.0000 value dp-loc \ Set in patchboot +: stacktop ( -- adr ) RAMtop ; +: dict-limit ( -- adr ) RAMtop h# 06.0000 - ; + +\ XXX What we should do is pass in the top address in SP, and have +\ boot.fth allocate the user area by subtracting user-size. But +\ we need some way of finding it again for exception re-entry. +\ prom-main-task is used in arch/pc/boot.fth . The constant +\ value is wired into the assembly code +stacktop user-size - ( fw-virt-base - ) constant prom-main-task \ user area for main task + +0 value load-limit \ Top address of area at load-base +' 2drop to sync-cache + +def-load-base ' load-base set-config-int-default + +true ' fcode-debug? set-config-int-default +\ false ' auto-boot? set-config-int-default + +" com1" ' output-device set-config-string-default +" com1" ' input-device set-config-string-default + +\ XXX should be loaded by basefw.bth +fload ${BP}/cpu/x86/initpgm.fth \ Basic boot handler +fload ${BP}/cpu/x86/msr.fth \ Access to machine specific registers + +: (cpu-arch ( -- adr len ) + " architecture" ['] root-node get-package-property drop + get-encoded-string +; +' (cpu-arch to cpu-arch + +h# 1000 to pagesize +d# 12 to pageshift + +dev / +1 encode-int " #address-cells" property +1 encode-int " #size-cells" property +" Generic PC" model +" PC" encode-string " architecture" property + +\ XXX figure out bus frequency. How? +\ d# 33,333,333 " clock-frequency" integer-property +device-end + +\ Memory management services +[ifdef] virtual-mode +fload ${BP}/ofw/core/clntmem1.fth \ client services for memory +[else] +fload ${BP}/ofw/core/clntphy1.fth \ client services for memory +[then] +fload ${BP}/ofw/core/memlist.fth \ Resource list common routines +fload ${BP}/ofw/core/showlist.fth \ Linked list display tool +fload ${BP}/ofw/core/allocph1.fth \ S Physical memory allocator +fload ${BP}/ofw/core/availpm.fth \ Available memory list +fload ${BP}/ofw/core/allocmor.fth \ Secondary allocator + +fload ${BP}/cpu/x86/pc/rootnode.fth \ Platform-specific root node changes + +fload ${BP}/cpu/x86/pc/alex/probemem.fth \ Memory probing + +[ifdef] virtual-mode +fload ${BP}/cpu/x86/loadvmem.fth \ /mmu node +stand-init: MMU + " /mmu" open-dev mmu-node ! +; +fload ${BP}/cpu/x86/pc/initdict.fth \ Dynamic dictionary allocation +[then] + +\ XXX should be elsewhere +dev /client-services +: chain ( len args entry size virt -- ) + release ( len args entry ) + h# 8000 alloc-mem h# 8000 + (init-program) ( len args ) + to %ebx to %ecx + go +; +device-end + +fload ${BP}/cpu/x86/crc32.fth \ Assembly language Zip CRC calculation +fload ${BP}/forth/lib/crc32.fth \ High-level portion of CRC calculation + +[ifdef] resident-packages + +\needs unix-seconds> fload ${BP}/ofw/fs/unixtime.fth \ Unix time calculation +support-package: ext2-file-system + fload ${BP}/ofw/fs/ext2fs/ext2fs.fth \ Linux file system +end-support-package + +support-package: zip-file-system + fload ${BP}/ofw/fs/zipfs.fth \ Zip file system +end-support-package + +support-package: dropin-file-system + fload ${BP}/ofw/fs/dropinfs.fth \ Dropin file system +end-support-package +[then] + +\ Load file format handlers + +: call32 ; + +fload ${BP}/ofw/core/allocsym.fth \ Allocate memory for symbol table +fload ${BP}/ofw/core/symcif.fth +fload ${BP}/ofw/core/symdebug.fth +: release-load-area ( boundary-adr -- ) drop ; + +fload ${BP}/cpu/x86/pc/fixkbd.fth \ Switch keyboard scan codes + +fload ${BP}/ofw/elf/elf.fth +fload ${BP}/ofw/elf/elfdebug.fth +[ifdef] virtual-mode +\ Depends on the assumption that physical memory is mapped 1:1 already +: (elf-map-in) ( va size -- ) 0 mem-claim drop ; +[else] +: (elf-map-in) ( va size -- ) 2drop ; +[then] +' (elf-map-in) is elf-map-in + +\ Reboot and re-entry code +fload ${BP}/cpu/x86/pc/reboot.fth \ Restart the client program +fload ${BP}/cpu/x86/pc/reenter.fth \ Various entries into Forth + +headerless +[ifdef] virtual-mode +: (initial-heap) ( -- adr len ) sp0 @ ps-size - dict-limit tuck - ; +[else] +: (initial-heap) ( -- adr len ) heap-base heap-size ; +[then] +' (initial-heap) is initial-heap +headers + +" /openprom" find-device + " FirmWorks,3.0" encode-string " model" property +device-end + +[ifdef] virtual-mode +fload ${BP}/cpu/x86/pc/mmusetup.fth \ Initial values for MMU lists +[then] + +fload ${BP}/cpu/x86/pc/rmtools.fth + +fload ${BP}/cpu/x86/pc/alex/devices.fth + +true ' local-mac-address? set-config-int-default +fload ${BP}/ofw/inet/loadtcp.fth + +support-package: http + fload ${BP}/ofw/inet/http.fth \ HTTP client +end-support-package + +[ifndef] use-timestamp-counter +fload ${BP}/cpu/x86/pc/mscal.fth +[then] +fload ${BP}/cpu/x86/pc/boot.fth +fload ${BP}/cpu/x86/pc/linux.fth + +hex +\ If there is a PCI ethernet adapter, use it as the default net device, +\ otherwise use any ethernet that can be found in the device tree. +: report-net ( -- ) + " /pci/ethernet" 2dup find-package if ( name$ phandle ) + drop ( name$ ) + else ( name$ ) + 2drop " /ethernet" ( name$' ) + then ( name$ ) + " net" 2swap $devalias ( ) +; + +fload ${BP}/cpu/x86/pc/alex/usb.fth + +\ false to stand-init-debug? +true to stand-init-debug? + +hex +stand-init-debug? [if] +warning @ warning off +: init +\ initial-heap add-memory + init + + standalone? if + cr ." Type 'i' to interrupt stand-init sequence" cr + d# 1000 ms + key? if + key upc ascii I = if ." Interacting" cr hex interact then + then + then +\ cr0@ h# 9fff.ffff and cr0! \ enable L1 and L2 caches +; +warning ! +[then] + +: (.firmware) ( -- ) + ." Open Firmware " .built cr + ." Copyright 1999 FirmWorks All Rights Reserved" cr +; +' (.firmware) to .firmware + +: linux-logo ( -- ) + " penguin.txt" find-drop-in if page type then +; + +: probe-all ( -- ) + " probe-" do-drop-in + ." probe-pci" cr +\ debug-me + probe-pci + probe-usb + report-net + report-disk + report-pci-fb +; + +\ This reduces processor use when waiting for a key. It helps +\ a lot when running on an emulator. +: c1-idle ( -- ) interrupts-enabled? if halt then ; +' c1-idle to stdin-idle + +: startup ( -- ) + standalone? 0= if exit then + ." calibrate-ms" cr + calibrate-ms + + ." nvramrc" cr + use-nvramrc? if nvramrc safe-evaluate then + + auto-banner? if + " Probing" ?type probe-all + install-mux-io +\ " Install console" ?type install-console +\ ?usb-keyboard + banner + then + + hex + warning on + only forth also definitions + + ." Installing alarms" cr + install-alarm + + #line off + + ." Open Firmware demonstration version by FirmWorks (info@firmworks.com)" cr + +[ifdef] linux-support + ." See " + blue-letters ." http://www.firmworks.com/linux/demo.html" black-letters + cr cr + + ." Type 'help-linux' to learn about Linux loading options" cr +[then] + quit +; + +fload ${BP}/cpu/x86/pc/watchall.fth + +alias crcgen drop ( crc byte -- crc' ) +fload ${BP}/cpu/x86/pc/saveabs.fth + +fload ${BP}/forth/lib/selstr.fth + +\needs ramdisk " " d# 128 config-string ramdisk +" console=tty0 console=ttyS0,115200" ' boot-file set-config-string-default + +" dhcp" ' ip-address set-config-string-default + +tag-file @ fclose tag-file off + +.( SAVING FW.dic ...) +" fw.dic" $save-forth cr + +.( Saving fw.img ...) +" fw.img" RAMbase save-abs-rom cr + +\ LICENSE_BEGIN +\ Copyright (c) 2011 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/x86/pc/alex/ofw.bth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/alex/ofw.bth Sat Aug 6 00:33:55 2011 (r2422) @@ -0,0 +1,62 @@ +purpose: Construct the final OFW image + +command: &builder &this +in: reset.di +in: start.di +in: ${BP}/cpu/x86/pc/alex/build/paging.di +in: fw.img +in: ${BP}/dev/usb2/hcd/ohci/build/ohci.fc +in: ${BP}/dev/usb2/hcd/uhci/build/uhci.fc +in: ${BP}/dev/usb2/hcd/ehci/build/ehci.fc +in: ${BP}/dev/usb2/device/hub/build/hub.fc +in: ${BP}/dev/usb2/device/net/build/usbnet.fc +in: ${BP}/dev/usb2/device/serial/build/usbserial.fc +in: ${BP}/dev/usb2/device/storage/build/usbstorage.fc +in: ${BP}/dev/usb2/device/keyboard/build/usbkbd.fc +in: ${BP}/dev/pci/build/pcibridg.fc +in: ${BP}/dev/ide/build/leghier.fc + +build-now + +fload ${BP}/cpu/x86/pc/alex/config.fth + +\ Always re-create the builton.fth file when we make a new rom.img +fload ${BP}/cpu/x86/pc/builton.bth + +hex + +.( --- Saving as ofw.elf - Coreboot payload format) cr +fload ${BP}/cpu/x86/pc/elfhdr.fth +writing ofw.elf +elf-header /elf-header ofd @ fputs + + " reset.di" $add-file + " start.di" $add-file + " paging.di" $add-file + + " ${BP}/cpu/x86/build/inflate.bin" " inflate" $add-dropin + + " fw.img" " firmware" $add-deflated-dropin + + " ${BP}/dev/pci/build/pcibridg.fc" " class060400" $add-deflated-dropin + " ${BP}/dev/ide/build/leghier.fc" " class01018a" $add-deflated-dropin + + " ${BP}/dev/usb2/hcd/ehci/build/ehci.fc" " class0c0320" $add-deflated-dropin + " ${BP}/dev/usb2/hcd/uhci/build/uhci.fc" " class0c0300" $add-deflated-dropin + + " ${BP}/dev/usb2/device/hub/build/hub.fc" " usb,class9" $add-dropin + " ${BP}/dev/usb2/device/keyboard/build/usbkbd.fc" " usb,class3,1" $add-dropin + " ${BP}/dev/usb2/device/net/build/usbnet.fc" " usbnet" $add-deflated-dropin + " ${BP}/dev/usb2/device/serial/build/usbserial.fc" " usbserial" $add-deflated-dropin + " ${BP}/dev/usb2/device/storage/build/usbstorage.fc" " usbstorage" $add-deflated-dropin + + " builton.fth" " probe-" $add-dropin + " ${BP}/ofw/fcode/memtest.fth" " memtest.fth" $add-deflated-dropin + " ${BP}/ofw/inet/telnetd.fth" " telnetd" $add-deflated-dropin + " ${BP}/ofw/termemu/15x30pc.psf" " font" $add-deflated-dropin + + ofd @ fsize pad ! \ file size; store in memory for convenience below + h# 44 ofd @ fseek \ Seek to file size field; see elfhdr.bth + pad 4 ofd @ fputs \ Patch file size + pad 4 ofd @ fputs \ Patch memory size +ofd @ fclose
Added: cpu/x86/pc/alex/pcinode.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/alex/pcinode.fth Sat Aug 6 00:33:55 2011 (r2422) @@ -0,0 +1,85 @@ +\ See license at end of file +purpose: PCI bus package + +\ XXX need slot-names property +[ifdef] notdef +h# 1000 encode-int " slave-only" property +h# 1800 encode-int \ Mask of implemented add-in slots +" PCI-1" encode-string encode+ +" PCI-2" encode-string encode+ +" PCI-3" encode-string encode+ + +" slot-names" property +[then] + +also forth definitions + +" 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,10,11,12,13,14,15,16,17,18,19,1a,1b,1c,1d,1e,1f" + dup config-string pci-probe-list + +previous definitions + +h# 1000.0000 to first-mem \ Avoid RAM at low addresses +h# 2000.0000 to mem-space-top +h# 0000.8000 to first-io \ Avoid mappings established by BIOS + +\ Configuration mechanism #1 as defined in the PCI spec. +: config-setup ( config-adr -- vaddr ) + \ Bit 31 ("enable") must be 1, bits 30:24 ("reserved") must be 0, + \ bits 1:0 must be 0. + dup h# ff.fffc and h# 8000.0000 or h# cf8 pl! ( config-adr ) + + 3 and h# cfc + \ Merge in the byte selector bits +; + +: config-b@ ( config-adr -- b ) config-setup pc@ ; +: config-w@ ( config-adr -- w ) config-setup pw@ ; +: config-l@ ( config-adr -- l ) config-setup pl@ ; +: config-b! ( b config-adr -- ) config-setup pc! ; +: config-w! ( w config-adr -- ) config-setup pw! ; +: config-l! ( l config-adr -- ) config-setup pl! ; + +: init ( -- ) ; + +\ Determine the parent interrupt information (the "interrupt line" in PCI +\ parlance) from the child's "interrupt pin" and the child's address, +\ returning "int-line true" if the child's interrupt line register should +\ be set or "false" otherwise. +: assign-int-line ( phys.hi.func INTx -- irq true ) + \ Reiterate the value that is already in the int line register, + \ which was presumably placed there by the BIOS + drop h# 3c + config-b@ true +; + +\ The io-base handling really ought to be in the root node, but +\ that would require more changes than I'm willing to do at present. +warning @ warning off +: map-out ( vaddr size -- ) + over io-base u>= if 2drop exit then ( vaddr size ) + map-out ( ) +; +warning ! + +\ LICENSE_BEGIN +\ Copyright (c) 2011 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/x86/pc/alex/probemem.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/alex/probemem.fth Sat Aug 6 00:33:55 2011 (r2422) @@ -0,0 +1,67 @@ +\ See license at end of file +purpose: Create memory node properties and lists + +dev /memory + +: /ram ( -- #bytes ) mem-info-pa la1+ l@ ; + +: release-range ( start-adr end-adr -- ) over - release ; + +: probe ( -- ) + 0 /ram reg \ Report extant memory + + \ Put h# 10.0000-1f.ffff and 28.0000-memsize in pool, + \ reserving 0..10.0000 for the firmware + \ and 20.0000-27.ffff for the "flash" + +\ h# 0.0000 h# 02.0000 release \ A little bit of DMA space, we hope +\ h# 10.0000 h# 0f.ffff release +\ h# 28.0000 h# 80.0000 h# 28.0000 - release + +\ Release some of the first meg, between the page tables and the DOS hole, +\ for use as DMA memory. + mem-info-pa 2 la+ l@ h# a.0000 release-range \ Below DOS hole + +[ifdef] virtual-mode + h# 10.0000 dropin-base over - release + dropin-base dropin-size + mem-info-pa la1+ l@ over - release + +[else] + fw-pa h# 10.0000 u> if + h# 10.0000 fw-pa over - release + fw-pa /fw-ram + heap-base heap-size + umax /ram release + then +[then] +; + +device-end + +also forth definitions +stand-init: Probing memory + " probe" memory-node @ $call-method +; +previous definitions + +\ LICENSE_BEGIN +\ Copyright (c) 2011 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/x86/pc/alex/reset.bth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/alex/reset.bth Sat Aug 6 00:33:55 2011 (r2422) @@ -0,0 +1,97 @@ +\ See license at end of file +purpose: Dropin dispatcher for i386 + +command: &builder &this +build-now + +fload ${BP}/cpu/x86/pc/alex/config.fth + +\needs start-assembling fload ${BP}/cpu/x86/asmtools.fth +\needs write-dropin fload ${BP}/forth/lib/mkdropin.fth + +fload ${BP}/cpu/x86/mmuparam.fth + +hex + +fload ${BP}/cpu/x86/pc/finddi.fth \ find-dropin and other tools +fload ${BP}/cpu/x86/pc/port80.fth \ Port 80 output + +h# 3e.0000 constant inflate-base +h# 30.0000 constant workspace + +start-assembling + +label my-entry + e9 c, 0 , \ To be patched later +end-code + +[ifdef] debug-startup +fload ${BP}/cpu/x86/pc/dot.fth \ Numeric output +[then] + +fload ${BP}/cpu/x86/pc/ramfind.fth \ find-dropin + +label startup + h# 10 port80 + cli cld + + h# 11 port80 +\ h# 80 h# 70 # isa-c! \ Disable NMI +\ h# 71 # al in \ Why do we do this? + +[ifdef] debug-startup +\ init-com1 + +carret report +linefeed report +ascii F report +ascii o report +ascii r report +[then] + + h# 12 port80 + " start" $find-dropin, \ Assemble call to find-dropin with literal arg + \ What should we do it this fails? Perhaps call a default routine + \ to try to initialize com1 and display a message? + \ For now, we assume success + + d# 32 # ax add \ Skip dropin header + ax call \ Execute the dropin + h# 13 port80 + + fload ${BP}/cpu/x86/pc/resetend.fth +end-code + +also 386-assembler +startup my-entry put-branch +previous + +end-assembling + +writing reset.di +asm-base here over - 0 " reset" write-dropin +ofd @ fclose + +\ LICENSE_BEGIN +\ Copyright (c) 2011 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/x86/pc/alex/start.bth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/alex/start.bth Sat Aug 6 00:33:55 2011 (r2422) @@ -0,0 +1,67 @@ +\ See license at end of file +purpose: Low-level startup code + +command: &builder &this +build-now + +\needs start-assembling fload ${BP}/cpu/x86/asmtools.fth +\needs write-dropin fload ${BP}/forth/lib/mkdropin.fth + +hex + +fload ${BP}/cpu/x86/pc/alex/config.fth + +fload ${BP}/cpu/x86/pc/report.fth \ Startup reports + +start-assembling + +label my-entry +[ifdef] debug-startup + e9 c, 0 , \ To be patched later +end-code + +fload ${BP}/cpu/x86/pc/dot.fth \ Numeric display +[then] + +label startup +[ifdef] debug-startup +\ ascii x report +[then] + ret +end-code + +[ifdef] debug-startup +also 386-assembler +startup my-entry put-branch +previous +[then] + +end-assembling + +writing start.di +asm-base here over - 0 " start" write-dropin +ofd @ fclose + +\ LICENSE_BEGIN +\ Copyright (c) 2011 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END
Added: cpu/x86/pc/alex/usb.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/alex/usb.fth Sat Aug 6 00:33:55 2011 (r2422) @@ -0,0 +1,139 @@ +purpose: Platform-specific USB elaborations +\ See license at end of file + +0 config-int usb-delay \ Milliseconds to wait before set-address + +devalias u /usb/disk + +\ Like $show-devs, but ignores pagination keystrokes +: $nopage-show-devs ( nodename$ -- ) + ['] exit? behavior >r ['] false to exit? + $show-devs + r> to exit? +; + +: (probe-usb2) ( -- ) + " device_type" get-property if exit then +[ifdef] use-usb-debug-port + \ I haven't figured out how to turn on the EHCI cleanly + \ when the Debug Port is running + dbgp-off +[then] + get-encoded-string " ehci" $= if + pwd$ open-dev ?dup if close-dev then + then +; +: (show-usb2) ( -- ) + " device_type" get-property if exit then + get-encoded-string " ehci" $= if + pwd$ $nopage-show-devs + then +; +: (probe-usb1) ( -- ) + " device_type" get-property if exit then + get-encoded-string 2dup " uhci" $= >r " ohci" $= r> or if + pwd$ open-dev ?dup if close-dev then + then +; +: (show-usb1) ( -- ) + " device_type" get-property if exit then + get-encoded-string 2dup " uhci" $= >r " ohci" $= r> or if + pwd$ $nopage-show-devs + then +; + +: silent-probe-usb ( -- ) + " /" ['] (probe-usb2) scan-subtree + " /" ['] (probe-usb1) scan-subtree + report-disk report-net +; +: probe-usb ( -- ) + silent-probe-usb + + ." USB2 devices:" cr + " /" ['] (show-usb2) scan-subtree + + ." USB1 devices:" cr + " /" ['] (show-usb1) scan-subtree +; +alias p2 probe-usb + +0 value usb-keyboard-ih + +: attach-usb-keyboard ( -- ) + " usb-keyboard" expand-alias if ( devspec$ ) + drop " /usb" comp 0= if ( ) + " usb-keyboard" open-dev to usb-keyboard-ih + usb-keyboard-ih add-input + exit + then + else ( devspec$ ) + 2drop + then +; + +: detach-usb-keyboard ( -- ) + usb-keyboard-ih if + usb-keyboard-ih remove-input + usb-keyboard-ih close-dev + 0 to usb-keyboard-ih + then +; + +: ?usb-keyboard ( -- ) + attach-usb-keyboard + " /usb/serial" open-dev ?dup if + add-input + then +; + +\ Unlink every node whose phys.hi component matches port +: port-match? ( port -- flag ) + get-unit if drop false exit then + get-encoded-int = +; +: rm-usb-children ( port -- ) + device-context? 0= if drop exit then + also ( port ) + 'child ( port prev ) + first-child begin while ( port prev ) + over port-match? if ( port prev ) + 'peer link@ over link! ( port prev ) \ Disconnect + else ( port prev ) + drop 'peer ( port prev' ) + then ( port prev ) + next-child repeat ( port prev ) + 2drop ( ) + previous definitions +; + +: usb-quiet ( -- ) + [ ' linux-hook behavior compile, ] \ Chain to old behavior + " usb1" " reset-usb" execute-device-method drop + " usb2" " reset-usb" execute-device-method drop +; +' usb-quiet to linux-hook + +\ LICENSE_BEGIN +\ Copyright (c) 2007 FirmWorks +\ +\ Permission is hereby granted, free of charge, to any person obtaining +\ a copy of this software and associated documentation files (the +\ "Software"), to deal in the Software without restriction, including +\ without limitation the rights to use, copy, modify, merge, publish, +\ distribute, sublicense, and/or sell copies of the Software, and to +\ permit persons to whom the Software is furnished to do so, subject to +\ the following conditions: +\ +\ The above copyright notice and this permission notice shall be +\ included in all copies or substantial portions of the Software. +\ +\ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +\ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +\ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +\ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +\ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +\ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +\ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +\ +\ LICENSE_END