Author: wmb Date: Wed Oct 13 09:42:47 2010 New Revision: 1977 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/1977
Log: OLPC XO-1.5 - Added choose-os for switching MBRs for different OSs on the same SD.
Added: cpu/x86/pc/olpc/via/chooseos.fth Modified: cpu/x86/pc/olpc/sba.fth cpu/x86/pc/olpc/via/fw.bth
Modified: cpu/x86/pc/olpc/sba.fth ============================================================================== --- cpu/x86/pc/olpc/sba.fth Wed Oct 13 01:09:18 2010 (r1976) +++ cpu/x86/pc/olpc/sba.fth Wed Oct 13 09:42:47 2010 (r1977) @@ -3,6 +3,8 @@
support-package: secure-boot-area
+h# 10.0000 constant sba-offset \ This leaves room for other stuff like saved MBRs + d# 512 constant /sector /sector instance buffer: sector-buf
@@ -29,7 +31,7 @@ sector-buf h# 1fe + le-w@ h# aa55 <> if false exit then \ FDisk? ptable-adr 4 + c@ 7 <> if false exit then \ NTFS? ptable-adr 8 + le-l@ 1- /sector um* to image-size \ The 1- skips sector 0 - /sector u>d to offset \ The SBA starts just after the Master Boot Record sector + sba-offset u>d to offset true ;
Added: cpu/x86/pc/olpc/via/chooseos.fth ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ cpu/x86/pc/olpc/via/chooseos.fth Wed Oct 13 09:42:47 2010 (r1977) @@ -0,0 +1,72 @@ +\ See license at end of file +purpose: OS chooser for dual boot (Windows and Linux) from a single SD card + +0 value mbr-ih + +d# 512 constant /mbr \ Size of a Master Boot Record sector + +d# 16 constant #switched \ Number of contiguous sectors to switch +\ 16 sectors is the size of the MBR plus the following code that Windows uses +\ for booting. The real-mode code in the MBR reads sectors 1-15, which +\ contains a simple NTFS reader that is subsequently used to read additional files. + +/mbr #switched * constant /switched + +\ Byte offset h# 80000 hopefully puts the saved MBRs in a different erase +\ block on the NAND FLASH inside the device, thus giving it some measure +\ of extra protection against corruption. +h# 80000 /mbr / constant saved-mbrs-base + +/switched buffer: desired-mbr +/switched buffer: current-mbr + +\ We use read-blocks and (especially) write-blocks so we don't cause extra +\ wear on the device by writing more data than necessary. The deblocking +\ used by read and write might use a large buffer size thus causing data +\ to be written + +: get-sectors ( adr sector# -- ) + #switched " read-blocks" mbr-ih $call-method ( nread ) + #switched <> abort" Read failed" +; +: put-sectors ( adr sector# -- ) + #switched " write-blocks" mbr-ih $call-method ( nread ) + #switched <> abort" Write failed" +; +: choose-os ( n -- ) + " int:0" open-dev dup to mbr-ih 0= abort" Can't open internal storage" ( n ) + current-mbr 0 get-sectors ( ) + desired-mbr swap #switched * saved-mbrs-base + get-sectors + desired-mbr /mbr is-mbr? 0= if + mbr-ih close-dev + true abort" The chosen MBR is invalid" cr + then + current-mbr desired-mbr /mbr comp if + desired-mbr 0 put-sectors + then + mbr-ih close-dev +; + +\ LICENSE_BEGIN +\ Copyright (c) 2010 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/via/fw.bth ============================================================================== --- cpu/x86/pc/olpc/via/fw.bth Wed Oct 13 01:09:18 2010 (r1976) +++ cpu/x86/pc/olpc/via/fw.bth Wed Oct 13 09:42:47 2010 (r1977) @@ -397,6 +397,7 @@ fload ${BP}/dev/via/smi.fth \ fload ${BP}/cpu/x86/pc/biosload/rmenter.fth fload ${BP}/cpu/x86/pc/biosints.fth +fload ${BP}/cpu/x86/pc/olpc/via/chooseos.fth [ifdef] Later fload ${BP}/cpu/x86/pc/olpc/biosresume.fth [then]
openfirmware@openfirmware.info