Oberon/A2/BootManager.Mod

(* ETH Oberon, Copyright 2001 ETH Zuerich Institut fuer Computersysteme, ETH Zentrum, CH-8092 Zuerich. Refer to the "General ETH Oberon System Source License" contract available at&#58; http&#58;//www.oberon.ethz.ch/ *) MODULE BootManager; (** AUTHOR "afi"; PURPOSE "Split the boot manager object code BootManager.Bin"; *) IMPORT Commands, Files; (** Split the boot manager object code BootManager.Bin, obtained by assembling BootManager.Asm, &#9;into a 512-byte MBR and the rest of it in bmsize sectors. *) PROCEDURE Split* (context&#58; Commands.Context); VAR fileName&#58; Files.FileName; &#9;fi, fo, fo2 &#58; Files.File; r &#58; Files.Reader; w &#58; Files.Writer; &#9;count,i &#58; SIGNED32; ch &#58; CHAR; BEGIN &#9;context.arg.SkipWhitespace; context.arg.String (fileName); &#9;fi &#58;&#61; Files.Old(fileName); &#9;fo &#58;&#61; Files.New("BootManagerMBR.Bin"); &#9;fo2 &#58;&#61; Files.New("BootManagerTail.Bin"); &#9;IF fi # NIL THEN &#9;&#9;Files.OpenReader(r, fi, 0); &#9;&#9;Files.OpenWriter(w, fo, 0); &#9;&#9;i &#58;&#61; 0; &#9;&#9;FOR count &#58;&#61; 1 TO 512 DO &#9;&#9;&#9;r.Char(ch); &#9;&#9;&#9;w.Char(ch); &#9;&#9;&#9;INC(i); &#9;&#9;END; &#9;&#9;w.Update; &#9;&#9;Files.Register(fo); &#9;&#9;Files.OpenWriter(w, fo2, 0); &#9;&#9;WHILE r.Available &#62; 0 DO &#9;&#9;&#9;r.Char(ch); &#9;&#9;&#9;w.Char(ch); &#9;&#9;&#9;INC(i); &#9;&#9;END; &#9;&#9;WHILE i MOD 512 # 0 DO &#9;&#9;&#9;w.Char(0X); &#9;&#9;&#9;INC(i); &#9;&#9;END; &#9;&#9;w.Update; &#9;&#9;Files.Register(fo2); &#9;END; END Split; BEGIN END BootManager. BootManager.Split BootManager.Bin &#126;