Dear OpenFirmware enthusiasts,
we recently created a new mailing list around Firmworks' OpenFirmware
implementation (the one that is used on OLPC for example):
https://www.openfirmware.info/mailman/listinfo/openfirmware
Due to this new mailing list, commit messages to Mitch's OpenFirmware
repository will go to the new mailing list from now on.
Best regards,
Stefan Reinauer
--
coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br.
Tel.: +49 761 7668825 • Fax: +49 761 7664613
Email: info(a)coresystems.de • http://www.coresystems.de/
Registergericht: Amtsgericht Freiburg • HRB 7656
Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
Author: wmb
Date: 2008-05-28 21:15:45 +0200 (Wed, 28 May 2008)
New Revision: 830
Modified:
cpu/x86/pc/olpc/security.fth
Log:
OLPC - made the "enter" client service check the security state,
so you can only get to the ok prompt that way if you have security
disabled or a developer key.
Modified: cpu/x86/pc/olpc/security.fth
===================================================================
--- cpu/x86/pc/olpc/security.fth 2008-05-28 19:13:34 UTC (rev 829)
+++ cpu/x86/pc/olpc/security.fth 2008-05-28 19:15:45 UTC (rev 830)
@@ -571,6 +571,10 @@
stand-init-io
" wp" find-tag if 2drop true to secure? then
;
+
+dev /client-services
+: enter ( -- ) secure? 0= security-off? or if visible enter then ;
+dend
warning !
: message-and-off ( -- )
Author: wmb
Date: 2008-05-28 21:13:34 +0200 (Wed, 28 May 2008)
New Revision: 829
Modified:
cpu/x86/pc/olpc/memtest.fth
Log:
OLPC - memtest didn't work on secure machines with a developer key
because the screen was frozen at the DCON level.
Modified: cpu/x86/pc/olpc/memtest.fth
===================================================================
--- cpu/x86/pc/olpc/memtest.fth 2008-05-28 18:26:14 UTC (rev 828)
+++ cpu/x86/pc/olpc/memtest.fth 2008-05-28 19:13:34 UTC (rev 829)
@@ -7,6 +7,7 @@
over h# 10000 = if ( vaddr size )
\ Map the frame buffer (virtual=physical)
h# 910 config-l@ dup 100.0000 -1 mmu-map
+ unfreeze
then
\ If it's not memtest, chain to the linux recognizer
Author: wmb
Date: 2008-05-27 20:24:54 +0200 (Tue, 27 May 2008)
New Revision: 827
Added:
cpu/x86/pc/olpc/memtest.fth
Removed:
cpu/x86/pc/memtest.fth
Modified:
cpu/x86/pc/olpc/fw.bth
Log:
Moved memtest.fth from pc/ to pc/olpc/ because it is OLPC-specific.
Deleted: cpu/x86/pc/memtest.fth
===================================================================
--- cpu/x86/pc/memtest.fth 2008-05-21 21:23:30 UTC (rev 826)
+++ cpu/x86/pc/memtest.fth 2008-05-27 18:24:54 UTC (rev 827)
@@ -1,41 +0,0 @@
-purpose: Interface to memtest86
-
-: ?memtest-elf-map-in ( vaddr size -- )
- \ We recognize memtest by its virtual address of 0x10000
- \ It expects that virtual = physical; we depend on the fact
- \ that we have low memory mapped V=P
- over h# 10000 = if ( vaddr size )
- \ Map the frame buffer (virtual=physical)
- h# 910 config-l@ dup 100.0000 -1 mmu-map
- then
-
- \ If it's not memtest, chain to the linux recognizer
- ?linux-elf-map-in
-;
-' ?memtest-elf-map-in is elf-map-in
-
-: memtest ( -- ) " rom:memtest" $boot ;
-
-\ LICENSE_BEGIN
-\ Copyright (c) 2008 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
Modified: cpu/x86/pc/olpc/fw.bth
===================================================================
--- cpu/x86/pc/olpc/fw.bth 2008-05-21 21:23:30 UTC (rev 826)
+++ cpu/x86/pc/olpc/fw.bth 2008-05-27 18:24:54 UTC (rev 827)
@@ -337,7 +337,7 @@
fload ${BP}/cpu/x86/pc/olpc/lzip.fth \ Access zip images from memory
fload ${BP}/cpu/x86/pc/olpc/gamekeys.fth
fload ${BP}/cpu/x86/pc/linux.fth
-fload ${BP}/cpu/x86/pc/memtest.fth
+fload ${BP}/cpu/x86/pc/olpc/memtest.fth
fload ${BP}/cpu/x86/pc/olpc/setwp.fth
fload ${BP}/cpu/x86/pc/olpc/security.fth
fload ${BP}/cpu/x86/pc/olpc/fsupdate.fth
Copied: cpu/x86/pc/olpc/memtest.fth (from rev 826, cpu/x86/pc/memtest.fth)
===================================================================
--- cpu/x86/pc/olpc/memtest.fth (rev 0)
+++ cpu/x86/pc/olpc/memtest.fth 2008-05-27 18:24:54 UTC (rev 827)
@@ -0,0 +1,41 @@
+purpose: Interface to memtest86
+
+: ?memtest-elf-map-in ( vaddr size -- )
+ \ We recognize memtest by its virtual address of 0x10000
+ \ It expects that virtual = physical; we depend on the fact
+ \ that we have low memory mapped V=P
+ over h# 10000 = if ( vaddr size )
+ \ Map the frame buffer (virtual=physical)
+ h# 910 config-l@ dup 100.0000 -1 mmu-map
+ then
+
+ \ If it's not memtest, chain to the linux recognizer
+ ?linux-elf-map-in
+;
+' ?memtest-elf-map-in is elf-map-in
+
+: memtest ( -- ) " rom:memtest" $boot ;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2008 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
Author: wmb
Date: 2008-05-21 23:23:30 +0200 (Wed, 21 May 2008)
New Revision: 826
Modified:
cpu/x86/pc/olpc/resume.bth
cpu/x86/pc/olpc/romstart.bth
Log:
Fixed of couple of "fload" lines to reflect the recent move
of the file "startmacros.fth".
Modified: cpu/x86/pc/olpc/resume.bth
===================================================================
--- cpu/x86/pc/olpc/resume.bth 2008-05-21 21:16:50 UTC (rev 825)
+++ cpu/x86/pc/olpc/resume.bth 2008-05-21 21:23:30 UTC (rev 826)
@@ -15,7 +15,7 @@
fload ${BP}/cpu/x86/pc/olpc/config.fth \ Configuration defines
-fload ${BP}/cpu/x86/pc/olpc/startmacros.fth
+fload ${BP}/dev/geode/startmacros.fth
\ This code will be copied to RAM at suspend-base
Modified: cpu/x86/pc/olpc/romstart.bth
===================================================================
--- cpu/x86/pc/olpc/romstart.bth 2008-05-21 21:16:50 UTC (rev 825)
+++ cpu/x86/pc/olpc/romstart.bth 2008-05-21 21:23:30 UTC (rev 826)
@@ -18,7 +18,7 @@
\ startmacros.fth defines some assembler macros that make MSR and I/O port
\ access very easy by hiding the details of register use.
-fload ${BP}/cpu/x86/pc/olpc/startmacros.fth
+fload ${BP}/dev/geode/startmacros.fth
\ This creates and dismisses a floating point exception, which causes
\ the IRQ13 to go high then low.
Author: wmb
Date: 2008-05-21 23:16:50 +0200 (Wed, 21 May 2008)
New Revision: 825
Removed:
cpu/x86/pc/lxdevel/usb8388.bth
cpu/x86/pc/olpc/draminit.fth
cpu/x86/pc/olpc/gpio.fth
cpu/x86/pc/olpc/linux.fth
cpu/x86/pc/olpc/startmacros.fth
cpu/x86/pc/olpc/usb.fth
Log:
Deleted files that the previous checkin moved to more generic locations.
Deleted: cpu/x86/pc/lxdevel/usb8388.bth
===================================================================
--- cpu/x86/pc/lxdevel/usb8388.bth 2008-05-21 21:12:54 UTC (rev 824)
+++ cpu/x86/pc/lxdevel/usb8388.bth 2008-05-21 21:16:50 UTC (rev 825)
@@ -1,25 +0,0 @@
-purpose: Fetch the firmware for the Marvell 8388 wireless LAN module
-
-command: &builder &this
-build-now
-
-fload ${BP}/cpu/x86/pc/olpc/versions.fth
-
-" wget -O - http://www.laptop.org/teamwiki/images/6/60/Libertas-firmware.tgz | tar xfz -" $sh
-" grep version: libertas-fw-${WLAN_DATE}/RELEASE_NOTES | cut -d ' ' -f 3 | tr -d \\n >libertas.version" expand$ $sh
-
-reading libertas.version
-here dup d# 50 ifd @ fgets ( adr len )
-ifd @ fclose ( adr len )
-
-" ${WLAN_VERSION}" expand$ $= 0= [if]
-.( Wrong Libertas version ) cr
-error-exit
-[then]
-
-" cp libertas-fw-${WLAN_DATE}/usb8388.bin ." expand$ $sh
-
-\ This forces the creation of an .log file, so we don't re-fetch
-writing usb8388.version
-" ${WLAN_VERSION}"n" expand$ ofd @ fputs
-ofd @ fclose
Deleted: cpu/x86/pc/olpc/draminit.fth
===================================================================
--- cpu/x86/pc/olpc/draminit.fth 2008-05-21 21:12:54 UTC (rev 824)
+++ cpu/x86/pc/olpc/draminit.fth 2008-05-21 21:16:50 UTC (rev 825)
@@ -1,117 +0,0 @@
- h# 18 # al mov al h# 80 # out
- h# 1430 # dx mov dx ax in h# 9999 # ax cmp = if
- h# 34 # al mov al h# 70 # out \ Write to CMOS 0x34
- h# 18 # al mov al h# 71 # out \ Write value 01
- then
-
- \ Enable DLL, load Extended Mode Register by set and clear PROG_DRAM
- 20000018 rmsr
- 10000001 bitset 20000018 wmsr
- 10000001 bitclr 20000018 wmsr
-
- \ Reset DLL (bit 27 is undocumented in GX datasheet, but is in the LX one)
- 08000001 bitset 20000018 wmsr
- 08000001 bitclr 20000018 wmsr
-
- \ Here we are supposed to wait 200 SDCLK cycles to let the DLL settle.
- \ That is approximately 2 uS. The ROM instruction access is so slow that
- \ anything we do will take quite a bit longer than that, so we just let the
- \ "rmsr, bitset" sequence take care of the time delay for us.
-
- \ In the following sequence of writes the 2000.0018 MSR, we
- \ take advantage of the fact that the existing value stays
- \ in EAX/EDX, so we don't have to re-read the value.
-
- \ Generate 2 refresh requests. The refresh queue is 8 deep, and we
- \ need to make sure 2 refreshes hit the chips, so we have to issue
- \ 10 requests to the queue. According to the GX datasheet, we don't
- \ have to clear the REF_TST bit (8) explicitly between writes
- 20000018 rmsr 8 bitset
- wrmsr wrmsr wrmsr wrmsr wrmsr wrmsr wrmsr wrmsr wrmsr wrmsr
- 8 bitclr
-
-\ LinuxBIOS LX raminit.c has a big delay here, using Port 61
-
- \ Load Mode Register
- 1 bitset 20000018 wmsr
- 1 bitclr 20000018 wmsr
-
- \ Set up a descriptor to give access to memory
- \ GLIU0 P2D Base Mask Descriptors - page 85
- 20000000.000fff00. 10000020 set-msr \ memory - 0..fffff
-
- \ The RAM DLL needs a write to lock on
- ax h# ffff0 #) mov
-
- h# 19 # al mov al h# 80 # out
- h# 1430 # dx mov dx ax in h# 9999 # ax cmp = if
- h# 34 # al mov al h# 70 # out \ Write to CMOS 0x34
- h# 19 # al mov al h# 71 # out \ Write value 01
- then
-
- \ Turn on the cache
- cr0 ax mov
- 6000.0000 bitclr \ Cache-disable off, coherent
- ax cr0 mov
- invd
-
- h# 1a # al mov al h# 80 # out
- h# 1430 # dx mov dx ax in h# 9999 # ax cmp = if
- h# 34 # al mov al h# 70 # out \ Write to CMOS 0x34
- h# 1a # al mov al h# 71 # out \ Write value 01
- then
-
- 0000f001.00001400. 5140000f set-msr \ PMS BAR
-
- \ It is tempting to test bit 0 of PM register 5c, but a 5536 erratum
- \ prevents that bit from working. Bit 1 works, but LX errata 34
- \ sometimes requires that we reset the system to fix the memory DLL,
- \ which destroys all the bits of PM register 5c. So we put a breadcrumb
- \ in a PM register that we don't otherwise use.
- 1430 port-rl h# 9999 # ax cmp = if \ Wakeup event flag
- 0 1430 port-wl
- h# 1b # al mov al h# 80 # out
- h# 34 # al mov al h# 70 # out \ Write to CMOS 0x34
- h# 1b # al mov al h# 71 # out \ Write value 01
-
- char r 3f8 port-wb begin 3fd port-rb 40 bitand 0<> until
-
- resume-data # sp mov
- resume-entry # ax mov ax call \ This might return if checksumming fails
- char x 3f8 port-wb begin 3fd port-rb 40 bitand 0<> until
- then
-
- h# 1c # al mov al h# 80 # out
- h# 1808 rmsr \ Default region configuration properties MSR
- h# 0fffff00 # ax and \ Top of System Memory field
- 4 # ax shl \ Shift into place
- ax mem-info-pa 4 + #) mov \ Put it where resetend.fth can find it
-
- \ char D 3f8 port-wb begin 3fd port-rb 40 bitand 0<> until
-
- \ Memory is now on
- h# 8.0000 # sp mov \ Setup a stack pointer for later code
-
- h# 1d # al mov al h# 80 # out
-\ Some optional debugging stuff ...
-[ifdef] debug-startup
-init-com1
-
-carret report
-linefeed report
-ascii F report
-ascii o report
-ascii r report
-[then]
-
-\ fload ${BP}/cpu/x86/pc/ramtest.fth
-
-0 [if]
-ax ax xor
-h# 12345678 # bx mov
-bx 0 [ax] mov
-h# 5555aaaa # 4 [ax] mov
-0 [ax] dx mov
-dx bx cmp <> if ascii B report ascii A report ascii D report begin again then
-[then]
-
Deleted: cpu/x86/pc/olpc/gpio.fth
===================================================================
--- cpu/x86/pc/olpc/gpio.fth 2008-05-21 21:12:54 UTC (rev 824)
+++ cpu/x86/pc/olpc/gpio.fth 2008-05-21 21:16:50 UTC (rev 825)
@@ -1,61 +0,0 @@
-\ See license at end of file
-purpose: Access to GPIO registers
-
-\ GPIO registers
-h# 00 constant OUT_VAL
-h# 04 constant OUT_EN
-h# 08 constant OUT_OD_EN
-h# 0c constant OUT_INVRT_EN
-h# 10 constant OUT_AUX1
-h# 14 constant OUT_AUX2
-h# 18 constant PU_EN
-h# 1c constant PD_EN
-h# 20 constant IN_EN
-h# 24 constant INV_EN
-h# 28 constant IN_FLTR_EN
-h# 2c constant EVNTCNT_EN
-h# 30 constant READ_BACK
-h# 38 constant EVNT_EN
-
-h# 1000 value gpio-base \ stand-init sets this from an MSR
-: gpio@ ( offset -- 0 ) gpio-base + pl@ ;
-: gpio! ( l offset -- ) gpio-base + pl! ;
-
-alias >set noop ( mask -- mask' )
-: >clr ( mask -- mask' ) d# 16 lshift ;
-
-: >hi ( reg# -- reg#' ) h# 80 + ; \ High bank for GPIO bits 16..31
-
-: gpio-data@ ( -- l ) h# 30 gpio@ ;
-
-
-h# 5140000C constant MSR_LBAR_GPIO
-
-stand-init: gpio
- MSR_LBAR_GPIO rdmsr ( lo hi )
- h# 0000f001 <> abort" GPIO not enabled"
- h# ff00 and to gpio-base
-;
-\ 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
Deleted: cpu/x86/pc/olpc/linux.fth
===================================================================
--- cpu/x86/pc/olpc/linux.fth 2008-05-21 21:12:54 UTC (rev 824)
+++ cpu/x86/pc/olpc/linux.fth 2008-05-21 21:16:50 UTC (rev 825)
@@ -1,534 +0,0 @@
-\ See license at end of file
-purpose: Linux bzImage program loading
-
-\ \needs ramdisk " disk:\boot\initrd.img" d# 128 config-string ramdisk
-\ " ro root=LABEL=OLPCRoot rootfstype=ext3 console=ttyS0,115200 console=tty0 fbcon=font:SUN12x22" ' boot-file set-config-string-default
-\ " disk:\boot\vmlinuz" ' boot-device set-config-string-default
-
-\ \needs ramdisk " " d# 128 config-string ramdisk
-\ " nand:\boot\vmlinuz" ' boot-device set-config-string-default
-\ " ro root=mtd0 rootfstype=jffs2 console=ttyS0,115200 console=tty0 fbcon=font:SUN12x22" ' boot-file set-config-string-default
-
-\needs ramdisk " " d# 128 config-string ramdisk
-" " ' boot-file set-config-string-default \ Let the olpcboot.fth file set the cmdline
-" disk:\boot\olpc.fth sd:\boot\olpc.fth nand:\boot\olpc.fth /prober /usb/ethernet /usb/wlan" ' boot-device set-config-string-default
-
-0 value ramdisk-adr
-0 value /ramdisk
-
-0 [if] \ From include/asm-i386/setup.h
-#define PARAM (boot_params)
-#define SCREEN_INFO (*(struct screen_info *) (PARAM+0))
-#define EXT_MEM_K (*(unsigned short *) (PARAM+2))
-#define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0))
-#define E820_MAP_NR (*(char*) (PARAM+E820NR))
-#define E820_MAP ((struct e820entry *) (PARAM+E820MAP))
-#define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+0x40))
-#define IST_INFO (*(struct ist_info *) (PARAM+0x60))
-#define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80))
-#define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0xa0))
-#define EFI_SYSTAB ((efi_system_table_t *) *((unsigned long *)(PARAM+0x1c4)))
-#define EFI_MEMDESC_SIZE (*((unsigned long *) (PARAM+0x1c8)))
-#define EFI_MEMDESC_VERSION (*((unsigned long *) (PARAM+0x1cc)))
-#define EFI_MEMMAP ((void *) *((unsigned long *)(PARAM+0x1d0)))
-#define EFI_MEMMAP_SIZE (*((unsigned long *) (PARAM+0x1d4)))
-#define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2))
-#define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8))
-#define VIDEO_MODE (*(unsigned short *) (PARAM+0x1FA))
-#define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC))
-#define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
-#define LOADER_TYPE (*(unsigned char *) (PARAM+0x210))
-#define KERNEL_START (*(unsigned long *) (PARAM+0x214))
-#define INITRD_START (*(unsigned long *) (PARAM+0x218))
-#define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c))
-#define EDID_INFO (*(struct edid_info *) (PARAM+0x140))
-#define EDD_NR (*(unsigned char *) (PARAM+EDDNR))
-#define EDD_MBR_SIG_NR (*(unsigned char *) (PARAM+EDD_MBR_SIG_NR_BUF))
-#define EDD_MBR_SIGNATURE ((unsigned int *) (PARAM+EDD_MBR_SIG_BUF))
-#define EDD_BUF ((struct edd_info *) (PARAM+EDDBUF))
-
-#define PARAM_SIZE 4096
-#define COMMAND_LINE_SIZE 256
-
-#define OLD_CL_MAGIC_ADDR 0x90020
-#define OLD_CL_MAGIC 0xA33F
-#define OLD_CL_BASE_ADDR 0x90000
-#define OLD_CL_OFFSET 0x90022
-#define NEW_CL_POINTER 0x228 /* Relative to real mode data */
-
-\ From arch/i386/kernel/setup.c
-#define RAMDISK_IMAGE_START_MASK 0x07FF
-#define RAMDISK_PROMPT_FLAG 0x8000
-#define RAMDISK_LOAD_FLAG 0x4000
-[then]
-
-create screen-info \ See struct screen_info in include/linux/tty.h
- 0 c, \ 0 x position
- 0 c, \ 1 y position
- 0 w, \ 2 plug in memory size here
- 0 w, \ 4 video page
- 0 c, \ 6 video mode - 7 means monochrome, anything else is color
- d# 80 c, \ 7 columns
- 0 w, \ 8 unused
- 0 w, \ a ega_bx - anything but 0x10
- 0 w, \ c unused
- d# 25 c, \ e lines
- 0 c, \ f isVGA?
- d# 16 w, \ 10 font height
-here screen-info - constant /screen-info
-
-
-h# 9.0000 constant linux-params
-h# 10.0000 value linux-base
-: code16-size ( -- #bytes ) load-base h# 1f1 + c@ 1+ d# 512 * ;
-0 value cmdline-offset
-
-\ Find the end of the largest piece of memory
-: memory-limit ( -- limit )
- " /memory" find-package 0= abort" No /memory node" ( phandle )
- " available" rot get-package-property abort" No memory node available property" ( $ )
- \ Find the memory piece that starts at 1 Meg
- begin dup 8 >= while ( $ )
- decode-int h# 10.0000 = if ( $ ) \ Found the one we want
- decode-int h# 10.0000 + ( $ limit )
- nip nip exit
- then ( $ )
- decode-int drop ( $ )
- repeat ( $ )
- 2drop true abort" No suitable memory piece"
-;
-
-d# 20 constant /root-dev-buf
-/root-dev-buf buffer: root-dev-buf
-
-: make-root-dev$ ( idx -- root-dev$ )
- root-dev-buf /root-dev-buf 0 fill
- " root=/dev/hda" rot
- 1+ base @ >r d# 10 base ! (.) r> base !
- $cat2
- 2dup 2>r root-dev-buf swap move
- 2r> free-mem
- root-dev-buf /root-dev-buf
-;
-: +lp ( offset -- adr ) linux-params + ;
-
-0 [if]
-: add-root-dev ( cmdline$ -- cmdline$' )
- 2>r " root=" 2r@ sindex -1 = if
- 2r>
- " disk:root,\" $partition-idx dup -1 <> if
- make-root-dev$ $cat2
- else
- drop
- then
- else
- 2r>
- then
-;
-[else]
-: add-root-dev ( cmdline$ -- cmdline$' )
-;
-[then]
-
-: set-parameters ( cmdline$ -- )
- screen-info linux-params /screen-info move \ Ostensibly screen info
-
- memory-limit ( #bytes )
- d# 1023 invert and d# 1024 / ( #kbytes )
- d# 1024 - h# 002 +lp w! \ Kbytes of extended (not the 1st meg) memory
-
- memory-limit ( #bytes )
- d# 1023 invert and d# 1024 / ( #kbytes )
- d# 1024 - h# 1e0 +lp l! \ Alternate amount of extended memory
-
- 0 h# 1f2 +lp w! \ root flags - non0 to mount root read-only
- 0 h# 1f8 +lp w! \ Ramdisk flags
-
-\ 301 for /dev/hda, 100 for /dev/ram0, 0 for nothing (set it from cmdline)
-\ h# 301 h# 1fc +lp w! \ root_dev - see init/main.c:parse_root_dev
-\ h# 100 h# 1fc +lp w! \ root_dev - see init/main.c:parse_root_dev
- h# 0 h# 1fc +lp w! \ root_dev - see init/main.c:parse_root_dev
-
- 0 h# 1ff +lp c! \ Aux device - set to AA if PS2 mouse present
- /ramdisk 0<> h# 210 +lp w! \ loader type - set non0 to enable ramdisk info
-\ h# 100000 h# 214 +lp l! \ kernel start - unused
- ramdisk-adr h# 218 +lp l! \ initrd start
- /ramdisk h# 21c +lp l! \ initrd size
-
- \ Put Open Firmware signature and IDT pointer in the params area
- " OFW " drop @ h# b0 +lp l! \ Validator for this area
- 1 h# b4 +lp l! \ Number of additional items (version#)
- cif-handler h# b8 +lp l! \ Client interface handler
- idt drop h# bc +lp l! \ So Linux can preserve our debug vectors
-
- \ Command line goes after the 16-bit wad
- ( cmdline$ ) add-root-dev
- ( cmdline$ ) cmdline-offset +lp swap 1+ move
- h# a33f h# 20 +lp w! \ Command line validator (magic number)
- cmdline-offset h# 22 +lp w! \ Command line offset
- cmdline-offset +lp h# 228 +lp l! \ New command line address
-;
-
-: linux-fixup ( -- )
-[ifdef] linux-logo linux-logo [then]
- args-buf cscount set-parameters ( )
- h# ff h# 21 pc! \ Squelch the timer interrupt and others
-
- linux-base linux-params (init-program)
- linux-params to %esi
-;
-
-d# 256 buffer: ramdisk-buf
-' ramdisk-buf " ramdisk" chosen-string
-
-defer load-ramdisk
-: $load-ramdisk ( name$ -- )
- 0 to /ramdisk ( name$ )
-
- ['] load-path behavior >r ( name$ r: xt )
- ['] ramdisk-buf to load-path ( name$ r: xt )
-
- ." Loading ramdisk image from " 2dup type ." ..." ( name$ r: xt )
- ['] boot-read catch ( throw-code r: xt )
- cr ( throw-code r: xt )
- r> to load-path ( throw-code )
- throw
- loaded to /ramdisk to ramdisk-adr
-;
-: cv-load-ramdisk ( -- )
- " ramdisk" eval dup 0= if 2drop exit then ( name$ )
- $load-ramdisk
-;
-' cv-load-ramdisk to load-ramdisk
-
-: claim-params ( -- )
-[ifdef] virtual-mode
- 0 0 1meg -1 mmu-map ( ) \ Make the parameter area accessible
-[then]
- 0 +lp h# 1000 0 mem-claim drop \ Play nice with memory reporting
- 0 +lp h# 1000 erase
-;
-
-0 value linux-loaded?
-: ?linux-elf-map-in ( va size -- )
- \ The Linux startup code really wants the physical address to be
- \ virtual_address AND 0x0fff.ffff. We recognize Linux by the virtual
- \ address range that it uses (0xc0xx.xxxx)
- over h# f000.0000 and h# c000.0000 = if
- h# 40.0000 to linux-base
- h# 800 to cmdline-offset
- true to linux-loaded?
- over h# 0fff.ffff and ( va size pa )
- -rot -1 ( pa va size mode )
- mmu-map
- exit
- then
- (elf-map-in)
-;
-' ?linux-elf-map-in is elf-map-in
-
-: init-bzimage? ( -- flag )
- loaded ( adr len )
- h# 202 /string ( adr' len' )
- 4 < if drop false exit then ( adr )
- " HdrS" comp if false exit then ( )
- h# 10.0000 to linux-base
- code16-size to cmdline-offset \ Save in case we clobber load-base
- load-base 0 +lp code16-size move \ Copy the 16-bit stuff
- loaded code16-size /string linux-base swap move \ Copy the 32-bit stuff
- true to linux-loaded?
- true
-;
-
-warning @ warning off
-: init-program ( -- )
- init-bzimage? if exit then
- init-program
-;
-
-: ?memtest-elf-map-in ( vaddr size -- )
- \ We recognize memtest by its virtual address of 0x10000
- \ It expects that virtual = physical; we depend on the fact
- \ that we have low memory mapped V=P
- over h# 10000 = if ( vaddr size )
- \ Map the frame buffer (virtual=physical)
- h# 910 config-l@ dup 100.0000 -1 mmu-map
- then
-
- \ If it's not memtest, chain to the linux recognizer
- ?linux-elf-map-in
-;
-' ?memtest-elf-map-in is elf-map-in
-
-: memtest ( -- ) unfreeze " rom:memtest" $boot ;
-
-: sym ( "name" -- adr )
- parse-word $sym> 0= if err-sym-not-found throw then
-;
-warning !
-
-warning @ warning off
-: init-program ( -- )
- false to linux-loaded?
- init-program
- linux-loaded? if
- claim-params
- ['] load-ramdisk guarded
- linux-fixup
- then
-;
-warning !
-
-: mcr ( -- ) cr exit? throw ;
-: help-debug ( -- )
- red-letters
- ." Debugging the Linux kernel requires a few patches to keep Linux from" mcr
- ." overwriting the firmware debug vector." mcr mcr
- black-letters
-
- ." COMMAND STACK EFFECT DESCRIPTION" mcr
- ." .registers ( -- ) Display registers" mcr
- ." go ( -- ) Resume execution" mcr
- ." step ( -- ) Single-step" mcr
- ." ^T ( -- ) (Control-T) Keystroke shortcut for 'step'" mcr
- ." steps ( n -- ) Single-step n times" mcr
- ." hop ( -- ) Step over subroutine calls" mcr
- ." hops ( n -- ) Hop n times" mcr
- ." dis ( addr -- ) Disassemble starting at given address" mcr
- ." +dis ( -- ) Continue disassembling" mcr
- ." bp ( addr -- ) Set breakpoint at given address" mcr
- ." till ( addr -- ) Set breakpoint at given address and go" mcr
- ." -bp ( addr -- ) Delete breakpoint at given address" mcr
- ." --bp ( -- ) Delete last breakpoint" mcr
- ." .bp ( -- ) Show breakpoints" mcr
- ." return ( -- ) Finish execution of current subroutine" mcr
- ." finish-loop ( -- ) Finish execution of current loop" mcr
- ." %eax ( -- n ) Push EAX (etc.) register value on stack" mcr
- ." %eip ( -- n ) Push EIP register value on stack" mcr
- ." %pc ( -- n ) Same as %eip" mcr
- ." to %eax ( n -- ) Set EAX (etc.) register value from stack" mcr
- ." to %eip ( n -- ) Set EIP register value from stack" mcr
- ." sym <name> ( -- n ) Push value of named kernel symbol on stack" mcr
- ." .adr ( n -- ) Display symbol name closest to n" mcr
- ." Examples: " mcr
- ." %pc dis Disassemble starting at program counter" mcr
- ." %ebx u. Display saved value of EBX register" mcr
- ." step Single step once" mcr
- ." 10 hops Step 10 times, don't go down into subroutines" mcr
- ." 1234 to %ebp Set EBP register to (hex) 1234" mcr
- ." sym kbd_init dis Disassemble starting at kbd_init" mcr
- ." sym kbd_init till Set breakpoint at kbd_init and go" mcr
- ." %pc 5 + to %pc Add 5 to the program counter register" mcr
-
- mcr
- ." More information: http://firmworks.com/QuickRef.html" cr
-;
-
-d# 34 to default-#lines
-
-warning @ warning off
-: help ( -- )
- blue-letters ." UPDATES:" black-letters mcr
- ." flash u:\q2c18.rom Rewrite the firmware from USB key" mcr
- ." flash nand:\q2c18.rom Rewrite the firmware from NAND file" mcr
- ." copy-nand u:\boot\nand290.img Rewrite the OS on NAND from USB key" mcr
- mcr
- blue-letters ." DIRECTORY LISTING:" black-letters mcr
- ." dir u:\ List USB key root directory" mcr
- ." dir u:\boot\ List USB key /boot directory" mcr
- ." dir nand:\boot\ List NAND FLASH /boot directory" mcr
- ." dir nand:\boot\*.rom List .rom files in NAND FLASH /boot directory" mcr
- mcr
- blue-letters ." BOOTING:" black-letters mcr
- ." boot Load the OS from list of default locations" mcr
- ." 'printenv boot-device' shows the list" mcr
- ." boot <cmdline> Load the OS, passing <cmdline> to kernel" mcr
- ." boot u:\boot\vmlinuz Load the OS from a specific location" mcr
- mcr
- blue-letters ." CONFIGURATION VARIABLES FOR BOOTING:" black-letters mcr
- ." boot-device Kernel or boot script path. Example: nand:\boot\olpc.fth" mcr
- ." boot-file Default cmdline. Example: console=ttyS0,115200" mcr
- ." ramdisk initrd pathname. Example: disk:\boot\initrd.imz" mcr
- mcr
- blue-letters ." MANAGING CONFIGURATION VARIABLES:" black-letters mcr
- ." printenv [ <name> ] Show configuration variables" mcr
- ." setenv <name> <value> Set configuration variable" mcr
- ." editenv <name> Edit configuration variable" mcr
- mcr
- blue-letters ." DIAGNOSTICS:" black-letters mcr
- ." test <device-name> Test device. Example: test mouse" mcr
- ." test-all Test all devices that have test routines" mcr
- mcr
- ." More information: "
- green-letters ." http://wiki.laptop.org/go/OFW_FAQ" black-letters cr
-;
-warning !
-
-0 [if]
-
-: linux ( "cmdline" -- )
- load-ramdisk
- load
- ." Linux start address at " %eip u. cr
- ." Type 'go' to start it or 'help-debug' to see debugger commands." cr
-;
-
-\ " load_ramdisk=1 root=/dev/ram0 console=/dev/ttyS0,9600 console=/dev/tty0"
-
-
-: uint8_t ( offset -- offset' )
- create dup , /c + does> @ the-struct + c@ ( b )
-;
-: uint16_t ( offset -- offset' )
- create dup , /w + does> @ the-struct + w@ ( w )
-;
-: uint32_t ( offset -- offset' )
- create dup , /l + does> @ the-struct + l@ ( l )
-;
-: uint8s ( offset size -- offset' ) sfield ;
-
-: reserved + ;
-: ends-at ( offset n -- ) nip ;
-struct \ x86_linux_header
- h# 1f1 reserved \ 0x000
- uint8_t setup_sects \ 0x1f1
- uint16_t root_flags \ 0x1f2
- uint16_t syssize \ 0x1f4
- uint16_t swapdev \ 0x1f6
- uint16_t ramdisk_flags \ 0x1f8
- uint16_t vid_mode \ 0x1fa
- uint16_t root_dev \ 0x1fc
- uint16_t boot_sector_magic \ 0x1fe
- \ 2.00+
- 2 reserved \ 0x200
- 4 uint8s header_magic \ 0x202
- uint16_t protocol_version \ 0x206
- uint32_t realmode_swtch \ 0x208
- uint16_t start_sys \ 0x20c
- uint16_t kver_addr \ 0x20e
- uint8_t type_of_loader \ 0x210
- uint8_t loadflags \ 0x211
- uint16_t setup_move_size \ 0x212
- uint32_t code32_start \ 0x214
- uint32_t ramdisk_image \ 0x218
- uint32_t ramdisk_size \ 0x21c
- 4 reserved \ 0x220
- \ 2.01+
- uint16_t heap_end_ptr \ 0x224
- 2 reserved \ 0x226
- \ 2.02+
- uint32_t cmd_line_ptr \ 0x228
- \ 2.03+
- uint32_t initrd_addr_max \ 0x22c
-[ifdef] TENATIVE
- \ 2.04+
- uint16_t entry32_off \ 0x230
- uint16_t internal_cmdline_off \ 0x232
- uint32_t low_base \ 0x234
- uint32_t low_memsz \ 0x238
- uint32_t low_filesz \ 0x23c
- uint32_t real_base \ 0x240
- uint32_t real_memsz \ 0x244
- uint32_t real_filesz \ 0x248
- uint32_t high_base \ 0x24C
- uint32_t high_memsz \ 0x250
- uint32_t high_filesz \ 0x254
- 0 field tail \ 0x258
-[else]
- 0 field tail \ 0x230
-[then]
- d# 32 d# 1024 * ends-at
-
-constant /x86-linux-header
-
-\ Not used, but possibly interesting to know
-: kernel-version ( -- cstr ) load-base d# 512 + kver_addr + ;
-
-Where stuff wants to load:
-
-16-bit segment at h# 9.0000
-32-bit segment at h# 10.0000
-ramdisk at h# 80.0000
-
-command line goes in 16-bit segment at command_line_off (first location after kern16_size)
-start16 code goes in 16-bit segment at setup16_off
-start32 code goes in 16-bit segment at setup32_off
-
-h# 90000 constant rm-seg
-h# 10.0000 constant seg32
-: +rm ( n -- adr ) rm-seg + ;
-
-: setup-linux ( -- )
- XXX need descriptors at GDT 60 and 68
-
- load-base rm-seg kern16-size move \ Copy real-mode code
-
- cmdline kern16-size +rm swap 1+ move \ Copy command line
- h# a33f h# 20 +rm w! \ CL_MAGIC_VALUE -> cl_magic
- kern16-size h# 22 w! \ cl_offset
-
- protocol_version h# 0202 >= if
- kern16-size +rm h# 228 +rm l!
- then
-
- h# ff h# 210 +rm c! \ LOADER_TYPE_UNKNOWN
-
- \ XXX ramdisk must have been copied to h# 800000 already
- ramdisk h# 21c +rm l! h# 218 l! \ address and length
-
- 0 to %eax 0 to %ebx 0 to %ecx 0 to %edx
- 0 +rm to %esi 0 to %edi 0 +rm to %esp seg32 to %eip
-
- loaded kern16-size /string seg32 swap move
-
- set-fb-info
- set-mem-info
-;
-
-
-What x86-setup-32.S does:
-
-finds the actual address of its data structures because
-it has been loaded at somewhere other than its link address
-
-calls x86_setup_state (might be unnecessary)
-
-Load a GDT with
- 0 - pointer to GDT
- 0x10 4GB flat code segment
- 0x18 4GB flat data segment
- 0x60 4GB flat code segment
- 0x68 4GB flat data segment
- .. other descriptors empty
-
- sets CS to 0x10
- sets DS,ES,SS,FS,GS to 0x18
-
- loads the general registers with values from the array
- jumps to the eip from the array
-
-[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
Deleted: cpu/x86/pc/olpc/startmacros.fth
===================================================================
--- cpu/x86/pc/olpc/startmacros.fth 2008-05-21 21:12:54 UTC (rev 824)
+++ cpu/x86/pc/olpc/startmacros.fth 2008-05-21 21:16:50 UTC (rev 825)
@@ -1,131 +0,0 @@
-\ See license at end of file
-
-\ Some x86 assembler macros for writing Geode early startup code
-\ in a clean, compact way. Most of the Geode initialization is
-\ done with 64-bit MSRs (Machine Specific Registers). These
-\ macros make it easy to set MSRs to specific values and to
-\ set and clear individual bits.
-
-\ The code keeps the MSR register number in %ecx, the low 32 bits
-\ of the value in %eax, and the high 32 bits in %edx, consistent
-\ with the way the rdmsr and wrmsr machine instructions work.
-\ The bitset and bitclr operations work on %eax, and the -hi versions
-\ work on %edx.
-\ In addition to the MSR operations, there are similar ones for
-\ I/O ports. They leave the data in %eax, so you can use bitset
-\ and bitclr with them too.
-
--1 value last-cx
-also 386-assembler definitions
-
-: forget-msr -1 to last-cx ;
-
-\ set-cx is an internal implementation factor used by wmsr and rmsr.
-\ It assembles code to put an MSR number in %ecx, optimizing out
-\ unnecessary code by remembering what was last put there.
-: set-cx ( reg# -- )
- [ also forth ]
- dup last-cx = if
- drop
- else
- dup to last-cx
- [ previous ] # cx mov [ also forth ]
- then
- [ previous ]
-;
-
-\ Read/write an MSR to/from %edx,%eax
-: rmsr ( reg# -- ) set-cx h# 0f c, h# 32 c, ;
-: wmsr ( reg# -- ) set-cx h# 0f c, h# 30 c, ;
-
-\ These bit operations can be used between "rmsr" and "wmsr"
-
-\ Bit operations on the low 32-bit value in %eax
-: bitset ( mask -- ) # ax or ;
-: bitand ( mask -- ) # ax and ;
-: bitclr ( mask -- ) invert bitand ;
-
-\ Bit operations on the high 32-bit value in %edx
-: bitset-hi ( mask -- ) # dx or ;
-: bitand-hi ( mask -- ) # dx and ;
-: bitclr-hi ( mask -- ) invert bitand-hi ;
-
-\ Set an MSR to a verbatim 64-bit value
-: set-msr ( d.val reg# -- ) -rot # dx mov # ax mov wmsr ;
-
-\ Set or clear bits in an MSR (read-modify-write the register)
-: bitset-msr ( mask reg# -- ) tuck rmsr bitset wmsr ;
-: bitclr-msr ( mask reg# -- ) tuck rmsr bitclr wmsr ;
-
-\ Some I/O port operations
-\ These could be optimized to generate the immediate forms of in and out
-\ for 8-bit port numbers, but it's not worth the trouble because we
-\ access very few low-numbered ports.
-: port-wb ( b port# -- ) swap # al mov # dx mov al dx out ;
-: port-rb ( port# -- ) # dx mov dx al in ;
-: port-ww ( w port# -- ) swap # ax mov # dx mov op: ax dx out ;
-: port-rw ( port# -- ) ax ax xor # dx mov op: dx ax in ;
-: port-wl ( l port# -- ) swap # ax mov # dx mov ax dx out ;
-: port-rl ( port# -- ) # dx mov dx ax in ;
-
-: config-setup ( config-adr -- )
- [ also forth ]
- dup 3 invert and h# 8000.0000 or ( config-adr cf8-value )
- [ previous ]
- # ax mov ( config-adr )
- h# cf8 # dx mov ( config-adr )
- ax dx out ( config-adr )
- [ also forth ]
- 3 and h# cfc or ( data-port )
- [ previous ]
- # dx mov
-;
-: config-wl ( l config-adr -- )
- config-setup ( l )
- # ax mov
- ax dx out
-;
-: config-rl ( config-adr -- ) \ Returns value in EAX
- config-setup
- dx ax in
-;
-: config-ww ( w config-adr -- )
- config-setup ( w )
- op: # ax mov ( )
- op: ax dx out
-;
-: config-rw ( config-adr -- ) \ Returns value AX
- config-setup ( )
- ax ax xor
- op: dx ax in
-;
-
-: set-base ( adr -- ) # bx mov ;
-: reg-save ( offset -- ) [bx] ax mov ax stos ;
-: reg-restore ( offset -- ) ax lods ax swap [bx] mov ;
-
-previous definitions
-
-\ 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
Deleted: cpu/x86/pc/olpc/usb.fth
===================================================================
--- cpu/x86/pc/olpc/usb.fth 2008-05-21 21:12:54 UTC (rev 824)
+++ cpu/x86/pc/olpc/usb.fth 2008-05-21 21:16:50 UTC (rev 825)
@@ -1,156 +0,0 @@
-purpose: USB elaborations for the OLPC platform
-\ See license at end of file
-
-0 config-int usb-delay \ Milliseconds to wait before set-address
-
-devalias usb1 /usb@f,4
-devalias usb2 /usb@f,5
-devalias u /usb/disk
-devalias net /usb/wlan
-
-\ If there is a USB ethernet adapter, use it as the default net device.
-: report-net ( -- )
- " /usb/ethernet" 2dup find-package if ( name$ phandle )
- drop ( name$ )
- " net" 2swap $devalias ( )
- else ( name$ )
- 2drop ( )
- then
-;
-
-[ifdef] notdef \ We have the graphical penguin
-: linux-logo ( -- )
- " penguin.txt" find-drop-in if page type then
-;
-[then]
-
-\ Like $show-devs, but ignores pagination keystrokes
-: $nopage-show-devs ( nodename$ -- )
- ['] exit? behavior >r ['] false to exit?
- $show-devs
- r> to exit?
-;
-
-: probe-usb ( -- )
- ." USB2 devices:" cr
- " /usb@f,5" open-dev ?dup if close-dev then
- " /usb@f,5" $nopage-show-devs
-
- ." USB1 devices:" cr
- " /usb@f,4" open-dev ?dup if close-dev then
- " /usb@f,4" $nopage-show-devs
-
- report-disk
- report-net
- report-keyboard
-;
-alias probe-usb2 probe-usb
-alias p2 probe-usb2
-
-: ?usb-keyboard ( -- )
- " keyboard" expand-alias if ( devspec$ )
- drop " /usb" comp 0= if ( )
- red-letters ." Using USB keyboard." cr black-letters
- " keyboard" input
- then
- 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
-;
-
-0 value usb-power-done-time
-
-\ This version assumes that power has been applied already, and
-\ all we have to do is wait enough time for the devices to be ready.
-: wait-usb-power ( -- )
- begin usb-power-done-time get-msecs - 0<= until ( )
-;
-
-: usb-quiet ( -- )
- [ ' go-hook behavior compile, ] \ Chain to old behavior
- " usb1" " reset-usb" execute-device-method drop
- " usb2" " reset-usb" execute-device-method drop
-;
-' usb-quiet to go-hook
-
-0 0 " " " /" begin-package
- " prober" device-name
- : open
- " /usb@f,5" open-dev ?dup if close-dev then
- " /usb@f,4" open-dev ?dup if close-dev then
- report-disk
- report-net
- report-keyboard
- false
- ;
- : close ;
-end-package
-
-stand-init: USB setup
- \ Set up an address routing to the USB Option Controller
- h# efc00000.efc00001. h# 5100.0029 wrmsr
- h# 400000ef.c00fffff. h# 5101.0020 wrmsr
- h# 00000002.efc00000. h# 5120.000b wrmsr
-[ifdef] virtual-mode
- h# efc00000 h# 1000 0 mmu-claim drop \ UOC
- h# efc00000 dup h# 1000 -1 mmu-map \ UOC
- h# fe01a000 h# 1000 0 mmu-claim drop \ OHCI
- h# fe01a000 dup h# 1000 -1 mmu-map \ OHCI
-[then]
- \ Configure the assignment of 2 USB Power Enable pins to USB ports
- \ to correspond to the way they are wired on the board.
- \ USB port 1 is PWR_EN2, USB ports 2-4 are PWR_EN1
- usb-port-power-map h# efc00000 l!
- 2 h# efc00004 l!
- h# 1 h# fe01a008 l! \ Reset OHCI host controller
- h# 1e.0000 h# fe01a04c l! \ Configure ports for individual power
- h# 100 h# fe01a058 l! \ Power-on ports 2 and 3
- d# 10 ms \ Stagger for glitch-prevention
- h# 100 h# fe01a054 l! \ Power-on port 1
- h# 100 h# fe01a05c l! \ Power-on port 3
- h# 100 h# fe01a060 l! \ Power-on port 4
- get-msecs d# 1000 + to usb-power-done-time
-;
-
-
-\ 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
Author: wmb
Date: 2008-05-21 23:12:54 +0200 (Wed, 21 May 2008)
New Revision: 824
Added:
cpu/x86/pc/linux.fth
cpu/x86/pc/lxdevel/addrs.fth
cpu/x86/pc/lxdevel/banner.fth
cpu/x86/pc/lxdevel/loaddropins.fth
cpu/x86/pc/lxdevel/rmstart.fth
cpu/x86/pc/memtest.fth
dev/geode/draminit.fth
dev/geode/gpio.fth
dev/geode/startmacros.fth
dev/geode/usb.fth
Modified:
cpu/x86/pc/lxdevel/config.fth
cpu/x86/pc/lxdevel/devices.fth
cpu/x86/pc/lxdevel/fw.bth
cpu/x86/pc/lxdevel/lxdevel.bth
cpu/x86/pc/lxdevel/msrinit.fth
cpu/x86/pc/lxdevel/pcinode.fth
cpu/x86/pc/lxdevel/rmstart.bth
cpu/x86/pc/lxdevel/romreset.bth
cpu/x86/pc/lxdevel/versions.fth
cpu/x86/pc/olpc/fw.bth
cpu/x86/pc/olpc/romreset.bth
cpu/x86/pc/olpc/versions.fth
dev/geode/nandflash/methods.fth
dev/geode/nandflash/nand5536.fth
dev/geode/nandflash/nandflash.bth
Log:
Fixed the lxdevel build by:
Moved some files that aren't really OLPC-specific from cpu/x86/pc/olpc into
cpu/x86/pc and dev/geode, doing a little refactoring (mostly just moving
code into different files) in the process.
Made lxdevel-specific versions of some files that contained OLPC dependencies
Removed spurious OLPC dependencies from the lxdevel build.
This change is intended to be functionally neutral for the OLPC build.
Added: cpu/x86/pc/linux.fth
===================================================================
--- cpu/x86/pc/linux.fth (rev 0)
+++ cpu/x86/pc/linux.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -0,0 +1,331 @@
+\ See license at end of file
+purpose: Linux bzImage program loading
+
+\ Example boot configuration variable settings:
+
+\ Example default values for a system that boots primarily from hard disk:
+
+\ \needs ramdisk " disk:\boot\initrd.img" d# 128 config-string ramdisk
+\ " ro root=LABEL=OLPCRoot rootfstype=ext3 console=ttyS0,115200 console=tty0"
+\ ' boot-file set-config-string-default
+\ " disk:\boot\vmlinuz" ' boot-device set-config-string-default
+
+\ Example default values for a system that boots primarily from JFFS2 on NAND:
+
+\ " nand:\boot\vmlinuz" ' boot-device set-config-string-default
+\ " ro root=mtd0 rootfstype=jffs2 console=ttyS0,115200 console=tty0"
+\ ' boot-file set-config-string-default
+
+0 value ramdisk-adr
+0 value /ramdisk
+
+create screen-info \ See struct screen_info in include/linux/tty.h
+ 0 c, \ 0 x position
+ 0 c, \ 1 y position
+ 0 w, \ 2 plug in memory size here
+ 0 w, \ 4 video page
+ 0 c, \ 6 video mode - 7 means monochrome, anything else is color
+ d# 80 c, \ 7 columns
+ 0 w, \ 8 unused
+ 0 w, \ a ega_bx - anything but 0x10
+ 0 w, \ c unused
+ d# 25 c, \ e lines
+ 0 c, \ f isVGA?
+ d# 16 w, \ 10 font height
+here screen-info - constant /screen-info
+
+
+h# 9.0000 constant linux-params
+h# 10.0000 value linux-base
+: code16-size ( -- #bytes ) load-base h# 1f1 + c@ 1+ d# 512 * ;
+0 value cmdline-offset
+
+\ Find the end of the largest piece of memory
+: memory-limit ( -- limit )
+ " /memory" find-package 0= abort" No /memory node" ( phandle )
+ " available" rot get-package-property abort" No memory node available property" ( $ )
+ \ Find the memory piece that starts at 1 Meg
+ begin dup 8 >= while ( $ )
+ decode-int h# 10.0000 = if ( $ ) \ Found the one we want
+ decode-int h# 10.0000 + ( $ limit )
+ nip nip exit
+ then ( $ )
+ decode-int drop ( $ )
+ repeat ( $ )
+ 2drop true abort" No suitable memory piece"
+;
+
+d# 20 constant /root-dev-buf
+/root-dev-buf buffer: root-dev-buf
+
+: make-root-dev$ ( idx -- root-dev$ )
+ root-dev-buf /root-dev-buf 0 fill
+ " root=/dev/hda" rot
+ 1+ base @ >r d# 10 base ! (.) r> base !
+ $cat2
+ 2dup 2>r root-dev-buf swap move
+ 2r> free-mem
+ root-dev-buf /root-dev-buf
+;
+: +lp ( offset -- adr ) linux-params + ;
+
+0 [if]
+: add-root-dev ( cmdline$ -- cmdline$' )
+ 2>r " root=" 2r@ sindex -1 = if
+ 2r>
+ " disk:root,\" $partition-idx dup -1 <> if
+ make-root-dev$ $cat2
+ else
+ drop
+ then
+ else
+ 2r>
+ then
+;
+[else]
+: add-root-dev ( cmdline$ -- cmdline$' )
+;
+[then]
+
+: set-parameters ( cmdline$ -- )
+ screen-info linux-params /screen-info move \ Ostensibly screen info
+
+ memory-limit ( #bytes )
+ d# 1023 invert and d# 1024 / ( #kbytes )
+ d# 1024 - h# 002 +lp w! \ Kbytes of extended (not the 1st meg) memory
+
+ memory-limit ( #bytes )
+ d# 1023 invert and d# 1024 / ( #kbytes )
+ d# 1024 - h# 1e0 +lp l! \ Alternate amount of extended memory
+
+ 0 h# 1f2 +lp w! \ root flags - non0 to mount root read-only
+ 0 h# 1f8 +lp w! \ Ramdisk flags
+
+\ 301 for /dev/hda, 100 for /dev/ram0, 0 for nothing (set it from cmdline)
+\ h# 301 h# 1fc +lp w! \ root_dev - see init/main.c:parse_root_dev
+\ h# 100 h# 1fc +lp w! \ root_dev - see init/main.c:parse_root_dev
+ h# 0 h# 1fc +lp w! \ root_dev - see init/main.c:parse_root_dev
+
+ 0 h# 1ff +lp c! \ Aux device - set to AA if PS2 mouse present
+ /ramdisk 0<> h# 210 +lp w! \ loader type - set non0 to enable ramdisk info
+\ h# 100000 h# 214 +lp l! \ kernel start - unused
+ ramdisk-adr h# 218 +lp l! \ initrd start
+ /ramdisk h# 21c +lp l! \ initrd size
+
+ \ Put Open Firmware signature and IDT pointer in the params area
+ " OFW " drop @ h# b0 +lp l! \ Validator for this area
+ 1 h# b4 +lp l! \ Number of additional items (version#)
+ cif-handler h# b8 +lp l! \ Client interface handler
+ idt drop h# bc +lp l! \ So Linux can preserve our debug vectors
+
+ \ Command line goes after the 16-bit wad
+ ( cmdline$ ) add-root-dev
+ ( cmdline$ ) cmdline-offset +lp swap 1+ move
+ h# a33f h# 20 +lp w! \ Command line validator (magic number)
+ cmdline-offset h# 22 +lp w! \ Command line offset
+ cmdline-offset +lp h# 228 +lp l! \ New command line address
+;
+
+: linux-fixup ( -- )
+[ifdef] linux-logo linux-logo [then]
+ args-buf cscount set-parameters ( )
+ h# ff h# 21 pc! \ Squelch the timer interrupt and others
+
+ linux-base linux-params (init-program)
+ linux-params to %esi
+;
+
+d# 256 buffer: ramdisk-buf
+' ramdisk-buf " ramdisk" chosen-string
+
+defer load-ramdisk
+: $load-ramdisk ( name$ -- )
+ 0 to /ramdisk ( name$ )
+
+ ['] load-path behavior >r ( name$ r: xt )
+ ['] ramdisk-buf to load-path ( name$ r: xt )
+
+ ." Loading ramdisk image from " 2dup type ." ..." ( name$ r: xt )
+ ['] boot-read catch ( throw-code r: xt )
+ cr ( throw-code r: xt )
+ r> to load-path ( throw-code )
+ throw
+ loaded to /ramdisk to ramdisk-adr
+;
+: cv-load-ramdisk ( -- )
+ " ramdisk" eval dup 0= if 2drop exit then ( name$ )
+ $load-ramdisk
+;
+' cv-load-ramdisk to load-ramdisk
+
+: claim-params ( -- )
+[ifdef] virtual-mode
+ 0 0 1meg -1 mmu-map ( ) \ Make the parameter area accessible
+[then]
+ 0 +lp h# 1000 0 mem-claim drop \ Play nice with memory reporting
+ 0 +lp h# 1000 erase
+;
+
+0 value linux-loaded?
+: ?linux-elf-map-in ( va size -- )
+ \ The Linux startup code really wants the physical address to be
+ \ virtual_address AND 0x0fff.ffff. We recognize Linux by the virtual
+ \ address range that it uses (0xc0xx.xxxx)
+ over h# f000.0000 and h# c000.0000 = if
+ h# 40.0000 to linux-base
+ h# 800 to cmdline-offset
+ true to linux-loaded?
+ over h# 0fff.ffff and ( va size pa )
+ -rot -1 ( pa va size mode )
+ mmu-map
+ exit
+ then
+ (elf-map-in)
+;
+' ?linux-elf-map-in is elf-map-in
+
+: init-bzimage? ( -- flag )
+ loaded ( adr len )
+ h# 202 /string ( adr' len' )
+ 4 < if drop false exit then ( adr )
+ " HdrS" comp if false exit then ( )
+ h# 10.0000 to linux-base
+ code16-size to cmdline-offset \ Save in case we clobber load-base
+ load-base 0 +lp code16-size move \ Copy the 16-bit stuff
+ loaded code16-size /string linux-base swap move \ Copy the 32-bit stuff
+ true to linux-loaded?
+ true
+;
+
+warning @ warning off
+: init-program ( -- )
+ init-bzimage? if exit then
+ init-program
+;
+
+: sym ( "name" -- adr )
+ parse-word $sym> 0= if err-sym-not-found throw then
+;
+warning !
+
+warning @ warning off
+: init-program ( -- )
+ false to linux-loaded?
+ init-program
+ linux-loaded? if
+ claim-params
+ ['] load-ramdisk guarded
+ linux-fixup
+ then
+;
+warning !
+
+: mcr ( -- ) cr exit? throw ;
+: help-debug ( -- )
+ red-letters
+ ." Debugging the Linux kernel requires a few patches to keep Linux from" mcr
+ ." overwriting the firmware debug vector." mcr mcr
+ black-letters
+
+ ." COMMAND STACK EFFECT DESCRIPTION" mcr
+ ." .registers ( -- ) Display registers" mcr
+ ." go ( -- ) Resume execution" mcr
+ ." step ( -- ) Single-step" mcr
+ ." ^T ( -- ) (Control-T) Keystroke shortcut for 'step'" mcr
+ ." steps ( n -- ) Single-step n times" mcr
+ ." hop ( -- ) Step over subroutine calls" mcr
+ ." hops ( n -- ) Hop n times" mcr
+ ." dis ( addr -- ) Disassemble starting at given address" mcr
+ ." +dis ( -- ) Continue disassembling" mcr
+ ." bp ( addr -- ) Set breakpoint at given address" mcr
+ ." till ( addr -- ) Set breakpoint at given address and go" mcr
+ ." -bp ( addr -- ) Delete breakpoint at given address" mcr
+ ." --bp ( -- ) Delete last breakpoint" mcr
+ ." .bp ( -- ) Show breakpoints" mcr
+ ." return ( -- ) Finish execution of current subroutine" mcr
+ ." finish-loop ( -- ) Finish execution of current loop" mcr
+ ." %eax ( -- n ) Push EAX (etc.) register value on stack" mcr
+ ." %eip ( -- n ) Push EIP register value on stack" mcr
+ ." %pc ( -- n ) Same as %eip" mcr
+ ." to %eax ( n -- ) Set EAX (etc.) register value from stack" mcr
+ ." to %eip ( n -- ) Set EIP register value from stack" mcr
+ ." sym <name> ( -- n ) Push value of named kernel symbol on stack" mcr
+ ." .adr ( n -- ) Display symbol name closest to n" mcr
+ ." Examples: " mcr
+ ." %pc dis Disassemble starting at program counter" mcr
+ ." %ebx u. Display saved value of EBX register" mcr
+ ." step Single step once" mcr
+ ." 10 hops Step 10 times, don't go down into subroutines" mcr
+ ." 1234 to %ebp Set EBP register to (hex) 1234" mcr
+ ." sym kbd_init dis Disassemble starting at kbd_init" mcr
+ ." sym kbd_init till Set breakpoint at kbd_init and go" mcr
+ ." %pc 5 + to %pc Add 5 to the program counter register" mcr
+
+ mcr
+ ." More information: http://firmworks.com/QuickRef.html" cr
+;
+
+d# 34 to default-#lines
+
+warning @ warning off
+: help ( -- )
+ blue-letters ." UPDATES:" black-letters mcr
+ ." flash u:\q2c18.rom Rewrite the firmware from USB key" mcr
+ ." flash nand:\q2c18.rom Rewrite the firmware from NAND file" mcr
+ ." copy-nand u:\boot\nand290.img Rewrite the OS on NAND from USB key" mcr
+ mcr
+ blue-letters ." DIRECTORY LISTING:" black-letters mcr
+ ." dir u:\ List USB key root directory" mcr
+ ." dir u:\boot\ List USB key /boot directory" mcr
+ ." dir nand:\boot\ List NAND FLASH /boot directory" mcr
+ ." dir nand:\boot\*.rom List .rom files in NAND FLASH /boot directory" mcr
+ mcr
+ blue-letters ." BOOTING:" black-letters mcr
+ ." boot Load the OS from list of default locations" mcr
+ ." 'printenv boot-device' shows the list" mcr
+ ." boot <cmdline> Load the OS, passing <cmdline> to kernel" mcr
+ ." boot u:\boot\vmlinuz Load the OS from a specific location" mcr
+ mcr
+ blue-letters ." CONFIGURATION VARIABLES FOR BOOTING:" black-letters mcr
+ ." boot-device Kernel or boot script path. Example: nand:\boot\olpc.fth" mcr
+ ." boot-file Default cmdline. Example: console=ttyS0,115200" mcr
+ ." ramdisk initrd pathname. Example: disk:\boot\initrd.imz" mcr
+ mcr
+ blue-letters ." MANAGING CONFIGURATION VARIABLES:" black-letters mcr
+ ." printenv [ <name> ] Show configuration variables" mcr
+ ." setenv <name> <value> Set configuration variable" mcr
+ ." editenv <name> Edit configuration variable" mcr
+ mcr
+ blue-letters ." DIAGNOSTICS:" black-letters mcr
+ ." test <device-name> Test device. Example: test mouse" mcr
+ ." test-all Test all devices that have test routines" mcr
+ mcr
+ ." More information: "
+ green-letters ." http://wiki.laptop.org/go/OFW_FAQ" black-letters cr
+;
+warning !
+
+
+\ 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/lxdevel/addrs.fth
===================================================================
--- cpu/x86/pc/lxdevel/addrs.fth (rev 0)
+++ cpu/x86/pc/lxdevel/addrs.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -0,0 +1,109 @@
+\ See license at end of file
+purpose: Establish address and I/O configuration definitions
+
+[ifdef] use-meg0
+h# f0.0000 constant dropin-base
+h# 08.0000 constant dropin-size
+h# 0.4000 constant fw-pa
+h# f.c000 constant /fw-ram
+[then]
+
+[ifdef] rom-loaded
+[ifdef] lx-devel
+h# fff8.0000 constant rom-pa \ Physical address of boot ROM
+h# 8.0000 constant /rom \ Size of boot ROM
+rom-pa constant dropin-base
+[else]
+h# fff0.0000 constant rom-pa \ Physical address of boot ROM
+h# 10.0000 constant /rom \ Size of boot ROM
+rom-pa h# 1.0000 + constant dropin-base
+[then]
+
+h# 8.0000 constant dropin-size
+
+dropin-base h# 20 + constant ResetBase \ Location of "reset" dropin in ROM
+
+h# 1c0.0000 constant fw-pa
+h# 20.0000 constant /fw-ram
+[then]
+
+[ifdef] linuxbios-loaded
+\ h# d8.0000 constant dropin-base
+h# fff2.0000 constant dropin-base \ Location of payload in FLASH
+\ h# fff8.0000 constant dropin-base \ Location of payload in FLASH
+dropin-base h# 80 + h# 20 + constant ResetBase \ Location of "reset" dropin in ROM
+h# 08.0000 constant dropin-size
+h# 1e0.0000 constant fw-pa
+h# 20.0000 constant /fw-ram
+h# fff0.0000 constant rom-pa
+h# 10.0000 constant /rom
+[then]
+
+[ifdef] old-bzimage-loaded
+\ h# d8.0000 constant dropin-base
+h# 10.0020 constant dropin-base \ RAM address where Linux normally loads
+h# 08.0000 constant dropin-size
+h# 20.0000 constant fw-pa
+h# 20.0000 constant /fw-ram
+[then]
+
+[ifdef] bzimage-loaded
+h# 1d8.0020 constant dropin-base \ RAM address where we want to end up
+h# 08.0000 constant dropin-size
+h# 1e0.0000 constant fw-pa
+h# 20.0000 constant /fw-ram
+[then]
+
+[ifdef] syslinux-loaded
+h# 10.1020 constant dropin-base
+h# 07.e0e0 constant dropin-size
+h# 20.0000 constant fw-pa
+h# 20.0000 constant /fw-ram
+[then]
+
+[ifdef] grub-loaded
+h# 1b8.0000 constant dropin-base
+h# 08.0000 constant dropin-size
+h# 1c0.0000 constant fw-pa
+h# 20.0000 constant /fw-ram
+[then]
+
+h# 80.0000 constant def-load-base \ Convenient for initrd
+
+\ The heap starts at RAMtop, which on this system is "fw-pa /fw-ram +"
+h# 20.0000 constant heap-size
+
+h# 300.0000 constant jffs2-dirent-base
+h# 500.0000 constant jffs2-inode-base
+h# 700.0000 constant dma-base
+h# 900.0000 constant dma-size
+
+h# f.0000 constant suspend-base \ In the DOS hole
+h# f.0008 constant resume-entry
+h# f.0800 constant resume-data
+
+fload ${BP}/cpu/x86/pc/virtaddr.fth
+
+\ 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/lxdevel/banner.fth
===================================================================
--- cpu/x86/pc/lxdevel/banner.fth (rev 0)
+++ cpu/x86/pc/lxdevel/banner.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -0,0 +1,56 @@
+\ See license at end of file
+purpose: Banner customization for this system
+
+headerless
+
+: .rom ( -- )
+ ." OpenFirmware "
+ push-decimal
+ major-release (.) type ." ." minor-release (.) type sub-release type
+ pop-base
+[ifdef] bzimage-loaded
+ ." booted from disk - " .built
+[then]
+;
+
+: (xbanner-basics) ( -- )
+ ?spaces cpu-model type ." , " .memory
+ ?spaces .rom
+;
+' (xbanner-basics) to banner-basics
+
+' (banner-warnings) to banner-warnings
+
+: stop-auto? ( -- flag ) idprom-valid? 0= auto-boot? and ;
+
+defer gui-banner ' true to gui-banner
+: ?gui-banner ( -- )
+ stop-auto? if suppress-auto-boot then
+
+ gui-banner drop
+;
+
+headers
+\ 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
Modified: cpu/x86/pc/lxdevel/config.fth
===================================================================
--- cpu/x86/pc/lxdevel/config.fth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/lxdevel/config.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -1,8 +1,6 @@
\ See license at end of file
purpose: Establish configuration definitions
-create olpc-gui \ Use OLPC graphics
-
create use-lx
create lx-devel
@@ -43,7 +41,7 @@
create use-null-nvram
-fload ${BP}/cpu/x86/pc/olpc/addrs.fth
+fload ${BP}/cpu/x86/pc/lxdevel/addrs.fth
\ LICENSE_BEGIN
\ Copyright (c) 2006 FirmWorks
Modified: cpu/x86/pc/lxdevel/devices.fth
===================================================================
--- cpu/x86/pc/lxdevel/devices.fth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/lxdevel/devices.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -1,9 +1,8 @@
\ See license at end of file
purpose: Load device drivers according to configuration definitions
-: board-revision ( -- n )
- h# 4c00.0014 rdmsr drop 4 rshift 7 and
-;
+: gx? ( -- flag ) h# 4c000017 msr@ drop 4 rshift 2 = ;
+: lx? ( -- flag ) h# 4c000017 msr@ drop 4 rshift 3 = ;
fload ${BP}/cpu/x86/pc/isaio.fth
@@ -221,12 +220,12 @@
dend
;
-fload ${BP}/cpu/x86/pc/olpc/mfgdata.fth \ Manufacturing data
-
\ fload ${BP}/dev/geode/lpcflash.fth \ Reflasher for PLCC FLASH on A-test
: +i encode-int encode+ ; : 0+i 0 +i ;
+false config-int tft-mode?
+
fload ${BP}/cpu/x86/fb16-ops.fth
fload ${BP}/ofw/termemu/fb16.fth
0 0 " 1,1" " /pci" begin-package
Modified: cpu/x86/pc/lxdevel/fw.bth
===================================================================
--- cpu/x86/pc/lxdevel/fw.bth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/lxdevel/fw.bth 2008-05-21 21:12:54 UTC (rev 824)
@@ -83,7 +83,7 @@
alias lmove lmove \ Needed by CS5536 NAND FLASH driver
dend
-fload ${BP}/cpu/x86/pc/olpc/gpio.fth \ Rudimentary GPIO driver
+fload ${BP}/dev/geode/gpio.fth \ Rudimentary GPIO driver
fload ${BP}/cpu/x86/pc/lxdevel/probemem.fth \ Memory probing
[ifdef] virtual-mode
@@ -117,12 +117,14 @@
[then]
[ifdef] linux-support
+\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
[then]
[ifdef] jffs2-support
+\needs unix-seconds> fload ${BP}/ofw/fs/unixtime.fth \ Unix time calculation
support-package: jffs2-file-system
fload ${BP}/ofw/fs/jffs2/jffs2.fth \ Journaling flash file system 2
end-support-package
@@ -224,7 +226,7 @@
fload ${BP}/cpu/x86/pc/boot.fth
h# 3ea constant usb-port-power-map \ USB4:PWR2 USB3:PWR1 USB2:PWR1 USB1:PWR1
-fload ${BP}/cpu/x86/pc/olpc/usb.fth
+fload ${BP}/dev/geode/usb.fth
false to stand-init-debug?
\ true to stand-init-debug?
@@ -277,33 +279,27 @@
;
[ifdef] linux-support
-fload ${BP}/cpu/x86/pc/olpc/linux.fth
+fload ${BP}/cpu/x86/pc/linux.fth
+\ Use values like these if you want to boot directly instead of through an intermediate script
+\ " disk:\vmlinuz" ' boot-device set-config-string-default
+\ " disk:\initrd" d# 128 config-string ramdisk
+
+\needs ramdisk " " d# 128 config-string ramdisk
+" " ' boot-file set-config-string-default \ Let the boot script set the cmdline
[then]
+" disk:\boot\boot.fth nand:\boot\boot.fth /prober /usb/ethernet" ' boot-device set-config-string-default
+
+
fload ${BP}/ofw/gui/bmptools.fth
fload ${BP}/dev/null.fth
fload ${BP}/ofw/core/bailout.fth
-[ifdef] olpc-gui
-\ GUI
-false value gui-safeboot?
+fload ${BP}/cpu/x86/pc/lxdevel/banner.fth
-\ FIXME need to implement user-ok to lockout ok prompt
-: 2tuck ( d1 d2 -- d2 d1 d2 ) 2swap 2over ;
-false value fru-test?
-: user-ok "ok" ; \ This is supposed to check for authorization
-true value user-mode?
-
-fload ${BP}/cpu/x86/pc/olpc/banner.fth
-[then]
-
fload ${BP}/ofw/gui/loadmenu.fth
\ fload ${BP}/ofw/gui/insticon.fth
-[ifdef] olpc-gui
-fload ${BP}/cpu/x86/pc/olpc/gui.fth
-[then]
-
\ Eliminate 4 second delay in install console for the case where
\ there is no keyboard. The delay is unnecessary because the screen
\ does not go blank when the device is closed.
@@ -349,14 +345,6 @@
fload ${BP}/ofw/ppp/loadppp.fth
[then]
-[ifdef] pc-linux
-" a:\initrd.imz" d# 128 config-string ramdisk
-" root=/dev/ram0 mount_ramdisk=1" ' boot-file set-config-string-default
-" a:\vmlinuz" ' boot-device set-config-string-default
-true ' client-symbols? set-config-int-default
-\ Also try " console=/dev/ttyS0,9600 console=/dev/tty0" in boot-file
-[then]
-
" dhcp" ' ip-address set-config-string-default
\ fload ${BP}/cpu/x86/pc/report.fth
@@ -492,15 +480,11 @@
quit
;
-fload ${BP}/cpu/x86/pc/olpc/copynand.fth
-
-[ifndef] olpc
\ This sometimes helps with VGA/EGA boards, enabling I/O space access
\ to the CRT registers that control the hardware cursor.
: cursor ( -- )
" begin-select /display 3 my-space 4 + config-w! unselect" evaluate
;
-[then]
\ This helps with TeraTerm, which sends ESC-O as the arrow key prefix
also hidden also keys-forth definitions
Added: cpu/x86/pc/lxdevel/loaddropins.fth
===================================================================
--- cpu/x86/pc/lxdevel/loaddropins.fth (rev 0)
+++ cpu/x86/pc/lxdevel/loaddropins.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -0,0 +1,22 @@
+\ Loads the set of drivers that is common to different output formats
+
+ " paging.di" $add-file
+ " ${BP}/cpu/x86/build/inflate.bin" " inflate" $add-dropin
+ " fw.img" " firmware" $add-deflated-dropin
+
+ " ${BP}/dev/usb2/hcd/ohci/build/ohci.fc" " class0c0310" $add-deflated-dropin
+ " ${BP}/dev/usb2/hcd/ehci/build/ehci.fc" " class0c0320" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/hub/build/hub.fc" " usb,class9" $add-dropin
+ " ${BP}/dev/usb2/device/net/build/usbnet.fc" " usbnet" $add-deflated-dropin
+ " ${BP}/dev/usb2/device/keyboard/build/usbkbd.fc" " usb,class3,1" $add-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
+
+ " ${BP}/dev/geode/ac97/build/ac97.fc" " pci1022,2093" $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/gallant.obf" " font" $add-deflated-dropin
Modified: cpu/x86/pc/lxdevel/lxdevel.bth
===================================================================
--- cpu/x86/pc/lxdevel/lxdevel.bth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/lxdevel/lxdevel.bth 2008-05-21 21:12:54 UTC (rev 824)
@@ -7,8 +7,6 @@
in: ${BP}/cpu/x86/pc/lxdevel/build/paging.di
in: ${BP}/cpu/x86/pc/lxdevel/build/fw.dic
in: ${BP}/dev/geode/nandflash/build/nandflash.fc
-in: ${BP}/dev/mmc/sdhci/build/sdhci.fc
-in: ${BP}/dev/mmc/sdhci/build/sdmmc.fc
in: ${BP}/dev/geode/ac97/build/ac97.fc
in: ${BP}/dev/usb2/hcd/ohci/build/ohci.fc
in: ${BP}/dev/usb2/hcd/ehci/build/ehci.fc
@@ -17,11 +15,7 @@
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/usb2/device/wlan/build/usb8388.fc
-in: ${BP}/dev/olpc/cafenand/build/cafenand.fc
-in: ${BP}/dev/olpc/cafecamera/build/cafecamera.fc
in: ${BP}/dev/pci/build/pcibridg.fc
-in: usb8388.bin
build-now
@@ -48,7 +42,7 @@
" romreset.di" $add-file
\ " resume.di" $add-file
- fload ${BP}/cpu/x86/pc/olpc/loaddropins.fth
+ fload ${BP}/cpu/x86/pc/lxdevel/loaddropins.fth
" ${BP}/dev/pci/build/pcibridg.fc" " class060400" $add-deflated-dropin
/rom h# 400 - pad-file \ rmstart image must start 0x400 from end
Modified: cpu/x86/pc/lxdevel/msrinit.fth
===================================================================
--- cpu/x86/pc/lxdevel/msrinit.fth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/lxdevel/msrinit.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -193,7 +193,7 @@
msr: 5100.0023 0189c001.01880001. \ IRQ mapper
msr: 5100.0024 0147c001.01400001. \ PMS
msr: 5100.0025 0187c001.01840001. \ ACPI
- msr: 5100.0026 014fc001.01480001. \ What?? 128 bytes (0x80)
+ msr: 5100.0026 014fc001.01480001. \ AC97
msr: 5100.0027 fe01a000.fe01a001. \ OHCI
msr: 5100.0028 fe01b000.fe01b001. \ EHCI
msr: 5100.0029 efc00000.efc00001. \ UOC
Modified: cpu/x86/pc/lxdevel/pcinode.fth
===================================================================
--- cpu/x86/pc/lxdevel/pcinode.fth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/lxdevel/pcinode.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -9,6 +9,7 @@
patch nonvirtual-probe-state? probe-state? map-in
\ patch noop assign-all-addresses prober
+warning @ warning off
: assign-pci-addr ( phys.lo phys.mid phys.hi len | -1 -- phys.hi paddr size )
2dup -1 <> swap virtual-pci-slot? and if ( phys.lo phys.mid phys.hi len )
2swap 2drop >r ( phys.hi r: len )
@@ -17,6 +18,7 @@
then
assign-pci-addr
;
+warning !
: ?clear-addresses ( -- )
my-space virtual-pci-slot? if exit then clear-addresses
Modified: cpu/x86/pc/lxdevel/rmstart.bth
===================================================================
--- cpu/x86/pc/lxdevel/rmstart.bth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/lxdevel/rmstart.bth 2008-05-21 21:12:54 UTC (rev 824)
@@ -8,4 +8,4 @@
\ create debug-reset
fload ${BP}/cpu/x86/pc/lxdevel/config.fth
-fload ${BP}/cpu/x86/pc/olpc/rmstart.fth
+fload ${BP}/cpu/x86/pc/lxdevel/rmstart.fth
Added: cpu/x86/pc/lxdevel/rmstart.fth
===================================================================
--- cpu/x86/pc/lxdevel/rmstart.fth (rev 0)
+++ cpu/x86/pc/lxdevel/rmstart.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -0,0 +1,277 @@
+\ See license at end of file
+purpose: x86 real mode startup code.
+
+command: &native &this
+build-now
+
+\ 386/486 processors begin executing at address ffff.fff0 in real mode
+\ when they come out of reset. Normally, that address would not be
+\ accessable in real mode, but the processor does some magic things to
+\ the Code Segment register so that the high order address lines are
+\ "boosted" up to the ffff.xxxx range just after reset. The "boosting"
+\ persists until the CS register is modified (i.e. with a far jump).
+
+\ The other segment register are not "boosted", so they can only access
+\ the normal real mode range, essentially just the first megabyte.
+
+\ The startup code must establish a Global Descriptor Table containing
+\ suitable mappings, and then enter protected mode. The space between
+\ ffff.fff0 and the end of the ROM is insufficient to do this, so the
+\ first few instructions must jump elsewhere, to a place where there
+\ is enough room.
+
+\ The code below is rather tricky, especially since the Forth assembler
+\ always assumes 32-bit operand size and 32-bit addressing modes.
+\ The code is executing in 16-bit mode, so the assembler must be used
+\ carefully to ensure generation of the correct opcodes, and override
+\ prefixes where necessary.
+
+
+\needs start-assembling fload ${BP}/cpu/x86/asmtools.fth
+\needs write-dropin fload ${BP}/forth/lib/mkdropin.fth
+
+hex
+
+start-assembling
+protected-mode
+hex
+
+\ Addresses where the following items will be located in the processor's
+\ physical address space:
+
+\ ffff.fc00: GDT ( 3 entries ) + padding
+\ ffff.fc20: GDT address + size ( 6 bytes ) plus padding
+\ ffff.fc28: Startup code plus padding
+\ ffff.fff0: Reset entry point - jump to startup code plus padding to end
+
+\ Assembler macros for startup diagnostics
+
+\ write a byte to an ISA port
+: risa-c! ( n a - ) " # dx mov # al mov al dx out " evaluate ;
+
+: num>asc ( al: b -- al: low ah: hi )
+ " al ah mov " evaluate
+ " h# f # al and " evaluate
+ " h# 9 # al cmp > if h# 57 # al add else h# 30 # al add then " evaluate
+
+ " ah shr ah shr ah shr ah shr " evaluate \ shift down four bits
+ " h# f # ah and " evaluate
+ " h# 9 # ah cmp > if h# 57 # ah add else h# 30 # ah add then " evaluate
+
+ " al bl mov ah al mov bl ah mov " evaluate
+
+;
+
+[ifdef] debug-reset
+.( debug reports enabled ) cr
+\ Assembler macro to assemble code to send the character "char" to COM1
+: report ( char -- )
+ " begin 3fd # dx mov dx al in 20 # al and 0<> until" evaluate
+ ( char ) " # al mov 3f8 # dx mov al dx out " evaluate
+ " begin 3fd # dx mov dx al in 20 # al and 0<> until" evaluate
+;
+\ Put character in al
+: reportc
+ " al ah mov " eval
+ " begin 3fd # dx mov dx al in 20 # al and 0<> until" evaluate
+ ( char ) " ah al mov 3f8 # dx mov al dx out " evaluate
+ " begin 3fd # dx mov dx al in 20 # al and 0<> until" evaluate
+;
+: init-com1 ( -- )
+ 1 3fc risa-c! \ DTR on
+ 80 3fb risa-c! \ Switch to bank 1 to program baud rate
+ 01 3f8 risa-c! \ Baud rate divisor low - 115200 baud
+ 0 3f9 risa-c! \ Baud rate divisor high - 115200 baud
+ 3 3fb risa-c! \ 8 bits, no parity, switch to bank 0
+;
+
+[else]
+: report ( char -- ) drop ;
+: reportc ( -- ) ;
+[then]
+
+hex
+
+\ odds for testing, evens for release
+d# 8 constant loader-version# \ monotonic
+2 constant loader-format# \ >1 when crc present
+
+.( ROM loader: version# ) loader-version# .d
+.( , format# ) loader-format# .d cr
+
+\ Real Mode Startup
+
+hex
+
+label rm-startup \ Executes in real mode with 16-bit operand forms
+
+ \ ffff.fc00 GDT
+
+ 0 w, 0 l, 0 w, \ 0 Mandatory null descriptor
+ 0 w, 0 l, 0 w, \ * Another null descriptor
+ ffff w, 9b.000000 l, 00.c.f w, \ 10 Code, linear=physical, full 4Gbytes
+ ffff w, 93.000000 l, 00.c.f w, \ 18 Data, linear=physical, full 4Gbytes
+
+ \ ffff.fc20 GDT limit + address
+
+ 1f w, ffff.fc00 l, \ # slots (4 * 8 - 1) , starting address
+ 0 w, \ Padding
+
+ \ ------->>>>> Startup code, reached by branch from main entry point below
+ \
+ \ ffff.fc28
+
+ here \ Mark the beginning of this code so its size may be determined
+ \ and so that a jump to it may be assembled later.
+
+ real-mode
+
+ h# 01 # al mov al h# 80 # out
+
+ \ This code is highly optimized because it runs when the CPU is in
+ \ it slowest operation mode, so we want to get it done fast.
+ \ GLCP_SYS_RSTPLL - page 406
+ \ If the PLL is already set up, we don't redo the 5536 setup
+ op: h# 4c000014 # cx mov rdmsr \ MSR value in dx,ax
+ al bl mov
+ op: h# fc00.0000 # ax and 0= if \ Start the PLL if not already on
+ rdmsr \ Get base MSR value with divisors
+ op: h# 04de.0000 # ax or \ Set the startup time (de) and breadcrumb (4)
+ op: h# 0000.04d9 # dx mov \ PLL value for 333 MB clk, 433 CPU
+ wrmsr \ Put in the base value
+ op: h# 0000.1800 invert # ax and \ Turn off the BYPASS bits
+
+ h# 6001 # ax or \ Set PD, RESETPLL
+ wrmsr \ Start the PLL and reset the CPU
+ then
+
+ \ Return to here after the reset
+ h# 02 # al mov al h# 80 # out
+
+
+[ifdef] init-com1 init-com1 [then]
+
+[ifdef] debug-reset
+carret report \ send it to com1 if you can...
+linefeed report \ send it to com1 if you can...
+ascii F report \ send it to com1 if you can...
+[then]
+
+ \ The following instruction uses the CS: segment override because
+ \ that segment is currently "boosted" up into the ROM space.
+ \ It uses the operation size override to load a 32-bit pointer.
+ \ The address override is not used; the GDT limit/address data structure
+ \ above is reachable with a 16-bit address and through the "boosted"
+ \ code segment.
+
+ op: cs: 0f c, 01 c, 16 c, fc20 w, \ lgdte cs:[fc20] Setup GDT
+
+ op: cr0 bx mov \ Get existing CR0 value
+
+ 1 # bl or \ Set "protected mode" bit
+
+ bx cr0 mov \ Enter protected mode
+ eb c, 0 c, \ jmp to next location to flush prefetch queue
+ \ note: CPL is now 0
+
+ h# 03 # al mov al h# 80 # out
+
+ \ We are in protected mode, but we are still executing from old
+ \ 16-bit code segment, and will continue to do so until the far jump
+ \ below
+
+[ifdef] debug-reset
+ascii o report
+[then]
+
+ \ set segment registers
+ bx bx xor \ Clear high byte
+ 18 # bl mov \ Data segment selector
+ bx ds mov \ Set segment register
+ bx es mov \ Set segment register
+ bx fs mov \ Set segment register
+ bx gs mov \ Set segment register
+
+[ifdef] debug-reset
+ascii r report
+[then]
+
+ bx ss mov \ Set segment register
+
+[ifdef] debug-reset
+ascii t report
+ascii h report
+[then]
+
+ h# 0f # al mov al h# 80 # out
+
+ op: h# 1430 # dx mov op: dx ax in op: h# 9999 # ax cmp = if
+ h# 34 # al mov al h# 70 # out \ Write to CMOS 0x34
+ h# 0f # al mov al h# 71 # out \ Write value 01
+ then
+
+ op: ad: ResetBase h# 10 #) far jmp \ Jump to Forth startup
+
+ real-mode
+
+ \ Pad the startup code so that the main entry point ends up at the
+ \ correct address.
+
+ here over - ( adr , size-of-preceding-code )
+
+ \ ffff.fc28 is the location of the code that follows the GDT
+ ffff.fff0 ffff.fc28 - swap - ( address #bytes-to-pad )
+
+ \ The code mustn't extend past ffff.ffc0, because that is where PC
+ \ manufacturers put the 0x10-byte BIOS version string.
+ dup h# 30 - also forth 0< previous abort" Real mode startup code is too big"
+
+ also forth here over h# ff fill previous \ fill with FFs
+ ( #bytes-to-pad ) allot \ Pad out to ffff.fff0
+
+ \ ------->>>>> Main Entry Point
+ \
+ \ ffff.fff0 - This is the hardwired address where the processor jumps
+ \ when it comes out of reset
+
+ cli cld \ Turn off interrupts (does not affect NMI)
+ #) jmp \ Relative jump back to ffff.fc28
+ 0 w, 0 c, \ align "pad" to end of ROM
+ loader-version# l, \ version#
+ loader-format# w, \ "format" (>1 when crc present)
+ ffff w, \ placeholder for crc
+
+end-code
+
+end-assembling
+
+writing rmstart.img
+rm-startup here over - ofd @ fputs
+ofd @ fclose
+
+here rm-startup - constant /rm-startup
+/rm-startup h# 400 <> abort" Real mode startup code is not the right size"
+
+\ 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
Modified: cpu/x86/pc/lxdevel/romreset.bth
===================================================================
--- cpu/x86/pc/lxdevel/romreset.bth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/lxdevel/romreset.bth 2008-05-21 21:12:54 UTC (rev 824)
@@ -17,7 +17,7 @@
\ startmacros.fth defines some assembler macros that make MSR and I/O port
\ access very easy by hiding the details of register use.
-fload ${BP}/cpu/x86/pc/olpc/startmacros.fth
+fload ${BP}/dev/geode/startmacros.fth
hex
@@ -62,6 +62,9 @@
\ setup CPU interface serial to mode C on both sides
44000020.00200013. 51000010 set-msr \ 5536 p 229
+ \ Set up GPIO base register
+ 0000f001.00001000. 5140000c set-msr \ GPIO BAR
+
\ Init UART
\ uart_init,serial.c
\ This is a garden-variety 8250 UART setup sequence
@@ -123,8 +126,17 @@
\ char b 3f8 port-wb begin 3fd port-rb 40 bitand 0<> until
h# 12 # al mov al h# 80 # out
-fload ${BP}/cpu/x86/pc/olpc/draminit.fth
+fload ${BP}/dev/geode/draminit.fth
+ \ Last-minute check for LX erratum 34 - reset if the DLL didn't start correctly
+ h# 4c000017 rmsr h# 10 bitand 0<> if \ LX branch
+ h# 4c00000f rmsr h# 7ff bitclr h# 4 bitset h# 4c00000f wmsr \ Set DLL_OV
+ h# 4c00000f rmsr h# 7ff # ax and h# 104 # ax cmp = if \ Check the result
+ \ The value 104 indicates that the DLL did not start, so we must reset
+ 1. 5140.0017 set-msr
+ then
+ then
+
\ Now we can use the stack and do conventional subroutine calls
h# 1f # al mov al h# 80 # out
Modified: cpu/x86/pc/lxdevel/versions.fth
===================================================================
--- cpu/x86/pc/lxdevel/versions.fth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/lxdevel/versions.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -3,11 +3,3 @@
\ The overall firmware revision
macro: FW_MAJOR C
macro: FW_MINOR 02
-
-\ The EC microcode
-macro: EC_VERSION b87
-
-\ The wireless LAN module firmware
-macro: WLAN_RPM 5.220.10.p5-1.olpc1
-macro: WLAN_VERSION 5.220.10.p5
-macro: WLAN_DATE 2007-03-30
Added: cpu/x86/pc/memtest.fth
===================================================================
--- cpu/x86/pc/memtest.fth (rev 0)
+++ cpu/x86/pc/memtest.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -0,0 +1,41 @@
+purpose: Interface to memtest86
+
+: ?memtest-elf-map-in ( vaddr size -- )
+ \ We recognize memtest by its virtual address of 0x10000
+ \ It expects that virtual = physical; we depend on the fact
+ \ that we have low memory mapped V=P
+ over h# 10000 = if ( vaddr size )
+ \ Map the frame buffer (virtual=physical)
+ h# 910 config-l@ dup 100.0000 -1 mmu-map
+ then
+
+ \ If it's not memtest, chain to the linux recognizer
+ ?linux-elf-map-in
+;
+' ?memtest-elf-map-in is elf-map-in
+
+: memtest ( -- ) " rom:memtest" $boot ;
+
+\ LICENSE_BEGIN
+\ Copyright (c) 2008 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
Modified: cpu/x86/pc/olpc/fw.bth
===================================================================
--- cpu/x86/pc/olpc/fw.bth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/olpc/fw.bth 2008-05-21 21:12:54 UTC (rev 824)
@@ -104,7 +104,7 @@
;
[then]
-fload ${BP}/cpu/x86/pc/olpc/gpio.fth \ Rudimentary GPIO driver
+fload ${BP}/dev/geode/gpio.fth \ Rudimentary GPIO driver
fload ${BP}/cpu/x86/pc/olpc/probemem.fth \ Memory probing
[ifdef] virtual-mode
@@ -244,7 +244,7 @@
h# 3aa \ USB4:PWR1 USB3:PWR1 USB2:PWR1 USB1:PWR1
then
;
-fload ${BP}/cpu/x86/pc/olpc/usb.fth
+fload ${BP}/dev/geode/usb.fth
\ false to stand-init-debug?
true to stand-init-debug?
@@ -336,7 +336,8 @@
fload ${BP}/cpu/x86/pc/olpc/crypto.fth \ Cryptographic image validation
fload ${BP}/cpu/x86/pc/olpc/lzip.fth \ Access zip images from memory
fload ${BP}/cpu/x86/pc/olpc/gamekeys.fth
-fload ${BP}/cpu/x86/pc/olpc/linux.fth
+fload ${BP}/cpu/x86/pc/linux.fth
+fload ${BP}/cpu/x86/pc/memtest.fth
fload ${BP}/cpu/x86/pc/olpc/setwp.fth
fload ${BP}/cpu/x86/pc/olpc/security.fth
fload ${BP}/cpu/x86/pc/olpc/fsupdate.fth
@@ -350,6 +351,13 @@
' gx-power-off to power-off
[then]
+" disk:\boot\olpc.fth sd:\boot\olpc.fth nand:\boot\olpc.fth /prober /usb/ethernet /usb/wlan"
+ ' boot-device set-config-string-default
+
+\needs ramdisk " " d# 128 config-string ramdisk
+" " ' boot-file set-config-string-default \ Let the boot script set the cmdline
+
+
: dimmer ( -- ) screen-ih if " dimmer" screen-ih $call-method then ;
: brighter ( -- ) screen-ih if " brighter" screen-ih $call-method then ;
Modified: cpu/x86/pc/olpc/romreset.bth
===================================================================
--- cpu/x86/pc/olpc/romreset.bth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/olpc/romreset.bth 2008-05-21 21:12:54 UTC (rev 824)
@@ -17,7 +17,7 @@
\ startmacros.fth defines some assembler macros that make MSR and I/O port
\ access very easy by hiding the details of register use.
-fload ${BP}/cpu/x86/pc/olpc/startmacros.fth
+fload ${BP}/dev/geode/startmacros.fth
hex
@@ -346,7 +346,7 @@
h# 12 # al mov al h# 71 # out \ Write value 01
then
-fload ${BP}/cpu/x86/pc/olpc/draminit.fth
+fload ${BP}/dev/geode/draminit.fth
\ Last-minute check for LX erratum 34 - reset if the DLL didn't start correctly
h# 4c000017 rmsr h# 10 bitand 0<> if \ LX branch
Modified: cpu/x86/pc/olpc/versions.fth
===================================================================
--- cpu/x86/pc/olpc/versions.fth 2008-05-21 21:05:04 UTC (rev 823)
+++ cpu/x86/pc/olpc/versions.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -2,7 +2,7 @@
\ The overall firmware revision
macro: FW_MAJOR D
-macro: FW_MINOR 14
+macro: FW_MINOR 14b
\ The EC microcode
macro: EC_VERSION d13
Added: dev/geode/draminit.fth
===================================================================
--- dev/geode/draminit.fth (rev 0)
+++ dev/geode/draminit.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -0,0 +1,117 @@
+ h# 18 # al mov al h# 80 # out
+ h# 1430 # dx mov dx ax in h# 9999 # ax cmp = if
+ h# 34 # al mov al h# 70 # out \ Write to CMOS 0x34
+ h# 18 # al mov al h# 71 # out \ Write value 01
+ then
+
+ \ Enable DLL, load Extended Mode Register by set and clear PROG_DRAM
+ 20000018 rmsr
+ 10000001 bitset 20000018 wmsr
+ 10000001 bitclr 20000018 wmsr
+
+ \ Reset DLL (bit 27 is undocumented in GX datasheet, but is in the LX one)
+ 08000001 bitset 20000018 wmsr
+ 08000001 bitclr 20000018 wmsr
+
+ \ Here we are supposed to wait 200 SDCLK cycles to let the DLL settle.
+ \ That is approximately 2 uS. The ROM instruction access is so slow that
+ \ anything we do will take quite a bit longer than that, so we just let the
+ \ "rmsr, bitset" sequence take care of the time delay for us.
+
+ \ In the following sequence of writes the 2000.0018 MSR, we
+ \ take advantage of the fact that the existing value stays
+ \ in EAX/EDX, so we don't have to re-read the value.
+
+ \ Generate 2 refresh requests. The refresh queue is 8 deep, and we
+ \ need to make sure 2 refreshes hit the chips, so we have to issue
+ \ 10 requests to the queue. According to the GX datasheet, we don't
+ \ have to clear the REF_TST bit (8) explicitly between writes
+ 20000018 rmsr 8 bitset
+ wrmsr wrmsr wrmsr wrmsr wrmsr wrmsr wrmsr wrmsr wrmsr wrmsr
+ 8 bitclr
+
+\ LinuxBIOS LX raminit.c has a big delay here, using Port 61
+
+ \ Load Mode Register
+ 1 bitset 20000018 wmsr
+ 1 bitclr 20000018 wmsr
+
+ \ Set up a descriptor to give access to memory
+ \ GLIU0 P2D Base Mask Descriptors - page 85
+ 20000000.000fff00. 10000020 set-msr \ memory - 0..fffff
+
+ \ The RAM DLL needs a write to lock on
+ ax h# ffff0 #) mov
+
+ h# 19 # al mov al h# 80 # out
+ h# 1430 # dx mov dx ax in h# 9999 # ax cmp = if
+ h# 34 # al mov al h# 70 # out \ Write to CMOS 0x34
+ h# 19 # al mov al h# 71 # out \ Write value 01
+ then
+
+ \ Turn on the cache
+ cr0 ax mov
+ 6000.0000 bitclr \ Cache-disable off, coherent
+ ax cr0 mov
+ invd
+
+ h# 1a # al mov al h# 80 # out
+ h# 1430 # dx mov dx ax in h# 9999 # ax cmp = if
+ h# 34 # al mov al h# 70 # out \ Write to CMOS 0x34
+ h# 1a # al mov al h# 71 # out \ Write value 01
+ then
+
+ 0000f001.00001400. 5140000f set-msr \ PMS BAR
+
+ \ It is tempting to test bit 0 of PM register 5c, but a 5536 erratum
+ \ prevents that bit from working. Bit 1 works, but LX errata 34
+ \ sometimes requires that we reset the system to fix the memory DLL,
+ \ which destroys all the bits of PM register 5c. So we put a breadcrumb
+ \ in a PM register that we don't otherwise use.
+ 1430 port-rl h# 9999 # ax cmp = if \ Wakeup event flag
+ 0 1430 port-wl
+ h# 1b # al mov al h# 80 # out
+ h# 34 # al mov al h# 70 # out \ Write to CMOS 0x34
+ h# 1b # al mov al h# 71 # out \ Write value 01
+
+ char r 3f8 port-wb begin 3fd port-rb 40 bitand 0<> until
+
+ resume-data # sp mov
+ resume-entry # ax mov ax call \ This might return if checksumming fails
+ char x 3f8 port-wb begin 3fd port-rb 40 bitand 0<> until
+ then
+
+ h# 1c # al mov al h# 80 # out
+ h# 1808 rmsr \ Default region configuration properties MSR
+ h# 0fffff00 # ax and \ Top of System Memory field
+ 4 # ax shl \ Shift into place
+ ax mem-info-pa 4 + #) mov \ Put it where resetend.fth can find it
+
+ \ char D 3f8 port-wb begin 3fd port-rb 40 bitand 0<> until
+
+ \ Memory is now on
+ h# 8.0000 # sp mov \ Setup a stack pointer for later code
+
+ h# 1d # al mov al h# 80 # out
+\ Some optional debugging stuff ...
+[ifdef] debug-startup
+init-com1
+
+carret report
+linefeed report
+ascii F report
+ascii o report
+ascii r report
+[then]
+
+\ fload ${BP}/cpu/x86/pc/ramtest.fth
+
+0 [if]
+ax ax xor
+h# 12345678 # bx mov
+bx 0 [ax] mov
+h# 5555aaaa # 4 [ax] mov
+0 [ax] dx mov
+dx bx cmp <> if ascii B report ascii A report ascii D report begin again then
+[then]
+
Added: dev/geode/gpio.fth
===================================================================
--- dev/geode/gpio.fth (rev 0)
+++ dev/geode/gpio.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -0,0 +1,61 @@
+\ See license at end of file
+purpose: Access to GPIO registers
+
+\ GPIO registers
+h# 00 constant OUT_VAL
+h# 04 constant OUT_EN
+h# 08 constant OUT_OD_EN
+h# 0c constant OUT_INVRT_EN
+h# 10 constant OUT_AUX1
+h# 14 constant OUT_AUX2
+h# 18 constant PU_EN
+h# 1c constant PD_EN
+h# 20 constant IN_EN
+h# 24 constant INV_EN
+h# 28 constant IN_FLTR_EN
+h# 2c constant EVNTCNT_EN
+h# 30 constant READ_BACK
+h# 38 constant EVNT_EN
+
+h# 1000 value gpio-base \ stand-init sets this from an MSR
+: gpio@ ( offset -- 0 ) gpio-base + pl@ ;
+: gpio! ( l offset -- ) gpio-base + pl! ;
+
+alias >set noop ( mask -- mask' )
+: >clr ( mask -- mask' ) d# 16 lshift ;
+
+: >hi ( reg# -- reg#' ) h# 80 + ; \ High bank for GPIO bits 16..31
+
+: gpio-data@ ( -- l ) h# 30 gpio@ ;
+
+
+h# 5140000C constant MSR_LBAR_GPIO
+
+stand-init: gpio
+ MSR_LBAR_GPIO rdmsr ( lo hi )
+ h# 0000f001 <> abort" GPIO not enabled"
+ h# ff00 and to gpio-base
+;
+\ 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
Modified: dev/geode/nandflash/methods.fth
===================================================================
--- dev/geode/nandflash/methods.fth 2008-05-21 21:05:04 UTC (rev 823)
+++ dev/geode/nandflash/methods.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -10,6 +10,27 @@
external
+: dma-alloc ( len -- adr ) " dma-alloc" $call-parent ;
+
+: dma-free ( adr len -- ) " dma-free" $call-parent ;
+
+: close ( -- ) ;
+
+: size ( -- d ) partition-size /page um* ;
+
+: $set-partition ( $ -- error? )
+ dup 0= if 2drop false exit then ( $ )
+ over c@ ascii 0 ascii 9 between if ( $ ) \ number
+ base @ >r decimal $number r> base ! if true exit then ( )
+ set-partition-number ( error? )
+ else ( $ ) \ name
+ set-partition-name ( error? )
+ then ( error? )
+ dup if ( error? )
+ ." NAND: No such partition" cr ( error? )
+ then
+;
+
: open ( -- okay? )
\ We assume that LinuxBIOS has already set up the address map
\ and the timing MSRs.
@@ -17,40 +38,34 @@
h# 51400010 msr@ drop h# 1000 " map-in" $call-parent to nand-base
+ 0 to partition#
+ 0 to partition-start
configure 0= if false exit then
get-bbt
+ usable-page-limit to partition-size
+ read-partmap
my-args dup if ( arg$ )
ascii , left-parse-string ( arg2$ arg1$ )
- 2dup " zip" $= if ( arg2$ arg1$ )
- 2drop ( arg2$ )
- map-reserved ( arg2$ )
- init-deblocker 0= if 2drop ?free-resmap false exit then ( arg2$ )
- \ If no file is specified, open the raw archive
- dup 0= if 2drop true exit then ( arg2$ )
-
- \ Otherwise interpose the filesystem handler
- " zip-file-system" find-package if ( arg2$ xt )
- interpose true ( true )
- else ( arg2$ )
- ." Can't find zip-file-system package" cr ( arg2$ )
- 2drop deblocker close-package ?free-resmap ( )
- false ( false )
- then
- exit
- then ( arg2$ arg1$ )
-
- \ Accept either "path" or "jffs2,path"
- 2dup " jffs2" $= if ( arg2$ arg1$ )
- 2drop ( arg2$ )
+ \ Handle partitions ( arg2$ arg1$ )
+ 2dup 1 min " \" $= if ( arg2$ arg1$ )
+ 2swap 2drop ( arg1$ )
+ \ If there is no "mtd" specifier and there is a partition map,
+ \ select the boot partition.
+ #partitions 0>= if ( arg1$ )
+ " boot" $set-partition if 2drop false exit then
+ then ( arg2$ arg1$ )
else ( arg2$ arg1$ )
- \ XXX probably should check that arg$2 is empty...
- 2swap 2drop ( arg1$ )
- then ( arg$ )
+ \ The argument is not a file so it must be a partition spec
+ #partitions 0< if 2drop 2drop false exit then ( arg2$ arg1$ )
+ $set-partition if 2drop false exit then ( arg2$ )
+ then ( arg$ )
- " jffs2-file-system" find-package if ( arg$ xt )
+ dup 0= if 2drop true exit then ( arg$ )
+
+ " jffs2-file-system" find-package if ( arg$ xt )
interpose true ( okay? )
else ( arg$ )
." Can't find jffs2-file-system package" cr
@@ -60,14 +75,7 @@
2drop true ( okay? )
then ( okay? )
;
-: close ( -- ) ?free-resmap ;
-: size ( -- d ) pages/chip /page um* ;
-
-: dma-alloc ( len -- adr ) " dma-alloc" $call-parent ;
-
-: dma-free ( adr len -- ) " dma-free" $call-parent ;
-
headers
[then]
Modified: dev/geode/nandflash/nand5536.fth
===================================================================
--- dev/geode/nandflash/nand5536.fth 2008-05-21 21:05:04 UTC (rev 823)
+++ dev/geode/nandflash/nand5536.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -42,8 +42,12 @@
: data ( -- ) 0 h# 800 nand! ;
: wait-ready ( -- ) data begin h# 810 nand@ 8 and until ;
+0 instance value partition#
+0 instance value partition-start \ Boundary between chip 0 and chip 1
+0 instance value partition-size \ Boundary between chip 0 and chip 1
+0 instance value usable-page-limit \ #pages excluding bad block tables
-: page-adr ( page# -- ) dup adr 8 rshift dup adr 8 rshift adr ;
+: page-adr ( page# -- ) partition-start + dup adr 8 rshift dup adr 8 rshift adr ;
: start-io ( page# offset cmd -- )
cmd ( page# offset )
wbsplit swap adr adr ( page# )
Modified: dev/geode/nandflash/nandflash.bth
===================================================================
--- dev/geode/nandflash/nandflash.bth 2008-05-21 21:05:04 UTC (rev 823)
+++ dev/geode/nandflash/nandflash.bth 2008-05-21 21:12:54 UTC (rev 824)
@@ -12,6 +12,7 @@
fload ${BP}/dev/geode/nandflash/nand5536.fth
fload ${BP}/dev/olpc/cafenand/configure.fth
fload ${BP}/dev/olpc/cafenand/badblock.fth
+fload ${BP}/dev/olpc/cafenand/redboot.fth
fload ${BP}/dev/geode/nandflash/methods.fth
end0
Added: dev/geode/startmacros.fth
===================================================================
--- dev/geode/startmacros.fth (rev 0)
+++ dev/geode/startmacros.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -0,0 +1,131 @@
+\ See license at end of file
+
+\ Some x86 assembler macros for writing Geode early startup code
+\ in a clean, compact way. Most of the Geode initialization is
+\ done with 64-bit MSRs (Machine Specific Registers). These
+\ macros make it easy to set MSRs to specific values and to
+\ set and clear individual bits.
+
+\ The code keeps the MSR register number in %ecx, the low 32 bits
+\ of the value in %eax, and the high 32 bits in %edx, consistent
+\ with the way the rdmsr and wrmsr machine instructions work.
+\ The bitset and bitclr operations work on %eax, and the -hi versions
+\ work on %edx.
+\ In addition to the MSR operations, there are similar ones for
+\ I/O ports. They leave the data in %eax, so you can use bitset
+\ and bitclr with them too.
+
+-1 value last-cx
+also 386-assembler definitions
+
+: forget-msr -1 to last-cx ;
+
+\ set-cx is an internal implementation factor used by wmsr and rmsr.
+\ It assembles code to put an MSR number in %ecx, optimizing out
+\ unnecessary code by remembering what was last put there.
+: set-cx ( reg# -- )
+ [ also forth ]
+ dup last-cx = if
+ drop
+ else
+ dup to last-cx
+ [ previous ] # cx mov [ also forth ]
+ then
+ [ previous ]
+;
+
+\ Read/write an MSR to/from %edx,%eax
+: rmsr ( reg# -- ) set-cx h# 0f c, h# 32 c, ;
+: wmsr ( reg# -- ) set-cx h# 0f c, h# 30 c, ;
+
+\ These bit operations can be used between "rmsr" and "wmsr"
+
+\ Bit operations on the low 32-bit value in %eax
+: bitset ( mask -- ) # ax or ;
+: bitand ( mask -- ) # ax and ;
+: bitclr ( mask -- ) invert bitand ;
+
+\ Bit operations on the high 32-bit value in %edx
+: bitset-hi ( mask -- ) # dx or ;
+: bitand-hi ( mask -- ) # dx and ;
+: bitclr-hi ( mask -- ) invert bitand-hi ;
+
+\ Set an MSR to a verbatim 64-bit value
+: set-msr ( d.val reg# -- ) -rot # dx mov # ax mov wmsr ;
+
+\ Set or clear bits in an MSR (read-modify-write the register)
+: bitset-msr ( mask reg# -- ) tuck rmsr bitset wmsr ;
+: bitclr-msr ( mask reg# -- ) tuck rmsr bitclr wmsr ;
+
+\ Some I/O port operations
+\ These could be optimized to generate the immediate forms of in and out
+\ for 8-bit port numbers, but it's not worth the trouble because we
+\ access very few low-numbered ports.
+: port-wb ( b port# -- ) swap # al mov # dx mov al dx out ;
+: port-rb ( port# -- ) # dx mov dx al in ;
+: port-ww ( w port# -- ) swap # ax mov # dx mov op: ax dx out ;
+: port-rw ( port# -- ) ax ax xor # dx mov op: dx ax in ;
+: port-wl ( l port# -- ) swap # ax mov # dx mov ax dx out ;
+: port-rl ( port# -- ) # dx mov dx ax in ;
+
+: config-setup ( config-adr -- )
+ [ also forth ]
+ dup 3 invert and h# 8000.0000 or ( config-adr cf8-value )
+ [ previous ]
+ # ax mov ( config-adr )
+ h# cf8 # dx mov ( config-adr )
+ ax dx out ( config-adr )
+ [ also forth ]
+ 3 and h# cfc or ( data-port )
+ [ previous ]
+ # dx mov
+;
+: config-wl ( l config-adr -- )
+ config-setup ( l )
+ # ax mov
+ ax dx out
+;
+: config-rl ( config-adr -- ) \ Returns value in EAX
+ config-setup
+ dx ax in
+;
+: config-ww ( w config-adr -- )
+ config-setup ( w )
+ op: # ax mov ( )
+ op: ax dx out
+;
+: config-rw ( config-adr -- ) \ Returns value AX
+ config-setup ( )
+ ax ax xor
+ op: dx ax in
+;
+
+: set-base ( adr -- ) # bx mov ;
+: reg-save ( offset -- ) [bx] ax mov ax stos ;
+: reg-restore ( offset -- ) ax lods ax swap [bx] mov ;
+
+previous definitions
+
+\ 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: dev/geode/usb.fth
===================================================================
--- dev/geode/usb.fth (rev 0)
+++ dev/geode/usb.fth 2008-05-21 21:12:54 UTC (rev 824)
@@ -0,0 +1,156 @@
+purpose: USB elaborations for the OLPC platform
+\ See license at end of file
+
+0 config-int usb-delay \ Milliseconds to wait before set-address
+
+devalias usb1 /usb@f,4
+devalias usb2 /usb@f,5
+devalias u /usb/disk
+devalias net /usb/wlan
+
+\ If there is a USB ethernet adapter, use it as the default net device.
+: report-net ( -- )
+ " /usb/ethernet" 2dup find-package if ( name$ phandle )
+ drop ( name$ )
+ " net" 2swap $devalias ( )
+ else ( name$ )
+ 2drop ( )
+ then
+;
+
+[ifdef] notdef \ We have the graphical penguin
+: linux-logo ( -- )
+ " penguin.txt" find-drop-in if page type then
+;
+[then]
+
+\ Like $show-devs, but ignores pagination keystrokes
+: $nopage-show-devs ( nodename$ -- )
+ ['] exit? behavior >r ['] false to exit?
+ $show-devs
+ r> to exit?
+;
+
+: probe-usb ( -- )
+ ." USB2 devices:" cr
+ " /usb@f,5" open-dev ?dup if close-dev then
+ " /usb@f,5" $nopage-show-devs
+
+ ." USB1 devices:" cr
+ " /usb@f,4" open-dev ?dup if close-dev then
+ " /usb@f,4" $nopage-show-devs
+
+ report-disk
+ report-net
+ report-keyboard
+;
+alias probe-usb2 probe-usb
+alias p2 probe-usb2
+
+: ?usb-keyboard ( -- )
+ " keyboard" expand-alias if ( devspec$ )
+ drop " /usb" comp 0= if ( )
+ red-letters ." Using USB keyboard." cr black-letters
+ " keyboard" input
+ then
+ 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
+;
+
+0 value usb-power-done-time
+
+\ This version assumes that power has been applied already, and
+\ all we have to do is wait enough time for the devices to be ready.
+: wait-usb-power ( -- )
+ begin usb-power-done-time get-msecs - 0<= until ( )
+;
+
+: usb-quiet ( -- )
+ [ ' go-hook behavior compile, ] \ Chain to old behavior
+ " usb1" " reset-usb" execute-device-method drop
+ " usb2" " reset-usb" execute-device-method drop
+;
+' usb-quiet to go-hook
+
+0 0 " " " /" begin-package
+ " prober" device-name
+ : open
+ " /usb@f,5" open-dev ?dup if close-dev then
+ " /usb@f,4" open-dev ?dup if close-dev then
+ report-disk
+ report-net
+ report-keyboard
+ false
+ ;
+ : close ;
+end-package
+
+stand-init: USB setup
+ \ Set up an address routing to the USB Option Controller
+ h# efc00000.efc00001. h# 5100.0029 wrmsr
+ h# 400000ef.c00fffff. h# 5101.0020 wrmsr
+ h# 00000002.efc00000. h# 5120.000b wrmsr
+[ifdef] virtual-mode
+ h# efc00000 h# 1000 0 mmu-claim drop \ UOC
+ h# efc00000 dup h# 1000 -1 mmu-map \ UOC
+ h# fe01a000 h# 1000 0 mmu-claim drop \ OHCI
+ h# fe01a000 dup h# 1000 -1 mmu-map \ OHCI
+[then]
+ \ Configure the assignment of 2 USB Power Enable pins to USB ports
+ \ to correspond to the way they are wired on the board.
+ \ USB port 1 is PWR_EN2, USB ports 2-4 are PWR_EN1
+ usb-port-power-map h# efc00000 l!
+ 2 h# efc00004 l!
+ h# 1 h# fe01a008 l! \ Reset OHCI host controller
+ h# 1e.0000 h# fe01a04c l! \ Configure ports for individual power
+ h# 100 h# fe01a058 l! \ Power-on ports 2 and 3
+ d# 10 ms \ Stagger for glitch-prevention
+ h# 100 h# fe01a054 l! \ Power-on port 1
+ h# 100 h# fe01a05c l! \ Power-on port 3
+ h# 100 h# fe01a060 l! \ Power-on port 4
+ get-msecs d# 1000 + to usb-power-done-time
+;
+
+
+\ 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
Author: wmb
Date: 2008-05-21 23:05:04 +0200 (Wed, 21 May 2008)
New Revision: 823
Modified:
cpu/x86/pc/olpc/rmstart.fth
cpu/x86/pc/olpc/romreset.bth
Log:
Put "[ifdef] cmos-startup-control" around the startup code that changes
memory and clock timing settings based on CMOS RAM values. That symbol
is not defined by default, so with this change, bad CMOS RAM contents
won't prevent the system from starting. The CMOS override feature can
be reinstated for test builds by defining that symbol in config.fth .
Modified: cpu/x86/pc/olpc/rmstart.fth
===================================================================
--- cpu/x86/pc/olpc/rmstart.fth 2008-04-18 08:20:31 UTC (rev 822)
+++ cpu/x86/pc/olpc/rmstart.fth 2008-05-21 21:05:04 UTC (rev 823)
@@ -183,17 +183,21 @@
h# 0017 # cx mov rdmsr \ Read CHIP_REVID
h# 0014 # cx mov \ Restore RSTPLL MSR number
h# 30 # al cmp >= if \ LX CPU
+[ifdef] cmos-startup-control
h# 60 # al mov al h# 70 # out h# 71 # al in \ Read CMOS 0x60
al al test 0= if
+[then]
rdmsr \ Get base MSR value with divisors
op: h# 04de.0000 # ax or \ Set the startup time (de) and breadcrumb (4)
op: h# 0000.04d9 # dx mov \ PLL value for 333 MB clk, 433 CPU
+[ifdef] cmos-startup-control
else
al dec al h# 71 # out \ Decrement safety counter
rdmsr \ Get base MSR value with divisors
op: h# 04de.0000 # ax or \ Set the startup time (de) and breadcrumb (4)
op: h# 0000.04d3 # dx mov \ PLL value for 333 MB clk, 333 CPU
then
+[then]
wrmsr \ Put in the base value
op: h# 0000.1800 invert # ax and \ Turn off the BYPASS bits
Modified: cpu/x86/pc/olpc/romreset.bth
===================================================================
--- cpu/x86/pc/olpc/romreset.bth 2008-04-18 08:20:31 UTC (rev 822)
+++ cpu/x86/pc/olpc/romreset.bth 2008-05-21 21:05:04 UTC (rev 823)
@@ -147,8 +147,10 @@
00000106.83104104. 00001983 set-msr \ Memory delay values
00000000.00000001. 00001980 set-msr \ Enable memory delays
+[ifdef] cmos-startup-control
h# 61 # al mov al h# 70 # out h# 71 # al in \ Read CMOS 0x61
al al test 0= if
+[then]
18000100.6a7332a0. 20000019 set-msr
\ The RAM controller is now set up
@@ -163,6 +165,7 @@
\ Delay on exit from power mode 1, use unbuffered RAM
130cd801. 2000001a set-msr \ MC_CF1017_DATA LX p 231
+[ifdef] cmos-startup-control
else
al dec al h# 71 # out \ Decrement safety counter
@@ -193,6 +196,7 @@
dx dx xor bx ax mov 2000001a wmsr \ MC_CF1017_DATA LX p 231
then
+[then]
00000200.00000000. 20000020 set-msr \ Power mode entry and exit delays
Dear People, I communicate with you for the purpose of obtaining advice or software sales OpenBios, I need to recover three bios chip whose mother had been adulterated by viruses. Try rewritable anyway but I was impossible, then I would buy a CD or what they deem to have and use them whenever necessary. I am look forward to your answers and congratulations on the achievements, I'm Argentine and I devote myself to teach computing to Disabled Motrices including Blind, the new version of ubuntu 8.04 to excellent result so far.
Ate. Jose Luis Brisa
_________________________________________________________________
¿Aburrido? Ingresá ya y divertite como nunca en MSN Juegos.
http://juegos.ar.msn.com/