openfirmware
Threads by month
- ----- 2026 -----
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
August 2011
- 1 participants
- 99 discussions
Author: wmb
Date: Sat Aug 6 00:40:25 2011
New Revision: 2425
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2425
Log:
Biosload reset.bth - eliminated some unnecessary early accesses to legacy ISA I/O registers.
Modified:
cpu/x86/pc/biosload/reset.bth
Modified: cpu/x86/pc/biosload/reset.bth
==============================================================================
--- cpu/x86/pc/biosload/reset.bth Sat Aug 6 00:36:34 2011 (r2424)
+++ cpu/x86/pc/biosload/reset.bth Sat Aug 6 00:40:25 2011 (r2425)
@@ -67,8 +67,8 @@
[then]
h# 11 port80
- 80 70 isa-c! \ Disable NMI
- 71 # dx mov dx al in \ Why do we do this?
+\ h# 80 h# 70 # isa-c! \ Disable NMI
+\ h# 71 # al in \ Why do we do this?
[ifdef] intel-chip-stuff
h# 8000.f880 # ax mov h# cf8 # dx mov ax dx out
1
0
Author: wmb
Date: Sat Aug 6 00:36:34 2011
New Revision: 2424
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2424
Log:
svn ignore
Modified:
cpu/x86/pc/alex/build/ (props changed)
1
0
Author: wmb
Date: Sat Aug 6 00:34:19 2011
New Revision: 2423
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2423
Log:
Initial checkin of Makefile for "Alex" ChromeBook.
Added:
cpu/x86/pc/alex/build/Makefile
Added: cpu/x86/pc/alex/build/Makefile
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ cpu/x86/pc/alex/build/Makefile Sat Aug 6 00:34:19 2011 (r2423)
@@ -0,0 +1,24 @@
+OS := $(shell uname)
+
+all: ofw.elf
+
+ofw.elf: FORCE build ../../../build/inflate.bin
+ ./build $@
+
+../../../${OS}/forth:
+ @make -C ../../../${OS} forth
+
+../../../build/inflate.bin:
+ @make -C ../../../build inflate.bin
+
+build: ../../../${OS}/forth
+ @ln -sf ../../../${OS}/forth build
+
+clean:
+ rm -f *.dic *.log headers *~ *.elf *.di *.img builton.fth build
+
+clean-all: clean
+ @make -C ../../../build clean
+ @make -C ../../../${OS} clean
+
+.PHONY: FORCE clean all clean-all
1
0
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(a)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
1
0
Author: wmb
Date: Sat Aug 6 00:29:59 2011
New Revision: 2421
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2421
Log:
New platform directory for "Alex" ChromeBook.
Added:
cpu/x86/pc/alex/
1
0
Author: wmb
Date: Sat Aug 6 00:28:47 2011
New Revision: 2420
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2420
Log:
Removed carriage returns from line endings in a file.
Modified:
dev/intel/graphics/pineview.fth
Modified: dev/intel/graphics/pineview.fth
==============================================================================
--- dev/intel/graphics/pineview.fth Sat Aug 6 00:26:44 2011 (r2419)
+++ dev/intel/graphics/pineview.fth Sat Aug 6 00:28:47 2011 (r2420)
@@ -1,424 +1,424 @@
-\ See license at end of file
-purpose: Display driver for Intel Pineview using 1280x800 LCD panel on LVDS
-
-\ This is an i915 variant. The driver hardcodes some assumptions about display
-\ resolution and output device.
-
-\ 0 0 " 2,0" " /pci" begin-package
-
-" display" device-name
-
-\ Configuration space registers
-my-address my-space encode-phys
- 0 encode-int encode+ 0 encode-int encode+
-
-\ MMIO register bank
-0 0 my-space 0200.0010 + encode-phys encode+
- 0 encode-int encode+ h# 80000 encode-int encode+
-
-\ I/O Space registers
-0 0 my-space h# 0100.0014 + encode-phys encode+
- 0 encode-int encode+ 8 encode-int encode+
-
-\ Aperture
-0 0 my-space h# 0200.0018 + encode-phys encode+
- 0 encode-int encode+ h# 1000.0000 encode-int encode+
-
-\ GATT
-0 0 my-space h# 0200.001c + encode-phys encode+
- 0 encode-int encode+ h# 0004.0000 encode-int encode+
-
- " reg" property
-
-: my-l@ ( offset -- l ) my-space + " config-l@" $call-parent ;
-: my-l! ( l offset -- ) my-space + " config-l!" $call-parent ;
-: my-w@ ( offset -- w ) my-space + " config-w@" $call-parent ;
-: my-w! ( w offset -- ) my-space + " config-w!" $call-parent ;
-
-false value scaled?
-
-d# 16 value depth
-
-0 value vdc
-: page-bits ( n -- n' ) h# fff invert and ;
-
-: pci-len ( bar-offset -- len )
- >r
- r@ my-l@ ( oldval )
- -1 r@ my-l! ( oldval )
- r@ my-l@ ( oldval writable-bits )
- swap r> my-l! ( writable-bits )
- h# f invert and ( top-bits )
- invert 1+ ( len )
-;
-
-0 value gtt
-0 value gatt
-
-0 value gtt-phys
-0 value gatt-phys
-0 value gtt-start
-0 value /gtt
-0 value /gatt
-0 value stolen-base
-0 value scratch-page
-0 value scratch-page-pa
-
-h# 20.0000 value /fb \ Enough for 1280x800x16bpp
-
-: mmio@ ( offset -- l ) vdc + rl@ ;
-: mmio! ( l offset -- ) vdc + rl! ;
-
-: adr>page# ( adr -- page# ) d# 12 rshift ;
-: page#>adr ( page# -- adr ) d# 12 lshift ;
-h# 1000 constant /page
-
-: map-bar ( phys.lo len bar# -- vadr )
- swap >r ( phys.lo bar# r: len )
- my-space + h# 200.0000 + ( phys.lo phys.hi r: len )
- 0 swap r> ( phys.lo,mid,hi len )
- " map-in" $call-parent
-;
-
-: /stolen ( -- n )
- h# 52 my-w@ 4 >> h# f and case
- 0 of 0 endof
- 1 of h# 10.0000 endof
- 3 of h# 80.0000 endof
- true abort" Invalid value in Graphics Mode Select field"
- endcase
-;
-: init-gtt ( -- )
- h# 18 my-l@ page-bits to gatt-phys
- h# 1c my-l@ page-bits to gtt-start
- h# 1c pci-len to /gtt \ Can also be determined from config register 52
- h# 18 pci-len to /gatt
- h# 5c my-l@ to stolen-base
-
- h# 0 /gtt h# 1c map-bar to gtt
-
- \ Insert the stolen pages into the GTT
- stolen-base 1 + ( pte-template )
- /stolen 0 do ( pte-template )
- dup i + gtt i adr>page# la+ rl! ( pte-template )
- /page +loop ( pte-template )
- drop
-
- \ Fill the rest of the GTT with PTEs for a scratch page
- /page " dma-alloc" $call-parent to scratch-page
- scratch-page h# 1000 false " dma-map-in" $call-parent to scratch-page-pa
-
- /gatt /stolen ?do
- scratch-page-pa 1+ gtt i adr>page# la+ rl!
- /page +loop
-
- gtt /gtt + /page - rl@ drop \ Sync
-;
-: memory-setup ( -- )
- h# 0 h# 80000 h# 10 map-bar to vdc \ &
- 4 my-w@ 7 or 4 my-w! \ Enable bus mastering, memory and I/O access
-
- init-gtt
-
- " address" get-my-property if
- gatt-phys encode-int " address" property
- h# 0 /fb h# 18 map-bar to frame-buffer-adr
- else
- decode-int to frame-buffer-adr
- 2drop
- then
-;
-
-\ Geometry for 1280x800 LCD
-
-d# 1280 constant hdisplay
-d# 1296 constant hsstart
-d# 1344 constant hsend
-d# 1440 constant htotal
-
-d# 800 constant vdisplay
-d# 801 constant vsstart
-d# 804 constant vsend
-d# 818 constant vtotal
-
-d# 1024 value width \ If scaled is false, will be replaced with hdisplay
-d# 768 value height \ If scaled is false, will be replaced with vdisplay
-
-\ h# d804.0000 constant dpll-val \ VCO, high speed, VGA disable, LVDS, clock div 10, post div 4
-h# 8480.0000 constant dpll-val-a \ Pipe A &
-h# 9802.0000 constant dpll-val-b \ Pipe B &
-dpll-val-b constant dpll-val
-
-h# 0020.0074 constant fp-val \ N, M1, M2 divisors &
-h# 9500.0000 constant dspcntr-val \ Enable, NoGamma, 16bpp ? no alpha, pipe b &
-
-\ Empirically this has no effect. It is probably for CRT output
-\ : dac-on ( -- )
-\ h# c000.0018 h# 61100 mmio! \ 80000000-DAC_ON 40000000-PIPEB 10-PVSYNC 8-PHSYNC
-\ ;
-
-: bytes/line ( -- n ) width depth 8 / * ;
-
-h# 0000 constant pipe-a
-h# 1000 constant pipe-b
-pipe-b value pipe
-
-: mmio!! ( value offset -- ) tuck mmio! mmio@ drop ;
-
-: pipe@ ( offset -- n ) pipe + mmio@ ;
-: pipe! ( n offset -- ) pipe + mmio! ;
-: pipe!! ( n offset -- ) pipe + mmio!! ;
-
-h# 70180 constant dspcntr-reg
-h# 70184 constant dspbase-reg
-h# 70008 constant pipeconf-reg
-h# 61230 constant pfit-reg
-h# 61180 constant lvds-reg
-
-\ Packs two 16-bit values into a 32-bit register, offsetting
-\ each value by -1
-: crtconf! ( low high reg -- )
- >r swap 1- swap 1- wljoin r> pipe!
-;
-
-\ A few of the pipe-dependent registers are at offsets of 4
-\ instead of h# 1000.
-
-: +pipe ( offset -- offset' ) pipe if 4 + then ;
-
-: fpreg! ( value -- ) h# 6040 +pipe mmio! ;
-
-: dpll! ( value -- )
- h# 6014 +pipe mmio!!
- d# 150 " us" evaluate
-;
-: dpll@ ( -- value ) h# 6014 +pipe mmio@ ;
-: wait-vblank ( -- ) d# 30 ms ;
-
-h# 8000.0000 constant enable-bit
-
-: load-lut ( -- )
- 100 0 do
- i i i 0 bljoin h# a000 pipe 2/ + i la+ l!
- loop
-;
-
-: crtc-dpms-off ( -- ) \ CRTC prepare method
- \ Disable display plane
- dspcntr-reg pipe@ ( val )
- dup enable-bit and if ( val )
- enable-bit invert and dspcntr-reg pipe!
- dspbase-reg pipe@ dspbase-reg pipe!!
- else
- drop
- then
- wait-vblank
-
- \ Disable display pipes
- pipeconf-reg pipe@ ( val )
- dup enable-bit and if ( val )
- enable-bit invert and pipeconf-reg pipe!!
- else
- drop
- then
- wait-vblank
-
- dpll@ dup enable-bit and if
- enable-bit invert and dpll!
- else
- drop
- then
-;
-
-: crtc-dpms-on ( -- ) \ CRTC commit method
- dpll@ dup enable-bit and 0= if ( value )
- dup dpll! ( value )
- enable-bit or dup dpll! dpll! ( )
- else ( value )
- drop ( )
- then
-
- pipeconf-reg pipe@ dup enable-bit and 0= if
- enable-bit or pipeconf-reg pipe!
- else
- drop
- then
-
- dspcntr-reg pipe@ dup enable-bit and if
- enable-bit or dspcntr-reg pipe!
- dspbase-reg pipe@ dspbase-reg pipe!
- else
- drop
- then
-
- load-lut
-;
-
-: lvds-set-mode ( -- )
- \ When using LVDS, you have to do this little dance to turn on the PLL
-
- fp-val fpreg!
- dpll-val enable-bit invert and dpll! \ VCO_ENABLE off for now
-
- lvds-reg mmio@ \ LVDS configuration
- h# c030.0300 or \ LVDS_PORT_EN , LVDS_PIPEB_SELECT , LVDS_A0A2_CLKA_POWER_UP ?? what is 30.0000 bit
- h# 0000.003c invert and \ ! LVDS_CLKB_POWER_UP , ! LVDS_B0B3_POWER_UP
- lvds-reg mmio!!
-
- fp-val fpreg!
- dpll-val dpll! \ VCO_ENABLE on
-
- \ Double write because Linux driver does it because BIOS does it
- dpll-val dpll! \ VCO_ENABLE on
-
- \ Now that the dance is over we can configure the geometry
-
- hdisplay htotal h# 60000 crtconf! \ H Display
- hdisplay htotal h# 60004 crtconf! \ H Blanking
- hsstart hsend h# 60008 crtconf! \ H Sync
- vdisplay vtotal h# 6000c crtconf! \ V Display
- vdisplay vtotal h# 60010 crtconf! \ V Blanking
- vsstart vsend h# 60014 crtconf! \ V Sync
-
- bytes/line h# 70188 pipe! \ Pitch (stride)
- width height h# 70190 crtconf! \ Size
- 0 h# 7018c pipe! \ Position
- height width h# 6001c crtconf! \ Pipe source
- enable-bit pipeconf-reg pipe!! \ Pipe config
-
- wait-vblank
-
- dspcntr-val dspcntr-reg pipe! \ Display control
-
- 0 dspbase-reg pipe! \ PIPExBASE
-
- enable-bit h# 71400 mmio! \ Disable VGA plane
-
- wait-vblank
-;
-
-d# 100 constant backlight-min-period
-false value backlight-inverse?
-: set-backlight ( percentage -- )
- h# 61254 mmio@ lwsplit nip ( percent max )
- backlight-min-period max ( percent max' )
- 1 invert and >r ( percent r: max' )
-
- d# 20 max ( percentage' r: max )
- r@ * d# 100 / ( duty-cycle r: max )
-
- backlight-inverse? if ( duty-cycle r: max )
- r@ swap - ( duty-cycle' )
- then ( duty-cycle r: max )
-
- 1 invert and ( duty-cycle r: max ) \ Low bit must be 0
- r> wljoin h# 61254 mmio! ( ) \ BLC_PWM_CTL
-;
-
-d# 100 value backlight-val
-
-h# 61200 constant pp-status
-h# 61204 constant pp-control
-: lvds-on ( -- )
- pp-control mmio@ 1 or pp-control mmio! \ POWER_TARGET_ON
- begin pp-status mmio@ enable-bit and until
- backlight-val set-backlight
-;
-: lvds-off ( -- )
- 0 set-backlight
- pp-control mmio@ 1 invert and pp-control mmio!
- begin pp-status mmio@ enable-bit and 0= until
-;
-
-: .ps pp-status mmio@ . ;
-: pctl pp-control mmio! ;
-
-: lvds-scaling ( -- )
- scaled? if h# 8000.2668 else 0 then
- pfit-reg mmio!
-\ pipe h# 1000 / d# 29 lshift pfit-reg mmio!
-;
-: setmode ( -- )
- scaled? if d# 1024 d# 768 else hdisplay vdisplay then
- to height to width
- memory-setup
- lvds-off \ Output prepare method
- crtc-dpms-off \ CRTC prepare method
- lvds-set-mode \ CRTC mode_set method
- lvds-scaling \ Output mode_set method
- crtc-dpms-on \ CRTC commit method
- lvds-on \ Output commit method
-;
-
-: erase-frame-buffer ( -- )
- frame-buffer-adr /fb ( adr len )
- depth case
- 8 of h# 0f fill endof
- d# 16 of h# ffff " wfill" evaluate endof
- d# 32 of h# ffff.ffff " lfill" evaluate endof
- ( default ) nip nip
- endcase
- h# f to background-color
-;
-: map-frame-buffer ( -- )
- 0 /fb h# 18 map-bar to frame-buffer-adr
-;
-: dump-regs ( -- )
- h# 80000 0 do
- i mmio@ dup 0<> swap h# ffffffff <> and if
- i 5 u.r i mmio@ 9 u.r cr
- then
- 4 +loop
-;
-
-: declare-props ( -- ) \ Instantiate screen properties
- " width" get-my-property if
- width encode-int " width" property
- height encode-int " height" property
- depth encode-int " depth" property
- bytes/line encode-int " linebytes" property
- else
- 2drop
- then
-;
-
-defer gp-install ' noop to gp-install
-
-: set-terminal ( -- )
- width height ( width height )
- over char-width / over char-height / ( width height rows cols )
- bytes/line depth " fb-install" evaluate gp-install ( )
-;
-
-
-0 value open-count
-
-: display-remove ( -- )
- open-count 1 = if
- then
- open-count 1- 0 max to open-count
-;
-
-: display-install ( -- )
- open-count 0= if
- setmode
- declare-props \ Setup properites
- map-frame-buffer
- erase-frame-buffer
- else
- map-frame-buffer
- then
- default-font set-font
- set-terminal
- open-count 1+ to open-count
-;
-
-: display-selftest ( -- failed? ) false ;
-
-' display-install is-install
-' display-remove is-remove
-' display-selftest is-selftest
-
-" display" device-type
-" ISO8859-1" encode-string " character-set" property
-0 0 encode-bytes " iso6429-1983-colors" property
+\ See license at end of file
+purpose: Display driver for Intel Pineview using 1280x800 LCD panel on LVDS
+
+\ This is an i915 variant. The driver hardcodes some assumptions about display
+\ resolution and output device.
+
+\ 0 0 " 2,0" " /pci" begin-package
+
+" display" device-name
+
+\ Configuration space registers
+my-address my-space encode-phys
+ 0 encode-int encode+ 0 encode-int encode+
+
+\ MMIO register bank
+0 0 my-space 0200.0010 + encode-phys encode+
+ 0 encode-int encode+ h# 80000 encode-int encode+
+
+\ I/O Space registers
+0 0 my-space h# 0100.0014 + encode-phys encode+
+ 0 encode-int encode+ 8 encode-int encode+
+
+\ Aperture
+0 0 my-space h# 0200.0018 + encode-phys encode+
+ 0 encode-int encode+ h# 1000.0000 encode-int encode+
+
+\ GATT
+0 0 my-space h# 0200.001c + encode-phys encode+
+ 0 encode-int encode+ h# 0004.0000 encode-int encode+
+
+ " reg" property
+
+: my-l@ ( offset -- l ) my-space + " config-l@" $call-parent ;
+: my-l! ( l offset -- ) my-space + " config-l!" $call-parent ;
+: my-w@ ( offset -- w ) my-space + " config-w@" $call-parent ;
+: my-w! ( w offset -- ) my-space + " config-w!" $call-parent ;
+
+false value scaled?
+
+d# 16 value depth
+
+0 value vdc
+: page-bits ( n -- n' ) h# fff invert and ;
+
+: pci-len ( bar-offset -- len )
+ >r
+ r@ my-l@ ( oldval )
+ -1 r@ my-l! ( oldval )
+ r@ my-l@ ( oldval writable-bits )
+ swap r> my-l! ( writable-bits )
+ h# f invert and ( top-bits )
+ invert 1+ ( len )
+;
+
+0 value gtt
+0 value gatt
+
+0 value gtt-phys
+0 value gatt-phys
+0 value gtt-start
+0 value /gtt
+0 value /gatt
+0 value stolen-base
+0 value scratch-page
+0 value scratch-page-pa
+
+h# 20.0000 value /fb \ Enough for 1280x800x16bpp
+
+: mmio@ ( offset -- l ) vdc + rl@ ;
+: mmio! ( l offset -- ) vdc + rl! ;
+
+: adr>page# ( adr -- page# ) d# 12 rshift ;
+: page#>adr ( page# -- adr ) d# 12 lshift ;
+h# 1000 constant /page
+
+: map-bar ( phys.lo len bar# -- vadr )
+ swap >r ( phys.lo bar# r: len )
+ my-space + h# 200.0000 + ( phys.lo phys.hi r: len )
+ 0 swap r> ( phys.lo,mid,hi len )
+ " map-in" $call-parent
+;
+
+: /stolen ( -- n )
+ h# 52 my-w@ 4 >> h# f and case
+ 0 of 0 endof
+ 1 of h# 10.0000 endof
+ 3 of h# 80.0000 endof
+ true abort" Invalid value in Graphics Mode Select field"
+ endcase
+;
+: init-gtt ( -- )
+ h# 18 my-l@ page-bits to gatt-phys
+ h# 1c my-l@ page-bits to gtt-start
+ h# 1c pci-len to /gtt \ Can also be determined from config register 52
+ h# 18 pci-len to /gatt
+ h# 5c my-l@ to stolen-base
+
+ h# 0 /gtt h# 1c map-bar to gtt
+
+ \ Insert the stolen pages into the GTT
+ stolen-base 1 + ( pte-template )
+ /stolen 0 do ( pte-template )
+ dup i + gtt i adr>page# la+ rl! ( pte-template )
+ /page +loop ( pte-template )
+ drop
+
+ \ Fill the rest of the GTT with PTEs for a scratch page
+ /page " dma-alloc" $call-parent to scratch-page
+ scratch-page h# 1000 false " dma-map-in" $call-parent to scratch-page-pa
+
+ /gatt /stolen ?do
+ scratch-page-pa 1+ gtt i adr>page# la+ rl!
+ /page +loop
+
+ gtt /gtt + /page - rl@ drop \ Sync
+;
+: memory-setup ( -- )
+ h# 0 h# 80000 h# 10 map-bar to vdc \ &
+ 4 my-w@ 7 or 4 my-w! \ Enable bus mastering, memory and I/O access
+
+ init-gtt
+
+ " address" get-my-property if
+ gatt-phys encode-int " address" property
+ h# 0 /fb h# 18 map-bar to frame-buffer-adr
+ else
+ decode-int to frame-buffer-adr
+ 2drop
+ then
+;
+
+\ Geometry for 1280x800 LCD
+
+d# 1280 constant hdisplay
+d# 1296 constant hsstart
+d# 1344 constant hsend
+d# 1440 constant htotal
+
+d# 800 constant vdisplay
+d# 801 constant vsstart
+d# 804 constant vsend
+d# 818 constant vtotal
+
+d# 1024 value width \ If scaled is false, will be replaced with hdisplay
+d# 768 value height \ If scaled is false, will be replaced with vdisplay
+
+\ h# d804.0000 constant dpll-val \ VCO, high speed, VGA disable, LVDS, clock div 10, post div 4
+h# 8480.0000 constant dpll-val-a \ Pipe A &
+h# 9802.0000 constant dpll-val-b \ Pipe B &
+dpll-val-b constant dpll-val
+
+h# 0020.0074 constant fp-val \ N, M1, M2 divisors &
+h# 9500.0000 constant dspcntr-val \ Enable, NoGamma, 16bpp ? no alpha, pipe b &
+
+\ Empirically this has no effect. It is probably for CRT output
+\ : dac-on ( -- )
+\ h# c000.0018 h# 61100 mmio! \ 80000000-DAC_ON 40000000-PIPEB 10-PVSYNC 8-PHSYNC
+\ ;
+
+: bytes/line ( -- n ) width depth 8 / * ;
+
+h# 0000 constant pipe-a
+h# 1000 constant pipe-b
+pipe-b value pipe
+
+: mmio!! ( value offset -- ) tuck mmio! mmio@ drop ;
+
+: pipe@ ( offset -- n ) pipe + mmio@ ;
+: pipe! ( n offset -- ) pipe + mmio! ;
+: pipe!! ( n offset -- ) pipe + mmio!! ;
+
+h# 70180 constant dspcntr-reg
+h# 70184 constant dspbase-reg
+h# 70008 constant pipeconf-reg
+h# 61230 constant pfit-reg
+h# 61180 constant lvds-reg
+
+\ Packs two 16-bit values into a 32-bit register, offsetting
+\ each value by -1
+: crtconf! ( low high reg -- )
+ >r swap 1- swap 1- wljoin r> pipe!
+;
+
+\ A few of the pipe-dependent registers are at offsets of 4
+\ instead of h# 1000.
+
+: +pipe ( offset -- offset' ) pipe if 4 + then ;
+
+: fpreg! ( value -- ) h# 6040 +pipe mmio! ;
+
+: dpll! ( value -- )
+ h# 6014 +pipe mmio!!
+ d# 150 " us" evaluate
+;
+: dpll@ ( -- value ) h# 6014 +pipe mmio@ ;
+: wait-vblank ( -- ) d# 30 ms ;
+
+h# 8000.0000 constant enable-bit
+
+: load-lut ( -- )
+ 100 0 do
+ i i i 0 bljoin h# a000 pipe 2/ + i la+ l!
+ loop
+;
+
+: crtc-dpms-off ( -- ) \ CRTC prepare method
+ \ Disable display plane
+ dspcntr-reg pipe@ ( val )
+ dup enable-bit and if ( val )
+ enable-bit invert and dspcntr-reg pipe!
+ dspbase-reg pipe@ dspbase-reg pipe!!
+ else
+ drop
+ then
+ wait-vblank
+
+ \ Disable display pipes
+ pipeconf-reg pipe@ ( val )
+ dup enable-bit and if ( val )
+ enable-bit invert and pipeconf-reg pipe!!
+ else
+ drop
+ then
+ wait-vblank
+
+ dpll@ dup enable-bit and if
+ enable-bit invert and dpll!
+ else
+ drop
+ then
+;
+
+: crtc-dpms-on ( -- ) \ CRTC commit method
+ dpll@ dup enable-bit and 0= if ( value )
+ dup dpll! ( value )
+ enable-bit or dup dpll! dpll! ( )
+ else ( value )
+ drop ( )
+ then
+
+ pipeconf-reg pipe@ dup enable-bit and 0= if
+ enable-bit or pipeconf-reg pipe!
+ else
+ drop
+ then
+
+ dspcntr-reg pipe@ dup enable-bit and if
+ enable-bit or dspcntr-reg pipe!
+ dspbase-reg pipe@ dspbase-reg pipe!
+ else
+ drop
+ then
+
+ load-lut
+;
+
+: lvds-set-mode ( -- )
+ \ When using LVDS, you have to do this little dance to turn on the PLL
+
+ fp-val fpreg!
+ dpll-val enable-bit invert and dpll! \ VCO_ENABLE off for now
+
+ lvds-reg mmio@ \ LVDS configuration
+ h# c030.0300 or \ LVDS_PORT_EN , LVDS_PIPEB_SELECT , LVDS_A0A2_CLKA_POWER_UP ?? what is 30.0000 bit
+ h# 0000.003c invert and \ ! LVDS_CLKB_POWER_UP , ! LVDS_B0B3_POWER_UP
+ lvds-reg mmio!!
+
+ fp-val fpreg!
+ dpll-val dpll! \ VCO_ENABLE on
+
+ \ Double write because Linux driver does it because BIOS does it
+ dpll-val dpll! \ VCO_ENABLE on
+
+ \ Now that the dance is over we can configure the geometry
+
+ hdisplay htotal h# 60000 crtconf! \ H Display
+ hdisplay htotal h# 60004 crtconf! \ H Blanking
+ hsstart hsend h# 60008 crtconf! \ H Sync
+ vdisplay vtotal h# 6000c crtconf! \ V Display
+ vdisplay vtotal h# 60010 crtconf! \ V Blanking
+ vsstart vsend h# 60014 crtconf! \ V Sync
+
+ bytes/line h# 70188 pipe! \ Pitch (stride)
+ width height h# 70190 crtconf! \ Size
+ 0 h# 7018c pipe! \ Position
+ height width h# 6001c crtconf! \ Pipe source
+ enable-bit pipeconf-reg pipe!! \ Pipe config
+
+ wait-vblank
+
+ dspcntr-val dspcntr-reg pipe! \ Display control
+
+ 0 dspbase-reg pipe! \ PIPExBASE
+
+ enable-bit h# 71400 mmio! \ Disable VGA plane
+
+ wait-vblank
+;
+
+d# 100 constant backlight-min-period
+false value backlight-inverse?
+: set-backlight ( percentage -- )
+ h# 61254 mmio@ lwsplit nip ( percent max )
+ backlight-min-period max ( percent max' )
+ 1 invert and >r ( percent r: max' )
+
+ d# 20 max ( percentage' r: max )
+ r@ * d# 100 / ( duty-cycle r: max )
+
+ backlight-inverse? if ( duty-cycle r: max )
+ r@ swap - ( duty-cycle' )
+ then ( duty-cycle r: max )
+
+ 1 invert and ( duty-cycle r: max ) \ Low bit must be 0
+ r> wljoin h# 61254 mmio! ( ) \ BLC_PWM_CTL
+;
+
+d# 100 value backlight-val
+
+h# 61200 constant pp-status
+h# 61204 constant pp-control
+: lvds-on ( -- )
+ pp-control mmio@ 1 or pp-control mmio! \ POWER_TARGET_ON
+ begin pp-status mmio@ enable-bit and until
+ backlight-val set-backlight
+;
+: lvds-off ( -- )
+ 0 set-backlight
+ pp-control mmio@ 1 invert and pp-control mmio!
+ begin pp-status mmio@ enable-bit and 0= until
+;
+
+: .ps pp-status mmio@ . ;
+: pctl pp-control mmio! ;
+
+: lvds-scaling ( -- )
+ scaled? if h# 8000.2668 else 0 then
+ pfit-reg mmio!
+\ pipe h# 1000 / d# 29 lshift pfit-reg mmio!
+;
+: setmode ( -- )
+ scaled? if d# 1024 d# 768 else hdisplay vdisplay then
+ to height to width
+ memory-setup
+ lvds-off \ Output prepare method
+ crtc-dpms-off \ CRTC prepare method
+ lvds-set-mode \ CRTC mode_set method
+ lvds-scaling \ Output mode_set method
+ crtc-dpms-on \ CRTC commit method
+ lvds-on \ Output commit method
+;
+
+: erase-frame-buffer ( -- )
+ frame-buffer-adr /fb ( adr len )
+ depth case
+ 8 of h# 0f fill endof
+ d# 16 of h# ffff " wfill" evaluate endof
+ d# 32 of h# ffff.ffff " lfill" evaluate endof
+ ( default ) nip nip
+ endcase
+ h# f to background-color
+;
+: map-frame-buffer ( -- )
+ 0 /fb h# 18 map-bar to frame-buffer-adr
+;
+: dump-regs ( -- )
+ h# 80000 0 do
+ i mmio@ dup 0<> swap h# ffffffff <> and if
+ i 5 u.r i mmio@ 9 u.r cr
+ then
+ 4 +loop
+;
+
+: declare-props ( -- ) \ Instantiate screen properties
+ " width" get-my-property if
+ width encode-int " width" property
+ height encode-int " height" property
+ depth encode-int " depth" property
+ bytes/line encode-int " linebytes" property
+ else
+ 2drop
+ then
+;
+
+defer gp-install ' noop to gp-install
+
+: set-terminal ( -- )
+ width height ( width height )
+ over char-width / over char-height / ( width height rows cols )
+ bytes/line depth " fb-install" evaluate gp-install ( )
+;
+
+
+0 value open-count
+
+: display-remove ( -- )
+ open-count 1 = if
+ then
+ open-count 1- 0 max to open-count
+;
+
+: display-install ( -- )
+ open-count 0= if
+ setmode
+ declare-props \ Setup properites
+ map-frame-buffer
+ erase-frame-buffer
+ else
+ map-frame-buffer
+ then
+ default-font set-font
+ set-terminal
+ open-count 1+ to open-count
+;
+
+: display-selftest ( -- failed? ) false ;
+
+' display-install is-install
+' display-remove is-remove
+' display-selftest is-selftest
+
+" display" device-type
+" ISO8859-1" encode-string " character-set" property
+0 0 encode-bytes " iso6429-1983-colors" property
1
0
Author: wmb
Date: Sat Aug 6 00:26:44 2011
New Revision: 2419
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2419
Log:
Fixed backlight control for Intel Pineview display driver.
Modified:
dev/intel/graphics/pineview.fth
Modified: dev/intel/graphics/pineview.fth
==============================================================================
--- dev/intel/graphics/pineview.fth Sat Aug 6 00:25:44 2011 (r2418)
+++ dev/intel/graphics/pineview.fth Sat Aug 6 00:26:44 2011 (r2419)
@@ -297,15 +297,20 @@
wait-vblank
;
+d# 100 constant backlight-min-period
false value backlight-inverse?
: set-backlight ( percentage -- )
h# 61254 mmio@ lwsplit nip ( percent max )
+ backlight-min-period max ( percent max' )
1 invert and >r ( percent r: max' )
+
d# 20 max ( percentage' r: max )
r@ * d# 100 / ( duty-cycle r: max )
+
backlight-inverse? if ( duty-cycle r: max )
r@ swap - ( duty-cycle' )
then ( duty-cycle r: max )
+
1 invert and ( duty-cycle r: max ) \ Low bit must be 0
r> wljoin h# 61254 mmio! ( ) \ BLC_PWM_CTL
;
1
0
Author: wmb
Date: Sat Aug 6 00:25:44 2011
New Revision: 2418
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2418
Log:
Additional file checkin for GUID Partition Table support.
Modified:
ofw/disklabel/common.fth
Modified: ofw/disklabel/common.fth
==============================================================================
--- ofw/disklabel/common.fth Sat Aug 6 00:24:56 2011 (r2417)
+++ ofw/disklabel/common.fth Sat Aug 6 00:25:44 2011 (r2418)
@@ -8,8 +8,10 @@
h# 83 constant ext2fs-type
h# a5 constant ufs-type
h# 96 constant iso-type
+h# ee constant gpt-type
0 value ufs-partition
+0 0 instance 2value partition-name$
0 instance value #part
0 instance value /sector \ Set in open by calling parent's block-size method
1
0
Author: wmb
Date: Sat Aug 6 00:24:56 2011
New Revision: 2417
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2417
Log:
Added coreboot filesystem support package.
Added:
ofw/fs/cbfs.fth
Added: ofw/fs/cbfs.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ ofw/fs/cbfs.fth Sat Aug 6 00:24:56 2011 (r2417)
@@ -0,0 +1,249 @@
+purpose: Coreboot filesystem ("CBFS") package
+\ See license at end of file
+
+h# ffc0.0000 value flash-base
+: .cbfs-type ( type -- )
+ case
+ h# 10 of ." stage" endof
+ h# 20 of ." payload" endof
+ h# 30 of ." optionrom" endof
+ h# 40 of ." bootsplash" endof
+ h# 50 of ." raw" endof
+ h# 51 of ." vsa" endof
+ h# 52 of ." mbi" endof
+ h# 53 of ." microcode" endof
+ h# aa of ." cmos_default" endof
+ h# 1aa of ." cmos_layout" endof
+ -1 of ." unused" endof
+ ( default ) dup push-hex d# 12 u.r pop-base
+ endcase
+;
+\ 0,1 magic 2 length 3 type 4 checksum 5 offset 6+ name\0
+: .cbfs ( -- )
+ ." Address Length Type Name" cr
+ flash-base
+ begin dup be-l@ h# 4c415243 = while ( adr )
+ push-hex ( adr )
+ dup dup 5 la+ be-l@ + 8 u.r space ( adr )
+ dup 2 la+ be-l@ 8 u.r space ( adr )
+ pop-base ( adr )
+ dup 3 la+ be-l@ .cbfs-type space ( adr )
+ dup 6 la+ cscount type cr ( adr )
+ dup 2 la+ be-l@ ( adr len )
+ over 5 la+ be-l@ ( adr len offset )
+ + + h# 40 round-up ( adr' )
+ repeat ( adr )
+ drop
+;
+
+support-package: cbfs-file-system
+
+headerless
+0 instance value image-size
+0 value open-count
+0 instance value seek-ptr
+0 instance value offset
+
+: clip-size ( adr len -- adr len' )
+ seek-ptr + image-size umin seek-ptr -
+;
+: update-ptr ( len' -- len' ) dup seek-ptr + to seek-ptr ;
+
+d# 255 instance buffer: pathbuf
+: fix-delims ( adr len -- adr' len' )
+ pathbuf pack count 2dup
+ bounds ?do ( adr len )
+ i c@ dup [char] | = swap [char] \ = or if [char] / i c! then
+ loop
+;
+
+headers
+external
+: seek ( d.offset -- status )
+ 0<> over image-size u> or if drop true exit then \ Seek offset too big
+ to seek-ptr
+ seek-ptr offset + 0 " seek" $call-parent
+;
+: size ( -- d.size ) image-size u>d ;
+: read ( adr len -- actual )
+ clip-size ( adr len' )
+ " read" $call-parent ( len' )
+ update-ptr ( len' )
+;
+
+headers
+d# 24 d# 64 + instance buffer: cbfs-hdr \ should be large enough
+
+d# 64 instance buffer: saved-name
+
+: cbfield \ name ( offset -- adr )
+ create over , + does> @ cbfs-hdr +
+;
+
+struct
+ 8 cbfield cb-magic \ 4c415243 48495645
+ /l cbfield cb-length \ Data length in bytes
+ /l cbfield cb-type \ Image type
+ /l cbfield cb-sum \ Checksum
+ /l cbfield cb-offset \ Offset to data
+ 0 cbfield cb-name \ Name
+constant /cb-hdr \ Size of header excluding name
+
+: cbfs-name$ ( -- adr len ) cb-name cscount ;
+
+\ ID of the header that's currently in the buffer
+-1 instance value header-id
+
+external
+: load ( adr -- len )
+ 0. seek drop ( adr )
+ image-size read ( len )
+ \ XXX should verify the checksum
+;
+
+headers
+: file-header? ( id -- id flag )
+ -1 to header-id ( id )
+ dup u>d seek drop ( id )
+ cb-magic 8 read drop ( id )
+ cb-magic " "(4c41524348495645)" comp 0= ( id adr )
+;
+: read-file-header ( -- )
+ cb-length h# 10 read drop ( id )
+ cb-name cb-offset be-l@ h# 18 - read drop ( id )
+;
+: get-file-header? ( id' -- id flag )
+ dup header-id = if true exit then ( id )
+ file-header? if ( id )
+ dup to header-id ( id )
+ read-file-header ( id )
+ true ( id true )
+ else ( id )
+ false ( false )
+ then ( id )
+;
+
+: +file ( id -- id' )
+ cb-length be-l@ + ( id' )
+ cb-offset be-l@ + ( id' )
+ h# 40 round-up ( id' )
+;
+
+: first-file-header ( -- false | id true )
+ d# 2000 0 do
+ i get-file-header? if +file true unloop exit else drop then ( )
+ loop
+ 0
+;
+
+: another-file? ( id -- false | id' true )
+ ?dup if ( id ) \ Not the first call
+ get-file-header? 0= if ( )
+ false exit
+ then ( id ) \ Get the old header into the buffer
+ +file ( id' ) \ Skip the old header
+ get-file-header? ( false | id true ) \ Get the new header
+ else ( )
+ first-file-header ( false | id' true )
+ then ( false | id' true )
+;
+
+\ When found, cbfs-hdr contains the file header
+: find-file ( name$ -- found? )
+ 0 ( name$ id )
+ begin another-file? while ( name$ id )
+ 2 pick 2 pick ( name$ id name$ )
+ cbfs-name$ $= if ( name$ id )
+ 3drop true ( true )
+ exit
+ then ( name$ id )
+ repeat ( name$ )
+ 2drop false ( false )
+;
+
+\ Called after find-file has located the file header.
+\ Adjusts offset and image-size so subsequent seeks and reads
+\ apply only to that file's data.
+: select-file-data ( -- okay? )
+ header-id cb-offset be-l@ + to offset ( )
+ cb-length be-l@ to image-size ( )
+ 0. seek drop ( )
+ true ( true )
+;
+
+: resolve-path
+ find-file if ( )
+ select-file-data ( flag )
+ else ( )
+ false ( false )
+ then ( flag )
+;
+
+external
+: open ( -- flag )
+ -1 to image-size 0 to offset
+ my-args fix-delims 2dup " /" $= if ( adr len )
+ 2drop ( )
+ true exit ( true )
+ else ( adr len )
+ over c@ [char] / = if 1 /string then ( adr' len' )
+ resolve-path ( flag )
+ exit ( flag )
+ then ( adr len )
+ 2drop false ( false )
+;
+: close ( -- ) ;
+
+: next-file-info ( id -- false | id' s m h d m y len attributes name$ true )
+ begin another-file? while ( id' )
+ cb-type be-l@ h# ffffffff <> if ( id )
+ " built-time-int" $find if ( id s m h xt )
+ execute ( id s m h packed-date )
+ d# 100 /mod d# 100 /mod ( id s m h d m y )
+ else ( id s m h adr len )
+ 2drop 0 0 0 ( id s m h d m y )
+ then ( id s m h d m y )
+ " built-date-int" $find if ( id s m h xt )
+ execute ( id s m h packed-date )
+ d# 100 /mod d# 100 /mod ( id s m h d m y )
+ else ( id s m h adr len )
+ 2drop 0 0 0 ( id s m h d m y )
+ then ( id s m h d m y )
+ cb-length be-l@ ( id s m h d m y size )
+ o# 555 h# 8000 or \ Ordinary,r-x ( id s m h d m y size attributes )
+ cbfs-name$ saved-name $save ( id s m h d m y size attr name$ )
+ true ( id s m h d m y size attr name$ true )
+ exit
+ then ( id )
+ repeat ( id )
+ drop ( )
+ false ( false )
+;
+
+: free-bytes ( -- d.#bytes ) 0. ;
+
+end-support-package
+
+\ 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
1
0
Aug. 5, 2011
Author: wmb
Date: Sat Aug 6 00:23:50 2011
New Revision: 2416
URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2416
Log:
Added GIUD Partition Table support.
Added:
ofw/disklabel/gpt.fth
ofw/disklabel/gpttools.fth
ofw/disklabel/showgpt.fth
Modified:
cpu/arm/basefw.bth
cpu/x86/basefw.bth
ofw/disklabel/loadpkg.fth
ofw/disklabel/methods.fth
ofw/fs/fatfs/fdisk2.fth
ofw/fs/fatfs/partition.fth
Modified: cpu/arm/basefw.bth
==============================================================================
--- cpu/arm/basefw.bth Fri Aug 5 03:16:10 2011 (r2415)
+++ cpu/arm/basefw.bth Sat Aug 6 00:23:50 2011 (r2416)
@@ -66,12 +66,12 @@
fload ${BP}/ofw/fs/cdfs/loadpkg.fth \ ISO 9660 CD-ROM file system reader
end-support-package
+fload ${BP}/ofw/disklabel/gpttools.fth
+
support-package: disk-label
fload ${BP}/ofw/disklabel/loadpkg.fth \ Disk label package
end-support-package
-[then]
-[ifdef] resident-packages
fload ${BP}/ofw/fs/fatfs/fdisk2.fth \ Partition map administration
[else]
autoload: fdisk2.fth
Modified: cpu/x86/basefw.bth
==============================================================================
--- cpu/x86/basefw.bth Fri Aug 5 03:16:10 2011 (r2415)
+++ cpu/x86/basefw.bth Sat Aug 6 00:23:50 2011 (r2416)
@@ -105,6 +105,8 @@
end-support-package
[then]
+fload ${BP}/ofw/disklabel/gpttools.fth
+
support-package: disk-label
fload ${BP}/ofw/disklabel/loadpkg.fth \ Disk label package
end-support-package
Added: ofw/disklabel/gpt.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ ofw/disklabel/gpt.fth Sat Aug 6 00:23:50 2011 (r2416)
@@ -0,0 +1,74 @@
+: gpt? ( -- flag )
+ sector-buf h# 1fe + le-w@ h# aa55 <> if false exit then
+ sector-buf h# 1c2 + c@ gpt-type =
+;
+
+\ Tasks:
+\ Choose a partition based on part# and partition-name$
+\ Set sector-offset, size-low, size-high, and partition-type
+
+-1 value the-sector
+: get-gpt-info ( -- error? )
+ 1 read-hw-sector ( )
+ sector-buf gpt-magic comp if true exit then
+ \ XXX should verify CRC
+ sector-buf d# 72 + le-x@ to partition-lba0
+ sector-buf d# 80 + le-l@ to #gpt-partitions
+ sector-buf d# 84 + le-l@ to /gpt-entry
+ -1 to the-sector
+ false
+;
+: read-gpt-sector ( sector# -- )
+ dup the-sector = if drop exit then ( sector# )
+ dup to the-sector ( sector# )
+ read-hw-sector
+;
+
+: select-gpt-partition ( adr -- )
+ dup gpt-blk0 x>u to sector-offset ( adr )
+ gpt-#blks /sector xu*d to size-high to size-low ( )
+;
+
+: partition-name= ( adr -- flag )
+ d# 56 + ( utf16-name-adr )
+ partition-name$ bounds ?do ( utf16-name-adr )
+ dup w@ i c@ <> if ( utf16-name-adr )
+ drop false unloop exit ( -- false )
+ then ( utf16-name-adr )
+ wa1+ ( utf16-name-adr' )
+ loop ( utf16-name-adr )
+ w@ 0= ( flag )
+;
+
+: >gpt-entry ( n -- adr )
+ /gpt-entry * ( offset )
+ /sector /mod ( rem quot )
+ partition-lba0 x>u + ( rem sector# )
+ read-gpt-sector ( rem )
+ sector-buf + ( adr )
+;
+: nth-gpt-partition ( n -- )
+ 1- >gpt-entry select-gpt-partition ( )
+;
+: gpt-active? ( adr -- flag ) d# 16 0 bskip 0<> ;
+
+: named-gpt-partition ( -- )
+ #gpt-partitions 0 ?do
+ i >gpt-entry ( adr )
+ dup gpt-active? if ( adr )
+ dup partition-name= if ( adr )
+ select-gpt-partition ( )
+ leave ( )
+ then ( adr )
+ then ( adr )
+ drop ( )
+ loop ( )
+;
+: gpt-map ( -- )
+ get-gpt-info abort" Invalid GUID Partition Table"
+ #part 1 >= if
+ #part nth-gpt-partition
+ else
+ named-gpt-partition
+ then
+;
Added: ofw/disklabel/gpttools.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ ofw/disklabel/gpttools.fth Sat Aug 6 00:23:50 2011 (r2416)
@@ -0,0 +1,20 @@
+32\ : le-x@ ( adr -- x ) dup le-l@ swap la1+ le-l@ ;
+0 value #gpt-partitions
+0 value /gpt-entry
+32\ 0. 2value partition-lba0
+32\ alias x>u drop
+32\ alias u>x u>d
+32\ alias x+ d+
+32\ alias x- d-
+32\ alias xswap 2swap
+32\ : onex 1. ;
+: du* ( d1 u -- d2 )
+ tuck u* >r ( d1.lo u r: d2.hi )
+ um* 0 r> d+ ( d2 )
+;
+32\ : xu*d ( x u -- d ) du* ;
+64\ alias xu*d um*
+
+: gpt-magic ( -- adr len ) " EFI PART" ;
+: gpt-blk0 ( adr -- d.blk0 ) d# 32 + le-x@ ;
+: gpt-#blks ( adr -- d.blks ) dup d# 40 + le-x@ rot gpt-blk0 x- onex d+ ;
Modified: ofw/disklabel/loadpkg.fth
==============================================================================
--- ofw/disklabel/loadpkg.fth Fri Aug 5 03:16:10 2011 (r2415)
+++ ofw/disklabel/loadpkg.fth Sat Aug 6 00:23:50 2011 (r2416)
@@ -12,6 +12,7 @@
[ifdef] hfs-support
fload ${BP}/ofw/fs/macfs/partition.fth
[then]
+fload ${BP}/ofw/disklabel/gpt.fth
fload ${BP}/ofw/disklabel/methods.fth
\ LICENSE_BEGIN
Modified: ofw/disklabel/methods.fth
==============================================================================
--- ofw/disklabel/methods.fth Fri Aug 5 03:16:10 2011 (r2415)
+++ ofw/disklabel/methods.fth Sat Aug 6 00:23:50 2011 (r2416)
@@ -80,6 +80,8 @@
mac-disk? if mac-map exit then
[then]
+ gpt? if gpt-map exit then
+
fdisk? if fdisk-map exit then
\ We check for ISO 9660 after the ones above, because they can be
@@ -162,6 +164,7 @@
\ <digit>: FDISK partition number
\ <letter>: UFS partition letter (a..h)
\ <digit><letter>: UFS partition embedded within FDISK partition
+\ -<decimal-digits>: The last N blocks of the disk
\ partition# is one of:
\ -1, meaning the default partition, i.e. no partition was specified
@@ -171,15 +174,26 @@
\ In addition, ufs-partition is set to the UFS partition letter (a..h)
\ if the string appears to contain a letter.
-: parse-partition ( -- )
- null$ to filename -1 to #part 0 to ufs-partition
+: decode-partition ( adr len -- rem$ )
+ \ If the string parses as a decimal number, it's a partition# if
+ \ positive or the last N blocks if negative
+ 2dup push-decimal $number pop-base 0= if ( adr len n )
+ dup 0< if ( adr len n )
+ /sector um* ( adr len d.partition-size )
+ get-disk-size size-low size-high ( adr len d.partition-size d.disk-size )
+ 2over d- /sector um/mod nip ( adr len d.partition-size partition-sector )
+ to sector-offset ( adr len d.partition-size )
+ to size-high to size-low ( adr len )
+ -2 to #part ( adr len ) \ Tell select-partition
+ else ( adr len n )
+ to #part ( adr len )
+ then ( adr len )
+ drop 0 ( adr 0 )
+ exit ( rem$ -- )
+ then ( adr len )
- my-args ( adr len )
-
- \ An empty arg string is treated as a null partition and a null filename
- dup 0= if 2drop exit then ( adr len )
-
- \ If the first character of the string is a digit, it's a partition #
+ \ If the first character of the string is a decimal number, it's a partition #,
+ \ possibly followed by UFS partition letter
over c@ ascii 0 ascii 9 between if ( adr len )
over c@ ascii 0 - to #part ( adr len )
1 /string ( adr' len' )
@@ -192,28 +206,24 @@
1 /string ( adr' len' )
dup 0= if 2drop exit then ( adr len )
then ( adr len )
+;
+: parse-partition ( -- )
+ null$ to filename null$ to partition-name$ -1 to #part 0 to ufs-partition
- \ If the first character is "-", it is followed by a decimal number N and
- \ the "partition" is the last N blocks
- over c@ ascii - = if ( adr len )
- 1 /string ( adr' len' )
- push-decimal $number pop-base if ( )
- ." Bad decimal number after '-' in partition spec" cr
- exit
- then ( n )
- /sector um* ( d.partition-size )
- get-disk-size size-low size-high ( d.partition-size d.disk-size )
- 2over d- /sector um/mod nip ( d.partition-size partition-sector )
- to sector-offset ( d.partition-size )
- to size-high to size-low ( )
- -2 to #part ( ) \ Tell select-partition
- exit
- then ( adr len )
+ my-args ( adr len )
- \ If the first character of the string is ",", discard it
- over c@ ascii , = if ( adr len )
- 1 /string ( adr' len' )
- then ( adr' len' )
+ \ An empty arg string is treated as a null partition and a null filename
+ dup 0= if 2drop exit then ( adr len )
+
+ \ If the string contains a comma, the first half is the partition name
+ " ," lex if ( tail$ head$ delim )
+ drop 2dup to partition-name$ ( tail$ head$ )
+ decode-partition 2drop ( tail$ )
+ to filename ( )
+ exit ( -- )
+ then ( adr len )
+
+ decode-partition ( rem$ )
\ The remainder of the string, if any, is the filename
to filename
@@ -239,7 +249,7 @@
: close ( -- ) sector-buf if sector-buf /sector free-mem then ;
: size ( -- d ) size-low size-high ;
: load ( adr -- len )
- \ This load method is used only for type 41 partitions
+ \ This load method is used only for type 41 (IBM "PREP") partitions
partition-type h# 41 <> if drop 0 exit then
0 0 " seek" $call-parent drop ( adr )
Added: ofw/disklabel/showgpt.fth
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ ofw/disklabel/showgpt.fth Sat Aug 6 00:23:50 2011 (r2416)
@@ -0,0 +1,180 @@
+\ See license at end of file
+purpose: GUID Partition Table handler
+
+d# 512 value /gpt-sector
+
+32\ : read-gpt-sector ( x.lba# -- )
+32\ drop /gpt-sector um* " seek" disk-dev $call-method drop
+32\ sector-buf /gpt-sector " read" disk-dev $call-method drop
+32\ ;
+0 value gpt-entries/sector
+
+-1 value this-sector
+: get-gpt-entry ( partition# -- adr )
+ gpt-entries/sector /mod ( rem quot )
+ dup this-sector <> if ( rem quot )
+ dup to this-sector ( rem quot )
+ u>x partition-lba0 x+ ( rem lba# )
+ read-gpt-sector ( rem )
+ else ( rem quot )
+ drop ( rem )
+ then ( rem )
+ /gpt-entry * sector-buf + ( adr )
+;
+: .gpt-bounds ( adr -- )
+ push-hex
+ dup gpt-blk0 d# 12 ud.r space ( adr )
+ gpt-#blks d# 10 ud.r space ( )
+ pop-base ( )
+;
+: utf16-emit ( w -- )
+ wbsplit if
+ \ Emit "?" for code points we can't handle
+ drop ." ?"
+ else
+ \ Don't emit nulls
+ ?dup if emit then
+ then
+;
+: .gpt-name ( adr -- )
+ d# 56 + d# 72 bounds do
+ i w@ utf16-emit
+ /w +loop
+;
+string-array partition-type-guids
+," 00000000-0000-0000-0000-000000000000" ," Unused entry"
+," 024DEE41-33E7-11D3-9D69-0008C781F39F" ," MBR scheme"
+," C12A7328-F81F-11D2-BA4B-00A0C93EC93B" ," EFI System"
+," 21686148-6449-6E6F-744E-656564454649" ," BIOS Boot"
+," E3C9E316-0B5C-4DB8-817D-F92DF00215AE" ," Windows Reserved"
+," EBD0A0A2-B9E5-4433-87C0-68B6B72699C7" ," Windows Basic data"
+," 5808C8AA-7E8F-42E0-85D2-E1E90434CFB3" ," Windows LDM metadata"
+," AF9B60A0-1431-4F62-BC68-3311714A69AD" ," Windows LDM data"
+," DE94BBA4-06D1-4D40-A16A-BFD50179D6AC" ," Windows Recovery Environment"
+," 37AFFC90-EF7D-4E96-91C3-2D7AE055B174" ," Windows IBM GPFS"
+," 75894C1E-3AEB-11D3-B7C1-7B03A0000000" ," HP-UX Data"
+," E2A1E728-32E3-11D6-A682-7B03A0000000" ," HP-UX Service"
+," 0FC63DAF-8483-4772-8E79-3D69D8477DE4" ," Linux filesystem data"
+," A19D880F-05FC-4D3B-A006-743F0F84911E" ," Linux RAID"
+," 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F" ," Linux Swap"
+," E6D6D379-F507-44C2-A23C-238F2A3DF928" ," Linux LVM"
+," 8DA63339-0007-60C0-C436-083AC8230908" ," Linux Reserved"
+," 83BD6B9D-7F41-11DC-BE0B-001560B84F0F" ," FreeBSD Boot"
+," 516E7CB4-6ECF-11D6-8FF8-00022D09712B" ," FreeBSD Data"
+," 516E7CB5-6ECF-11D6-8FF8-00022D09712B" ," FreeBSD Swap"
+," 516E7CB6-6ECF-11D6-8FF8-00022D09712B" ," FreeBSD UFS"
+," 516E7CB8-6ECF-11D6-8FF8-00022D09712B" ," FreeBSD Vinum volume manager"
+," 516E7CBA-6ECF-11D6-8FF8-00022D09712B" ," FreeBSD ZFS"
+," 48465300-0000-11AA-AA11-00306543ECAC" ," Apple HFS+"
+," 55465300-0000-11AA-AA11-00306543ECAC" ," Apple UFS"
+," 6A898CC3-1DD2-11B2-99A6-080020736631" ," Apple ZFS"
+," 52414944-0000-11AA-AA11-00306543ECAC" ," Apple RAID"
+," 52414944-5F4F-11AA-AA11-00306543ECAC" ," Apple RAID offline"
+," 426F6F74-0000-11AA-AA11-00306543ECAC" ," Apple Boot"
+," 4C616265-6C00-11AA-AA11-00306543ECAC" ," Apple Label"
+," 5265636F-7665-11AA-AA11-00306543ECAC" ," Apple TV Recovery"
+," 6A82CB45-1DD2-11B2-99A6-080020736631" ," Solaris Boot"
+," 6A85CF4D-1DD2-11B2-99A6-080020736631" ," Solaris Root"
+," 6A87C46F-1DD2-11B2-99A6-080020736631" ," Solaris Swap"
+," 6A8B642B-1DD2-11B2-99A6-080020736631" ," Solaris Backup"
+," 6A898CC3-1DD2-11B2-99A6-080020736631" ," Solaris /usr"
+," 6A8EF2E9-1DD2-11B2-99A6-080020736631" ," Solaris /var"
+," 6A90BA39-1DD2-11B2-99A6-080020736631" ," Solaris /home"
+," 6A9283A5-1DD2-11B2-99A6-080020736631" ," Solaris Alternate sector"
+," 6A945A3B-1DD2-11B2-99A6-080020736631" ," Solaris Reserved"
+," 6A9630D1-1DD2-11B2-99A6-080020736631" ," Solaris Reserved"
+," 6A980767-1DD2-11B2-99A6-080020736631" ," Solaris Reserved"
+," 6A96237F-1DD2-11B2-99A6-080020736631" ," Solaris Reserved"
+," 6A8D2AC7-1DD2-11B2-99A6-080020736631" ," Solaris Reserved"
+," 49F48D32-B10E-11DC-B99B-0019D1879648" ," NetBSD Swap"
+," 49F48D5A-B10E-11DC-B99B-0019D1879648" ," NetBSD FFS"
+," 49F48D82-B10E-11DC-B99B-0019D1879648" ," NetBSD LFS"
+," 49F48DAA-B10E-11DC-B99B-0019D1879648" ," NetBSD RAID"
+," 2DB519C4-B10F-11DC-B99B-0019D1879648" ," NetBSD Concatenated"
+," 2DB519EC-B10F-11DC-B99B-0019D1879648" ," NetBSD Encrypted"
+," FE3A2A5D-4F32-41A7-B725-ACCC3285A309" ," ChromeOS kernel"
+," 3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC" ," ChromeOS rootfs"
+," 2E0A753D-9E48-43B0-8337-B15192CB1B5E" ," ChromeOS future-use"
+end-string-array
+
+\ Convert the binary encoding of a GUID to the text encoding
+\ The first three components are in native byte order - which I think
+\ means little-endian for GPT GUIDs. The last two components are big-endian.
+d# 36 buffer: 'guid
+
+: >guid$ ( adr -- adr len )
+ push-hex ( adr )
+ dup le-l@ (.8) 'guid swap move
+
+ [char] - 'guid 8 + c!
+ dup 4 + le-w@ (.4) 'guid d# 9 + swap move
+
+ [char] - 'guid d# 13 + c!
+ dup 6 + le-w@ (.4) 'guid d# 14 + swap move
+
+ [char] - 'guid d# 18 + c!
+ dup 8 + be-w@ (.4) 'guid d# 19 + swap move
+
+ [char] - 'guid d# 23 + c!
+ d# 10 + ( adr )
+ 6 0 do ( adr )
+ dup i + c@ (.2) ( adr $ )
+ 'guid d# 24 + i wa+ swap move ( adr )
+ loop ( adr )
+ drop ( )
+
+ pop-base ( )
+
+ 'guid d# 36 2dup upper ( adr len )
+;
+
+: .gpt-type ( adr -- )
+ >guid$ 2>r 0 ( string# r: guid$ )
+ begin ( string# r: guid$ )
+ dup ['] partition-type-guids ( string# string# xt r: guid$ )
+ catch 0= while ( string# 'this r: guid$ )
+ count 2r@ $= if ( string# r: guid$ )
+ 1+ partition-type-guids count type ( r: guid$ )
+ 2r> 2drop exit ( -- )
+ then ( string# r: guid$ )
+ 2+ ( string#' r: guid$ )
+ repeat ( string# x r: guid$ )
+ 2r> type ( string# x )
+ 2drop ( )
+;
+
+: .gpt-partition ( adr # -- )
+ \ Skip unused entries
+ over 8 0 bskip 0= if 2drop exit then ( adr i )
+ push-decimal 2 u.r space pop-base ( adr )
+ dup .gpt-bounds ( adr )
+ dup .gpt-name ( adr )
+\ dup .gpt-guid ( adr )
+ d# 50 to-column ( adr )
+ dup .gpt-type ( adr )
+ drop cr ( )
+;
+: .gpt-partitions ( -- )
+ cr
+ ." # FirstBlk NumBlks Name Type" cr
+ ." - -------- ------- ---- ----" cr
+ #gpt-partitions 0 do ( )
+ i get-gpt-entry i 1+ .gpt-partition ( )
+ loop ( )
+;
+: .gpt ( -- )
+ onex read-gpt-sector
+ sector-buf gpt-magic comp if
+ ." Bad signature in GUID partition table header" cr
+ exit
+ then
+ push-hex
+\ ." FirstBlk: " sector-buf d# 40 le-x@ d.
+\ ." LastBlk: " sector-buf d# 48 le-x@ d.
+ pop-base
+ sector-buf d# 72 + le-x@ to partition-lba0
+ sector-buf d# 80 + le-l@ to #gpt-partitions
+ sector-buf d# 84 + le-l@ to /gpt-entry
+ /gpt-sector /gpt-entry / to gpt-entries/sector
+ .gpt-partitions
+;
Modified: ofw/fs/fatfs/fdisk2.fth
==============================================================================
--- ofw/fs/fatfs/fdisk2.fth Fri Aug 5 03:16:10 2011 (r2415)
+++ ofw/fs/fatfs/fdisk2.fth Sat Aug 6 00:23:50 2011 (r2416)
@@ -27,6 +27,11 @@
headerless
+0 value sector-buf
+h# 200 constant /sector
+0 value disk-dev
+fload ${BP}/ofw/disklabel/showgpt.fth \ GUID Partition table decoding
+
0 value partition#
0 value partition-offset
true value primary?
@@ -40,6 +45,7 @@
cr
cr
;
+
: .0x ( n -- )
push-hex
dup 9 <= if 6 u.r else ." 0x" (.2) type then \ Type field
@@ -49,8 +55,7 @@
: (.1partition) ( adr -- )
dup d# 12 + le-l@ 0= if drop exit then \ Empty entry
primary? 0= if dup 4 + c@ 5 = if drop exit then then \ Logical extension entry
- base @ >r
- decimal
+ push-decimal
partition# dup 5 u.r 6 spaces 1+ to partition#
primary? if ." Primary" else ." Logical" then \ Primary/Logical partition
dup c@ if ." Yes " else ." No " then \ Boot indicator
@@ -64,6 +69,7 @@
h# c of ." FAT-32 LBA" endof
h# e of ." FAT-16 LBA" endof
h# 83 of ." ext2 " endof \ Linux EXT2
+ h# ee of ." GUID " endof
dup .0x
endcase
\ dup 1 + .hsc
@@ -72,28 +78,31 @@
\ dup 8 + le-l@ 9 u.r \ Start block
2 spaces
d# 12 + le-l@ d# 1024 + d# 2048 / 6 u.r \ Size in MB
- r> base !
cr
+ pop-base
;
-0 value sector-buf
-h# 200 constant /sector
-0 value disk-dev
: (.partitions) ( block-adr -- )
- dup h# 1be +
- 4 0 do
- dup (.1partition)
- dup 4 + c@ 5 = if
- d# 8 + le-l@ partition-offset +
- primary? if dup to partition-offset then
- /sector um* " seek" disk-dev $call-method drop
- dup /sector " read" disk-dev $call-method drop
- false to primary?
- recurse unloop exit
- then
- h# 10 +
- loop
- 2drop
+ dup h# 1be + ( adr partadr )
+ 4 0 do ( adr partadr )
+ dup (.1partition) ( adr partadr )
+ dup 4 + c@ case ( adr partadr )
+ 5 of ( adr partadr )
+ d# 8 + le-l@ partition-offset + ( adr part-offset )
+ primary? if dup to partition-offset then ( adr part-offset )
+ /sector um* " seek" disk-dev $call-method drop ( adr )
+ dup /sector " read" disk-dev $call-method drop ( adr )
+ false to primary? ( adr )
+ recurse unloop exit ( -- )
+ endof ( adr partadr )
+ h# ee of ( adr partadr )
+ .gpt ( adr partadr )
+ leave ( adr partadr )
+ endof ( adr partadr )
+ endcase ( adr partadr )
+ h# 10 + ( adr partadr' )
+ loop ( adr partadr )
+ 2drop ( )
;
: free-buf ( -- ) sector-buf /sector free-mem ;
Modified: ofw/fs/fatfs/partition.fth
==============================================================================
--- ofw/fs/fatfs/partition.fth Fri Aug 5 03:16:10 2011 (r2415)
+++ ofw/fs/fatfs/partition.fth Sat Aug 6 00:23:50 2011 (r2416)
@@ -53,12 +53,12 @@
false
;
-\ ??? i b s n apparently means #sectors start-sector boot-indicator system-indicator
-\ system-indicator: 0 no FAT, 1 12-bit FAT, 4 16-bit FAT, 5 extended, 6 over 32M
-\ ... b FAT 32, c FAT 32 LBA, e FAT-16 LBA, f extended LBA
+\ ??? n,s,b,t means #sectors start-sector boot-indicator type
+\ type: 0 empty, 1 12-bit FAT, 4 16-bit FAT, 5 extended, 6 over 32M
+\ ... b FAT 32, c FAT 32 LBA, e FAT-16 LBA, f extended LBA
\ boot-indicator: 80 bootable
-: process-ptable ( -- true | i1 b1 s1 n1 i2 b2 s2 n2 i3 b3 s3 n3 i4 b4 s4 n4 false )
+: process-ptable ( -- true | n,s,b,t4 n,s,b,t3 n,s,b,t2 n,s,b,t1 false )
sector-buf h# 1fe + le-w@ h# aa55 <> if true exit then
\ Process a real partition table
@@ -73,31 +73,31 @@
0 instance value extended-offset
false value found?
-defer suitable? ( s n -- s n flag )
+defer suitable? ( b t -- b t flag )
: (find-partition ( sector-offset -- not-found? )
- >r process-ptable if r> drop false exit then r>
+ >r process-ptable if r> drop false exit then r> ( n,s,b,t*4 sector-offset )
- 4 0 do ( i,b,s,nN ... i,b,s,n1 sector-offset )
- >r ( ... i,b,s,n )
- found? if \ partition was found ( ... i,b,s,n )
+ 4 0 do ( n,s,b,tN ... n,s,b,t1 sector-offset )
+ >r ( ... n,s,b,t )
+ found? if \ partition was found ( ... n,s,b,t )
2drop 2drop ( ... )
- else ( ... i,b,s,n )
- ?dup 0= if ( ... i,b,s )
- \ no FAT, skip it.
+ else ( ... n,s,b,t )
+ ?dup 0= if ( ... n,s,b )
+ \ empty, skip it.
3drop ( ... )
- else ( ... i,b,s,n )
- dup 5 = over h# f = or if \ extended partition ( ... i,b,s,n )
- 2drop nip ( ... b )
+ else ( ... n,s,b,t )
+ dup 5 = over h# f = or if \ extended partition ( ... n,s,b,t )
+ 2drop nip ( ... s )
extended-offset dup 0= if over to extended-offset then
+ dup read-sector recurse drop ( ... )
- else \ Ordinary partition ( ... i,b,s,n )
- suitable? if ( ... i,b,s,n )
- to partition-type drop ( ... i,b )
- r@ + to sector-offset ( ... i )
+ else \ Ordinary partition ( ... n,s,b,t )
+ suitable? if ( ... n,s,b,t )
+ to partition-type drop ( ... n,s )
+ r@ + to sector-offset ( ... n )
/sector um* to size-high to size-low ( ... )
true to found? ( ... )
- else ( ... i,b,s,n )
+ else ( ... n,s,b,t )
4drop ( ... )
then ( ... )
then ( ... )
1
0