./PaxHeaders.14419/loadlin-1.6f0000644000175000017500000000013212025461344014262 xustar000000000000000030 mtime=1347838692.977616078 30 atime=1347838662.018370842 30 ctime=1347838692.977616078 loadlin-1.6f/0000755000175000017500000000000012025461344013155 5ustar00samysamy00000000000000loadlin-1.6f/PaxHeaders.14419/test.par0000644000175000017500000000013212025461304015661 xustar000000000000000030 mtime=1347838660.998395712 30 atime=1347838662.018370842 30 ctime=1347838660.998395712 loadlin-1.6f/test.par0000644000175000017500000000456412025461304014645 0ustar00samysamy00000000000000# EDIT THIS BEFORE USING ! # # this is an example commandline parameter file for LOADLIN # You may have comments starting with "#" at any place # comments end at end of a line # any number of empty lines may be inserted. # The contents are compacted by LOADLIN to produce an as small # commandline as possible. # For more commandline options see the file PARAMS.DOC. # # There can only be one parameter file and LOADLIN must be called as: # LOADLIN @param_file # However, the parameters in param_file may be overwritten by # (or appended to) those following the @param_file, e.g: # LOADLIN @param_file image=other_image root=/dev/other # # ..\zImage # first value must be the filename of the Linux-kernel # if this should be changed at load time, # the keyword 'image=' must be used (see above) #-v # verbose the actual params, but load anyway -t # write debug output and stop. #-d c:\dump # write debug output to file c:\dump and stop. vga=ask # legal values are: # numeric: # -3 ask # -2 extended # -1 normal # 0..9 as if entered on boot-prompt # symbolic: # ask # normal # extended # However, starting with Linux-1.3.75 the code for # vga=has changed, to get the actual values for your # special video card, you should use 'ask' and remember # the values that were printed on screen. # # See also linux/Documentation/svga.txt root=/dev/hdb2 # the device which gets mounted as root FS # root=201 # NOTE: the numeric device tokens are hexa ! # root=/dev/sda1 # .... ro # rw #initrd=..\initdisk.gz # This file gets loaded as 'initial ramdisk' # see initrd.txt for more #noinitrd # This keyword is usefull, if you wany get # the 'initial ramdisk' loaded, but not # processed at startup. # It will remain as /dev/initrd. # this can be used in /etc/rc to do some special work MY_SPECIAL_OPTION=what_I_need #ether=10,0x280,0xc8000,0xcbfff,eth0 #ether=10,0x280,0xd0000,0xd3fff,eth0 loadlin-1.6f/PaxHeaders.14419/loadlin.exe0000644000175000017500000000013212025461304016323 xustar000000000000000030 mtime=1347838660.990395908 30 atime=1347838662.018370842 30 ctime=1347838660.990395908 loadlin-1.6f/loadlin.exe0000644000175000017500000012260212025461304015301 0ustar00samysamy00000000000000MZR Xj"$ҳ f؎м 1@9tjL1UWVS/r~1"L l9s9r T)B9|ڃ[^_]UWVSJy11!l9}t)T  B9|1[^_]V1Ɋ Au^UWVS,@|D$phD$T$D$ T$D,|@ |$T$HD <ЁEL$VL$L Pl$% ЉD$‰ L$|, rtdD,L$LF9u;D$‹E|,I% ȉT$ D,T$<ЁD$61Ҋ : BuL$ D,|$D8,[^_]UWVSǃǃPǃ ǃ  YL$L$ L$qu L$A 2L$1 T,D@;D$ul$ 1*D, tD,LG9u1B D,,ЋE t9u ED,|G;|$u1j ( T$L$ D,xt681Ҋ : BuL$ T$D,D(FL$ ;0r[^_]Ë$zR| 4MAA AAEA AA4TMAA AAEA AA AT<AA AAC@AA AA<ZAA AAC0AA AA( P pf g ` i i 8@(G f f  .>euV1PXt4PXt-@PX0u.>eu3 f tt.iøfx 1>>f>XXX0u>f> EMMQt>f> EMMXt.eȎЍ&؎4.e6>>0< uF&.&A> :sƇeeee &e &eee&+re&ece;eseeeeex>eu> R gereuS>euLeEe/eeeeu>eu .Tee>et>uf-=!s$2YhR >M?ee11f)lPˌ؎Ѝ&>et efffs>!f늴>!{뀴>!2u9u݁>UuՌύߋef1Ɋ.u^wljeffEr9u>er>eu $^>et>ee+effff>erpefff`.f.feee+effff+f.f> `.tef.f> `.Y.>etS>f>HdrSue>&oe> e> +1ef=puEEDDEf1>euZfe fef;fr >e>rt ?r"6eD>ete>ete>et>et2>et>!Y>et}<efe>effekeD>esf$f9>!>t>eu }= W.+>ewt>eu1>&o>.e؎>ew e؍&Pjf`pȎ؎$of& oЍ&>et .f& ofae9etAee ڎ11f)9wڎ11feeÍ&>et >u RՎwZs>ir`W.>et )*L!<SQV1t<$uN)t@!>ete@!^Y[.>eu.ePRZXÜPRopZX $.>er'PRptp.e.>ev p.eZX Now reading INITRD: LOADING.$SfP>es ffe'.f+ef-fefX[fVRfQff?!_r9|+9uf)ff9w?!>r[+ff)fYff)Zf^fYff)PWJ1->e_XfPSee{{HfJPfCXf<`f5-fffifififififif`-[fXfQfPoOfO-fffȉGfGgfXfYs+2m>ru*< t<#t2Gs< w܁v } uOE -ࣁnqru߀= uf>@@lou f>adlitr=!ref>nx@@uV60x1^À>rtô>!À>rtdtC1ô?!`1Au~Aϋv?CCuGFaf`>Љ>7t>5t>669t>5t6Љ67t5t֋4 >;t7txTtGtAw<֋4 tS|uBt Et7t~ 7tsxV>9tL^>9tE ;67tr륍Ћ7 t<t>9t>9tE 9tG냧tK߉faimage=rwroQR1_B1?tWPtX1}=u@ZYø.e>f>HdrSu .6.eƄrer6>u4>>-ufzimage므>@u1뙍>-ramdiskvgamemrootrorwno387singleauto-v-t-d-rb-rx-ja-clonedebugno-hltreservehdbmousemax_scsi_lunsxd-n-txmode-finitrd-noheap-wait-dskresethvvvwwwwwwvvvw%w-w5wwwwwwwwAwYwIwPvv7vQw>ү>үu>kucW>ү_=nSfeB>W>ү_e%VW>"_^eee}sүtSQR1ɍүү6w)e6t<:t<\teuE >eBOOT_IMAGE=W< t< u0uN_&=te&R !e(SƇ[Zut,1Ptu u^XÜQ1Ɋlku fYÀmu<-uFfSfQfRfWfVf f1f1fGZrDu XXX0uU&f> EMMXt &f> EMMQu=@gu4Fg@r*Zgug$gugD$$g$Eggfd$fa h(fh,f1ҍ6f%f9uf 1UVWfFf^fff1vgfii_^]f`=z!r#øD!P>!Xr e fa1$BIOSINTf`=A{!rYÍŹ ?!P>!XrB= u=e.>et)&f.f;u)&f .f;u.>˥u fae1eC:\REALBIOS.INT>eu>eu 'u_[ue f%"f1"ظ0Ў؎ $"{.~{Ў؎f&z{'faÜSpȈqĈpq[PQVW1.>et.>T&fT.fR..ev@6f.>e16˹f !p!!..!1&T|&V0."&ʀ0u0.e_^YXÀt..R..>eu.ef`f&z{{ffii(f6efi gWQ1IHY_)f1>eu_>rW>tPfVfR6fffzfff1|tt <#u[ffffZf^fPfRfPgD$$fZfXtfP$0<9vfXfPfffXfPfffXfPfffXeeef>etfeô>eTs>et&">eu.>˥u. hm~f6Rff ff`ɀP6->eu!>r>t)fe;>et `oAfe >ertJ$+e7*>r1PYɍ6r&Ɓfff㋗'^>et@>ftOf ff+ fvhb,>it 6w#>et wς)>et%>evW >etE> >erdt}&ee >1PYɍ6^Ä݄>eu>et>iu7fef;fr>e^v.>etsfa Your current LINUX kernel boot configuration is: image file: $ kernel version $ kernel size: 0x$ setup size: 0x$ (high loaded) setup size: 0x$, heap: 0x$ VGA mode: 0x$ command line (size 0x$): $ Your current DOS/CPU configuration is: load buffer size: 0x$! $ VCPI$ EXT $ XMS $, setup buffer size: 0x$ (reloc setup)$ lowmem buffer: 0x$ (part of load buffer)$ total memory: 0x$ CPU is in $, BIOSINTV.SYS: $, REALBIOS: $YES, but ROM-BIOS-DATE differs, must rerun REALBIOS.EXE$ SetupIntercept: $YES$NO$V86 mode$REAL mode$undocumented REAL PAGING mode, trying any way$YES, patching setup code$YES, legal intercept, setup header version $ stat$4: VCPI_present, physmap=logmap, all OK for switch to realmode$3: VCPI_present, but physmap != logmap (check aborted)$2: cpu_V86, but no VCPI available (check aborted)$1: cpu in real 386 mode, no need to backswitch$0: cpu < 386$Z(񃲃 input params (size 0x$): $ LOADLIN started from $DOS-prompt $CONFIG.SYS (shell= ...) $ You are running under MS-WINDOWS or Windows 95 $WARNING: Your CPU is in realmode, but PAGING is enabled ! This is possible, but neither documented nor supported by INTEL. May be your motherboard's BIOS is mapping shadow ram this way, or you are using one of those old and strange EMM managers, but probably this is an indication of a not exactly compatible 486 clone. If you are not using one of the older EMM-managers you better should use the -clone switch to work around. $WARNING: Not enough free memory (load buffer size)$ WARNING: The setup buffer of LOADLIN is too small (must recompile)$ WARNING: Option -f set, CPU-Check bypassed !$ f`>etPSe>!e[Xf`.>et.>eu.e .>et @.fe>fl>f;lwfaLOADLIN v1.6e (C) 1994..2002 Hans Lermen $ (C) 2008..2010 Samuel Thibault $comspecwindirNot enough free memory between 90000h and 9ffffh, may be you have some zombie programs, try to reboot. If this doesn't help, try to find out what driver occupies this space. $Please enter name of kernel image file followed by optional command line parameters for Linux (e.g. root=XXXX) or @file ( file = param file ) or "empty string" to abort: $LOADLIN aborted by user $Image file not found, $enter file name of Image: $not an Image file, $Your current configuration needs interception of "setup.S," but the setup-code in your Image file is *very* old (or wrong) Please use BIOSINTV/REALBIOS or try an other Image file $Ooops..., size of "setup.S" has become too long for LOADLIN, please E-mail this condition to samuel.thibault@ens-lyon.org ! $not enough memory below 90000h to load kernel $IO Error during load $Insert floppy disk for loading into RAMDISK $ CPU is in V86-mode (may be WINDOWS, EMM386, QEMM, 386MAX, ...) You need pure 386/486 real mode or a VCPI server to boot Linux VCPI is supported by most EMS drivers (if EMS is enabled), but never under WINDOWS-3.1 or WINDOWS'95. (However, real DOS-Mode of WINDOWS'95 can have EMS driver with VCPI) If loading via VCPI you also MUST have: 1. An interceptable setup-code (see MANUAL.TXT) 2. Identical Physical-to-Virtual mapping for the first 640 Kbytes $You need a 386 CPU at minimum, but you haven't ! $error on reading command line response file $ Option -t set, Linux not loaded $ ERROR detected, Linux not loaded $ LOADLIN holding in idle loop (You must reboot) $ USAGE: LOADLIN @params LOADLIN [zimage_file] [options] [boot_params] without any params, LOADLIN displays this help message. @params: params is a DOS file containing all other options zimage_file: DOS file name of compressed Linux kernel image options: -v verbose, show information on params and configuration -t test mode, do all but starting Linux, also sets -v -d file debug mode, same as -t, but duplicates output to "file" -clone ( Please read MANUAL.TXT before using this switch! ) -n no translation for root=/dev/... -txmode switch to textmode 80x25 on startup -noheap disable use of setup heap -wait=nn after loading wait nn (DOS)ticks before booting Linux -dskreset after loading reset all disks before booting Linux boot_params: root=xxx filesystem to be mounted by Linux as "/" (string passed unchanged to the kernel) xxx = hex number (e.g. root=201 for /dev/fd1) = /dev/mmmn (e.g. root=/dev/hda2) mmm = fd,hda,hdb,sda,sdb... n = 1..10.. decimal ro mount "/" readonly rw mount "/" read/write initrd=x (for kernels > 1.3.72) load file x into /dev/ram. If FS in x contains /linuxrc, execute it, and then remount to root=xxx. If root=/dev/ram, just load, bypass execution of /linuxrc for more boot params see PARAMS.TXT or Paul Gortmakers HOWTO: http://sunsite.unc.edu/mdw/HOWTO/BootPrompt-HOWTO.html http://rsphy1.anu.edu/~gpg109/BootPrompt-HOWTO.html $f`fjjjjjfUjjh.f&z{ܕffii(.f6efi g0Ў؎.f&z{F f .fifaPwXËeffff fFƁ4% ffffFǁ % fff  "fffff ffffPfVfWfQ.6f..&.> f. .&6fYf_f^fXÍtPS.fe.eC/e.feSR.f>et.e .e t .eZ[f f1PSR.e .e t.e.fZ[Xؗo Cannot lock XMS memory $PSR.e .e.e .eZ[Xfs ff`fffrf>>e>f>1f>1>frf66e6f61f6166 .efaf`ff1ff1fffffaf`feff ffeff ff+ ff ff>f>itG.>er>..e@Dt3.feffffffffff fffaø-v#ffffffffff뷀>etfRgfrffff fZf>fvBfff ff; fs f fÀ>ftfffffRgf%fZf1Ҁ>f>f>ffPSfQRUfVfWҳrf͉ffrGgIr?sfffffQfffYffrgf_f^]ZfY[fX,>ffPSfQRUfVfWҳsfnjfffffff>fՉff-rYfefrJsffffr f>efffffffffffrf>eff;f_f^]ZfY[fXÀ>ft.SfWֳf޳>ҳLJfֳff_[À>fSfWfҳftOfuFfPfQfVfWsfnjfffffff_f^fYfXffҳֳKff_[f`f.>fu!f1fffffa rfnjffff(ffa>!N Out of memory (may be low or extended) $.>ef`>f="!effeff%fffrff ffff)f%fe>fu'f=vff+%f9rfef+%f9sMff>efeoegr.f9u)>!fafa3f@feff؞ can't open image file for initrd $ no place after kernel for initrd $ warning: loading above 16MB using INT15 $ IO-error while reading initrd $ no support in setup for reading initrd $QRfVB11!PRB11!fYZB!ff^ZYPQW1>?$[ڳܳ_YX i`i`Loadlin-1.6eloadlin-1.6f/PaxHeaders.14419/linux.bat0000644000175000017500000000013212025461304016025 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.018370842 30 ctime=1347838660.986396005 loadlin-1.6f/linux.bat0000644000175000017500000000033412025461304015000 0ustar00samysamy00000000000000rem Sample DOS batch file to boot Linux. rem First, ensure any unwritten disk buffers are flushed: smartdrv /C rem Start the LOADLIN process: c:\loadlin\loadlin c:\loadlin\zimage root=/dev/hdb2 ro vga=3 loadlin-1.6f/PaxHeaders.14419/files0000644000175000017500000000013212025461304015223 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.018370842 30 ctime=1347838660.986396005 loadlin-1.6f/files0000644000175000017500000000065212025461304014201 0ustar00samysamy00000000000000COPYING README.1ST files linux.bat loadlin.exe test.par doc doc/announce.txt doc/changes doc/initrd.txt doc/lodlin16.lsm doc/manual.txt doc/params.doc doc/quicksta.rt initrd initrd/Makefile initrd/freeramdisk.c initrd/linuxrc.c initrd/mkdisk src src/Makefile src/loadlin.asm src/loadlina.asm src/loadlini.asm src/loadlinj.asm src/loadlinm.asm src/srclinux src/srclinux/Makefile src/srclinux/loadlinh.S src/srclinux/pgadjust.c loadlin-1.6f/PaxHeaders.14419/README.1ST0000644000175000017500000000013212025461304015464 xustar000000000000000030 mtime=1347838660.982396102 30 atime=1347838662.018370842 30 ctime=1347838660.982396102 loadlin-1.6f/README.1ST0000644000175000017500000000623212025461304014442 0ustar00samysamy00000000000000 LOADLIN.EXE, a loader (running under DOS) for LINUX kernel images (fully supporting the kernel's command line feature) (C) 1994..1995 Hans Lermen (lermen@elserv.ffm.fgan.de) (C) 2008..2010 Samuel Thibault (samuel.thibault@ens-lyon.org) ================================================================= LOADLIN uses the same principle as BOOTLIN from F.Coutant, but has enhanced error checking and fully supports the "command line feature" of Linux. It also accepts a response file, so the command line can be greater than 128 bytes. LOADLIN-1.6 is highly adaptable to different DOS configurations, and now has very few loading restrictions. It makes use of extended memory and also can load big kernels (bzImages) and ramdisk images (initrd) directly high. The bzImage+initrd standard was jointly developed by the LILO-author (Werner Almesberger) and the LOADLIN-author (me) and is part of the official kernel since version 1.3.73. It is also capable of booting a UMSDOS-based system from a DOS drive. Some options (-v, -t, -d) produce debug information, so if you have problems, you can follow what is really being done by LOADLIN. LOADLIN also can load out of Virtual-86 mode (which is normal when using EMS drivers) if a VCPI server is present. The loader program works from the DOS prompt or from CONFIG.SYS under the following conditions: 1. The buffer memory (lowmem + extended) is great enough to hold the compressed kernel image (zImage or bzImage) aswell as the initrd image (optional). 2. A) The CPU is not in virtual-8086 mode or B) The EMS driver supports VCPI. Note that some VCPI drivers overwrite the ACPI table located at the end of the memory. This that reduces Linux hardware support, it is thus recommended to avoid using such VCPI driver. Some old BIOSes can not load data above 16MB. If your kernel+initrd does not fit in 16MB, loadlin emits a warning. If the machine crashes, try using a memory manager instead of relying on the BIOS only. For a quick start read the QUICKSTA.RT file For a detailed description please read the MANUAL.TXT file. =========================================================================== Contents of LODLIN16.TGZ ------------------------ readme.1st you're reading me now! loadlin.exe the loader copying GPL of Free Software Foundation test.par a sample response (params) file linux.bat a sample DOS batch file initrd a _very_ simple initrd (/linuxrc) example doc doc/changes history of LOADLIN doc/quicksta.rt as the file name says, but you will need more to read doc/manual.txt the manual doc/params.doc description of Linux command line parameters doc/announce.txt the posting that announced bzImage+initrd doc/initrd.txt description of initrd (as of linux/Documentation/*) doc/lodlin16.lsm src source src/loadlin.asm src/loadlina.asm src/loadlini.asm src/loadlinj.asm src/loadlinm.asm src/makefile makefile for TASM src/srclinux 32-bit source (must compile under Linux) loadlin-1.6f/PaxHeaders.14419/COPYING0000644000175000017500000000013212025461304015231 xustar000000000000000030 mtime=1347838660.982396102 30 atime=1347838662.018370842 30 ctime=1347838660.982396102 loadlin-1.6f/COPYING0000644000175000017500000004362412025461304014215 0ustar00samysamy00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. loadlin-1.6f/PaxHeaders.14419/src0000644000175000017500000000013012025461304014706 xustar000000000000000029 mtime=1347838660.99439581 30 atime=1347838662.018370842 29 ctime=1347838660.99439581 loadlin-1.6f/src/0000755000175000017500000000000012025461304013740 5ustar00samysamy00000000000000loadlin-1.6f/src/PaxHeaders.14419/loadlinm.asm0000644000175000017500000000013012025461304017264 xustar000000000000000029 mtime=1347838660.99439581 30 atime=1347838662.018370842 29 ctime=1347838660.99439581 loadlin-1.6f/src/loadlinm.asm0000644000175000017500000006722112025461304016251 0ustar00samysamy00000000000000; >>> this is file LOADLINM.ASM ;============================================================================ ; LOADLIN v1.6 (C) 1994..1996 Hans Lermen (lermen@elserv.ffm.fgan.de) ; (C) 2008..2010 Samuel Thibault (samuel.thibault@ens-lyon.org) ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; ;---------------------------------------------------------------------------- ; Comments and bug reports are welcome and may be sent to: ; E-Mail: samuel.thibault@ens-lyon.org ; ;============================================================================ ;--------------------------------------------------------------------------- call_pmode_routine proc near ; NOTE: must have called get_VCPI_interface before this ; _AND_ must be already moved high, else the pagetable ; will not be aligned. ; input: ; AX = offset of protected mode routine ; The called routine will have a pointer in ebp to a pushad_struct ; of the other input registers, and all segment register point to ; High_seg ; @@regs struc pushAD_struc @@ @@regs ends pushf CLI pushad mov ebp,esp ; IRET stack for return to VM86 push 0 push gs push 0 push fs push 0 push ds push 0 push es push 0 push ss push ebp sub sp,4 ; space for EFLAGS push 0 push cs push 0 push offset @@pmode_return ; IRET stack for return to VM86 mov cs:pmode_return_esp,esp lea ax,@@pmode_task movzx eax,ax mov dword ptr protected_mode_target,eax mov word ptr protected_mode_target+4,g_code movzx esi,cs:High_Seg shl esi,4 lea si,our_CR3[si] mov ax,0DE0Ch int emm_int ; jumps to protected mode ; and comes here in 16-bit protected mode @@pmode_task: mov ax,g_data mov ss,ax mov ds,ax mov es,ax mov fs,ax mov gs,ax mov esp,cs:pmode_return_esp ; ebp pointing to pushad_struct mov ax, word ptr [bp].@@eax call ax ; call the routine ; now we return to VM86 mode cli ; to be save mov ax,g_core ; selector for addressing first MByte mov ds,ax .386p CLTS ; clear taskswitch flag .386 mov eax,0DE0Ch call far fword ptr cs:server_vcpi_entry ; back to VM86 ; and returns here in VM86 mode @@pmode_return: popad popf ret call_pmode_routine endp IF 0 AUXPAGE = (modul_end-code_org0) ; behind our code ELSE AUXPAGE = 0 ; at start of our segment, only used in protected mode ENDIF AUXPAGE_size = 02000h AUXPAGE_entry = (AUXPAGE shr (12-2)) AUXPAGE_S = AUXPAGE AUXPAGE_T = AUXPAGE+AUXPAGE_size AUXPAGE_S_entry equ page0+AUXPAGE_entry[bx] AUXPAGE_T_entry equ page0+(AUXPAGE_entry+(AUXPAGE_size shr (12-2)))[bx] AUXPAGE_BITS = 3 ; writeable, present move_anywhere_vcpi proc near ; input: ; ESI= linear source address ; EDI= linear target address ; CX= size to move, must be <= 4096 !!! ; output: ; all registers preserved ; we are in VM86 and at this point assume to have VCPI push ax lea ax,@@pmove call call_pmode_routine pop ax ret ; this will be executed in 16-bit protected mode @@pmove: @@regs struc pushAD_struc @@ @@regs ends ; save pagetable-entries mov bx,High_Seg shr bx,(12-4-2) push AUXPAGE_S_entry push AUXPAGE_S_entry+4 push AUXPAGE_T_entry push AUXPAGE_T_entry+4 mmm macro reg,st mov eax,[bp].@@e® mov reg,ax and reg,0fffh lea reg,[reg]+AUXPAGE_&st and ax,0f000h or al,AUXPAGE_BITS mov AUXPAGE_&st&_entry,eax add eax,1000h mov AUXPAGE_&st&_entry+4,eax endm mmm si,S ; map source mmm di,T ; map target .386p mov eax,CR3 ; flush TLB mov CR3,eax .386 cld movzx ecx,cx ror ecx,2 rep movsd rol ecx,2 rep movsb ; restore pagetable-entries pop AUXPAGE_T_entry+4 pop AUXPAGE_T_entry pop AUXPAGE_S_entry+4 pop AUXPAGE_S_entry ret move_anywhere_vcpi endp ;--------------------------------------------------------------- move_anywhere_INT15 proc near ; input: ESI = source linear address ; EDI = destination linear address ; CX = count ; returns: ; all registers preserved ; @@descript struc @@limit dw ? @@base0 dw ? @@base16 db ? @@typbyte db ? @@limit16 db ? @@base24 db ? @@descript ends push_ es,eax,esi,edi,ecx mov cs:@@src.@@base0,si shld eax,esi,16 mov cs:@@src.@@base16,al mov cs:@@src.@@base24,ah mov cs:@@dest.@@base0,di shld eax,edi,16 mov cs:@@dest.@@base16,al mov cs:@@dest.@@base24,ah mov cx,(1000h/2) ; force to be one page ; NOTE: INT15 moves are in WORDS, ; because we always move 1000h, ; we simple do it also for the last page push cs pop es lea si,@@gdt mov ax,08700h int 15h pop_ es,eax,esi,edi,ecx ret align qword @@gdt @@descript <0,0,0,0,0,0> @@descript <0,0,0,0,0,0> @@src @@descript <0ffffh,0,0,093h,0,0> @@dest @@descript <0ffffh,0,0,093h,0,0> @@descript <0,0,0,0,0,0> ; BIOS CS @@descript <0,0,0,0,0,0> ; BIOS SS move_anywhere_INT15 endp ;============================================================================ DUMMY_XMS_BLOCK_START = 100000h XMS_GET_VERSION = 0 XMS_QUERY_FREE = 8 XMS_ALLOC = 9 XMS_FREE = 0ah XMS_MOVE_BLOCK = 0bh XMS_LOCK_BLOCK = 0ch XMS_UNLOCK_BLOCK = 0dh xmscall macro function mov ah,function call cs:xms_entry endm check_for_XMS proc near push_ ds,es,ax,bx mov cs:xms_entry,0 mov cs:xms_avail,0 mov ax,4300h INT 2fh cmp al,80h jnz @@ex mov ax,4310h INT 2fh mov word ptr cs:xms_entry,bx mov word ptr cs:xms_entry+2,es xmscall XMS_GET_VERSION cmp ax,200h jb @@ex0 xmscall XMS_QUERY_FREE or ax,ax jz @@ex0 mov cs:xms_avail,ax @@ex: pop_ ds,es,ax,bx cmp cs:xms_entry,0 ret @@ex0: mov cs:xms_entry,0 jmp @@ex check_for_XMS endp allocate_xms_block proc near push_ bx,dx cmp cs:xms_entry,0 je @@ex0 mov dx,cs:xms_avail xmscall XMS_ALLOC or ax,ax je @@ex0 mov cs:xms_handle,dx @@ex: pop_ bx,dx or eax,eax ret @@ex0: xor eax,eax jmp @@ex allocate_xms_block endp lock_xms_block proc near ; try to lock the XMS block ; (needed to get the phys.address) push_ ax,bx,dx mov dx,cs:xms_handle xmscall XMS_LOCK_BLOCK or ax,ax je @@err mov word ptr cs:xms_phys_addr,bx mov word ptr cs:xms_phys_addr+2,dx pop_ ax,bx,dx ret @@err: push cs pop ds lea dx,@@tx call print jmp exit_to_dos @@tx db 13,10,'Cannot lock XMS memory',13,10,'$' lock_xms_block endp free_xms_block proc near push_ ax,bx,dx mov dx,cs:xms_handle xmscall XMS_UNLOCK_BLOCK mov dx, cs:xms_handle xmscall XMS_FREE pop_ ax,bx,dx ret free_xms_block endp move_anywhere_xms proc near ; input: ; ESI= linear source address ; EDI= linear target address ; CX= size to move, must be <= 4096 !!! (actually _is_ always 4096) ; output: ; all registers preserved cmp edi,DUMMY_XMS_BLOCK_START jae @@high cmp esi,DUMMY_XMS_BLOCK_START jb move_simple @@high: pushad push ds mov ecx,1000h ; force a length of one page to move ; NOTE: XMS moves have to be even, ; because we alway move 1000h, ; we simple do it also for the last page mov @@length,ecx sub edi,DUMMY_XMS_BLOCK_START jb @@lowdi mov @@doffs,edi ; high destination, just record mov di,xms_handle mov @@dhandle,di jmp @@source @@lowdi: ror edi,4 mov word ptr [@@doffs+2],di xor di,di rol edi,4 mov word ptr [@@doffs],di xor di,di mov word ptr [@@dhandle],di @@source: sub esi,DUMMY_XMS_BLOCK_START jb @@lowsi mov [@@soffs],esi ; high destination, just record mov si,xms_handle mov [@@shandle],si jmp @@done @@lowsi: ror esi,4 mov word ptr @@soffs+2,si xor si,si rol esi,4 mov word ptr @@soffs,si xor si,si mov word ptr [@@shandle],si @@done: lea si,[@@length] push cs pop ds xmscall XMS_MOVE_BLOCK pop ds popad ret @@length dd ? @@shandle dw ? @@soffs dd ? @@dhandle dw ? @@doffs dd ? move_anywhere_xms endp ;-------------------------------------------------------------------- move_simple proc near ; input: ; ESI= linear source address ; EDI= linear target address ; CX= size to move, must be <= 4096 !!! ; output: ; all registers preserved pushad push_ ds,es movzx ecx,cx cld ror edi,4 mov es,di xor di,di rol edi,4 ror esi,4 mov ds,si xor si,si rol esi,4 ror ecx,2 rep movsd rol ecx,2 rep movsb @@ex: pop_ ds,es popad ret move_simple endp build_buffer_heap proc near pushad ; first we setup the normal low heap ; (why not use it) movzx eax,kernel_load_frame shl eax,4 mov heap_ptr,eax movzx eax,High_Seg ; NOTE: this is page aligned ! shl eax,4 mov heap_end,eax sub eax,heap_ptr shr eax,12 mov heap_max_pages,eax ; now we try to get some extended memory cmp need_mapped_put_buffer,0 jz @@err cmp cpu_type,cpu_386V86 je @@vcpi ; we check what we can use to access extended memory call check_for_XMS jz @@need_int15 cmp cs:xms_avail,128 jb @@need_int15 sub cs:xms_avail,64 ; leave a 64K minimum for system call allocate_xms_block jz @@need_int15 movzx eax,cs:xms_avail shr eax,2 ; from 1KB to 4KB add heap_max_pages,eax mov high_heap_ptr,DUMMY_XMS_BLOCK_START mov high_mem_access,USING_XMS mov move_anywhere, offset move_anywhere_xms @@ex: mov eax,heap_max_pages shl eax,12 mov load_buffer_size,eax popad ret @@need_int15: mov ax,08800h int 15h sub ax,64+64 ; leave HMA untouched, we need 64Kminimum ; (else we would waste more mem than winning) jbe @@err movzx eax,ax shr eax,2 ; from 1KB to 4KB add heap_max_pages,eax mov high_heap_ptr,0110000h mov high_mem_access,USING_INT15 mov move_anywhere, offset move_anywhere_int15 jmp @@ex @@err: mov high_mem_access,0 mov move_anywhere, offset move_simple jmp @@ex @@vcpi: cmp have_VCPI,0 jz @@ex push edx mov ax,0DE03h ; get avail 4K VCPI-page int emm_int sub edx,(64/4) ; leave a 64K minimum for system jb @@err add heap_max_pages,edx mov high_mem_access,USING_VCPI mov move_anywhere, offset move_anywhere_vcpi pop edx jmp @@ex build_buffer_heap endp get_buffer_from_heap proc near ; output: EAX = linear address of 4K buffer, page aligned ; (if XMS, then the offset within the buffer) ; CARRY =1, if memory overflow cmp heap_max_pages,0 jna @@err dec heap_max_pages mov eax,heap_ptr cmp eax,heap_end jnb @@high add heap_ptr,1000h @@ex1: clc @@ex: ret @@high: cmp high_mem_access,USING_VCPI ; what heap are we using je @@vcpi mov eax,high_heap_ptr add high_heap_ptr,1000h jmp @@ex1 @@vcpi: push edx mov ax,0DE04h ; get 4K VCPI-page int emm_int mov eax,edx and ax,0f000h pop edx jmp @@ex1 @@err: xor eax,eax stc jmp @@ex get_buffer_from_heap endp free_extended_memory proc near cmp need_mapped_put_buffer,0 jz @@ex cmp high_mem_access,USING_XMS je @@xms cmp high_mem_access,USING_VCPI jne @@ex @@vcpi: push_ eax,bx,ecx,dx,bp,esi,edi mov cx,word ptr pageadjlist.ncount sub cx,1 jc @@ex1 mov bp,cx mov bx,cx shr bp,(9 - 2) shl bx,3 and bp,~03h @@bigloop: and bx,0fffh @@loop: mov edx,pagelist[bx] cmp edx,0100000h jb @@ex1 mov ax,0DE05h ; free 4K VCPI-page int emm_int dec cx jc @@ex1 sub bx,8 jnc @@loop sub bp,4 ; get the page adresses page mov esi,pageadjlist.sources[bp] mov di,ds movzx edi,di shl edi,4 add edi,offset [pagelist] push ecx mov ecx,01000h call move_anywhere pop ecx mov edx,esi cmp edx,0100000h jb @@ex1 mov ax,0DE05h ; free 4K VCPI-page int emm_int jmp @@bigloop @@ex1: pop_ eax,bx,ecx,dx,bp,esi,edi @@ex: ret @@xms: call free_xms_block jmp @@ex free_extended_memory endp final_page_adjust_list_handling proc near cmp need_mapped_put_buffer,0 jz @@ex push_ eax,bx,ecx,dx,bp,esi,edi mov dx,word ptr [pageadjlist.ncount] sub dx,1 jc @@ex1 ; allocate a page for the pending page adresses call get_buffer_from_heap jnc @@gotmem jmp errnomem @@gotmem: ; always copy the pending page adresses mov edi,eax mov si,ds movzx esi,si shl esi,4 add esi,offset [pagelist] mov ecx,01000h call move_anywhere xchg esi,edi mov bp,dx shr bp,(9 - 2) and bp,~03h mov pageadjlist.sources[bp],eax cmp high_mem_access,USING_XMS jne @@ex1 call lock_xms_block mov bp,dx mov bx,dx shr bp,(9 - 2) shl bx,3 and bp,~03h @@bigloop: and bx,0fffh @@loop: mov eax,pagelist[bx] sub eax,DUMMY_XMS_BLOCK_START jb @@done add eax,xms_phys_addr mov pagelist[bx],eax sub dx,1 jc @@done sub bx,8 jnc @@loop xchg esi,edi mov ecx,01000h call move_anywhere sub edi,DUMMY_XMS_BLOCK_START jb @@low add edi,xms_phys_addr mov pageadjlist.sources[bp],edi @@low sub bp,4 ; get the next page adresses page mov esi,pageadjlist.sources[bp] mov di,ds movzx edi,di shl edi,4 add edi,offset [pagelist] mov ecx,01000h call move_anywhere jmp @@bigloop @@done: xchg esi,edi mov ecx,01000h call move_anywhere sub edi,DUMMY_XMS_BLOCK_START jb @@low2 add edi,xms_phys_addr mov pageadjlist.sources[bp],edi mov eax, edi call writehexdword @@low2 @@ex1: pop_ eax,bx,ecx,dx,bp,esi,edi @@ex: ret final_page_adjust_list_handling endp open_new_mapped_block proc near ; input: ; EDI = linear address of final target address cmp need_mapped_put_buffer,0 jz @@ex push_ bx,edi mov bx,word ptr pageadjlist.number_of_blocks shl bx,3 ; * sizeof(pblock) and di,0f000h mov pageadjlist.blocks.taddr[bx],edi mov di,word ptr pageadjlist.ncount mov pageadjlist.blocks.tstart[bx],di mov pageadjlist.blocks.tcount[bx],0 inc pageadjlist.number_of_blocks mov do_mapped_put_buffer,1 ; notice 'put_buffer' what to do pop_ bx,edi @@ex: ret open_new_mapped_block endp map_high_page proc near ; input: ; EDI = linear address of source address ; because this is called strict sequentially, the target address ; is allways given by the next free entry in the pageadjlist cmp need_mapped_put_buffer,0 jz @@ex push_ bx,edi mov ebx,[pageadjlist.ncount] test ebx,ebx jz @@ok test ebx,01ffh jnz @@ok ; needs to save the previous page of page addresses push_ eax,ecx,esi,edi call get_buffer_from_heap jnc @@gotmem jmp errnomem @@gotmem: mov edi,eax mov si,ds movzx esi,si shl esi,4 add esi,offset [pagelist] mov ecx,01000h call move_anywhere mov di,bx shr di,(9 - 2) and di,~03h sub di,4 mov pageadjlist.sources[di],eax pop_ eax,ecx,esi,edi @@ok: and bx,01ffh shl bx,3 and di,0f000h mov pagelist[bx],edi inc dword ptr [pageadjlist.ncount] mov bx,word ptr [pageadjlist.number_of_blocks] dec bx shl bx,3 ; * sizeof(pblock) inc dword ptr pageadjlist.blocks.tcount[bx] pop_ bx,edi @@ex: ret map_high_page endp put_buffer proc near ; input: ; AX= count ; EDI= linear destination address (may be > 0100000h) ; DS:DX= source address in lowmem ; output: ; none, all registers preserved ; in case of memory overflow it doesn't return (jumps to exit_to_dos) ; pushad push_ ds,es movzx ecx,ax cmp cs:need_mapped_put_buffer,0 jnz @@mapped ; we can mov it normally cld ror edi,4 mov es,di xor di,di rol edi,4 mov si,dx ror ecx,2 rep movsd rol ecx,2 rep movsb @@ex: pop_ ds,es popad ret @@mapped: ; do high move call get_buffer_from_heap jc @@err ; we don't need EDI any more, because ; if we come here we are writing ; strict sequentialy and have set the ; starting address of the block ; via open_new_mapped_block mov edi,eax mov si,ds movzx esi,si shl esi,4 movzx edx,dx add esi,edx call map_high_page call move_anywhere jmp @@ex @@err: pop_ ds,es popad errnomem: DosCall DOS_CLOSE_FILE lea dx,@@tx call print jmp exit_to_dos @@tx db 13,10,'Out of memory (may be low or extended)',13,10,'$' put_buffer endp ; --------------------------------------------------------------- ; initrd stuff MAXPHYSMEM_FOR_INT15 = 1000000h load_initrd proc near cmp cs:option_initrd,0 jz @@ex pushad cmp need_mapped_put_buffer,0 jz @@err_unable ; first get ramdisk size mov ax,DOS_OPEN_FILE shl 8 lea dx,[rdimage_name] DosInt jc @@err_open mov fhandle,ax mov bx,ax call get_filesize mov ramdisk_size,eax ; then compute kernel end estimation ; movzx eax,kernel_size ; add ax,0ffh ; mov al,0 ; round up to page boundary ; shl eax,4 ; size of compressed kernel mov eax,kernel_size add eax,0fffh ; round up to page boundary and eax,0fffff000h ; size of compressed kernel mov ecx,eax shl eax,1 ; estimated size of decompressed kernel ; (we assume a decompression rate of 1:2) sub ecx,(90000h - 2000h) ; the low buffer size (for bzimages) jb @@3 add eax,ecx ; add padding @@3: add eax,(100000h+2000h) ; (+ gunzip-heap), now we have end of kernel mov [@@kernel_limit],eax ; then get size of memory call get_effective_physmem ; drop 1/16 of the memory to avoid e.g. ACPI data mov ebx,eax shr ebx,4 sub eax,ebx ; limit ourselves to 2G since we use special values in ; pgadjust.c and eax,7fffffffh mov end_of_physmem,eax cmp high_mem_access,USING_INT15 jne @@1 ; INT15 on some BIOSes will not access above 16Mb cmp eax,MAXPHYSMEM_FOR_INT15 jbe @@1 ; more than 16MB and using INT15, try to load below 16MB, in case the ; BIOS is buggy mov eax,MAXPHYSMEM_FOR_INT15 sub eax,ramdisk_size and ax,0f000h ; round down to full page boundary cmp [@@kernel_limit],eax jb @@2 ; yes, fits! ; print warning for the user mov dx,offset @@tx16 call print mov eax,end_of_physmem @@1: sub eax,ramdisk_size and ax,0f000h ; round down to full page boundary cmp [@@kernel_limit],eax jnb @@err_mem ; ok we have place ; now loading the kernel ; NOTE: needing EDI for open_new_mapped_block @@2: mov ramdisk_image,eax mov edi,ramdisk_image call open_new_mapped_block ; open the first block mov bx,fhandle mov ecx,ramdisk_size mov print_dots,3 call read_handle ; read the ramdisk call print_crlf mov print_dots,0 call print_crlf jc @@err_io cmp eax,ecx jnz @@err_io ; ok, all is read into memory DosCall DOS_CLOSE_FILE popad @@ex: ret @@err: popad mov dx,@@errtx_addr call print jmp exit_to_dos @@err_open: mov @@errtx_addr,offset @@tx jmp @@err @@err_mem: mov @@errtx_addr,offset @@txmem jmp @@err @@err_io: mov @@errtx_addr,offset @@txio jmp @@err @@err_unable: mov @@errtx_addr,offset @@txno jmp @@err @@tx db 13,10,"can't open image file for initrd",13,10,'$' @@txmem db 13,10,"no place after kernel for initrd",13,10,'$' @@tx16 db 13,10,"warning: loading above 16MB using INT15",13,10,'$' @@txio db 13,10,"IO-error while reading initrd",13,10,'$' @@txno db 13,10,"no support in setup for reading initrd",13,10,'$' @@errtx_addr dw 0 @@kernel_limit dd 0 load_initrd endp get_filesize proc near ; input: ; bx = filehandle ; output: ; eax = filesize, all other registers reserved push_ cx,dx,esi mov ax,4201h ; seek to current position xor cx,cx xor dx,dx DosInt ; ... and return current position in DX:AX push_ ax,dx ; save it mov ax,4202h ; seek to last position xor cx,cx xor dx,dx DosInt ; ... and return EOF position in DX:AX mov si,dx shl esi,16 mov si,ax pop_ dx,cx mov ax,4200h ; seek to saved position DosInt mov eax,esi pop_ cx,dx,esi ret get_filesize endp loadlin-1.6f/src/PaxHeaders.14419/loadlinj.asm0000644000175000017500000000013012025461304017261 xustar000000000000000029 mtime=1347838660.99439581 30 atime=1347838662.018370842 29 ctime=1347838660.99439581 loadlin-1.6f/src/loadlinj.asm0000644000175000017500000010653012025461304016243 0ustar00samysamy00000000000000; >>> this is file LOADLINj.ASM ;============================================================================ ; LOADLIN v1.6 (C) 1994..1996 Hans Lermen (lermen@elserv.ffm.fgan.de) ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; ;---------------------------------------------------------------------------- ; Comments and bug reports are welcome and may be sent to: ; E-Mail: samuel.thibault@ens-lyon.org ; ;============================================================================ check_VCPI_present proc near pushad push es push ds lea esp,[esp-4] ; local space @@stack struc @@handle dw ? dw ? @@ds dw ? @@es dw ? pushad_struc @@ @@stack ends xor eax,eax ; check EMM_interrupt present mov [esp].@@eax,eax mov es,ax mov es,word ptr es:[emm_int*4+2] cmp Dword ptr es:[10+4],'0XXX' jne @@ex cmp dword ptr es:[10],'XMME' je @@ok cmp dword ptr es:[10],'QMME' ; this also works (as told by ) jne @@ex @@ok: mov ax,4000h ; check emm menager status int emm_int or ah,ah jnz @@ex mov ax,_GET_VERSION*256 ; get version int emm_int cmp ax,40h ; version must be greater 4.0 jb @@ex mov ax,_ALLOCATE_RAW_PAGES mov bx,4 int emm_int cmp ah,0 jnz @@ex mov word ptr [esp].@@handle,dx ; save handle mov ax,0DE00h ; check for VCPI present int emm_int cmp ah,0 jne short @@notok mov byte ptr [esp].@@eax,1 @@notok: mov dx,word ptr [esp].@@handle mov ax,_DEALLOCATE_PAGES*256 int emm_int @@ex: lea esp,[esp+4] ; discar local space pop ds pop es popad or ax,ax ret check_VCPI_present endp get_VCPI_interface proc near push cs ;* buffer for server GDT entries push offset gdtvcpi_code ;* push cs ;* buffer for server page0 push offset page0 ;* call get_protected_mode_interface ret get_VCPI_interface endp check_low_mem_mapping proc near call get_VCPI_interface xor edx,edx lea si,page0 cld mov cx,(640/4) @@loop: lodsd and ax,0f000h cmp eax,edx jne @@ex_false add edx,1000h loop @@loop mov ax,1 @@ex: or ax,ax ret @@ex_false: xor ax,ax jmp @@ex check_low_mem_mapping endp get_protected_mode_interface proc near ARG server_pagebuffer:dword,server_selectors:dword = returnpop push bp mov bp,sp push si push di push ds push es ; convert pagebuffer to linear address movzx eax,word ptr server_pagebuffer+2 movzx ebx,word ptr server_pagebuffer shl eax,4 add eax,ebx shr eax,4 ; make real mode address ;XXXXXXXXXX push ds mov es,ax ; ES = frame of server_pagebuf xor di,di ; ES:DI = >buffer for page0-table< lds si,server_selectors ; DS:DI = >3 GDT entries for VCPI ; calling VCPI server mov ax,0DE01h int emm_int pop ds ; save VCPI server entry for protected mode mov dword ptr server_vcpi_entry,ebx ; set the VCPI-Code selector mov word ptr server_vcpi_entry+4,g_vcpi_code ;XXXXXXXXXXX pop es pop ds pop di pop si pop bp ret returnpop get_protected_mode_interface endp try_biosintv proc near pushad mov ax,DOS_OPEN_FILE shl 8 lea dx,@@fname DosInt jc @@ex_false mov bx,ax mov ax,4402h mov cx,size intv_buf lea dx,intv_buf DosInt pushf push ax DosCall DOS_CLOSE_FILE pop ax popf jc @@ex_false mov intv_size,ax mov ax,1 @@ex: or ax,ax popad ret @@ex_false: xor ax,ax jmp @@ex @@fname db '$BIOSINT',0 try_biosintv endp try_realbios proc near pushad mov ax,DOS_OPEN_FILE shl 8 lea dx,@@fname_realbios DosInt jc @@ex_false mov bx,ax lea dx,intv_buf mov cx,realbios_end-intv_buf DosCall DOS_READ_FROM_HANDLE pushf push ax DosCall DOS_CLOSE_FILE pop ax popf jc @@ex_false cmp ax,realbios_end-intv_buf jne @@ex_false mov intv_size,ax cmp cs:option_rx,1 je @@ex_true ; we now check the BIOS-revision to be sure ; that we have the right file push es mov ax,0ffffh mov es,ax mov eax,dword ptr es:[biosdate-reset_jmpop] cmp eax,dword ptr cs:biosdate jne @@ex_wrong_bios mov eax,dword ptr es:[(biosdate-reset_jmpop)+4] cmp eax,dword ptr cs:biosdate+4 jne @@ex_wrong_bios ; we check the real_bios_magic cmp cs:real_bios_magic,0a5a5h jne @@ex_wrong_bios @@ex_true: mov ax,1 pop es @@ex: or ax,ax popad ret @@ex_false: mov intv_size,0 xor ax,ax jmp @@ex @@ex_wrong_bios: pop es mov wrong_realbios,1 call force_error_verbose jmp @@ex_false @@fname_realbios db REALBIOS_FILE,0 try_realbios endp get_default_bios_intvectors proc near cmp option_ja,0 jnz @@first_javier cmp option_realbios,0 jnz @@first_realbios call try_biosintv jnz @@ex call try_realbios @@ex: ret @@first_realbios: call try_realbios jnz @@ex call try_biosintv jmp @@ex @@first_javier: mov intv_size,0 jmp @@ex get_default_bios_intvectors endp pmode_return_esp dd ? ; used to return from real-mode-switch real_IDTR dw 03ffh ;needed to load real intvector after switch dd 0 pmode_task proc near ; We come here in protected mode via VCPI-CALL ; have only to set up all things to switch back to 386-realmode ; ; We follow the INTEL recomended procedure to do this ; (80386 Programmer's Reference Manual, Chapter 14.5) ; .386p CLI ; just to be sure ; 1. We know, that paging is enabled, ; that linear addresses have identical mapping ; so we can clear the PG bit mov eax,CR0 and eax,07fffffffh mov CR0,eax ; paging is off xor eax,eax mov CR3,eax ; clear out paging cache ; 2. We must transfer control to segment with 64K limit ; we ARE on such a segment, no need to do it here ; 3. Load segment registers SS,DS,ES,FS,GS with a selector ; that points to a descriptor containing the the values: ; limit 64k = 0FFFFh ; byte granularity ; Expand up ; writable ; present ; ; We have that descriptor, its our gdt_data. mov ax,g_data mov ss,ax mov ds,ax mov es,ax mov fs,ax mov gs,ax ; 4. Disable Interrrupts ; ( we did that above ) ; 5. Clear the PE bit in CR0 mov eax,CR0 and al,0feh mov CR0,eax ; we are go back to realmode ; 6. Flush the instruction queue and load CS with approritate value ;jmp far ptr @@here db 0EAh dw @@here reloc_hseg_1 dw High_Seg_ @@here label far ; 7. Use LIDT instruction to load the base and limits of the ; real-mode interrupt vector table lidt fword ptr cs:real_IDTR .386 ; 8. Enable interrupts (we are doing this later) ; 9. Load segment register mov ax,High_Seg_ reloc_hseg_2 equ word ptr ($-2) mov ss,ax mov ds,ax mov es,ax mov fs,ax mov gs,ax mov esp,pmode_return_esp ; now we are in "real" real-mode call restore_bios_default_vectors @@ex: popad ret pmode_task endp iodelay macro jmp short $+2 jmp short $+2 endm get_mem_from_CMOS proc near pushf cli push bx mov al,18h out [070h],al dec al mov bl,al iodelay in al,[071h] mov ah,al mov al,bl iodelay out [070h],al iodelay in al,[071h] ; extended mem read from CMOS pop bx popf ret get_mem_from_CMOS endp restore_bios_default_vectors proc near push_ es,ds,ax,cx,si,di xor di,di mov es,di cmp cs:have_to_intercept_setup,0 jz @@p2 ; No REALBIOS or device driver cmp word ptr cs:intv_buf+(4*15h+2),0 jne @@ex ; Only once mov eax,dword ptr es:[4*15h] mov dword ptr cs:intv_buf+(4*15h),eax call get_mem_from_CMOS mov cs:real_bios_int15,ax jmp @@p1 @@p2: mov cx,cs:intv_size shr cx,2 jcxz @@ex ; we now reset the intvector to bios-defaults push cs pop ds cmp cx,(size intv_buf)/4 ; have we REALBIOS jna @@1 ; no ; yes ; restoring BIOSdata also mov cx,(dummy_dos_data-intv_buf)/4 @@1: lea si,intv_buf cld rep movsd cmp cs:intv_size,(size intv_buf) ; have we REALBIOS jna @@8 ; no ; yes, restoring BIOSscratch also mov di,09FC0h mov es,di xor di,di lea si,bios_scratch mov cx,(size bios_scratch)/4 rep movsd ; now reprogram the PICs (8259A) ; (may be redirected by VCPI-client) mov al,11h ; enter programming mode out [20h],al ; master iodelay out [0A0h],al ; slave iodelay mov al,8 ; IRQ0..7 --> INT8..F out [21h],al ; master iodelay mov al,70h ; IRQ8..F --> INT70..77 out [0A1h],al ; slave iodelay mov al,4 ; master bit out [21h],al ; master iodelay mov al,2 ; slave bit out [0A1h],al ; slave iodelay mov al,1 ; 8086 mode out [21h],al ; master iodelay out [0A1h],al ; slave iodelay mov al,cs:slaveIMR out [0A1h],al ; slave iodelay mov al,cs:masterIMR out [21h],al ; master @@p1: ; we hook on the INT15 xor ax,ax mov es,ax mov word ptr es:[4*15h],offset our_int15 mov word ptr es:[4*15h+2],cs ; now we must reinit the video controler ; to the values just set in the BIOS-data ; we do it by calling the appropriate INT 10h mov ax,3003h ; al = color mode and ah,byte ptr cs:bios_data+10h ; get EQUIPPEMENT-flags cmp ah,30h jne @@6 mov al,7 ; al = mono mode @@6: xor ah,ah INT 10h @@8: push ds pop es @@ex: mov cs:intv_size,0 ; avoid second call pop_ es,ds,ax,cx,si,di ret restore_bios_default_vectors endp our_int15 proc near ; interrupt 15 hook, in case of realbios cmp ah,88h je @@we_do_it jmp dword ptr cs:intv_buf+(4*15H) @@we_do_it: mov ax,cs:real_bios_int15 ;;;test mov ax,0c00h*4 iret our_int15 endp switch_to_protected_mode_and_return_in_386realmode proc near ; NOTE: must have called get_VCPI_interface before this ; ; returns with interrpts disabled ; all registers preserved, all segment registers = "High_Seg" cmp cs:have_to_force_realmode,0 jnz @@goon ret @@goon: mov cs:have_to_force_realmode,0 pushad mov pmode_return_esp,esp lea ax,pmode_task movzx eax,ax mov dword ptr protected_mode_target,eax mov word ptr protected_mode_target+4,g_code movzx esi,High_Seg shl esi,4 lea si,our_CR3[si] CLI mov ax,0DE0Ch int emm_int ; jumps to protected mode ; does NOT return here ; "pmode_task" does return directly to our caller switch_to_protected_mode_and_return_in_386realmode endp ; input: ; ES:DI pointer to string ; AL = terminating character ; output: ; AX= length of string, not counting terminating character ; all other registers preserved strlen proc near .8086 push_ di,cx xor cx,cx dec cx cld repne scasb mov ax,di dec ax pop_ di,cx sub ax,di .386 ret strlen endp get_kernel_version proc near ; Input: ; DS=CS ; Output: ; EAX= converted verion number as: ; 1.2.3 (root:pipapo) #4 ... ---> EAX= 01020304h ; 1.2.3 ---> EAX= 01020300h ; all other registers preserved xor eax,eax cmp have_to_intercept_setup,2 jne @@ex cmp setup_header_version,0105h jb @@ex cmp kernel_version,0 jz @@ex push_ esi,edx mov si,kernel_version lea si,setup_prog[si] call value_of mov edx,eax call value_of ror eax,8 shld edx,eax,8 call value_of ror eax,8 shld edx,eax,8 xor eax,eax cmp byte ptr [si-1],0 ; end of string ? je @@ex_ cld @@loop: lodsb test ax,ax jz @@ex_ cmp al,'#' jne @@loop call value_of ror eax,8 @@ex_: shld edx,eax,8 mov eax,edx pop_ esi,edx @@ex: ret get_kernel_version endp writechar proc near push_ eax,edx push eax mov byte ptr [esp+1],'$' mov dx,sp call print add sp,4 pop_ eax,edx ret writechar endp writestring proc near cld @@1: lodsb test al,al jz @@ex call writechar loop @@1 @@ex: ret writestring endp writehexdigit proc near push eax and al,0fh add al,'0' cmp al,'9' jna @@m1 add al,'A'-('9'+1) @@m1: call writechar pop eax ret writehexdigit endp writehexbyte proc near push eax ror eax,4 call writehexdigit rol eax,4 call writehexdigit pop eax ret writehexbyte endp writehexword proc near push eax ror eax,8 call writehexbyte rol eax,8 call writehexbyte pop eax ret writehexword endp writehexdword proc near push eax ror eax,16 call writehexword rol eax,16 call writehexword pop eax ret writehexdword endp force_error_verbose proc near mov option_v,1 mov option_t,1 mov option_t_forced,1 ret force_error_verbose endp get_effective_physmem proc near ; input: none ; output: EAX = number of total physical RAM in bytes ; (may be set by mem= param) cmp end_of_physmem,0 jz @@continue mov eax,end_of_physmem ret @@continue: mov ah,88h cmp intv_size,15h*4 jnb @@sim_int15 cmp have_to_intercept_setup,0 jz @@sim_int15_1 call get_mem_from_CMOS jmp @@1 ; we take int 15 as is, result may be wrong ; but Linux takes this as memory @@sim_int15_1: int 15h jmp @@1 @@sim_int15: cmp wrong_realbios,0 jne @@sim_int15_1 cmp cs:real_bios_magic,0a5a5h ; have we a saved value jne @@sim_int15_2 ; no mov ax,cs:real_bios_int15 ; yes jmp @@1 @@sim_int15_2: ; we take int 15 routine as saved by BIOSINTV ; hopefully this gets better result pushf cli push cs push offset @@1 push dword ptr intv_buf+(15h*4) retf @@1: movzx eax,ax shl eax,10 ; now have extended mem in bytes add eax,100000h ; we add we 1Meg of conventional mem ret get_effective_physmem endp print_verbose proc near pushad push_ ds,es @@print macro tx lea dx,tx call print endm @@cr macro call print_crlf endm @@prints macro tx,count mov cx,count lea si,tx call writestring endm @@hexw macro v mov ax,v call writehexword endm @@print @@t1 @@prints image_name, cmp have_to_intercept_setup,2 jne @@m1 cmp setup_header_version,0105h jb @@m1 cmp kernel_version,0 jz @@m1 @@print @@t1_ mov dx,kernel_version add dx,offset setup_prog call print @@m1: @@print @@t2 ; @@hexw kernel_size mov eax,kernel_size call writehexdword cmp have_big_kernel,0 jz @@m1_1 @@print @@t2_big jmp @@m1_2 @@m1_1: @@print @@t2_ @@m1_2: @@hexw new_setup_size cmp setup_version,0201h jb @@m1_5 test loadflags,CAN_USE_HEAP jz @@m1_5 @@print @@t2_heap mov ax,heap_end_ptr sub ax,new_setup_size @@hexw ax @@m1_5: @@print @@v1 @@hexw vga_mode @@print @@c2 lea di,command_line xor ax,ax call strlen push ax call writehexword @@print @@c1 pop cx @@prints command_line,cx @@cr @@verbose_stat: @@print @@t21 mov eax,load_buffer_size call writehexdword movzx bx,high_mem_access shl bx,1 mov dx,@@hmtable[bx] call print @@print @@t21_ mov ax,maximum_setup_sects*512 call writehexword cmp have_relocated_setup,0 jz @@mmt22 @@print @@t21_oc @@mmt22: cmp high_mem_access,0 jz @@mmt23 @@print @@t22low mov eax,heap_end sub eax,heap_ptr call writehexdword @@print @@t22low2 @@mmt23: @@print @@t22 call get_effective_physmem call writehexdword @@print @@t5 lea dx,@@real_ cmp cpu_type,cpu_386GE je @@3 lea dx,@@real_p ja @@3 lea dx,@@v86 @@3: call print cmp wrong_realbios,0 je @@3__ @@print @@t6_ lea dx,@@t6__ jmp @@3_1 @@3__: cmp intv_size,0 jz @@3_1_ lea dx,@@t6 cmp intv_size,(size intv_buf) ; have we REALBIOS jna @@3_ lea dx,@@t6_ @@3_: call print lea dx,@@no cmp intv_size,0 jz @@3_1 lea dx,@@yes @@3_1: call print @@3_1_: @@print @@t7 lea dx,@@no cmp have_to_intercept_setup,1 jb @@3_2 lea dx,@@setup_ je @@3_2 lea dx,@@setup call print mov ax,setup_version call writehexword jmp @@3_2_1 @@3_2: call print @@3_2_1: @@print @@s mov bx,cpu_check_status mov dx,@@stable[bx] call print @@print @@cc2 lea di,comline+1 xor ax,ax call strlen push ax call writehexword @@print @@cc1 pop cx @@prints comline+1,cx @@print @@started lea dx,@@rundos cmp can_exit_to_dos,0 jnz @@4_1 lea dx,@@runshell @@4_1: call print cmp cannot_load_because_of_windows,0 jz @@5 @@print @@sw @@5: cmp cpu_type,cpu_386GE_real_paging jne @@6 @@print @@w1 @@6: ; movzx eax,kernel_size ; shl eax,4 mov eax,kernel_size cmp eax,load_buffer_size jb @@7 @@print @@w2 @@7: cmp new_setup_size,maximum_setup_sects*512 jna @@8 @@print @@w3 @@8: cmp option_force,0 jz @@8_1 @@print @@w4 @@8_1: pop_ ds,es popad ret @@t1 db 13,10,'Your current LINUX kernel boot configuration is:' db 13,10,' image file: $' @@t1_ db 13,10,' kernel version $' @@t2 db 13,10,' kernel size: 0x$' ;@@t2_ db '0 setup size: 0x$' ;@@t2_big db '0 (high loaded) setup size: 0x$' @@t2_ db ' setup size: 0x$' @@t2_big db ' (high loaded) setup size: 0x$' @@t2_heap db ', heap: 0x$' IF 0 @@t3 db 13,10,' ram disk size: 0x$' @@t4 db 13,10,' root device: 0x$' @@tro db ' read only$' @@trw db ' read/write$' ENDIF @@v1 db 13,10,' VGA mode: 0x$' @@c2 db 13,10,' command line (size 0x$' @@c1 db '):' db 13,10,' $' @@t21 db 13,10,'Your current DOS/CPU configuration is:' db 13,10,' load buffer size: 0x$' @@hmtable dw @@lowtx,@@vcpitx,@@int15tx,@@xmstx @@lowtx db ' $' @@vcpitx db ' VCPI$' @@int15tx db ' EXT $' @@xmstx db ' XMS $' @@t21_ db ', setup buffer size: 0x$' @@t21_oc db ' (reloc setup)$' @@t22low db 13,10,' lowmem buffer: 0x$' @@t22low2 db ' (part of load buffer)$' @@t22 db 13,10,' total memory: 0x$' @@t5 db 13,10,' CPU is in $' @@t6 db ', BIOSINTV.SYS: $' @@t6_ db ', REALBIOS: $' @@t6__ db 'YES, but ROM-BIOS-DATE differs, must rerun REALBIOS.EXE$' @@t7 db 13,10,' SetupIntercept: $' @@yes db 'YES$' @@no db 'NO$' @@v86 db 'V86 mode$' @@real_ db 'REAL mode$' @@real_p db 'undocumented REAL PAGING mode, trying any way$' @@setup_ db 'YES, patching setup code$' @@setup db 'YES, legal intercept, setup header version $' @@s db 13,10,' stat$' @@s8 db '4: VCPI_present, physmap=logmap, all OK for switch to realmode$' @@s6 db '3: VCPI_present, but physmap != logmap (check aborted)$' @@s4 db '2: cpu_V86, but no VCPI available (check aborted)$' @@s2 db '1: cpu in real 386 mode, no need to backswitch$' @@s0 db '0: cpu < 386$' @@stable dw @@s0,@@s2,@@s4,@@s6,@@s8 @@cc2 db 13,10,' input params (size 0x$' @@cc1 db '):' db 13,10,' $' @@started db 13,10,' LOADLIN started from $' @@rundos db 'DOS-prompt',13,10,'$' @@runshell db 'CONFIG.SYS (shell= ...)',13,10,'$' @@sw db ' You are running under MS-WINDOWS or Windows 95',13,10,'$' @@w1 db 'WARNING:',13,10 db ' Your CPU is in realmode, but PAGING is enabled !',13,10 db ' This is possible, but neither documented nor supported by INTEL.',13,10 db " May be your motherboard's BIOS is mapping shadow ram this way,",13,10 db ' or you are using one of those old and strange EMM managers,',13,10 db ' but probably this is an indication of a not exactly compatible',13,10 db ' 486 clone. If you are not using one of the older EMM-managers',13,10 db ' you better should use the -clone switch to work around.',13,10,'$' @@w2 db 'WARNING: Not enough free memory (load buffer size)$',13,10 @@w3 db 'WARNING: The setup buffer of LOADLIN is too small (must recompile)$',13,10 @@w4 db 'WARNING: Option -f set, CPU-Check bypassed !$',13,10 print_verbose_stat: pushad push_ ds,es jmp @@verbose_stat print_verbose endp close_debug_file proc near cmp debug_file_handle,0 jz @@ex push_ ax,bx mov bx,debug_file_handle DosCall DOS_CLOSE_FILE mov debug_file_handle,0 pop_ ax,bx @@ex: ret close_debug_file endp wait_and_reset_dsk proc near pushad push_ ds,es,fs,gs pushf sti cmp cs:option_dskreset,0 jz @@wait mov ax,0 mov dl,80h ; reset the whole disk system int 13h cmp cs:option_wait,0 jnz @@wait mov cs:option_wait,9 ; wait at least 1/2 a second @@wait: cmp cs:option_wait,0 jz @@ex cli mov ax,40h mov ds,ax movzx eax,cs:option_wait add eax,dword ptr ds:[6ch] sti nop @@loop: nop cli cmp eax,dword ptr ds:[6ch] sti ja @@loop @@ex: popf pop_ ds,es,fs,gs popad ret wait_and_reset_dsk endp ;============================================================================= logo_tx label byte IFDEF ALPHA INCLUDE LOADLINA.ASM ENDIF db 'LOADLIN v',LOADLIN_VERSION,' (C) 1994..2002 Hans Lermen ',13,10,'$' db ' (C) 2008..2010 Samuel Thibault ',13,10,'$' comspec_tx db 'comspec',0 windows_tx db 'windir',0 err_uppermem_tx db 'Not enough free memory between 90000h and 9ffffh,',13,10 db 'may be you have some zombie programs, try to reboot.',13,10 db "If this doesn't help, try to find out what driver occupies this space." newline_tx db 13,10,'$' enter_commandline_tx db 'Please enter name of kernel image file followed by optional ',13,10 db 'command line parameters for Linux (e.g. root=XXXX)',13,10 db 'or @file ( file = param file ) or "empty string" to abort:',13,10,'$' abort_tx db 'LOADLIN aborted by user',13,10,'$' err_file_notfound_tx db 'Image file not found,',13,10,'$' enter_file_tx db 'enter file name of Image:',13,10,'$' err_wrong_file_tx db 'not an Image file,',13,10,'$' err_wrong_setup_tx db 'Your current configuration needs interception of "setup.S,"',13,10 db 'but the setup-code in your Image file is *very* old (or wrong)',13,10 db 'Please use BIOSINTV/REALBIOS or try an other Image file',13,10,'$' err_setup_too_long_tx db 'Ooops..., size of "setup.S" has become too long for LOADLIN,',13,10 db 'please E-mail this condition to samuel.thibault@ens-lyon.org !',13,10,'$' err_kernel_to_big_tx db 'not enough memory below 90000h to load kernel',13,10,'$' err_io_tx db 'IO Error during load',13,10,'$' insert_floppy_tx db 'Insert floppy disk for loading into RAMDISK',13,10,'$' err_cpu_v86_tx db 13,10,'CPU is in V86-mode (may be WINDOWS, EMM386, QEMM, 386MAX, ...)',13,10 db 'You need pure 386/486 real mode or a VCPI server to boot Linux',13,10 db 'VCPI is supported by most EMS drivers (if EMS is enabled),',13,10 db "but never under WINDOWS-3.1 or WINDOWS'95.",13,10 db "(However, real DOS-Mode of WINDOWS'95 can have EMS driver with VCPI)",13,10 db 'If loading via VCPI you also MUST have:',13,10 db ' 1. An interceptable setup-code (see MANUAL.TXT)',13,10 db ' 2. Identical Physical-to-Virtual mapping for the first 640 Kbytes',13,10,'$' err_wrong_cpu_tx db 'You need a 386 CPU at minimum, but you haven''t !',13,10,'$' err_comfile_tx db 'error on reading command line response file',13,10,'$' option_t_terminate_tx db 13,10,'Option -t set, Linux not loaded',13,10,'$' option_t_forced_tx db 13,10,'ERROR detected, Linux not loaded',13,10,'$' err_in_config_sys_tx db 13,10,'LOADLIN holding in idle loop (You must reboot)',13,10,'$' ;----------------------------------------------------------------------------- usage_tx db 13,10 db 'USAGE:',13,10 db ' LOADLIN @params',13,10 db ' LOADLIN [zimage_file] [options] [boot_params]',13,10 db ' without any params, LOADLIN displays this help message.',13,10 db ' @params:',13,10 db ' params is a DOS file containing all other options',13,10 db ' zimage_file:',13,10 db ' DOS file name of compressed Linux kernel image',13,10 db ' options:',13,10 db ' -v verbose, show information on params and configuration',13,10 db ' -t test mode, do all but starting Linux, also sets -v',13,10 db ' -d file debug mode, same as -t, but duplicates output to "file"',13,10 db " -clone ( Please read MANUAL.TXT before using this switch! )",13,10 db " -n no translation for root=/dev/...",13,10 db " -txmode switch to textmode 80x25 on startup",13,10 db " -noheap disable use of setup heap",13,10 db " -wait=nn after loading wait nn (DOS)ticks before booting Linux",13,10 db " -dskreset after loading reset all disks before booting Linux",13,10 db ' boot_params:',13,10 db ' root=xxx filesystem to be mounted by Linux as "/"',13,10 db ' (string passed unchanged to the kernel)',13,10 db ' xxx = hex number (e.g. root=201 for /dev/fd1)',13,10 db ' = /dev/mmmn (e.g. root=/dev/hda2)',13,10 db ' mmm = fd,hda,hdb,sda,sdb...',13,10 db ' n = 1..10.. decimal',13,10 db ' ro mount "/" readonly',13,10 db ' rw mount "/" read/write',13,10 db ' initrd=x (for kernels > 1.3.72) load file x into /dev/ram. If FS in x',13,10 db ' contains /linuxrc, execute it, and then remount to root=xxx.',13,10 db ' If root=/dev/ram, just load, bypass execution of /linuxrc',13,10,13,10 db ' for more boot params see PARAMS.TXT or Paul Gortmakers HOWTO:',13,10 db ' http://sunsite.unc.edu/mdw/HOWTO/BootPrompt-HOWTO.html',13,10 db ' http://rsphy1.anu.edu/~gpg109/BootPrompt-HOWTO.html',13,10 empty_tx db '$' loadlin-1.6f/src/PaxHeaders.14419/loadlini.asm0000644000175000017500000000013012025461304017260 xustar000000000000000029 mtime=1347838660.99439581 30 atime=1347838662.022370746 29 ctime=1347838660.99439581 loadlin-1.6f/src/loadlini.asm0000644000175000017500000006644312025461304016252 0ustar00samysamy00000000000000; >>> this is file LOADLINI.ASM ;============================================================================ ; LOADLIN v1.6 (C) 1994..1996 Hans Lermen (lermen@elserv.ffm.fgan.de) ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; ;---------------------------------------------------------------------------- ; Comments and bug reports are welcome and may be sent to: ; E-Mail: samuel.thibault@ens-lyon.org ; ;============================================================================ relocate_setup_code proc near ; NOTE: This routine has to be updated whenever a new access to ; High_seg or High_addr is inserted in the code ! ; It relocates those addresses, if the setup code is ; not loaded at 9000h ; push_ eax,bx mov have_relocated_setup,1 ; these can simply overwriten mov ax,High_seg mov reloc_hseg_1,ax mov reloc_hseg_2,ax @@relocd macro desc lea bx,desc call relocate_descriptor endm ; these descriptors have to get added the displacement @@relocd gdt_code @@relocd gdt_data @@relocd gdt_ldt @@relocd gdt_tss ; these DWORDS have to get added the displacement sub ax,High_seg_ movsx eax,ax shl eax,4 add our_CR3,eax add our_GDTRptr,eax add our_IDTRptr,eax add laddr_GDT,eax add laddr_IDT,eax add pagedir_template,eax add pageadjlist_ptr,eax call preset_pagedir_from_template pop_ eax,bx ret relocate_setup_code endp relocate_descriptor proc near ; input: ; AX = new 'High_seg' frame ; BX = offset of descriptor ; bases address of descriptor must be relative to 'High_seg_' ; outpout: ; all registers preserved, descriptor bases updated push_ ecx,eax mov ch,[bx].base24 mov cl,[bx].base16 shl ecx,16 mov cx,[bx].base0 sub ax,High_seg_ movsx eax,ax shl eax,4 add eax,ecx mov [bx].base0,ax shr eax,16 mov [bx].base16,al mov [bx].base24,ah pop_ ecx,eax ret relocate_descriptor endp read_comline_from_file proc near ;; mov ax,DOS_OPEN_FILE shl 8 ;; lea dx,image_name+1 ;; DosInt push fs call @@open jnc @@isopen @@err: lea dx,err_comfile_tx call print mov word ptr comline-1,0 jmp @@ex @@ioerr: ;; DosCall DOS_CLOSE_FILE call @@close jmp @@err @@isopen: mov bx,ax cld lea di,comline+1 @@loop: mov dx,di mov cx,1 ;; DosCall DOS_READ_FROM_HANDLE call @@read jc @@ioerr cmp ax,1 jne @@eof mov al,byte ptr [di] cmp al,13 je @@loop cmp al,'#' je @@skipeol @@skipcontinue: inc di cmp di, offset comline_end-1 jnb @@eof cmp al,' ' ja @@loop cmp di,offset comline+2 jna @@1 cmp byte ptr [di-2],' ' ; ignore multiple spaces jne @@1 dec di jmp @@loop @@1: mov byte ptr [di-1],' ' jmp @@loop @@eof: mov byte ptr [di],0 mov ax,di sub ax,offset comline+1 xchg al,ah mov word ptr comline-1,ax ;; DosCall DOS_CLOSE_FILE call @@close jmp @@ex @@skipeol: mov dx,di mov cx,1 ;; DosCall DOS_READ_FROM_HANDLE call @@read jc @@ioerr cmp ax,1 jne @@eof cmp byte ptr [di],10 jne @@skipeol jmp @@skipcontinue @@ex: pop fs ret ; ----------- @@virtual db 0 @@open: ; virtual open routine cmp dword ptr image_name,'ol@@' jne @@open_d cmp dword ptr image_name+4,'ilda' je @@open_v @@open_d: mov @@virtual,0 lea dx,image_name+1 mov ax,DOS_OPEN_FILE shl 8 DosInt ret @@open_v: mov @@virtual,1 mov ax,High_Seg cmp dword ptr image_name+4+4,'@@xn' jne @@open_vhex mov fs,ax lea ax,params_from_loadlinX clc ret @@open_vhex: push si lea si,image_name+4+2 mov word ptr [si],'x0' call value_of mov fs,ax xor ax,ax ; carry is also 0 pop si ret @@close: cmp @@virtual,0 jz @@close_d ret @@close_d: DosCall DOS_CLOSE_FILE ret @@read: cmp @@virtual,0 jz @@read_d mov al, byte ptr fs:[bx] or al,al jz @@read_eof inc bx mov byte ptr [di],al mov ax,1 clc ret @@read_eof: xor ax,ax clc ret @@read_d: DosCall DOS_READ_FROM_HANDLE ret read_comline_from_file endp build_arglist proc near ; input: ; ES=DS=CS= seg of all pointers ; SI = pointing to commandline like string ; DI = target buffer ; output: ; DI = pointing to next free byte in target buffer ; all other registers preserved @@stack struc pushA_struc @@ @@stack ends pusha mov bp,sp xor cx,cx @@1: inc cx call get_token jnz @@1 mov di,[bp].@@di mov bx,di inc cx shl cx,1 add di,cx mov si,[bp].@@si @@2: mov word ptr [bx],di inc bx inc bx call get_token mov di,ax jnz @@2 mov word ptr [bx-2],0 mov [bp].@@di,ax popa ret build_arglist endp handle_response_file proc near IF 0 call read_comline_from_file ELSE pushad cld lea di,aligned_auxbuff mov @@list,di call build_arglist ; we save the rest of the old commandline mov @@ptr,di call read_comline_from_file cmp word ptr aligned_auxbuff,0 ; nothing left in the old ? jz @@ex lea si,comline+1 mov @@cptr,si cld mov di,@@ptr call build_arglist ;we scan the read-in commandline ; now we check if there are overwrites mov si,word ptr aligned_auxbuff mov @@list,si mov dx,@@ptr mov si,dx mov si,word ptr [si] or si,si jz @@ex_0 ; check if we have to replace the image lea di,@@image mov bx,@@list ; string list of old args call check_token js @@2 mov bx,word ptr aligned_auxbuff[bx] mov byte ptr [bx],1 ; mark as 'used' cmp byte ptr [bx+5],0 je @@2 cmp byte ptr [bx+6],0 je @@2 lea si,[bx+6] ; take what is behind 'image=' jmp @@2 @@1: mov si,dx mov si,word ptr [si] or si,si jz @@ex_0 ; we check for the special case 'ro','rw' cmp byte ptr [si+2],0 jne @@1_3 cmp word ptr [si],'or' jne @@1_1 lea di,@@rw ; search the opposite (rw replaces ro) jmp @@1_2 @@1_1: cmp word ptr [si],'wr' jne @@1_3 lea di,@@ro ; search the opposite (ro replaces rw) @@1_2: mov bx,@@list ; string list of old args call check_token jmp @@1_4 @@1_3: mov di,si mov bx,@@list ; string list of old args call check_token @@1_4: js @@2 ; we have to take the old one mov si,word ptr aligned_auxbuff[bx] @@2: push si mov di,@@cptr call stringcpy pop si mov @@cptr,di mov byte ptr [di-1],' ' add dx,2 cmp si,@@list ; avoid overwriting our constants jb @@1 mov byte ptr [si],1 jmp @@1 @@ex_0: ; we have to take the rest of the old commandline lea bx,aligned_auxbuff ; string list of old args @@ex_1: mov si,word ptr [bx] add bx,2 or si,si jz @@ex_2 cmp byte ptr [si],1 je @@ex_1 ; skip, what we already replaced mov di,@@cptr call stringcpy mov @@cptr,di mov byte ptr [di-1],' ' jmp @@ex_1 @@ex_2: mov bx,@@cptr mov byte ptr [bx-1],0 sub bx, offset comline+1 jz @@ex_5 dec bx @@ex_5: xchg bh,bl mov word ptr comline-1,bx @@ex: popad ret @@ptr dw 0 @@list dw 0 @@cptr dw 0 @@image db 'image=',0 @@rw db 'rw',0 @@ro db 'ro',0 ENDIF handle_response_file endp check_token proc near ; input: ; ES=DS=CS= seg of all pointers ; DI = pointing to token ; BX = pointing to string-table, terminated by a ZERO-string ; output: ; AX = -1, no match found ; = 0, found a matching string, BX = index*2 of that string ; = 1, same as AX=0, but token was terminated by '=' ; DI = pointing to token behind terminator (0 or '=') ; push_ cx,dx cld xor dx,dx jmp @@loop_entry @@loop: pop di inc dx xchg bx,di xor ax,ax mov cx,-1 repnz scasb ; skip to next string in table xchg bx,di cmp byte ptr [bx],0 jz @@not_found @@loop_entry: push di mov cx,size aux_token call name_compare jz @@loop pop ax ; clean up stack xchg dx,bx ; get index shl bx,1 xor ax,ax cmp byte ptr [di-1],'=' jne @@ex inc ax @@ex: pop_ cx,dx test ax,ax ret @@not_found: mov ax,-1 jmp @@ex check_token endp get_setup_version proc near mov cs:setup_version,0 cmp dword ptr ds:setup_header_sign,SIGNATURE jne @@ex push word ptr cs:setup_header_version pop cs:setup_version @@ex: ret get_setup_version endp parscommandline proc near mov image_name,0 parscommandline_: call clear_to_default mov cx,word ptr comline-1 xchg ch,cl jcxz @@ex_carry mov si,cx mov comline[si+1],0 mov command_line,0 mov cl_pointer,offset command_line lea si,comline+1 cld cmp image_name,0 jnz @@1 lea di,image_name call get_token ; get the zImage-file name jz @@ex_carry cmp image_name,'-' jne @@0 mov dword ptr image_name,'amiz' mov word ptr image_name+4,'eg' mov image_name+6,0 jmp parscommandline_ @@0: ; got zImage-name ; try to get params cmp image_name,'@' jne @@1 call handle_response_file jmp parscommandline @@1: lea di,image_name call tolower jmp @@next_token @@token_table label byte db 'ramdisk',0 db 'vga',0 db 'mem',0 db 'root',0 db 'ro',0 db 'rw',0 db 'no387',0 db 'single',0 db 'auto',0 db '-v',0 db '-t',0 db '-d',0 db '-rb',0 db '-rx',0 db '-ja',0 db '-clone',0 ; db '-oldxd',0 db 'debug',0 db 'no-hlt',0 db 'reserve',0 db 'hd',0 db 'bmouse',0 db 'max_scsi_luns',0 db 'xd',0 db '-n',0 db '-txmode',0 db '-f',0 db 'initrd',0 db '-noheap',0 db '-wait',0 db '-dskreset',0 db 0 @@jmp_table dw @@ramdisk dw @@vga dw @@mem ;@@tolower ; mem dw @@tolower ; root dw @@tolower ; ro dw @@tolower ; rw dw @@tolower ; no387 dw @@tolower ; single dw @@tolower ; auto dw @@option_v dw @@option_t dw @@option_d dw @@option_realbios dw @@option_rx dw @@option_ja dw @@option_clone ; dw @@option_oldxd dw @@tolower ; debug dw @@tolower ; no-hlt dw @@tolower ; reserve= dw @@tolower ; hd= dw @@tolower ; bmouse= dw @@tolower ; max_scsi_luns= dw @@tolower ; xd= dw @@option_n dw @@option_txmode dw @@option_force dw @@option_initrd dw @@option_noheap dw @@option_wait dw @@option_dskreset @@next_token: lea di,aux_token call get_token jz @@ex0 lea di,aux_token lea bx,@@token_table call check_token js @@not_my_token jmp @@jmp_table[bx] @@mem: jz @@not_my_token push di lea di,aux_token call tolower pop di cmp byte ptr [di],'n' ; = 'nopentium' je @@not_my_token xchg si,di call value_of call adjust_k_or_m xchg si,di mov end_of_physmem,eax jmp @@not_my_token @@option_wait: jz @@not_my_token push di lea di,aux_token call tolower pop di xchg si,di call value_of xchg si,di mov option_wait,ax jmp @@next_token @@option_initrd: jz @@not_my_token push_ si,di xchg si,di lea di,rdimage_name call stringcpy pop_ si,di mov option_initrd,1 jmp @@next_token @@ramdisk: ; have ramdisk param mov got_ram_disk,1 mov new_ram_disk,1440 jz @@next_token xchg si,di call value_of cmp word ptr [si],'on' ; disable diskchange prompt ? jne @@ramdisk_1 mov option_nodiskprompt,1 @@ramdisk_1: xchg si,di mov new_ram_disk,ax jmp @@next_token @@token_table_vga label byte db 'normal',0 db 'extended',0 db 'ask',0 db 0 @@vga: ; have vga - param mov got_vga_mode,1 mov new_vga_mode,-1 ; default = NORMAL jz @@next_token mov bx,di cmp byte ptr [bx],'-' jne @@vga_1 inc bx @@vga_1: cmp byte ptr [bx],'0' jb @@check_vga_sym cmp byte ptr [bx],'9' jna @@check_vga_num @@check_vga_sym: ; DI already pointing to value lea bx,@@token_table_vga call check_token js @@next_token shr bx,1 not bx mov new_vga_mode,bx jmp @@next_token @@check_vga_num: xchg si,di call value_of xchg si,di mov new_vga_mode,ax jmp @@next_token @@option_t: mov option_t,1 ; forces also option -v @@option_v: mov option_v,1 jmp @@next_token @@option_noheap: mov option_noheap,1 jmp @@next_token @@option_d: lea di,aux_token ; get output file name call get_token jz @@option_t ; no file name push_ bx,cx,dx xor cx,cx lea dx,aux_token DosCall DOS_CREATE_FILE pop_ bx,cx,dx jc @@option_t mov debug_file_handle,ax jmp @@option_t @@option_realbios: mov option_realbios,1 jmp @@next_token @@option_rx: mov option_rx,1 jmp @@next_token @@option_ja: mov option_ja,1 jmp @@next_token @@option_clone: mov option_clone,1 dec token_count jmp @@next_token @@option_n: mov option_n,1 jmp @@next_token @@option_force: mov option_force,1 jmp @@next_token @@option_dskreset: mov option_dskreset,1 jmp @@next_token @@option_txmode: pusha push_ ds,es xor ax,ax mov es,ax mov ax,3003h ; al = color mode and ah,byte ptr es:[0410h] ; get EQUIPPEMENT-flags cmp ah,30h jne @@option_txmode6 mov al,7 ; al = mono mode @@option_txmode6: xor ah,ah INT 10h pop_ ds,es popa jmp @@next_token @@not_my_token: push si lea si,aux_token call @@append_to_commandline pop si jmp @@next_token @@tolower: lea di,aux_token call tolower jmp @@not_my_token @@ex0: lea si,@@boot_tx call @@append_to_commandline dec cl_pointer lea si,image_name cld mov di,si @@ex1: lodsb test al,al jz @@ex3 cmp al,':' je @@ex2 cmp al,'\' je @@ex2 cmp al,'/' jne @@ex1 @@ex2: mov di,si jmp @@ex1 @@ex3: mov si,di call @@append_to_commandline @@ex: clc ret @@ex_carry: stc ret @@append_to_commandline: mov di,cl_pointer @@append_to_1: lodsb stosb test al,al jnz @@append_to_1 mov byte ptr [di-1],' ' mov byte ptr [di],al mov cl_pointer,di ret @@boot_tx db 'BOOT_IMAGE=',0 parscommandline endp handle_kernel_specifics proc near IF 0 cmp kernelversion,0 jz @@ex ; put here kernel dependent stuff @@ex: ENDIF ret handle_kernel_specifics endp get_token proc near ; returns: ; ZFLAG = 1 on EOF ; AX = increased DI push di @@skip_loop: lodsb cmp al,' ' je @@skip_loop jmp @@ok @@loop: lodsb cmp al,' ' jne @@ok xor al,al @@ok: stosb test al,al jne @@loop dec si mov ax,di pop di cmp byte ptr es:[di],0 jz @@ex inc token_count @@ex: test byte ptr es:[di],255 ret get_token endp readstring proc near push dx mov comline-1,255-2 lea dx,comline-1 DosCall DOS_BUFFERED_INPUT lea dx,newline_tx call print push bx movzx bx,comline mov comline[bx+1],0 mov comline-1,0 pop bx pop dx ret readstring endp stringcpy proc near ; input: ; DS:SI= source address ; DS:DI= target address push_ ds,ds pop es cld @@loop: lodsb stosb or al,al jnz @@loop @@ex: pop ds ret stringcpy endp tolower proc near ; input: ; DS:DI= address to ASCIIZ-string cld xchg si,di @@loop: lodsb or al,al jz @@ex cmp al,'A' ; tolower ! jb @@loop cmp al,'Z' ja @@loop add byte ptr [si-1],'a'-'A' jmp @@loop @@ex: xchg si,di ret tolower endp name_compare proc near ; input: ; DS:DI= address to ASCIIZ-string (name1) ; (a "=" marks end of string also) ; CS:BX= address to ASCIIZ-string (name2) ; (a "=" marks end of string also) ; CX= max number of character to compare ; compare is done by ignoring upper/lower-case ; Output: ; AX= 0 if not equal else equal ; DI= as changed by lodsb, pointing behind terminator (0 or '=') ; all other register preserved cld push bx xchg si,di sub bx,si @@m3: lodsb cmp al,'=' ; may be name in environement jne short @@32 xor al,al jmp short @@m35 @@32: cmp al,'A' ; tolower ! jb short @@m35 cmp al,'Z' ja short @@m35 add al,'a'-'A' @@m35: mov ah,al mov al,byte ptr cs:[si+bx-1] cmp al,'=' ; may be name in environement jne short @@34 xor al,al jmp short @@m36 @@34: cmp al,'A' ; tolower ! jb short @@m36 cmp al,'Z' ja short @@m36 add al,'a'-'A' @@m36: or al,al jz short @@ex_ or ah,ah jz short @@exfalse cmp ah,al jne @@exfalse loop @@m3 @@extrue: mov ax,1 @@ex: xchg si,di pop bx or ax,ax ret @@ex_: or ax,ax jz @@extrue @@exfalse: xor ax,ax ; not equal jmp @@ex name_compare endp get_env_variable proc near ; Input ; CS:BX= Pointer to string (ASCIIZ) of desired env-variable ; Output: ; ES:DI= pointer to string (ASCIIZ) of variable contents (without "=") ; or ZERO-string if not found ; All other registers preserved push ds push ax push si mov ds,PSP_frame mov ds,ds:PSP_envir_frame xor si,si mov al,byte ptr [si] @@m1: mov cx,80 or al,al mov di,si jz @@ex call name_compare jnz @@found ; string is equal, found the variable cld @@m2: ; skip to next string lodsb or al,al jnz @@m2 mov al,byte ptr [si] jmp @@m1 @@found: @@ex: push ds pop es pop si pop ax pop ds ret get_env_variable endp adjust_k_or_m proc near ; Input: ; DS:SI, EAX as delivered by 'value_of' pushf push cx xor cx,cx mov ch, byte ptr [si-1] cmp ch,'k' jne @@1 mov cl,10 @@ex: shl eax,cl @@ex0: pop cx popf ret @@1: cmp ch,'m' jne @@ex0 mov cl,20 jmp @@ex adjust_k_or_m endp value_of proc near ; Input: ; DS:SI= pointer to string (ASCIIZ), which contains number to be converted ; (i.e.: 1234, 0xa00, ... ), all non-digit-characters (0..9,a..f,A..F) ; are "delimiters" and mark the end of the string ; Output: ; EAX= converted number ; SI= pointing at the first byte behind the delimiter cmp byte ptr [si],'-' pushf jnz @@m0 inc si @@m0: push_ ebx,ecx,edx,edi,esi mov ebx,10 xor edx,edx xor edi,edi inc edi cld lodsb call @@check_white jc @@ex jne @@m1 lodsb or al,20h ; convert to lowercase cmp al,'x' jne @@m1 mov ebx,16 lodsb @@m1: call @@check_white jb @@ex xor ecx,ecx @@m2: inc ecx lodsb call @@check_white jnc @@m2 std mov [esp],esi ;advance pointer dec si dec si @@m3: lodsb or al,20h ; convert to lowercase cmp al,'9' jna short @@m4 add al,9 @@m4: and al,0fh movzx eax,al imul eax,edi imul edi,ebx add edx,eax loop @@m3 @@ex: mov eax,edx pop_ ebx,ecx,edx,edi,esi popf jnz @@ex_ neg eax @@ex_: ret @@check_white: mov ah,'f' cmp bl,16 je short @@7 mov ah,'9' @@7: or al,20h cmp al,'0' jb short @@9 cmp al,ah ja short @@9 cmp al,'9' jbe short @@8 cmp al,'a' jae short @@8 @@9: mov al,' ' @@8: cmp al,'0' ret value_of endp loadlin-1.6f/src/PaxHeaders.14419/loadlina.asm0000644000175000017500000000013012025461304017250 xustar000000000000000029 mtime=1347838660.99439581 30 atime=1347838662.022370746 29 ctime=1347838660.99439581 loadlin-1.6f/src/loadlina.asm0000644000175000017500000000021412025461304016222 0ustar00samysamy00000000000000 db 'ALPHA ALPHA Preliminary version 12 of 1.6 ALPHA ALPHA',13,10 db 'DO NOT DISTRIBUTE DO NOT DISTRIBUTE DO NOT DISTRIBUTE',13,10 loadlin-1.6f/src/PaxHeaders.14419/loadlin.asm0000644000175000017500000000013012025461304017107 xustar000000000000000029 mtime=1347838660.99439581 30 atime=1347838662.022370746 29 ctime=1347838660.99439581 loadlin-1.6f/src/loadlin.asm0000644000175000017500000016724312025461304016101 0ustar00samysamy00000000000000TESTX = 0 LOADLIN_VERSION equ '1.6f' ; >>> this is file LOADLIN.ASM ;============================================================================ ; LOADLIN v1.6 (C) 1994..1996 Hans Lermen (lermen@elserv.ffm.fgan.de) ; (C) 2008..2010 Samuel Thibault (samuel.thibault@ens-lyon.org) ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; ;---------------------------------------------------------------------------- ; Comments and bug reports are welcome and may be sent to: ; E-Mail: samuel.thibault@ens-lyon.org ; ;============================================================================ ; ; NOTE: ; ; This program could not have been written as quickly without ; the information found in the source code of F.Coutant's BOOTLIN ; ; This program contains some modified source code from ; my protected mode extender (LDOSX (C) 1991..1994 H.Lermen), ; which was written as a fast multitasking alternative ; to DJ.Delorie's extender (it runs DJ-GCC compiled binaries under DOS). ; ; I was too lazy to reprogram the subroutines completely, so, ; if You wonder what nonsense they are doing, keep in mind that they ; were written for an other purpose. ; ;============================================================================ ; ; Contributions and bug fixes for 1.5: ; ; ; Javier Achirica ; ; invented the switch-out-of-setup method (Javier's method), ; which makes the BIOSINTV and REALBIOS method superfluous on nearly ; all machines. The trick is: let setup run in V86 and intercept ; just before going to protected mode. ; (Thank you Javier for this very good work). ; ; Contributions for 1.6: ; ; Werner Almesberger ; ; Werner and me cooperated in realizing high loading of the kernel ; and preloading the RAMdisk. ; The changes needed in setup.S for both, LILO and LOADLIN, ; are a common work of us. ; Also the needed kernel patches are the fruits of a very fertile ; cooperation. The changes to LILO-1.8 as well as to LOADLIN-1.6 ; have been developed 'synchroniously' in order to let the whole ; Linux community participate on the new boot features. ; ;============================================================================ name load_linux .386 locals jumps REALBIOS_FILE equ 'C:\REALBIOS.INT' SIGNATURE = 'SrdH' ; "HdrS" space4k = 1000h space2k = 800h space1k = 400h our_stacksize = space2k kernel_start_ equ 01000h ; here the kernel must go kernel_end equ 09000h standard_setup_sects equ 4 ; number of setup sectors, older kernels maximum_setup_sects equ (48-1) ; max number of setup sectors for newer kernels High_Seg_ equ kernel_end ; here first 512 + 4*512 + n*512 bytes of image must go High_Addr_ equ (High_Seg_*16) setup_intercept_int equ 7fh debug_stop macro marker mov ax,0b800h mov ds,ax mov byte ptr ds:[1],70h mov byte ptr ds:[0],marker jmp short $ endm align_ macro start,val org (((($-start)+(val-1))/val)*val) endm psp_seg segment at 0 use16 ; -------------PSP Program Segment Prefix---------------------- org 2h PSP_memend_frame dw ? org 2ch PSP_envir_frame dw ? org 80h PSP_DTA db ? (100h-80h) dup(?) ; ------------------------------------------------------------- psp_seg ends code segment para use16 assume cs:code,ds:psp_seg,es:code code_org0 label byte ; --------------------------------------------------------------------- ; Bootsector (512 bytes) ; within this BEFORE start of setup: ; (may be set by "LOADLIN") bootsec label byte org 20h CL_MAGIC dw ? ;0020 commandline magic number (=0xA33F) CL_OFFSET dw ? ;0022 commandline offset ; Address of commandline is calculated: ; 0x90000 + contents of CL_OFFSET ; The command line is parsed by "init/main.c" ; Value of NAME=XXXX are put into the environement ; and can then be interpreted by the drivers ; and /etc/rc. The variabel "root=xxxx" is ; interpreted by main directly, "single" is ; interpreted by init or simpleinit. org 1F1h setup_sects db ? ; no. of sectors ro_flag dw ? ; =0: root file system should be mounted read-write ;<>0: root file system should be mounted readonly ; (this will be overwritten by the kernel commandline ; options "ro" / "rw") ; -------------------------------- ; within this AFTER setup has run: org 0 curr_curs dw ? ;0000 saved cursor position ext_mem_size dw ? ;0002 extended memory size in Kb (from int 0x15) org 80h hd0_disk_par label byte ;080 hd0-disk-parameter from intvector 0x41 hd1_disk_par label byte ;090 hd1-disk-parameter from intvector 0x46 ; -------------------------------- ; within this as loaded from "zImage" org 01F4h kernel_size16 dw ? ; size of kernel-part in the image-file ; (in 16 byte units, rounded up) swap_dev dw ? ; swap device ram_disk dw ? ;01F8 size of ram-disk (in 1Kb units ) or ZERO ; if ram_disk is nonZERO then the kernel ; (driver/block/ramdisk.c: rd_load() ) ; will try to load the contents for the ram-disk ; from the "root_dev" which MUST then have the ; floppyMAJOR. ; The file-system on that floppy must be MINIX ; If rd_load() succeeds it sets the root_dev ; to the ramdisk for mounting it. ; ; LOADLIN parses the commandline for the string ; "ramdisk=nnn" where nnn is the value for "ram_disk" ; after the kernel images has been loaded by LOADLIN ; it asks for inserting the floppy. ; (NOTE: You may have LOADLIN in A: and root_dev in B: ; or vice versa). vga_mode dw ? ;01FA VGA-Mode ; -3 = ask ; -2 = Extended VGA ; -1 = Normal VGA ; 0 = as "0" was pressed ; n = as "n" was pressed ; ; LOADLIN parses the commandline for the string ; "vga=nnn" where nnn is the value for "vga_mode" ; it also excepts: ; "vga=ask","vga=normal",'vga=extended" root_dev dw ? ;01FC Root Device (high=Major, low=minor) ;(this can be overwritten by the kernel commandline ; option "root=XXXX") bootmagic dw ? ;01FE Bootsector magic (0AA55h) ; ------------------------------------------------------------------- ; this area will be used to pass params ; from LOADLINX to LOADLIN, if the params file name is @@loadlinx@@ switch ; ; NOTE: '@@loadlinx@@' or '@@loadliXXXX' ; must NOT be used, ; if starting LOADLIN without LOADLINX or ULOADLIN org 0200h params_from_loadlinX label byte ; ------------------------------------------------------------------- org 0200h setup_prog label byte ; the setup-program itself ; must be started at 9020h:0 !!! ; ======= jmp short start_of_setup ; the setup header ; (if you have applied the setup.S patch, ; or later, if we have it in the standard kernel) setup_header_sign dd ? setup_header_version dw ? setup_realmode_switch dd ? start_sys_seg dw ? kernel_version dw ? ; end of v1.5-header ; NOTE: above part of header is compatible ; with loadlin-1.5 (header v1.5), ; must not change it type_of_loader db 0 ; = 0, old one (LILO, Loadlin, ; Bootlin, SYSLX, bootsect...) ; else it is set by the loader: ; 0xTV: T=0 for LILO ; T=1 for Loadlin ; T=2 for bootsect-loader ; V = version loadflags db 0 ; unused bits =0 ; (reserved for future development) LOADED_HIGH = 1 ; bit within loadflags, ; if set, then the kernel is loaded high CAN_USE_HEAP = 80h ; if set, the loader also has set heap_end_ptr ; to tell how much space behind setup.S ; can be used for heap purposes. ; Only the loader knows what is free! setup_move_size dw 8000h ; size to move, when we (setup) are not ; loaded at 0x90000. We will move ourselves ; to 0x90000 then just before jumping into ; the kernel. However, only the loader ; know how much of data behind us also needs ; to be loaded. code32_start dd 1000h ; here loaders can put a different ; start address for 32-bit code. ; 0x1000 = default for zImage ; 0x100000 = default for big kernel ramdisk_image dd 0 ; address of loaded ramdisk image ; Here the loader (or kernel generator) puts ; the 32-bit address were it loaded the image. ; This only will be interpreted by the kernel. ramdisk_size dd 0 ; it's size in bytes bootsect_kludge dd 0 ; pointing to boot_sect_helper heap_end_ptr dw 0 ; pointing to end of setup loacal heap. ; Space from here (exclusive) down to ; end of setup code can be used by setup ; for loacal heap purposes. ; ---- end of v2.0 setup-header -------------------- start_of_setup: org setup_prog db maximum_setup_sects*512 dup(?) ; ------------------------------------------------------------- ; the following layout is private to LOADLIN.EXE : align_ code_org0,4096 end_of_setup_buffer label byte pagedir dd 2 dup(0) ; must be aligned to 4 K ; NOTE: we have only 1 (one) pagetable, so we ; need only 1 pagedir entry ; All current known CPUs (386,486,PENTIUM) ; tolerate the garbage behind this, ; as long as there is no access > 4MB. ; So we may overlap the pagedir with ; our code ; ----------------------------v ; the following are the params we have to pass to 32-bit adjustemt code pageadjlist_ptr dd (High_Seg_*16) + (pageadjlist-code_org0) real_32_startup dd 1000h ; ----------------------------^ ; ------------------------------------------------------------- align_ code_org0,16 ; org 02010h startup_32: ; here we insert the GCC compiled 32-bit code part ; it will be our point to start Linux ; it's current address is 0x95010 ; CHECKIT------^^^^^^^ !!! IF 1 INCLUDE PGADJUST.ASM ELSE INCLUDE PGADJTES.ASM ENDIF ; ------------------------------------------------------------- PSP_frame dw 0 ; our psp fhandle dw 0 ; file handle of imagefile kernel_start dw 0 ; place were the kernel must at time of ; start of setup free_mem_start dw 0 ; frame of free memory, starting at the begin of LOADLIN.EXE kernel_load_frame dw 0 ; where to load the image ; The following (High_Seg,High_Addr) ; will be set to lower values, if we have setup v2.0 ; _and_ if 9000 is occupied (W95+DRVSPACE) High_Seg dw kernel_end ; here first 512 + 4*512 + n*512 bytes of image must go ;spaeter, damit syntaxfehler enstehen: High_Addr dd (High_Seg_*16) ; ----------------------------v ; the following values are cleared on each call to "parscommandline" ; (see "clear_to_default") parse_switches label byte new_setup_size dw 0,0 ; NOTE: need the high word to be 0 new_vga_mode dw 0 new_ram_disk dw 0 cl_pointer dw 0 ; while parsing: aux pointer to command_line got_vga_mode db 0 got_ram_disk db 0 option_v db 0 option_t db 0 option_t_forced db 0 option_realbios db 0 option_rx db 0 option_ja db 0 option_clone db 0 option_oldxd db 0 option_n db 0 option_nodiskprompt db 0 option_force db 0 option_initrd db 0 option_noheap db 0 intv_size dw 0 option_wait dw 0 option_dskreset db 0 wrong_realbios db 0 have_to_force_realmode db 0 ; 0 = is in realmode ; 1 = is in V86, have to reenter realmode before ; kernel goes to protected mode ; have_to_intercept_setup db 0; 0 = old method, no interception ; 1 = intercept boot/setup.S (Javier's method) ; of older kernels just before going to ; protected mode. ; 2 = same as 1, but intercepting newer kernels ; with the setup.dif patch applied. ; debug_file_handle dw 0 ; set to file handle if option -d is set logo_out db 0 kernelversion dd 0 ; binary kernel version, decoded from ; the version string as follows: ; "1.2.3 (root@...) #4" becomes 01020304h ; if string is only 1.2.3 ---> #0 is assumed token_count db 0 end_of_physmem dd 0 parse_switches_end label byte ; ----------------------------^ can_exit_to_dos db 0 have_VCPI db 0 have_big_kernel db 0 have_relocated_setup db 0 cannot_load_because_of_windows db 0 print_dots db 0 cpu_check_status dw 0 setup_version dw 0 ; =0, if old setup ; else contents of setup_header_version kernel_size dd 0 ; will be either calculated from kernel_size16 ; or from the filesize of the image ;--------------------higmem stuff -----v xms_entry dd 0 xms_avail dw 0 xms_handle dw 0 xms_phys_addr dd 0 pblock struc taddr DD ? ; linear address where the block of pages ; must be moved to ; 65536 pages -> 256MB max tstart DW ? ; index within sources of first entry tcount DW ? ; number of entries for taddr in sources pblock ends pages_list struc ncount DD ? ; number of entries in 'sources' number_of_blocks DD ? ; number of valid blocks-items auxbuf DD ? ; address of 4096 bytes auxiliary buffer blocks pblock 4 dup(?) ; Dynamic pgadjust uses one indirection. ; 128 pages of adresse+usedby gives us the above 65536 maximum pages. sources DD 128 dup (?) ; list of addresses where the block of pages pages_list ends need_mapped_put_buffer db 0 do_mapped_put_buffer db 0 ; 1, if need high load over pagemap load_buffer_size dd 0 heap_ptr dd 0 heap_end dd 0 high_heap_ptr dd 0 heap_max_pages dd 0 move_anywhere dw move_simple ; this routine gets called ; when needing to move buffers high_mem_access db 0 ; = 0, if nothing available USING_VCPI = 1 USING_INT15 = 2 USING_XMS = 3 ;-----------------------------^ ;NOTE: all uninitialized data has been moved to end of modul ; since version 1.4 ; ------------------------------------------------------------- _DEALLOCATE_PAGES = 45h; _GET_VERSION = 46h; _ALLOCATE_RAW_PAGES = 5A01H EMM_int = 67h; descript struc limit dw ? base0 dw ? base16 db ? typbyte db ? limit16 db ? base24 db ? descript ends Gdescript struc gateoffs0 dw ? gateselector dw ? gatenotused db ? gatetyppbyte db ? gateoffs16 dw ? Gdescript ends ; definition of COMMON decriptor types (bit0..4 of descript.typbyte ) ; (bit 4 of descript.typbyte =0) data_d = 10000b ; data segment descriptor writable = 00010b ; =1 if write acces allowed to data segment expand_down = 00100b ; =1 limit counts down from base code_d = 11000b ; code segment readable = 00010b ; =1 if code also can be read (cannot be ovwritten) conforming = 00100b ; =1 code can be accesses and executed ; regardless of it's privilege level ; definition of SYSTEM decriptor types (bit0..4 of descript.typbyte ) ; (bit 4 of descript.typbyte =0) TSS286_avail_d = 01h LDT_d = 02h TSS286_busy_d = 03h call_gate_d = 04h task_gate_d = 05h INT286_gate_d = 06h TRAP286_gate_d = 07h TSS386_avail_d = 09h TSS386_busy_d = 0bh call386_gate_d = 0ch INT386_gate_d = 0eh TRAP386_gate_d = 0fh ; definition of privilege levels (bit5..6 of descript.typbyte ) p0 = 0 ; p1 = 1*32 ; super visor levels p2 = 2*32 ; puser = 3*32 ;definition of granularity ( bits7..8 in descript.limit16 ) gran_byte = 0 gran_page = 10000000b ; 4k granularity ; for data_selectors: data_USE16 = 0 gran_big = 01000000b ; big segment data_USE32 = gran_big ; use 32-bit stack pointer ESP instead of SP ; Intel says: relevant only together with expand_down for data_d ; But that is WRONG : ; BIG segment must be set also if the descriptor is greater 64K ; and is used to load SS ! ; (because SP cannot access behind 64K) ; ; for code_selectors: code_USE32 = 01000000b ; default operand size 32 bit (for code segments) code_USE16 = 00000000b ; default operand size 16 bit (for code segments) ; segment present bit (bit7 of descript.typbyte ) is_present =128 not_present =0 descriptor macro name,typ,plevel,present,limit,gran,base name descript endm ;GDT Global Descriptor Table -------------------------v align_ code_org0,16 gdtnull descript ;0000 never accessable gdtvcpi_code descript ;0008 gdtvcpi2 descript ;0010 gdtvcpi3 descript ;0018 descriptor gdt_core,(data_d+writable),p0,is_present,0fffffh,(gran_page+data_USE32),0 descriptor gdt_code,(code_d+readable),p0,is_present,0ffffh,(gran_byte+code_USE16),High_Addr_ descriptor gdt_data,(data_d+writable),p0,is_present,0ffffh,(gran_byte+data_USE16),High_Addr_ descriptor gdt_ldt,LDT_d,p0,is_present,7,gran_byte,(High_Addr_+(ldtnull-code_org0)) descriptor gdt_tss,TSS286_avail_d,p0,is_present,0ffh,gran_byte,(High_Addr_+(our_tss-code_org0)) gdtlast descript ; dummy for addressing g_vcpi_code equ (gdtvcpi_code-gdtnull) g_core equ (gdt_core-gdtnull) g_code equ (gdt_code-gdtnull) g_data equ (gdt_data-gdtnull) g_ldt equ (gdt_ldt-gdtnull) g_tss equ (gdt_tss-gdtnull) ;GDT Global Descriptor Table -------------------------^ ;LDT Local Descriptor Table -------------------------v ldtnull descript ;0000 never accessable ldtlast descript ; dummy for addressing ;LDT Local Descriptor Table -------------------------^ ; align_ SYSTEMDATA_,1024 ;IDT Interrupt Descriptor Table -------------------------v idtnull descript 32 dup (<0>) idtlast descript ; dummy for addressing ;IDT Interrupt Descriptor Table -------------------------^ our_tss dd 128 dup (?) ; our TSS Task State Segment ;params for switching TO protected mode -------------------------v ;NOTE: this Data MUST be in LOW_MEM (below 1 Mbyte), ; data referenced by this structure ; CAN be in memory above 1 Mbyte ; On switching to protected mode the server ; first loads CR3 (paging base) from "our_CR3". ; ; value of CR3 to be loaded by server our_CR3 dd (High_Addr_+(pagedir-code_org0)) ; linear address in first Mbyte pointing to ; value of GDTR ("our_GDTR") to be loaded by server our_GDTRptr dd (High_Addr_+(our_GDTR-code_org0)) ; linear address in first Mbyte pointing to ; value of IDTR ("our_IDTR") to be loaded by server our_IDTRptr dd (High_Addr_+(our_IDTR-code_org0)) ; value of LDTR to be loaded by server our_LDTR dw g_ldt ; value of TR to be loaded by server our_TR dw g_tss ; Fword, pointer to code to be started by server protected_mode_target DD ? DW g_code ; belongs to above our_GDTR dw (gdtlast-gdtnull)-1 ;limit (byte gran) ;linear (not physical) base address of "gdtnull" laddr_GDT dd (High_Addr_+(gdtnull-code_org0)) dw ? ; (just for align "laddr_IDT" to Dword) our_IDTR dw (idtlast-idtnull)-1 ;limit (byte gran) ;linear (not physical) base address of "Idtnull" laddr_IDT dd (High_Addr_+(idtnull-code_org0)) ;-------------------------------------------------------------------^ server_vcpi_entry df 0 ; this is the address we must call instead of INT67 ; when in protected mode pagedir_template dd (High_Addr_+(page0-code_org0)+3) ;============================================================================= DOS_WRITE_STRING = 009h ; Display a '$' terminated string DOS_BUFFERED_INPUT = 00Ah ; Read text and store it in a buffer DOS_OPEN_FILE = 03Dh ; Open an existing file DOS_CREATE_FILE = 03Ch ; create a new file DOS_CLOSE_FILE = 03Eh ; Close a file DOS_READ_FROM_HANDLE = 03Fh ; Read from DOS file handle DOS_WRITE_TO_HANDLE = 040h ; write to DOS file handle DOS_TERMINATE_EXE = 04Ch ; Terminate program DosCall macro function_code mov ah,function_code int 21h endm DosInt macro int 21h endm push_ macro r1,r2,r3,r4,r5,r6,r7,r8,rx irp parm,<&r1,&r2,&r3,&r4,&r5,&r6,&r7,&r8,&rx> ifndef parm exitm endif push parm endm endm pop_ macro r1,r2,r3,r4,r5,r6,r7,r8 irp parm,<&r8,&r7,&r6,&r5,&r4,&r3,&r2,&r1> ifdef parm pop parm endif endm endm pushAD_struc macro prefix irp parm, prefix&&parm dd ? endm endm pushA_struc macro prefix irp parm, prefix&&parm dw ? endm endm cpu_86 equ 0 cpu_286 equ 2 cpu_386V86 equ 3 ; is >=386, but in virtual 86 mode cpu_386GE equ 4 ; >=386 cpu_386GE_real_paging equ 5 cpu_type dw 0 cpu_check proc near pushf cmp option_force,0 jnz is_force_386GE xor ax,ax ;0000 to ax push ax popf ; try to put that in flags pushf pop ax ; look at what really went into flags and ah,0f0h ; mask off high flag bits cmp ah,0f0h je is_8086 mov ax,0f000h push ax ; try to set the high bits popf pushf pop ax ; look at actual flags and ah,0f0h je is_80286 ; is x86, x >= 3 ; check for V86 or real-paging -mode mov ah,040h ; try to clear IOPL push ax popf pushf pop ax and ah,030h jne is_v86 cmp option_clone,0 jnz @@clone .386p mov eax,cr0 ; normally this would cause a GP(0)-exception ; (i386 Programmers Reference Guide, INTEL 1987) ; if in V86-mode, but most EMMXXXX drivers ; seem to intercept this exception and allow ; reading the CR0. .386 or eax,eax jz is_v86 ; not a valid CR0, reserved bits are allways set ; (this may be not true on a 486 clone such as ; the 486DLC, so if you have trouble with ; interpreting real mode as V86 use the -clone switch ; test al,01h ; test PE -bit jz is_greater_equal_80386 is_v86: mov ax,cpu_386V86 cpu_check_exit: mov cpu_type,ax popf ret is_8086: mov ax,cpu_86 jmp cpu_check_exit is_80286: mov ax,cpu_286 jmp cpu_check_exit is_greater_equal_80386: test eax,eax ; test PG - bit js is_386_real_pageing mov ax,cpu_386GE jmp cpu_check_exit is_force_386GE: mov ax,cpu_386GE jmp cpu_check_exit is_386_real_pageing: mov ax,cpu_386GE_real_paging jmp cpu_check_exit @@clone: ; on some 486 clones we have problems with CR0, ; so we are looking for EMM, and then ; we assume to be in V86, if we have EMM. push ds xor ax,ax mov ds,ax mov ds,word ptr ds:[emm_int*4+2] mov ax,cpu_386V86 cmp dword ptr ds:[10+4],'0XXX' jne @@cl1 cmp dword ptr ds:[10],'QMME' je @@clex cmp dword ptr ds:[10],'XMME' je @@clex @@cl1: mov ax,cpu_386GE @@clex: pop ds jmp cpu_check_exit cpu_check endp ;============================================================================= start: .8086 ; we are not sure here if on a 368 CPU mov cs:PSP_frame,es mov ax,cs ; switch the to our stack mov ss,ax lea sp,stack_top mov ds,ax mov es,ax call clear_uninitialized_data mov ds,cs:PSP_frame cld lea si,PSP_DTA+1 lea di,comline+1 mov cl,PSP_DTA xor ch,ch jcxz start__2 start__: ; skip leading blanks cmp byte ptr [si],' ' jne start__2 inc si loop start__ start__2: mov comline-1,ch mov comline,cl inc cx ; get the CR too rep movsb ; get the commandline out of psp push cs pop ds assume ds:code ; from now on we have CS=DS=ES=SS ; make sure that size byte is correct ; ( some DOS versions set only CR .. sometimes ) lea di,comline+1 mov al,13 call strlen cmp al,comline jnb start_0 mov comline,al start_0: mov bx,word ptr comline-1 xchg bh,bl mov comline[bx+1],0 ; replace CR by ZERO mov logo_out,0 mov print_dots,0 mov kernel_start,kernel_start_ ; real kernel_start mov free_mem_start,cs ;save CS as later freemem ; now check if (on error) we can exit do DOS lea bx,comspec_tx call get_env_variable ; we expect COMSPEC= in the environement mov al,byte ptr es:[di] mov can_exit_to_dos,al ; check if we are running under windows lea bx,windows_tx call get_env_variable ; we expect WINDIR= in the environement mov al,byte ptr es:[di] mov cannot_load_because_of_windows,al push ds pop es lea ax,modul_end+15 shr ax,4 mov bx,ax add ax,High_Seg mov es,PSP_frame IF 1 sub ax,es:PSP_memend_frame ELSE ;TEST (to simulate an occupied 90000 segment ) ; sub ax,09500h sub ax,05500h ENDIF jb start_3 ; we have the 9000 page occupied by some program ; and we try to move down the setup code below that ; if we later detect an older setup-version, ; we must give up, jumping to "err_uppermem". neg ax add High_Seg,ax and High_Seg,0ff00h ; allign on next lower page boundary ; (need this for the pagetables) call relocate_setup_code start_3: push ds pop es ; restore es mov ax,free_mem_start cmp ax,kernel_start jnb start_9 mov ax,kernel_start start_9: mov kernel_load_frame,ax mov token_count,-1 ; check if we are on the right CPU mov cpu_check_status,0 mov option_clone,1 ; avoid reading CR0 before parsing -clone call cpu_check lea dx,err_wrong_cpu_tx cmp ax,cpu_386V86 jb err_print ; has no 386 or greater at all .386 ; now we are sure beeing on a 386(and greater) CPU cmp can_exit_to_dos,0 jnz m2 lea di,comline+1 ; as DOS (stupidly) converts all from ; CONFIG.SYS to UPPERCASE, we do TOLOWER call tolower m2: call parscommandline call cpu_check ; do it once more, because of option_clone mov cpu_check_status,2 call get_default_bios_intvectors cmp ax,cpu_386GE jb m2_1 test intv_size,0fffch jnz start_continue ; has $BIOSINTV or REALBIOS.INT cmp option_t_forced,0 jnz start_continue mov have_to_intercept_setup,1 jmp start_continue m2_1: mov cpu_check_status,4 ; have 386, but are in V86-mode call check_VCPI_present jz err_wrong_cpu ; has no VCPI-server mov have_vcpi,1 mov cpu_check_status,6 call check_low_mem_mapping jz err_wrong_cpu ; has no identical phys/log mapping mov have_to_force_realmode,1 test intv_size,0fffch jnz plain_switch ; has $BIOSINTV or REALBIOS.INT ; has no $BIOSINTV driver loaded ; but will try to start Linux anyway cmp option_t_forced,0 jnz plain_switch mov word ptr cs:intv_buf+(4*15h+2),0 mov have_to_intercept_setup,1 plain_switch: mov cpu_check_status,8 start_continue: cmp token_count,0 jg m3 jz start_continue_1 cmp comline,0 ; have we an emtpy string ? jnz m3 start_continue_1: mov need_mapped_put_buffer,1 ; | we are doing this to call build_buffer_heap ; | get the avail mem for printing lea dx,empty_tx jmp err_print ; have file-name at minimum ; trying to open it m3: mov ax,DOS_OPEN_FILE shl 8 lea dx,image_name DosInt jnc fileopened m4: lea dx,err_file_notfound_tx m4_: call print lea dx,enter_commandline_tx call print call readstring cmp comline,0 ; have we an emtpy string ? jnz m2 lea dx,abort_tx call print jmp err_exit fileopened: mov fhandle,ax IFNDEF DEBUG ;--------------------------------------- mov ax,High_Seg ; move us high mov es,ax push cs pop ds xor si,si xor di,di lea cx,modul_end+3 shr cx,2 rep movsd push es pop ds ; we have move ourself up ; must now change cs push ds lea ax,back_from_low push ax retf back_from_low: mov ax,ds ; switch the stack to top mov ss,ax lea sp,stack_top ENDIF ; from now on we have CS=DS=ES=SS=setup_memory ;------------------------------------------- cmp have_to_force_realmode,0 je back_from_low_continue ; we have to do this once more ; because some VCPI-servers rely on an unmovable page0 call get_VCPI_interface back_from_low_continue: ; first look if it is really an image mov bx,fhandle mov ecx,512 mov di,cs movzx edi,di shl edi,4 call read_handle ; read the bootsector jnc have_bootsect fileopened_wrong: DosCall DOS_CLOSE_FILE lea dx,err_wrong_file_tx jmp m4_ err_wrong_setup: DosCall DOS_CLOSE_FILE lea dx,err_wrong_setup_tx jmp m4_ err_setup_too_long: DosCall DOS_CLOSE_FILE lea dx,err_setup_too_long_tx jmp m4_ have_bootsect: cmp ax,cx jne fileopened_wrong cmp bootmagic,0AA55h jne fileopened_wrong ; ok, now get the setup part mov di,cs lea bx,setup_prog shr bx,4 add di,bx mov bx,fhandle xor ecx,ecx mov ch,setup_sects shl cx,1 jnz new_bootsect mov ch,2*standard_setup_sects new_bootsect: cmp cx,maximum_setup_sects*512 ; XXX: this check is not enough, now that setup has a BSS since it's C... ja err_setup_too_long mov new_setup_size,cx movzx edi,di shl edi,4 call read_handle ; read setup jc fileopened_wrong cmp ax,cx jne fileopened_wrong call get_setup_version call handle_kernel_size ; kernel >2.4.5 we may have bzImages > 1Meg cmp setup_version,0201h ; do we have to set setup heap ? jb new_bootsect_3 ; no cmp option_noheap,0 ; yes, but is it disabled ? jnz new_bootsect_3 ; yes or loadflags,CAN_USE_HEAP ;no mov heap_end_ptr,(end_of_setup_buffer-setup_prog) new_bootsect_3: ; if we have setup-code not at 9000 ; we have to check for setup-version >= 2.0 cmp High_seg,High_seg_ je have_setup_3 ; no need for version 2.0 cmp word ptr setup_version,0200h jb err_uppermem ; we can't continue ; ok, we set the correct move size lea ax,modul_end mov setup_move_size,ax have_setup_3: mov ax,High_Seg sub ax,kernel_load_frame movzx eax,ax shl eax,4 mov load_buffer_size,eax ; if we have setup > 2.0, we set our loader version cmp setup_version,0200h jb have_setup_4 ;@@@@@@@@@@@@@@@@@@@@@ ; well here the new tricky loadling stuff is prepared mov type_of_loader,10h ; our loader type + version ; we tell setup not to start the kernel, ; but our special 32-bit page-adjust-routine mov ax,High_Seg movzx eax,ax shl eax,4 add eax,(startup_32-code_org0) mov cs:code32_start,eax ; we tell 'read_handle' to use mapped move mov cs:need_mapped_put_buffer,1 ; we build the two heaps, low and high ; for this we need to align the low to page boundary ; align the kernel_load_frame to page boundary mov ax,kernel_load_frame add ax,0ffh mov al,0 mov kernel_load_frame,ax mov ax,High_Seg sub ax,kernel_load_frame movzx eax,ax shl eax,4 mov load_buffer_size,eax call build_buffer_heap mov edi,01000h ;the address the image must go mov cs:real_32_startup,edi ; were the kernel gets started ; we now determin what kind of zImage we have test cs:loadflags,LOADED_HIGH jz must_start_low mov have_big_kernel,1 mov edi,0100000h ;the address the image must go mov cs:real_32_startup,edi ; were the kernel gets started must_start_low: ; even if the image starts low, ; we use the 'high load' routines, ; so we force this bit in loadflags or cs:loadflags,LOADED_HIGH ; NOTE: needing EDI from above for open_new_mapped_block call open_new_mapped_block ; open the first block ;@@@@@@@@@@@@@@@@@@@@@ have_setup_4: cmp have_to_intercept_setup,0 jz dont_patch cmp dword ptr ds:setup_header_sign,SIGNATURE jnz not_signed mov have_to_intercept_setup,2 mov word ptr ds:setup_realmode_switch,offset real_switch mov ax,High_Seg mov word ptr ds:setup_realmode_switch+2,ax mov ax,kernel_load_frame mov word ptr ds:start_sys_seg,ax jmp dont_patch not_signed: xor di,di mov cx,new_setup_size mov al,0FAh ; cli cld keep_searching: repnz scasb jcxz err_wrong_setup cmp dword ptr [di],70E680B0h ; mov al,80h ; out 70h,al jnz keep_searching mov byte ptr [di-1],0CDh ; int op code mov byte ptr [di],setup_intercept_int ; int number mov word ptr [di+1],4444h ; inc sp adjust stack ; inc sp (discard flags) mov byte ptr [di+3],90h ; nop dont_patch: ; we convert the kernel version string ; to a binary number xor eax,eax cmp have_to_intercept_setup,2 jne dont_patch_ call get_kernel_version dont_patch_: mov kernelversion,eax call handle_kernel_specifics ; ok, now check the size of the kernel ; movzx eax,kernel_size ; shl eax,4 mov eax,kernel_size cmp eax,load_buffer_size jb have_space lea dx,err_kernel_to_big_tx cmp option_t,0 je err_print have_space: ; now we update the params cmp command_line,0 jz no_comline mov CL_MAGIC,0A33Fh lea ax,command_line mov CL_OFFSET,ax mov si,cl_pointer mov byte ptr [si-1],0 ;delete the last blank no_comline: ; check for ramdisk cmp got_ram_disk,0 jz no_change_on_ramdisk mov ax,new_ram_disk mov ram_disk,ax no_change_on_ramdisk: ; check for vga cmp got_vga_mode,0 jz no_change_on_vga mov ax,new_vga_mode mov vga_mode,ax no_change_on_vga: cmp cannot_load_because_of_windows,0 jz no_windows call force_error_verbose no_windows: ; check for -v option cmp option_v,0 jz no_option_v ; option -v (verbose) is set ; print some information call print_verbose no_option_v: ; check for -t option cmp option_t,0 jz no_option_t DosCall DOS_CLOSE_FILE lea dx,option_t_terminate_tx cmp option_t_forced,0 jz no_option_t_forced lea dx,option_t_forced_tx no_option_t_forced: call print jmp err_exit no_option_t: ; start of critical section ; ========================= call close_debug_file ; now loading the kernel mov bx,fhandle ; movzx ecx,kernel_size ; shl ecx,4 mov ecx,kernel_size mov di,kernel_load_frame movzx edi,di shl edi,4 mov print_dots,2 call read_handle ; read the kernel call print_crlf mov print_dots,0 call print_crlf jc err_io cmp setup_version,0202h jae no_need_to_roundup add eax,15 and al,0f0h no_need_to_roundup: cmp eax,ecx jnz fileopened_wrong ; ok, all is read into memory DosCall DOS_CLOSE_FILE cmp ram_disk,0 ; have we a ramdisk jz no_ram_disk cmp option_nodiskprompt,0; jnz no_ram_disk ;we must prompt for insertion of floppy lea dx,insert_floppy_tx call print call readstring ; just to wait for prompt no_ram_disk: ; now we try to load the initrd ramdisk-image call load_initrd ; now we clean up all entries in the page adjust list call final_page_adjust_list_handling ; that's it ; here we handle -wait and -dskreset ; These option are to avoid outstanding disk-IRQs ; happen, when Linux tries to detect the hardware. ; In most cases we will not need this. call wait_and_reset_dsk cli ___go: cmp have_to_intercept_setup,1 ja ___go_switch je ___go_skip_move call move_kernel_down ___go_skip_move: cmp have_to_intercept_setup,1 jne ___go_switch xor ax,ax mov ds,ax mov word ptr ds:[4*setup_intercept_int],offset real_switch mov word ptr ds:[4*setup_intercept_int+2],cs ___go_switch: mov ax,cs:High_Seg mov ds,ax mov es,ax cmp have_to_intercept_setup,0 ja ___go_continue call switch_to_protected_mode_and_return_in_386realmode ___go_continue: call restore_bios_default_vectors lea bx,setup_prog shr bx,4 mov ax,High_Seg add ax,bx lea sp,setup_stack_top ; separate stack during ; setup and real_switch push ax push 0 retf ; and now it's the job of setup ; but NOTE: ; on have_to_force_realmode >0 setup calls real_switch setup_own_stack df 0 real_switch proc far ; NOTE: we have to preserve ALL registers ! ; to avoid conflicts with future kernels cli push_ ds,es,fs,gs pushad mov al,80h out [70h],al mov ax,cs mov ds,ax mov es,ax mov word ptr setup_own_stack+4,ss mov dword ptr setup_own_stack,esp ; Ok,ok, today setup has our stack (no need to switch) mov ss,ax ; ... but we want to be sure for the future, lea sp,stack_top ; so we switch to our stack cmp have_to_intercept_setup,2 ; have we to move the kernel down ? je @@3 ; no, setup will do it (knows the location of the image) ; yes, we have patched in the intercept code, ; so the kernel expects the kernel at 10000h call move_kernel_down @@3: call switch_to_protected_mode_and_return_in_386realmode lss esp,cs:setup_own_stack ; restore setup's stack popad pop_ ds,es,fs,gs retf real_switch endp ;============================================================================= move_kernel_down proc near ; is the kernel at its right place ? cli mov ax,kernel_start cmp kernel_load_frame,ax je short @@ex ; yes ; no, must move it down push_ ds,es cld mgran = 08000h mov bp,mgran shr 4 mov ax,kernel_size16 mov bx,kernel_start mov dx,kernel_load_frame @@loop: mov cx,mgran shr 2 mov ds,dx mov es,bx xor si,si xor di,di rep movsd add bx,bp add dx,bp sub ax,bp cmp ax,bp ja @@loop mov cx,ax shl cx,2 mov ds,dx mov es,bx xor si,si xor di,di rep movsd pop_ ds,es mov ax,kernel_start mov kernel_load_frame,ax @@ex: ret move_kernel_down endp err_wrong_cpu: lea dx,err_cpu_v86_tx err_print: cmp token_count,0 jz err_print_1 jg err_print_2 cmp word ptr comline-1,0 ; have we an command line jnz err_print_2 ; yes ; no, print help and status err_print_1: push dx lea dx,usage_tx call print pop dx err_print_2: call print cmp cpu_type,cpu_386V86 jb err_exit call print_verbose_stat jmp err_exit err_io: lea dx,err_io_tx call print jmp err_exit err_uppermem: lea dx,err_uppermem_tx call print err_exit: cmp cs:can_exit_to_dos,0 jz idle mov al,1 exit_to_dos: call free_extended_memory call close_debug_file DosCall DOS_TERMINATE_EXE idle: lea dx,err_in_config_sys_tx call print call close_debug_file idle_: sti jmp idle_ real_print proc near ; input: DX = offset of string within CODE .8086 push ds push cs pop ds push_ bx,cx,si mov si,dx cld xor ax,ax @@loop: lodsb test ax,ax jz @@ok cmp al,'$' jnz @@loop @@ok: dec si sub si,dx jz @@null mov cx,si mov bx,1 DosCall DOS_WRITE_TO_HANDLE cmp debug_file_handle,0 jz @@ex mov bx,debug_file_handle DosCall DOS_WRITE_TO_HANDLE @@null: @@ex: pop_ bx,cx,si pop ds ret .386 real_print endp print proc near cmp cs:logo_out,0 jnz @@ex mov cs:logo_out,1 push_ ax,dx lea dx,logo_tx call real_print pop_ ax,dx @@ex: call real_print ret print endp print_crlf proc near pushf push ax push dx lea dx,@@crlf call print pop dx pop ax popf ret @@crlf db 13,10,'$' print_crlf endp print_dot proc near pushf cmp cs:print_dots,1 jb @@ex push ax push dx lea dx,@@dot_tx je @@1 lea dx,@@start_tx dec cs:print_dots cmp cs:print_dots,1 jbe @@1 lea dx,@@start_tx_2 dec cs:print_dots @@1: call print pop dx pop ax @@ex: popf ret @@start_tx_2 db 13,10,'Now reading INITRD:' @@start_tx db 13,10,'LOADING' @@dot_tx db '.$' print_dot endp granularity = 01000h handle_kernel_size proc near ; this tries to find out the actual kernel size ; because kernels > 2.4.5 can have bigger bzImages then 1Meg and ; kernel_size16 simply will wrap around without notification push bx push eax ; first check if the kernel follows the old standard cmp setup_version,0202h jae @@bigger movzx eax,kernel_size16 shl eax,4 jmp short @@ex @@bigger: ; first get the filesize mov bx,fhandle call get_filesize ; now subtract bootsect and setup.S size sub eax,dword ptr new_setup_size ; minus setup.S sub eax,200h ; minus bootsector @@ex: mov kernel_size,eax pop eax pop bx ret handle_kernel_size endp read_handle proc near ; input: ; BX= handle ; ECX= count ; EDI= linear destination address ; output: ; CARRY =1 , then read-error ; EAX= number of bytes transferred (even on CARRY=1) ; push ds push esi push dx push ecx push cs pop ds ; target seg = IO_buffer lea dx,aligned_auxbuff ; target off = IO_buffer mov esi,ecx mov ecx,granularity jmp @@start @@next: DosCall DOS_READ_FROM_HANDLE call print_dot jc @@err call put_buffer cmp ax,cx jne @@eof sub esi,ecx add edi,granularity @@start: cmp esi,ecx ja @@next mov cx,si DosCall DOS_READ_FROM_HANDLE call print_dot jc @@err call put_buffer @@eof: movzx eax,ax sub esi,eax pop ecx mov eax,ecx sub eax,esi clc @@ex: pop dx pop esi pop ds ret @@err: pop ecx mov eax,ecx sub eax,esi stc jmp @@ex read_handle endp clear_to_default proc near push_ ax,di,es call close_debug_file push cs pop es xor ax,ax mov cx,parse_switches_end-parse_switches lea di,parse_switches cld rep stosb pop_ ax,di,es ret clear_to_default endp ;============================================================================= INCLUDE LOADLINI.ASM INCLUDE LOADLINJ.ASM INCLUDE LOADLINM.ASM ;============================================================================= ; ------------------------------------------------------------- clear_uninitialized_data proc near .8086 ; we need to have clean 8086 code, ; because we don't yet know on which machine we are push_ es,ax,cx,di xor ax,ax lea di,uninitialized_data_start mov cx,(uninitialized_data_stop-uninitialized_data_start)/2 cld rep stosw call preset_pagedir_from_template les ax,@@aux mov word ptr pageadjlist.auxbuf,ax mov word ptr pageadjlist.auxbuf+2,es pop_ es,ax,cx,di ret .386 @@aux dd ((High_Seg_*16) + (aligned_auxbuff-code_org0)) clear_uninitialized_data endp preset_pagedir_from_template proc near mov ax,word ptr pagedir_template mov word ptr pagedir,ax mov ax,word ptr pagedir_template+2 mov word ptr pagedir+2,ax ret preset_pagedir_from_template endp ;------------------------------------------------------------------------ ; Here we expect the realy end of any _preset_ data in the .EXE. ; Below we have _uninitialized_ data, that will not appear in the binary. ; We put the LOADLIN >= 1.6 Magic and suffix-structure here: align dword dd 0 ; relative offset within file to previous suffix ; (e.g the size of the appended part) dd 0 ; flags, indicating what kind of appended ; file we have db 0 ; suffix level, 0= no further suffix db 'Loadlin-',LOADLIN_VERSION ; exactly 11 bytes !!! ;------------------------------------------------------------------------ ; align dword ; NOTE: this is align from above ! ; if we realign it here, we may get the ; suffix above corrupted, because it then isn't ; the last part of the executable (.EXE) db space1k dup(?) setup_stack_top label byte db space1k dup(?) stack_top label byte uninitialized_data_start label byte db ? ; belongs to comline comline db 128 dup(?) ; copied from PSP_DTA db 2*1024-128 dup(?) ; extended commandline comline_end label byte image_name db 80 dup(?) aux_token db 80 dup(?) rdimage_name db 80 dup(?) ;command_line db space2k dup(?) ; kernel accepts maximum of 2Kb command_line db 360h dup(?) ; limited to 1Kb to get bigger heap ; -------------------------------v ; this is for 32-bit code pageadjlist pages_list ; -------------------------------^ pagelist dd 1024 dup (?) ; temporary buffer for page adjust list, ; to be pushed to high memory. ; -------------------------------v ; this buffer is for the "default bios interruptvectors" ; as is set from the BIOS, ; Its contents are delivered by the BIOSINTV.SYS device driver ; (must be AT TOP of config.sys). ; Or from the REALBIOS.INT file. ; We need this after returning from V86-mode ; because NOTHING is valid any more but the ROM-BIOS ; (and LOADLIN of cause) ; intv_buf dd 128 dup(?) ; intvector 0:0 dd 128 dup(?) bios_data db 256 dup(?) ; BIOS-data 40:0 dummy_dos_data db (256-4-16-2) dup(?) ; (DOS-data 50:0, not valid at boot tome real_bios_int15 dw ? ; result of int15 at time of realbios real_bios_magic dw ? ; must be 0a5a5h for post alpha-release reset_jmpop db ? ; TOP BIOS FFFF:0 reset_entry dd ? biosdate db 9 dup(?) machineid db ? db ? masterIMR db ? ; port 21 slaveIMR db ? ; port A1 bios_scratch db 1024 dup(?) ; scratch 9FC0:0 realbios_end label byte ; -------------------------------^ ; -------------------------------v align_ code_org0,4096 aligned_auxbuff dd 1024 dup(?) ; must be aligned to 4 K page0 dd 1024 dup(?) ; must be aligned to 4 K ; -------------------------------^ uninitialized_data_stop label byte ; ------------------------------------------------------------- modul_end: code ends end start loadlin-1.6f/src/PaxHeaders.14419/Makefile0000644000175000017500000000013212025461304016425 xustar000000000000000030 mtime=1347838660.990395908 30 atime=1347838662.026370649 30 ctime=1347838660.990395908 loadlin-1.6f/src/Makefile0000644000175000017500000000153412025461304015403 0ustar00samysamy00000000000000# Makefile for LOADLIN-1.6 (C) 1994..1995 Hans Lermen # # To compile with Borland TASM 3.1 # LISTING = , #CCFLAGS = -ml -v -1 -w-pia -f- -y -G -IC:\TC\INCLUDE -LC:\TC\LIB CCFLAGS = -ml -1 -w-pia -f- -G -IC:\TC\INCLUDE -LC:\TC\LIB AS = tasm #ASFLAGS = /m3 /zi /DMAKE_EXE_FILE /DDEBUG ASFLAGS = /m3 /zi /DMAKE_EXE_FILE #ASFLAGS = /m3 /DMAKE_EXE_FILE LD = tlink #LDFLAGS = /m/v # need this (/f) for TLINK >3, disables FAR-optimization !! #LDFLAGS = /f /m #LDFLAGS = /f /m/v LDFLAGS = /m #LDFLAGS = /v/s/l #ALPHA = loadlina.asm #ALPHAD = /DALPHA all: loadlin.exe loadlin.exe: loadlin.obj makefile $(LD) $(LDFLAGS) loadlin.obj, loadlin.exe,, loadlin.obj: $(ALPHA) loadlin.asm loadlini.asm loadlinj.asm loadlinm.asm pgadjust.asm makefile $(AS) $(ASFLAGS) $(ALPHAD) loadlin, $(LISTING); loadlin-1.6f/src/PaxHeaders.14419/srclinux0000644000175000017500000000013212025461304016557 xustar000000000000000030 mtime=1347838660.998395712 30 atime=1347838662.026370649 30 ctime=1347838660.998395712 loadlin-1.6f/src/srclinux/0000755000175000017500000000000012025461304015607 5ustar00samysamy00000000000000loadlin-1.6f/src/srclinux/PaxHeaders.14419/pgadjust.c0000644000175000017500000000013212025461304020621 xustar000000000000000030 mtime=1347838660.998395712 30 atime=1347838662.026370649 30 ctime=1347838660.998395712 loadlin-1.6f/src/srclinux/pgadjust.c0000644000175000017500000002366712025461304017612 0ustar00samysamy00000000000000/* * padjust.c * * partially stolen from linux/arch/i386/boot/compressed/misc.c * */ #ifdef STANDALONE_DEBUG #include #include #include #endif /* * These are set up by the setup-routine at boot-time: */ struct screen_info { unsigned char orig_x; unsigned char orig_y; unsigned char unused1[2]; unsigned short orig_video_page; unsigned char orig_video_mode; unsigned char orig_video_cols; unsigned short unused2; unsigned short orig_video_ega_bx; unsigned short unused3; unsigned char orig_video_lines; unsigned char orig_video_isVGA; }; /* * This is set up by the setup-routine at boot-time */ #define EXT_MEM_K (*(unsigned short *)0x90002) #define DRIVE_INFO (*(struct drive_info *)0x90080) #define SCREEN_INFO (*(struct screen_info *)0x90000) #define RAMDISK_SIZE (*(unsigned short *)0x901F8) #define ORIG_ROOT_DEV (*(unsigned short *)0x901FC) #define AUX_DEVICE_INFO (*(unsigned char *)0x901FF) /* --------------------------------------------------------------------- */ /* * This (also set up by the setup-routine) is our special extension * Here we have all params we got from 16-bit LOADLIN */ struct pblock { unsigned long taddr; /* linear address where the block of pages must be moved to */ unsigned short start; /* index within sources of first entry */ unsigned short tcount; /* number of entries for taddr in sources */ }; struct source_entry { unsigned long unused:12; unsigned long pagenum:20; unsigned long usedby; #define IS_UNUSED 0xffffffffUL #define IS_MOVED 0xfffffffeUL #define IS_PGLIST 0x80000000UL }; struct pages_list { unsigned long count; /* number of entries in 'sources' */ long number_of_blocks; /* number of valid blocks-items */ void *auxbuf; /* address of 4096 bytes auxiliary buffer */ struct pblock blocks[4]; struct source_entry *(sources[1]); /* list of addresses where the block of pages currently _is_ located */ }; static unsigned long setup_base = 0x95000; #ifndef STANDALONE_DEBUG #define PAGELIST (*(struct pages_list **)(setup_base + 8)) #else static struct pages_list *PAGELIST=0; #endif #define S(i) PAGELIST->sources[(i) / 512][(i) % 512] #define REAL_STARTUP_32 ( *((unsigned long *)(setup_base + 0xc)) ) /* --------------------------------------------------------------------- */ static void error(char *m); #ifndef STANDALONE_DEBUG /* ---- outb_p stolen from linux/include/asm/io.h ---- */ #define SLOW_DOWN_IO __asm__ __volatile__("outb %al,$0x80") #define __OUT1(s,x) \ static inline void __out##s(unsigned x value, unsigned short port) { #define __OUT2(s,s1,s2) \ __asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1" #define __OUT(s,s1,x) \ __OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); } \ __OUT1(s##c,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); } \ __OUT1(s##_p,x) __OUT2(s,s1,"w") : : "a" (value), "d" (port)); SLOW_DOWN_IO; } \ __OUT1(s##c_p,x) __OUT2(s,s1,"") : : "a" (value), "id" (port)); SLOW_DOWN_IO; } __OUT(b,"b",char) #define outb_p(val,port) \ ((__builtin_constant_p((port)) && (port) < 256) ? \ __outbc_p((val),(port)) : \ __outb_p((val),(port))) /* ---- end of outb_p ----- */ static int puts(const char *); static void * memcpy(void * __dest, void * __src, unsigned int __n); static char *vidmem = (char *)0xb8000; static int vidport; static int lines, cols; static void scroll() { int i; memcpy ( vidmem, vidmem + cols * 2, ( lines - 1 ) * cols * 2 ); for ( i = ( lines - 1 ) * cols * 2; i < lines * cols * 2; i += 2 ) vidmem[i] = ' '; } static int puts(const char *s) { int x,y,pos; char c; x = SCREEN_INFO.orig_x; y = SCREEN_INFO.orig_y; while ( ( c = *s++ ) != '\0' ) { if ( c == '\n' ) { x = 0; if ( ++y >= lines ) { scroll(); y--; } } else { vidmem [ ( x + cols * y ) * 2 ] = c; if ( ++x >= cols ) { x = 0; if ( ++y >= lines ) { scroll(); y--; } } } } SCREEN_INFO.orig_x = x; SCREEN_INFO.orig_y = y; pos = (x + cols * y) * 2; /* Update cursor position */ outb_p(14, vidport); outb_p(0xff & (pos >> 9), vidport+1); outb_p(15, vidport); outb_p(0xff & (pos >> 1), vidport+1); return 0; } static void * memcpy(void * __dest, void * __src, unsigned int __n) { int i; char *d = (char *)__dest, *s = (char *)__src; for (i=0;i<__n;i++) d[i] = s[i]; } #endif static void put_hex(unsigned long v) { static char table[17]="0123456789ABCDEF"; char b[9]; int i; for (i=7; i >=0; i--) { b[i] = table[v & 15]; v >>=4; } b[8]=0; puts(b); } static void error(char *x) { puts("\n\n"); puts(x); puts("\n\n -- System halted"); while(1); /* Halt */ } #ifdef STANDALONE_DEBUG static void memcpy_page(void *t,void *s) { printf("%p = %p\n",t,s); } #else static void memcpy_page(void *t,void *s) { memcpy(t,s,4096); } #endif static int index_within_sources(unsigned long pgnum) { int i; for (i=0; i< PAGELIST->number_of_blocks; i++) { unsigned long pstart=(PAGELIST->blocks[i].taddr >> 12); unsigned long pstop= pstart + PAGELIST->blocks[i].tcount; if ((pgnum >= pstart) && (pgnum < pstop)) { return (pgnum - pstart) + PAGELIST->blocks[i].start; } } return IS_UNUSED; } static void * address_of_target(int sindex) { int i, j=0; for (i=0; i < PAGELIST->number_of_blocks; i++) { j += PAGELIST->blocks[i].tcount; if (sindex < j) { return (void *)(((PAGELIST->blocks[i].taddr >> 12) + (sindex - PAGELIST->blocks[i].start)) << 12); } } return 0; /* invalid */ } static void build_references(void) { int i,j; for (i=0; i < PAGELIST->count; i++) { S(i).usedby = IS_UNUSED; } for (i=0; i < (PAGELIST->count+511) / 512; i++) { j = index_within_sources((unsigned long)PAGELIST->sources[i] >> 12); if (j != IS_UNUSED) S(j).usedby = IS_PGLIST | i; } for (i=0; i < PAGELIST->count; i++) { j= index_within_sources(S(i).pagenum); if ( j != IS_UNUSED ) { if (j == i) S(i).usedby = IS_MOVED; else S(j).usedby = i; } } } static int recursion_start_index=0; #ifdef VERBOSE static printmove(int sindex) { static int count=0; if (!(count++ & 3)) puts("\n"); put_hex((long)address_of_target(sindex)); puts(" <-- "); put_hex(S(sindex).pagenum << 12); puts(" "); } #endif static void make_free(int sindex) { if (S(sindex).usedby == IS_MOVED) return; if (S(sindex).usedby == IS_UNUSED) { } else if (S(sindex).usedby & IS_PGLIST) { int index = S(sindex).usedby & ~IS_PGLIST; void *addr = (void*) (S(recursion_start_index).pagenum << 12); int j; /* we can just exchange with recursion_start_index and fix */ memcpy_page(PAGELIST->auxbuf, addr); S(recursion_start_index).pagenum = (unsigned long)(PAGELIST->auxbuf) >> 12; memcpy_page(addr, address_of_target(sindex)); PAGELIST->sources[index] = addr; j = index_within_sources(((unsigned long) addr) >> 12); if (j != IS_UNUSED) S(j).usedby = IS_PGLIST | index; } else if (S(sindex).usedby == recursion_start_index) { /* we have to stop recursion and need the aux-buffer to save the page */ memcpy_page(PAGELIST->auxbuf, address_of_target(sindex)); S(recursion_start_index).pagenum = (unsigned long)(PAGELIST->auxbuf) >>12; } else { if (S(sindex).usedby != IS_UNUSED) make_free(S(sindex).usedby); /* recursion */ } memcpy_page(address_of_target(sindex), (void *)(S(sindex).pagenum << 12)); S(sindex).usedby = IS_MOVED; #ifdef VERBOSE printmove(sindex); #endif } static void adjust(void) { int i; if (PAGELIST == 0) return; build_references(); #ifdef STANDALONE_DEBUG for (i=0; i < PAGELIST->count; i++) { printf("%3d %p source=%x usedby=%d\n",i,address_of_target(i), S(i).pagenum << 12, S(i).usedby); } #endif for (i=0; i < PAGELIST->count; i++) { recursion_start_index=i; make_free(i); if (S(i).usedby != IS_MOVED) { memcpy_page(address_of_target(i), (void *)(S(i).pagenum << 12)); S(i).usedby = IS_MOVED; #ifdef VERBOSE printmove(i); #endif } } } #ifdef STANDALONE_DEBUG static int read_pagelist(char *fname) { FILE *f; long v; int i=0, bi=0, n; f=fopen(fname, "r"); if (!f) exit(1); PAGELIST = malloc(0x10000); while (fscanf(f, "%li", &v) == 1) { if (v >= 4096) { PAGELIST->blocks[bi].taddr=v; PAGELIST->blocks[bi].start=i; if (bi>0) PAGELIST->blocks[bi-1].tcount=i-PAGELIST->blocks[bi-1].start; bi++; PAGELIST->number_of_blocks=bi; } else { S[i++].pagenum = v; } } PAGELIST->count=i; PAGELIST->blocks[bi-1].tcount=i-PAGELIST->blocks[bi-1].start; PAGELIST->auxbuf=(void *)0x10000000; fclose(f); } int main(int argc, char** argv) { read_pagelist(argv[1]); if (PAGELIST) { printf("count %d nblocks %d\n", PAGELIST->count, PAGELIST->number_of_blocks); adjust(); } return 0; } #else unsigned long page_adjustment() { int i= S(0).pagenum; #if 0 if (SCREEN_INFO.orig_video_mode == 7) { vidmem = (char *) 0xb0000; vidport = 0x3b4; } else { vidmem = (char *) 0xb8000; vidport = 0x3d4; } lines = SCREEN_INFO.orig_video_lines; cols = SCREEN_INFO.orig_video_cols; #else /* setup does not use a fixed address for video modes any more */ lines=25; cols=80; vidmem = (char *) 0xb8000; vidport = 0x3d4; SCREEN_INFO.orig_x = 0; SCREEN_INFO.orig_y = 2; #endif /* The setup base may not be 0x95000 if that wasn't available */ unsigned long pc; asm("call 1f\n\t" "1: pop %0\n\t": "=r" (pc)); setup_base = pc & ~0xfff; #if 0 /* this won;t work any more, because 2.1.22 changed the format of EXT_MEM_K, see STANDARD_MEMORY_BIOS_CALL in setup.S */ if (EXT_MEM_K < (3*1024)) error("Less than 4MB of memory.\n"); #endif if (PAGELIST) { #ifdef VERBOSE puts("Adjusting high loaded pages..."); #endif adjust(); #ifdef VERBOSE puts("done.\nNow starting decompressor...\n"); #endif } #ifdef VERBOSE put_hex( REAL_STARTUP_32); #endif return REAL_STARTUP_32; } #endif loadlin-1.6f/src/srclinux/PaxHeaders.14419/loadlinh.S0000644000175000017500000000013212025461304020552 xustar000000000000000030 mtime=1347838660.998395712 30 atime=1347838662.026370649 30 ctime=1347838660.998395712 loadlin-1.6f/src/srclinux/loadlinh.S0000644000175000017500000000167012025461304017531 0ustar00samysamy00000000000000/* * loadlinh.S ( part of page adjustment ) * * stolen from linux/boot/head.S ( Copyright (C) 1991..1995 Linus Torvalds ) */ .text #define __ASSEMBLY__ #define OUR_STACK 0xa0000 /* this stack is top of 640Kb */ .globl startup_32 startup_32: cli cld movw %cs,%ax addb $8,%al #KERNEL_DS is always one slot behind KERNEL_CS # movl $(KERNEL_DS),%eax mov %ax,%ds mov %ax,%es mov %ax,%fs mov %ax,%gs mov %ax,%ss mov $(OUR_STACK),%esp xorl %eax,%eax 1: incl %eax # check that A20 really IS enabled movl %eax,0x000000 # loop forever if it isn't cmpl %eax,0x100000 je 1b /* * Initialize eflags. Some BIOS's leave bits like NT set. This would * confuse the debugger if this code is traced. * XXX - best to initialize before switching to protected mode. */ pushl $0 popfl /* * Do the page adjustment, and jump to the kernel decompressor.. */ call page_adjustment xorl %ebx,%ebx # ljmp $(KERNEL_CS), $0x1000 jmp *%eax loadlin-1.6f/src/srclinux/PaxHeaders.14419/Makefile0000644000175000017500000000013012025461304020272 xustar000000000000000029 mtime=1347838660.99439581 30 atime=1347838662.026370649 29 ctime=1347838660.99439581 loadlin-1.6f/src/srclinux/Makefile0000644000175000017500000000256212025461304017254 0ustar00samysamy00000000000000IMAGE_OFFSET = 0x95010 KDIR = /usr/src/linux HEAD = loadlinh.o SYS_SIZE = -DSYS_SIZE=0xFFFF OBJECTS = $(HEAD) pgadjust.o CFLAGS = -D__KERNEL__ -march=i386 -Os -DSTDC_HEADERS -fomit-frame-pointer \ -fno-strength-reduce -fPIC -ffreestanding -fno-stack-protector CC=gcc -m32 all: ../pgadjust.asm Makefile #all: testpg Makefile ../pgadjust.asm: pgadjust.out Makefile echo "; 32-bit code, linkaddress: $(IMAGE_OFFSET)" >pgadjust.as hexdump -v -e '" DD " 8/4 "0%Xh," 1/4 "0%Xh\n"' pgadjust.out >>pgadjust.as perl -pe 's/\n/\r\n/' ../pgadjust.asm rm -f pgadjust.as pgadjust.out: pgadjust Makefile objcopy -O binary pgadjust pgadjust.out # objdump -k -q -o $(IMAGE_OFFSET) pgadjust > pgadjust.out loadlinh.o: loadlinh.S $(CC) -traditional -c loadlinh.S pgadjust: $(OBJECTS) Makefile ld -m elf_i386 -Ttext $(IMAGE_OFFSET) -N -e startup_32 -o pgadjust $(OBJECTS) # this avoids page align ^^ (and holes between sections) pgadjust.o: pgadjust.c $(CC) $(CFLAGS) -c pgadjust.c -o pgadjust.o testpg: pgadjust.c $(CC) $(CFLAGS) -DSTANDALONE_DEBUG -o testpg pgadjust.c clean: rm -f $(OBJECTS) ../pgadjust.asm pgadjust.out pgadjust # for final distrib leave pgadjust.asm in the DOS part distclean: rm -f $(OBJECTS) pgadjust.out pgadjust *~ (cd ..; mv -f loadlin.exe ..; rm -f *~ *.obj *.lst) (cd ..; tar -czf srclinux.tgz srclinux) loadlin-1.6f/PaxHeaders.14419/initrd0000644000175000017500000000013212025461304015412 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.026370649 30 ctime=1347838660.986396005 loadlin-1.6f/initrd/0000755000175000017500000000000012025461304014442 5ustar00samysamy00000000000000loadlin-1.6f/initrd/PaxHeaders.14419/mkdisk0000644000175000017500000000013212025461304016674 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.026370649 30 ctime=1347838660.986396005 loadlin-1.6f/initrd/mkdisk0000755000175000017500000000055612025461304015660 0ustar00samysamy00000000000000#!/bin/sh if [ -z $1 ]; then exit 1 fi PROGRAM=$1 SIZE=`/bin/ls -l $PROGRAM |awk '{print $5}'` SIZE=`expr $SIZE / 1024 + 50` mke2fs /dev/ram $SIZE mount -t ext2 /dev/ram /mnt mkdir /mnt/dev mknod /mnt/dev/tty1 c 4 1 mkdir /mnt/proc chmod 555 /mnt/proc cp -p $PROGRAM /mnt/linuxrc umount /dev/ram dd if=/dev/ram bs=1k count=$SIZE of=initdisk freeramdisk /dev/ram loadlin-1.6f/initrd/PaxHeaders.14419/linuxrc.c0000644000175000017500000000013212025461304017317 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.026370649 30 ctime=1347838660.986396005 loadlin-1.6f/initrd/linuxrc.c0000644000175000017500000000151512025461304016274 0ustar00samysamy00000000000000#include #include #include #include #include #include #include void mount_proc(void) { /* mkdir("/proc",0744); */ mount(0,"/proc","proc",0,0); } main(int argc, char **argv, char **env) { char **a=argv, **e=env; char *real_root; FILE *f; fputs("\n\n\n\nHello, here ist /linuxrc printing\n",stdout); fputs("This is our argv[]:\n",stdout); while (*a) printf(">%s<\n",*a++); fputs("This is our env[]:\n",stdout); while (*e) printf(">%s<\n",*e++); real_root = getenv("real_root"); if (real_root) { printf("we are changing root to device %s\n",real_root); mount_proc(); if (! (f=fopen("/proc/sys/kernel/real-root-dev","w"))) return 0; fprintf(f, "%s\n",real_root); fclose(f); } fputs("\n\n",stdout); return 0; } loadlin-1.6f/initrd/PaxHeaders.14419/freeramdisk.c0000644000175000017500000000013212025461304020127 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.026370649 30 ctime=1347838660.986396005 loadlin-1.6f/initrd/freeramdisk.c0000644000175000017500000000130412025461304017100 0ustar00samysamy00000000000000#include #include #include #include #include #include #include #include #include #include main(int argc, char **argv) { char rname[256]="/dev/ram"; char b[256]; int f; if (argv[1]) strcpy(rname,argv[1]); #if 0 /* don't use on a living system, /etc/mtab is not updated */ if (umount(rname) && (errno != ENOENT)) { sprintf(b,"freeramdisk: cannot umount %s %d",rname,errno); perror(b); exit(1); } #endif if ((f=open(rname,O_RDWR)) == -1) { sprintf(b,"freeramdisk: cannot open %s",rname); perror(b); exit(1); } ioctl(f,BLKFLSBUF); close(f); } loadlin-1.6f/initrd/PaxHeaders.14419/Makefile0000644000175000017500000000013212025461304017127 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.026370649 30 ctime=1347838660.986396005 loadlin-1.6f/initrd/Makefile0000644000175000017500000000052612025461304016105 0ustar00samysamy00000000000000CC = gcc CFLAGS = -O2 -fomit-frame-pointer all: initdisk freeramdisk Makefile linuxrc: linuxrc.c $(CC) $(CFLAGS) -static -o linuxrc linuxrc.c initdisk: linuxrc Makefile freeramdisk mkdisk ./mkdisk linuxrc freeramdisk: freeramdisk.c $(CC) $(CFLAGS) -o freeramdisk freeramdisk.c clean: rm -f hello initdisk freeramdisk *~ *.o linuxrc loadlin-1.6f/PaxHeaders.14419/doc0000644000175000017500000000013212025461304014666 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.026370649 30 ctime=1347838660.986396005 loadlin-1.6f/doc/0000755000175000017500000000000012025461304013716 5ustar00samysamy00000000000000loadlin-1.6f/doc/PaxHeaders.14419/quicksta.rt0000644000175000017500000000013212025461304017136 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.026370649 30 ctime=1347838660.986396005 loadlin-1.6f/doc/quicksta.rt0000644000175000017500000000342012025461304016110 0ustar00samysamy00000000000000Quickstart for LOADLIN-1.6 ========================== Version 1.6 of LOADLIN (as opposite to prior versions) normally needs no special configuration and has been reported very stable by all ALPHA testers, so I guess you will only need LOADLIN.EXE, Copy this file to a DOS partition (e.g C:\LOADLIN). To boot Linux you need also a compressed kernel image file such as the "/vmlinuz" or the "/usr/src/zImage". In Slackware distribution you can find a lot of kernels (bare, scsi, modern, ...) in the directory ..../slackware/kernels of the site you got it from. Copy the image file to your DOS partion (e.g. C:\). To boot type at dos prompt: 1. For a Linux partition (ext2, minix, ...) to mount as root loadlin c:\vmlinuz root=/dev/hdb2 ro == 2. For an UMSDOS filesystem to mount as root loadlin c:\vmlinuz root=/dev/hda1 rw == 3. To boot for installation from a ramdisk image as a file (may be directly from CD) haveing a kernel >= 1.3.73 loadlin c:zimage root=/dev/ram rw initrd=c:rootdsk.gz 4. To boot from a SlackWare installation root floppy in drive A: having the kernel ( < 1.3.48 ) image file on the hard disk. loadlin c:bare root=/dev/fd0 rw ramdisk=1440 The same, but with a kernel >= 1.3.48 loadlin c:bare root=/dev/fd0 rw load_ramdisk=1 Dito, but haveing a prompt before insertion of the floppy loadlin c:bare root=/dev/fd0 rw load_ramdisk=1 prompt_ramdisk=1 NOTE: You must know what root partition to use, the above /dev/xxx are only examples !!! If you didn't succeed, please read the file MANUAL.TXT. Hans Lermen loadlin-1.6f/doc/PaxHeaders.14419/params.doc0000644000175000017500000000013212025461304016715 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.026370649 30 ctime=1347838660.986396005 loadlin-1.6f/doc/params.doc0000644000175000017500000003043512025461304015675 0ustar00samysamy00000000000000------------------------------------------------------------------------ LOADLIN 1.6 ((C) 1994..1995 lermen@elserv.ffm.fgan.de (C) 2008..2010 samuel.thibault@ens-lyon.org) and Linux version: 0.99.14, 0.99.15, 1.0, 1.1.47, 1.3.97 ------------------------------------------------------------------------ NOTE: The below list of Linux commandline parameters is quite out of date, though most of it will be still valid at this time (1.3.97). I only edited a few new things into it. A much better list of boot parameters can be found in Paul Gortmakers BootPrompt-HOWTO, which can be accessed via WWW: http://sunsite.unc.edu/mdw/HOWTO/BootPrompt-HOWTO.html or http://rsphy1.anu.edu/~gpg109/BootPrompt-HOWTO.html ------------------------------------------------------------------------ This is a list of command line parameters recognized and interpreted by: ======================================================================== 1. LOADLIN initrd=file file name of the initial ramdisk to be loaded by LAODLIN. See initrd.txt for more information vga=mode 2. The Linux kernel mem=number (for > 0.99.15, number = end of physical memory in bytes) root=device ro rw no387 debug sets console_loglevel = 10 no-hlt disables check of HLT isntruction at startup load_ramdisk=N N=0 or 1 prompt_ramdisk=N N=0 or 1 3. init single auto 4. Some drivers reserve=port1,num1,...,port5,num5 #reserves 80x86 ioports ether=irq,base_addr,mem_start,mem_end,dev_name hd=cyl,head,sect # for 2 drives you need this twice # first relates to drive 0 bmouse=irq max_scsi_luns=n # (n should be between 1 and 8) st0x=base_address,irq # SEAGATE controller ST01/ST02 tmc8xx=base_address,irq # Future Domain TMC-885,TMC-950 t128=address,irq # Trantor T128/T128F/T228 ncr5380=port,irq,dma # Generic NCR5380 driver aha152x=portbase,irq,scsiid,reconnect # Adaptec AHA-152x driver xd=type,irq,iobase,dma mcd=port,irq sound=0x0TTPPPID, .. sbpcd=sbport,SoundBlaster sbpcd=LMport,LaserMate sbpcd=SpeaFXport,SPEA 5. Environment All parameters of format name=xxxx which are not recogized by the kernel or a driver are put onto the environment. LOADLIN itself always puts BOOT_IMAGE=imagefile onto the environ- ment. The user may put additional values onto the environment in order to allow /etc/rc to behave differently for a given condition. ============================================================================== Following are detailed descriptions: Parameters recognized by LOADLIN: ================================= ramdisk=size ------------ size number of Kbytes for the RAMDISK device. The image for the ramdisk is loaded by the kernel at startup from a floppy drive, if root=/dev/fdx is also given. After loading the image, the kernel then makes the ramdisk the root device (NOT the floppy). In addition to this, LOADLIN prompts for inserting the ramdisk image into the floppy drive if it no longer needs the drive (i.e. after loading the kernel). vga=mode -------- mode -3 the user is asked to specify the VGA mode ask equal to -3 -2 80x50 extended VGA mode extended equal to -2 -1 80x25 normal mode normal equal to -1 0 as if "0" was entered at the boot prompt . . n as if the number "n" was entered at the boot prompt ro -- "ro" forces the root device to be mounted read-only (Not for UMSDOS!) rw -- "rw" forces the root device to be mounted read/write. initrd=file ----------- file name of the initial ramdisk to be loaded by LAODLIN. See initrd.txt for more information ------------------------------------------------------------------------------ Parameters recognized only by the kernel: ========================================= root=device ----------- device may be a symbolic device name such as "/dev/hda2" or the numeric device number (hex) (highbyte=major, lowbyte=minor) recognized symbolic devices (with their partitions) are: "hda", "hdb", "hdc", "hdd", "sda", "sdb", "sdc", "sdd", "sde", "fd", "xda", "xdb" Examples: root=302 root=/dev/hda2 root=/dev/sda10 mem=number ---------- number End of physical RAM, this is recognized by kernels of 0.99.15 and higher and is useful if the exact installed RAM size cannot be determined automatically. may be 0x1000000, 16M, 4096K or some thing like that. mem=nopentium disables 4M page tables. no387 ----- "no387" disables use of the hardware math coprocessor. since 1.1.47 (or perhaps earlier) the following options are no more passed to init: ro,rw,no387 ----------- debug sets console_loglevel high enough to dispay all ----- no-hlt ------ disables check of HLT instruction at startup. If you have a clone 486, this option is *very* usefull. ------------------------------------------------------------------------------ Option Parameters recognized by "init": ======================================= single ------ Enter "single user mode" on boot auto ---- ro,rw,no387 (forwarded from kernels < 1.1.47). (see !!comment!! above) ----------- ------------------------------------------------------------------------------ Configuration of ethernet cards: ================================ ether=irq,base_addr,mem_start,mem_end,dev_name --------------------------------------------- irq number, IRQ-number (3..15) base_addr number, IO-base (0x280,...) mem_start number, shared mem start mem_end number, shared mem end dev_name string, eth0..3 all configured ethernetcards dl0 D-Link DE600 pocket adaptor atp0 AT-LAN-TEC (RealTek) pocket adaptor plip0..2 parallel IP (PLIP) sl0..3 serial IP (SLIP) example: ether=10,0x280,0xc8000,0xcbfff,eth0 related files: net/inet/eth.c, drivers/net/Space.c ------------------------------------------------------------------------------ Reserving I/O port space: ========================= reserve=port1,num1,...,port5,num5 --------------------------------- portn first IOport-address in range numn number of addresses in this range to reserve (there will be bits set to "1" in "ioport_register") related files: kernel/ioport.c ------------------------------------------------------------------------------ Setting hard disk parameters for the root device: ================================================= hd=cyl,head,sect --------------- # NOTE: if you have two drives, you must put # two hd= params into the commandline # the first for drive 1, the second for drive 2 # eg. # loadlin zimage hd=1001,15,17 hd=989,15,56 root=/dev/hdb2 ro # (this example from my machine however is not needed, # you need it only, if Linux can't get the drive params properly # from the BIOS). related files: drivers/block/hd.c config: CONFIG_BLK_DEV_HD ------------------------------------------------------------------------------ Setting IDE CDrom support (ATAPI) ================================= hdX=cdrom --------- Where X may be a,b,c,d. Example: hdc=cdrom ------------------------------------------------------------------------------ Setting the IRQ for the bus-mouse: ================================== bmouse=irq ---------- related files: drivers/char/busmouse.c config: CONFIG_BUSMOUSE ------------------------------------------------------------------------------ Parameters for SCSI controllers: ================================ max_scsi_luns=n (n should be between 1 and 8) st0x=base_address,irq SEAGATE controller ST01/ST02 tmc8xx=base_address,irq Future Domain TMC-885,TMC-950 t128=address,irq Trantor T128/T128F/T228 ncr5380=port,irq,dma Generic NCR5380 driver aha152x=portbase,irq,scsiid,reconnect Adaptec AHA-152x driver related files: drivers/scsi/seagate.c, t128.c, g_NCR5380.c, aha152x.c config: CONFIG_SCSI_SEAGATE, CONFIG_SCSI_T128, CONFIG_SCSI_GENERIC_NCR5380, CONFIG_SCSI_AHA152X ------------------------------------------------------------------------------ Parameters for SCSI Tapes: ========================= st=buffer_size,write_threshould,max_buffers buffer_size Size of tape buffer in Kbyte (i.e. ST_BLOCK_SIZE) write_threshould Number of Kbytes to buffer before write. (must be < buffer_size) max_buffers Number of buffers to reserve related files: drivers/scsi/st.c config: CONFIG_CHR_DEV_ST ------------------------------------------------------------------------------ Parameter for XT hard disk controller (DTC 5150X): ================================================== xd=type,irq,iobase,dma ---------------------- related files: drivers/block/xd.c config: CONFIG_BLK_DEV_XD ------------------------------------------------------------------------------ Parameter for Mitsumi CDROM driver: =================================== mcd=port,irq ------------ related files: drivers/block/mcd.c config: CONFIG_MCD ------------------------------------------------------------------------------ Parameter for sound cards: ========================== sound=0x0TTPPPID, .. ---------------- all values are enbedded in one longint, the above format shows a hex number, each place is a hex-digit TT Supported card type. This is the index into the list of configured cards If all cards are configured (which normally is not the case) the following order is kept: Roland MPU-401 Gravis Ultrasound ProAudio Spectrum SoundBlaster SoundBlaster 16 SB16 MPU-401 (SB16-MIDI port) AdLib PPP Port Address I IRQ D DMA Channel related files: drivers/sound/dev_table.h,dev_table.c config: CONFIG_SOUND ------------------------------------------------------------------------------ Parameter for IDE-style CD-ROM device driver (Kotobuki/Matsushita/Panasonic): ============================================================================= sbpcd=sbport,SoundBlaster ------------------------ sbpcd=LMport,LaserMate ---------------------- sbpcd=SpeaFXport,SPEA ---------------------- sbport soundblaster base port +0x10 (i.e 0x230 = 0x220+0x10) LMport MPU-type port at 0x300 or equivalent SpeaFXport base port on SpeaFX card related files: drivers/block/sbpcd.c config: CONFIG_SBPCD ------------------------------------------------------------------------------ loadlin-1.6f/doc/PaxHeaders.14419/manual.txt0000644000175000017500000000013212025461304016761 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.026370649 30 ctime=1347838660.986396005 loadlin-1.6f/doc/manual.txt0000644000175000017500000007762712025461304015757 0ustar00samysamy00000000000000 LOADLIN User Guide 96-04-28 ============================================================================ LOADLIN v1.6 (C) 1996 Hans Lermen (lermen@elserv.ffm.fgan.de) (C) 2008..2010 Samuel Thibault (samuel.thibault@ens-lyon.org) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You may have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ============================================================================ CONTENTS ======== 1. Why use LOADLIN ? 2. Features of LOADLIN 3. How to use LOADLIN 3.1. What you need 3.2. Booting from the DOS prompt 3.2.1 Quick start 3.2.2 Quick help 3.2.3 Starting linux from a batch file (LINUX.BAT) 3.2.4 Loading Ramdisks with newer kernels 3.2.5 Floppys and Ramdisks using older kernels ( Linux < 1.3.48 ) 3.2.6 System constraints 3.3 Booting from CONFIG.SYS 3.3.1 Example of a CONFIG.SYS file (DOS) 3.3.2 Example of a CONFIG.SYS file (Windows 95) 3.3.3 Constraints in CONFIG.SYS syntax 4. The LOADLIN command line parameters 4.1 Maximum length of the command line 5. If you have problems 5.1 Problems detecting V86 5.2. Description of debug output (-v,-t,-d) 6. Where to send comments and bug reports 7. Contributions and Credits --------- +++ -------- 1. Why use LOADLIN ? ================= LOADLIN is the safest way to boot Linux from your hard disk, if you have a bootable DOS-partition besides Linux on your machine. Most Linux-newbees are too impatient to read the very good (but also long) documentation of LILO (the standard Linux loader), and start using it incorrectly, resulting in an unbootable DOS after this (the MBR gets overwritten, 'fdisk /MBR' not always repairs). For those impatient ones LOADLIN is the best loader to start with. LOADLIN needs not to be installed in any way, it is usable as is and the kernel images can reside on any DOS accessable medium (even on a network drive). This also makes LOADLIN an exellent tool, if it comes to boot your Linux after a crash and a filesystem restore from backup medium (you must run LILO after this, but you can't if you have not yet booted, isn't it?). Many CDrom producers already have seen the advantage of starting the Linux-installation process by means of LOADLIN, because it runs out of the box. And using DOS to push Linux on the road isn't wrong, if you have DOS (or Windows 95 DOS mode) available. With LOADLIN you can directly boot Linux from the CD without needing an intermediate bootfloppy. --------- +++ -------- 2. Features of LOADLIN =================== LOADLIN is highly adaptable to different DOS configurations, and now has very few loading restrictions. It makes use of extended memory and also can load big kernels (bzImages) and ramdisk images (initrd) directly high. The bzImage+initrd standard was jointly developed by the LILO-author (Werner Almesberger) and the LOADLIN-author (me) and is part of the official kernel since version 1.3.73. It is also capable of booting a UMSDOS-based system from a DOS drive. Some options (-v, -t, -d) produce debug information, so if you have problems, you can follow what is really being done by LOADLIN. LOADLIN also can load out of Virtual-86 mode (which is normal when using EMS drivers) if a VCPI server is present. --------- +++ -------- 3. How to use LOADLIN ================== NOTE: LOADLIN is a utility which starts a "logical reload" of your machine, causing DOS to be completely overlaid with Linux. When you wish to return to DOS you must use the Linux "reboot" command. 3.1. What you need ------------- 1. A 386 or higher CPU (of course!), DOS or WINDOWS95 installed on your machine. 2. Any compressed linux kernel image (zImage, bzImage). NOTE: zImage is the old kernel binary format, bzImage is the new one ( kernel version >= 1.3.73), which can have a commpressed size of 1Meg, hence taking kernels up to 2Meg uncompressed. In the following we will refer only to zImage, though you may put a bzImage in place of it. 3. The LODLIN16.TGZ package, which includes among other things: ( Note: these are DOSish files ) LOADLIN.EXE DOC\MANUAL.TXT (this file) Example parameters file, DOC\TEST.PAR DOC\PARAMS.DOC 3.2. Booting from the DOS prompt --------------------------- 3.2.1 Quick start ----------- For the rest of this documentation I will assume that you have unpacked LODLIN16.TGZ into the directory C:\LOADLIN. At the DOS prompt you can type, for example: C:> CD \LOADLIN C:\LOADLIN> LOADLIN zimage /dev/hdb1 ro vga=ask or, if you want to load a big kernel together with a RAM disk: C:\LOADLIN> LOADLIN bzimage /dev/ram rw initrd=diskimage or, if you have more parameters than will fit into the 128-byte DOS command line: C:\LOADLIN> LOADLIN @params An example params file is "test.par". Please read it. A detailed collection (extracted from kernel sources) of most command line parameters can be found in the file PARAMS.DOC ( however, it is a bit out of date now ) A much better list of boot parameters can be found in Paul Gortmakers BootPrompt-HOWTO, which can be access by WWW: http://sunsite.unc.edu/mdw/HOWTO/BootPrompt-HOWTO.html or http://rsphy1.anu.edu/~gpg109/BootPrompt-HOWTO.html 3.2.2 Quick help ---------- You can get online help and configuration analysis by typing: C:\LOADLIN> loadlin or, perhaps a bit more helpful: C:\LOADLIN> loadlin | more You then get an output like this (from my machine) .... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - LOADLIN v1.6 (C) 1994..1996 Hans Lermen USAGE: LOADLIN @params LOADLIN [zimage_file] [options] [boot_params] without any params, LOADLIN displays this help message. @params: params is a DOS file containing all other options zimage_file: DOS file name of compressed Linux kernel image options: -v verbose, show information on params and configuration -t test mode, do all but starting Linux, also sets -v -d file debug mode, same as -t, but duplicates output to "file" -clone ( Please read MANUAL.TXT before using this switch! ) -n no translation for root=/dev/... -txmode switch to textmode 80x25 on startup -noheap disable use of setup heap -wait=nn after loading wait nn (DOS)ticks before booting Linux -dskreset after loading reset all disks before booting Linux boot_params: root=xxx filesystem to be mounted by Linux as "/" (string passed unchanged to the kernel) xxx = hex number (e.g. root=201 for /dev/fd1) = /dev/mmmn (e.g. root=/dev/hda2) mmm = fd,hda,hdb,sda,sdb... n = 1..10.. decimal ro mount "/" readonly rw mount "/" read/write initrd=x (for kernels > 1.3.72) load file x into /dev/ram. If FS in x contains /linuxrc, execute it, and then remount to root=xxx. If root=/dev/ram, just load, bypass execution of /linuxrc for more boot params see PARAMS.TXT or Paul Gortmakers HOWTO: http://sunsite.unc.edu/mdw/HOWTO/BootPrompt-HOWTO.html http://rsphy1.anu.edu/~gpg109/BootPrompt-HOWTO.html Your current DOS/CPU configuration is: load buffer size: 0x0082D000 VCPI, setup buffer size: 0x3E00 (reloc setup) lowmem buffer: 0x0006DC00 (part of load buffer) total memory: 0x01000000 CPU is in V86 mode SetupIntercept: YES, patching setup code stat4: VCPI_present, physmap=logmap, all OK for switch to realmode input params (size 0x0000): LOADLIN started from DOS-prompt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - NOTE: All LOADLIN options (such as -t,... ) MUST come before the Linux command_line params 3.2.3 Starting linux from a batch file (LINUX.BAT) -------------------------------------------- Most DOS users have disk caching (e.g. SMARTDRV) activated. If "write-behind" caching is supported by the cache program, then any unwritten cache buffers MUST be flushed before LOADLIN is called. Example: C\LOADLIN> smartdrv /C do this to "sync" your disk (usually not needed for DOS 6.2, but it doesn't hurt) C\LOADLIN> loadlin .... It would be much smarter to use a batch file something like this: +-------------------- start of LINUX.BAT | | SMARTDRV /C | C:\LOADLIN\LOADLIN C:\LOADLIN\ZIMAGE root=/dev/hdb2 ro vga=3 | +-------------------- end of LINUX.BAT So you could simply type: C> linux ... and you are on the road! A sample LINUX.BAT file is provided with the LOADLIN package. 3.2.4 Loading Ramdisks with newer kernels ----------------------------------- If you have a kernel image which is newer than version 1.3.72, LOADLIN can load the ramdisk directly from a file and let Linux mount the ramdisk (/dev/ram) as root filesystem. The file must contain the image of any Linux supported file system, such as minix or ext2. The technique used is called 'initrd' and is more flexible than the old loading from floppy. There can be the following cases: A) You simple want to load the ramdisk and have that mounted as root FS. C\LOADLIN> loadlin zimage root=/dev/ram rw initrd=imagefile You will see two LOADING.... sequences, one for the kernel and the other for the ramdisk. B) You want to have the ramdisk loaded and mounted only to bootstrap a bigger system. Your kernel has only support for few driver, but not all. Well, then the contents of your ramdisk image must contain an executable '/linuxrc' which is able to load kernel modules (via insmod). After /linuxrc has terminated, the root FS is remounted either to the device you supplied via root=/dev/..., or to the device that /linuxrc has chosen. This technique is described in detail in the file linux/Documentation/initrd.txt which is part of the kernel source. The LOADLIN call for loading such a configuration is: C\LOADLIN> loadlin zimage root=/dev/hda1 ro initrd=imagefile The non-initrd method, i.e. _not_ LOADLIN loads the ramdisk but the kernel does it from a floppy, has changed with Linux 1.3.48. It now look like this: C\LOADLIN> loadlin zimage root=/dev/fd0 rw load_ramdisk=1 or, if you want have a prompt before inserting the floppy: C\LOADLIN> loadlin zimage root=/dev/fd0 rw load_ramdisk=1 prompt_ramdisk=1 The size of the ramdisk is allocated dynamically. NOTE: In all cases the ramdisk image may be compressed (gziped) 3.2.5 Floppys and Ramdisks using older kernels ( Linux < 1.3.48 ) ----------------------------------------------------------- If LOADLIN encounters ramdisk=xxxx together with root=/dev/fdx it loads the kernel image into memory, but before starting up Linux it prompts for insertion of the root floppy. This enables you to boot DOS (and start LOADLIN) from the same floppy drive as the root disk. Of course, this is a two-floppy boot, but with Linux becoming bigger and bigger there will be no room on the root floppy to hold both the kernel image and the root filesystem. With LOADLIN there is no need for any fancy tricks to install a distribution when your drive configuration doesn't match that of the distribution. Examples: LST distribution comes only with a 3.5 inch floppy but your drive A: is 5.25 inch. Slackware 3.0 has a big directory tree with lots of possible drive constellations. With LOADLIN you need only the image disk and an appropriate root disk. 3.2.6 System constraints ------------------ With LOADLIN-1.6 there are _very_ few contraints left, given you use a newer kernel, because the kernel now supports LOADLIN and aids to overcome the restrictions of old LOADLIN-1.5. The * (asterix) marked parts below only apply, if your kernel is an old one (not supporting LOADLIN). * There must be enough memory to load the compressed kernel image (between the start of LOADLIN and 090000h). - If loading newer kernels, you must have enough konventional plus extended/XMS/VCPI memory to temporary hold the image (and eventually the ramdisk image) - The field "load buffer size" of the LOADLIN verbose output tells you what you really have. * The setup program and LOADLIN itself go into 090000h ... 09B000h, therefor you MUST have 640 K byte of base memory. - Starting with Linux 1.1.43 the setup program does no longer fit into 2 K, so it is made of variable size and will grow over the time. Currently (1.3.91) setup is 9 * 512 bytes long and the setup buffer of LOADLIN has 31 * 512 bytes, so this will work for a long time. - The field "setup buffer size" of the LOADLIN verbose output tells you what you really have. * The remaining 12 Kbyte memory on top of the 640 K is hopefully enough for BIOS- and highloaded driver-data. - DOS programs can be executed only in the so-called real mode (or on >386 in virtual-86 mode (V86)). Linux, however, runs in protected mode, and the kernel must be able to enter privilege level 0 (P0, supervisor mode). However, from V86 it is impossible to switch to protected mode P0 if the V86 server does not allow this (as is the case with DPMI). Therefore: - You must be in 86 real mode (no EMS driver, no WINDOWS, no Windows 95 Graphics mode ...). or - You must have the VCPI server enabled in your EMS driver (still not running WINDOWS or Windows 95, however). Using EMM386 please avoid the NOVCPI-option, but NOEMS doesn't hurt. VCPI allows P0 and is supported by most EMS drivers, but never under MS-WINDOWS or Windows 95 (MICROSOFT doesn't like P0 for users). - Physical-to-Virtual memory mapping must be identical for the first 640K of RAM, which is a given under normal conditions but which also can be forced, typically by an EMS driver option like: EXCLUDE=1000-A000 (for 386MAX) or B=A000 (for EMM386.EXE, but normally not needed). Check the manual for your EMS driver for details. Don't worry, if something is missing LOADLIN will tell you. NOTE: May be that your VCPI server does garbage collection before entering protected mode, so please BE PATIENT, especially on systems with many mega bytes ! - Of course you must not execute LOADLIN out of Linux DOSEMU ! If you do it, fortunately DOSEMU terminates because DOSEMU has no VCPI server, so your file systems remain intact. 3.3 Booting from CONFIG.SYS ----------------------- Starting with DOS version 6.0 it is possible to boot different configurations during the startup of MSDOS. This is handled at the time of CONFIG.SYS interpretation. Therefore this is often a good place to put the LOADLIN/Linux stuff. Even if you have decided to boot DOS, you can boot Linux later, either from the DOS command line or from a batch file. 3.3.1 Example of a CONFIG.SYS file (DOS) --------------------------------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SWITCHES=/F [MENU] menuitem=DOS, DOS boot menuitem=LINUX_1, LINUX boot menuitem=LINUX_2, LINUX boot via param file menuitem=LINUX_3, LINUX boot via param file, but overwrite root device menuitem=LINUX_4, Create a dump file for bug report [DOS] device=c:\dos\himem.sys device=c:\dos\emm386.exe 2048 ram DOS=HIGH,UMB SHELL=C:\COMMAND.COM C:\ /e:1024 /p ... etc., etc., etc. [LINUX_1] shell=c:\loadlin\loadlin.exe c:\loadlin\zimage root=/dev/hdb2 ro [LINUX_2] shell=c:\loadlin\loadlin.exe @c:\loadlin\linux.par [LINUX_3] shell=c:\loadlin\loadlin.exe @c:\loadlin\linux.par root=/dev/hdb2 [LINUX_4] shell=c:\loadlin\loadlin.exe c:\loadlin\zimage -d c:\dump.txt root=/dev/hda1 rem ^^^^^^^^^^^^^^ rem This writes debug information to a file ---------^ rem All is set up as usual, but Linux is not loaded and LOADLIN idles. rem CAUTION: Don't do this if you haven't a [MENU] in CONFIG.SYS, rem because you then need a DOS System floppy to boot normally. [COMMON] rem Here we put any other "common" configuration stuff .... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3.3.2 Example of a CONFIG.SYS file (Windows 95) ----------------------------------------- Having Windows 95 and Linux together on your machine, requires that you switch off some option in the hidden C:\MSDOS.SYS file. (which is a text file in Windows 95). NOTE: DO NOT TRY TO START LOADLIN FROM WITHIN THE GUI ! Change attribs of C:\MSDOS.SYS, so that it becomes visible and edit it: C:\MSDOS.SYS -------------------------------------- BootGUI=0 Logo=0 ... --------------------------------------------------- This will avoid booting directly into the GUI and will you get a normal DOS prompt when chosing menuitem W95. ( To enter the GUI you only have to type: C:>win ) Logo=0 switches the (graphics) logo off. There have been reports, that together with some graphic cards, Linux may come up with a 'blind' screen, if the Logo is displayed prior to booting. C:\CONFIG.SYS ------------------------------------- [menu] menuitem=W95, Boot W95 DOS menuitem=LINUX, Boot Linux menudefault=W95,10 [W95] rem all what you need for DOS ... [LINUX] shell=c:\loadlin\loadlin.exe @C:\loadlin\linuxpar.1 [COMMON] rem THERE SHOULD BE NOTHING for COMMON rem move all you have to W95 part --------------------------------------------------- 3.3.3 Constraints in CONFIG.SYS syntax -------------------------------- 1. All parameters on the "shell=" lines are converted to uppercase by DOS, but Linux parameters are case sensitive. LOADLIN converts the following parameters back to lowercase: root=... ro rw mem=... no387 single auto debug no-hlt reserve=... hd=... xd=... bmouse=... max_scsi_luns= Also, when using 'shell=loadlin.exe @params more_params' out of CONFIG.SYS, all of 'more_params' will be converted to lowercase. The following parameters are not put onto the commandline, but converted to numeric values for the boot sector: vga=... ramdisk= 2. You can bypass the uppercase/lowercase problem by using a parameter file. An example CONFIG.SYS line would be: [LINUX] shell=c:\loadlin\loadlin.exe @c:\loadlin\params You may ovewrite params which are _in_ the file by those coming behind the @..., such as [LINUX] shell=c:\loadlin\loadlin.exe @c:\loadlin\params root=/dev/other An example parameter file is "test.par". Please read it. --------- +++ -------- 4. The LOADLIN command line parameters =================================== Note that if you use a parameters file (for example @TEST.PAR), this must be the FIRST parameter you use on the LOADLIN command line. Other parameters, including the name of the zImage file, are contained within the parameters file. All parameter behind the @.. will be inserted after the parameters file has been read, and equal keywords are replaced. The first name within the parameters file _must_ be the kernel image file, if you want to overwrite it, you have to use the keyword 'image=' such as: C:> loadlin @test.par image=otherfile When Linux boots it gets a runstring passed from setup (the program that checks the basic hardware configuration and puts the machine into protected mode ). This string, the command line, is then checked for some well known compiled-in keywords. Some are used to change kernel variables (such as mem=, root=, ro, rw, no387), some are passed to the device drivers (such as ether=, hd=, sound=) and some (such as single and auto) are passed as options to /etc/init (or /bin/init or /sbin/init, whatever is found first). See the file "PARAMS.DOC" for details. Any unknown keywords of format "keyword=value" are placed in "envp_init", which is also passed to /linuxrc (if you have initrd=) and to /etc/init. This environment string can be checked in /etc/rc* (/etc/rc.d/rc.*). The whole commandline also is available via /proc/cmdline. 4.1 Maximum length of the command line ---------------------------------- The length of a DOS command line can be 127 bytes (including the program name). With a params file (@param) the length of the string passed to the kernel can in theory be 2047 bytes, but the string is held in a temporary place and must be copied by the kernel to a save static buffer in init/main. This forces the maximum length to a compiled-in constant, which currently is 256 bytes. If you need a greater size, you can simply change COMMAND_LINE_SIZE in arch/i386/kernel/setup.c. --------- +++ -------- 5. If you have problems ==================== With the thousands of possible hardware/software configurations of a PC, a program can never be totally bug-free. So please, I need your feedback regarding problems you encounter. If you recognize a bug, please don't work around it, mail it to me ! But, if you report a problem, I need information! Something like "My screen always displays in blue, what is wrong?" is not enough. LOADLIN can produce information for me (and for you) if you use the -d or -t switch. 5.1 Problems detecting V86 ---------------------- On some 486 clones we have problems with CR0 while probing for V86 mode. (as reported by Jacek Zapala zapala@if.pw.edu.pl ). It can happen that the CPU is in realmode, but PAGING is enabled ! This is possible, but neither documented nor supported by INTEL. May be the motherboard's BIOS is mapping shadow ram this way, or one of those old and strange EMM managers is used, but probably this is an indication of a not exactly compatible 486 clone. The -clone switch byepasses the CR0 check and assumes V86 if an EMM manger is found. But of course this EMM manager must not use real paging ! On the other hand, if LOADLIN detects V86 _and_ you are sure that the machine is in _real_ realmode, then you may use the -f switch in order to force LOADLIN to 'detect' realmode. NOTE: This option intentionaly is not mentioned elsewere, because it realy is dangerous. 5.2. Description of debug output (-v,-t,-d) -------------------------------------- The ouput produced by the -v, -t or -d options occurs at the point at which the boot sector and setup are loaded and updated by LOADLIN. The information is that seen by Linux, but in the case of -t and -d, the zimage file is not loaded and linux is not started. Description: Your current LINUX kernel boot configuration is: image file: d:\tmp\1-1-47.0 <- filename of kernel image kernel size: 0x5BFF0 setup size: 0x0A00 ^ ^- size of setup in bytes |---------------------- size of kernel in bytes kernel version: 1.1.47 (root@el15) #4 Mon Aug 00:57:07 MET DST 1994 ^---- this only if setup.S has the LOADLIN patches VGA mode: 0xFFFF <- video mode at startup command line (size 0x0015): <- contents of command_line as BOOT_IMAGE=zimage seen by Linux Your current DOS/CPU configuration is: +-----------using VCPI buffer, this also | can be EXT or XMS. load buffer size: 0x0081F000 VCPI, setup buffer size: 0x3E00 ^ ^- size of buffer in bytes which | holds the setup code. | must be >= "setup size" |---------------------- buffer space in bytes which can hold the uncompressed image and the initrd. lowmem buffer: 0x0006D000 (part of load buffer) ^-------------------- the low mem part of buffer space total memory: 0x0FE0000 <- highest RAM address as seen by Linux, calculated from the INT15 information CPU is in V86 mode <- if in Virtual-86 mode or CPU is in REAL mode or CPU is in undocumented REAL PAGING mode, trying any way SetupIntercept: NO <- using LOADLIN-1.4 mode or SetupIntercept: YES, patching setup code <- using Javier's method or SetupIntercept: YES, legal intercept <- dito, but legal Setup (compiled in patches) One of four possible status messages may appear here: stat1: cpu in real 386 mode stat2: cpu_V86, but no VCPI available (check aborted) stat3: VCPI_present, but physmap != logmap (check aborted) stat4: VCPI_present, physmap=logmap, all OK for switch to realmode The following may come from the DOS command line or from the params file: input params (size 0x000c): <- contents of DOS command line ..\zimage -t Some additional information and/or warnings can follow: LOADLIN started from DOS-prompt <- one of these two Lines " " " CONFIG.SYS <- (LOADLIN assumes the environ. has a COMSPEC= for DOS) You are running under MS-WINDOWS <- this warning, if in WINDOWS. (LOADLIN assumes the environ. has a WINDIR= for WINDOWS) --------- +++ -------- 6. Where to send comments and bug reports ====================================== Comments and bug reports are welcome and may be sent to: E-Mail: samuel.thibault@ens-lyon.org ... and PLEASE, PLEASE, PLEASE: Check your "Reply to" path for a valid E-Mail address, I get many "bounced" mails back ! It's not a fun having answered your mail for the trash. --------- +++ -------- 7. Contributions and Credits ========================= Version-1.6 of LOADLIN ist part of a jointly developed new booting strategie (bzImage+initrd) for both LILO and LOADLIN, so I say many thanks to Werner Almesberger for cooperating with me. Thanks to Hubert Mantel from S.u.S.E GmbH, who compiled 'lots' of kernels with the bzImage+initr patches, and testet them havily on several machines. Without him the patches never would have stabilized as quickly. He also was the first to realize a reasonable working /linuxrc. This program would be absolutely superfluous without Linus Torvalds, and thanks to him for putting our patches into the official kernel. This program could not have been written as quickly without the information found in the source code of F.Coutant's BOOTLIN. Jacques Gelinas encouraged me in realizing the VCPI-support. Alessandro Rubini contributed some code from his linuxEXE package and gave some important hints. Chuck Munro gave hints concerning problems with QEMM and ALPHA- tested version 1.4. He also did much work for better documentation. Javier Achirica invented the switch-out-of-setup method (LOADLIN-1.5). The trick is: let setup run in V86 and intercept just before going to protected mode. Important problem and bug reports came from: Mitchum Dsouza, UK Claus Tondering, Denmark Johann Friedrich Heinrichmeyer, Germany Jacek Zapala, Poland Jon Peatfield, UK Matthias Sattler, Germany Pim Zandenberg, Netherlands Thanks also to all the ALPHA testers, who responded on my "call for testers". The list is too long to put it here, but some of them did heavy testings: Michael Goddard, US Shih-Hua Chao, US Rene Baart, Netherlands Asad Khan, Jan Lien, Sweden Many thanks also to those people, who did not have any problems with LOADLIN, but nevertheless mailed me "it works" ( positive feedback is the best one ). --------- END -------- loadlin-1.6f/doc/PaxHeaders.14419/lodlin16.lsm0000644000175000017500000000013212025461304017110 xustar000000000000000030 mtime=1347838660.986396005 30 atime=1347838662.026370649 30 ctime=1347838660.986396005 loadlin-1.6f/doc/lodlin16.lsm0000644000175000017500000000213712025461304016066 0ustar00samysamy00000000000000Begin3 Title: LOADLIN, loads Linux with command line from DOS Version: 1.6f Entered-date: 17SEP12 Description: This is a boot loader for Linux that runs under MSDOS. It can boot Linux from a DOS prompt or CONFIG.SYS, and fully supports the command line feature of the Linux kernel. This new version also supports bzImage+initrd, i.e it can load directly 'high' and can load the ramdisk. bzImage+initrd (since 1.3.73 in the official kernel) was jointly developed by Werner Almesberger (LILO) and Hans Lermen (LOADLIN). Keywords: LOADLIN, BOOT, bzImage, initrd Author: Hans Lermen Maintained-by: Samuel Thibault Original-site: youpibouh.thefreecat.org loadlin 89k loadlin-1.6f.tgz Platform: Linux >= 1.3.73 for bzImage+initrd, Linux >= 0.99.15f for zImage, MSDOS, WINDOWS95's DOS (or compatible operating system) Copying-policy: GPL End loadlin-1.6f/doc/PaxHeaders.14419/initrd.txt0000644000175000017500000000013212025461304016775 xustar000000000000000030 mtime=1347838660.982396102 30 atime=1347838662.030370552 30 ctime=1347838660.982396102 loadlin-1.6f/doc/initrd.txt0000644000175000017500000002661512025461304015762 0ustar00samysamy00000000000000Using the initial RAM disk (initrd) =================================== Written 1996 by Werner Almesberger and Hans Lermen initrd adds the capability to load a RAM disk by the boot loader. This RAM disk can then be mounted as the root file system and programs can be run from it. Afterwards, a new root file system can be mounted from a different device. The previous root (from initrd) is then either moved to the directory /initrd or it is unmounted. initrd is mainly designed to allow system startup to occur in two phases, where the kernel comes up with a minimum set of compiled-in drivers, and where additional modules are loaded from initrd. Operation --------- When using initrd, the system boots as follows: 1) the boot loader loads the kernel and the initial RAM disk 2) the kernel converts initrd into a "normal" RAM disk and frees the memory used by initrd 3) initrd is mounted read-write as root 4) /linuxrc is executed (this can be any valid executable, including shell scripts; it is run with uid 0 and can do basically everything init can do) 5) when linuxrc terminates, the "real" root file system is mounted 6) if a directory /initrd exists, the initrd is moved there otherwise, initrd is unmounted 7) the usual boot sequence (e.g. invocation of /sbin/init) is performed on the root file system Note that moving initrd from / to /initrd does not involve unmounting it. It is therefore possible to leave processes running on initrd (or leave file systems mounted, but see below) during that procedure. However, if /initrd doesn't exist, initrd can only be unmounted if it is not used by anything. If it can't be unmounted, it will stay in memory. Also note that file systems mounted under initrd continue to be accessible, but their /proc/mounts entries are not updated. Also, if /initrd doesn't exist, initrd can't be unmounted and will "disappear" and take those file systems with it, thereby preventing them from being re-mounted. It is therefore strongly suggested to generally unmount all file systems (except of course for the root file system, but including /proc) before switching from initrd to the "normal" root file system. In order to deallocate the memory used for the initial RAM disk, you have to execute freeramdisk (see 'Resources' below) after unmounting /initrd. Boot command-line options ------------------------- initrd adds the following new options: initrd= (LOADLIN only) Loads the specified file as the initial RAM disk. When using LILO, you have to specify the RAM disk image file in /etc/lilo.conf, using the INITRD configuration variable. noinitrd initrd data is preserved but it is not converted to a RAM disk and the "normal" root file system is mounted. initrd data can be read from /dev/initrd. Note that the data in initrd can have any structure in this case and doesn't necessarily have to be a file system image. This option is used mainly for debugging. Note that /dev/initrd is read-only and that it can only be used once. As soon as the last process has closed it, all data is freed and /dev/initrd can't be opened any longer. root=/dev/ram initrd is mounted as root, and /linuxrc is started. If no /linuxrc exists, the normal boot procedure is followed, with the RAM disk still mounted as root. This option is mainly useful when booting from a floppy disk. Compared to directly mounting an on-disk file system, the intermediate step of going via initrd adds a little speed advantage and it allows the use of a compressed file system. Also, together with LOADLIN you may load the RAM disk directly from CDrom or disk, hence having a floppyless boot from CD, e.g.: E:\loadlin E:\bzImage root=/dev/ram initrd=E:\rdimage Installation ------------ First, the "normal" root file system has to be prepared as follows: # mknod /dev/initrd b 0 250 # chmod 400 /dev/initrd # mkdir /initrd If the root file system is created during the boot procedure (i.e. if you're creating an install floppy), the root file system creation procedure should perform these operations. Note that neither /dev/initrd nor /initrd are strictly required for correct operation of initrd, but it is a lot easier to experiment with initrd if you have them, and you may also want to use /initrd to pass data to the "real" system. Second, the kernel has to be compiled with RAM disk support and with support for the initial RAM disk enabled. Also, at least all components needed to execute programs from initrd (e.g. executable format and file system) must be compiled into the kernel. Third, you have to create the RAM disk image. This is done by creating a file system on a block device and then by copying files to it as needed. With recent kernels, at least three types of devices are suitable for that: - a floppy disk (works everywhere but it's painfully slow) - a RAM disk (fast, but allocates physical memory) - a loopback device (the most elegant solution, but currently requires a modified mount) We'll describe the RAM disk method: 1) make sure you have a RAM disk device /dev/ram (block, major 1, minor 0) 2) create an empty file system of the appropriate size, e.g. # mke2fs -m0 /dev/ram 300 (if space is critical, you may want to use the Minix FS instead of Ext2) 3) mount the file system on an appropriate directory, e.g. # mount -t ext2 /dev/ram /mnt 4) create the console device: # mkdir /mnt/dev # mknod /mnt/dev/tty1 c 4 1 5) copy all the files that are needed to properly use the initrd environment. Don't forget the most important file, /linuxrc Note that /linuxrc's permissions must include "x" (execute). 6) unmount the RAM disk # umount /dev/ram 7) copy the image to a file # dd if=/dev/ram bs=1k count=300 of=/boot/initrd 8) deallocate the RAM disk # freeramdisk /dev/ram For experimenting with initrd, you may want to take a rescue floppy (e.g. rescue.gz from Slackware) and only add a symbolic link from /linuxrc to /bin/sh, e.g. # gunzip /dev/ram # mount -t minix /dev/ram /mnt # ln -s /bin/sh /mnt/linuxrc # umount /dev/ram # dd if=/dev/ram bs=1k count=1440 of=/boot/initrd # freeramdisk /dev/ram Finally, you have to boot the kernel and load initrd. Currently, preliminary versions of LOADLIN 1.6 and LILO 18 support initrd (see below for where to get them). With LOADLIN, you simply execute LOADLIN initrd= e.g. LOADLIN C:\LINUX\VMLINUZ initrd=C:\LINUX\INITRD With LILO, you add the option INITRD= to either the global section or to the section of the respective kernel in /etc/lilo.conf, e.g. image = /vmlinuz initrd = /boot/initrd and run /sbin/lilo Now you can boot and enjoy using initrd. Setting the root device ----------------------- By default, the standard settings in the kernel are used for the root device, i.e. the default compiled in or set with rdev, or what was passed with root=xxx on the command line, or, with LILO, what was specified in /etc/lilo.conf It is also possible to use initrd with an NFS-mounted root; you have to use the nfs_root_name and nfs_root_addrs boot options for this. It is also possible to change the root device from within the initrd environment. In order to do so, /proc has to be mounted. Then, the following files are available: /proc/sys/kernel/real-root-dev /proc/sys/kernel/nfs-root-name /proc/sys/kernel/nfs-root-addrs real-root-dev can be changed by writing the number of the new root FS device to it, e.g. # echo 0x301 >/proc/sys/kernel/real-root-dev for /dev/hda1. When using an NFS-mounted root, nfs-root-name and nfs-root-addrs have to be set accordingly and then real-root-dev has to be set to 0xff, e.g. # echo /var/nfsroot >/proc/sys/kernel/nfs-root-name # echo 193.8.232.2:193.8.232.7::255.255.255.0:idefix \ >/proc/sys/kernel/nfs-root-addrs # echo 255 >/proc/sys/kernel/real-root-dev If the root device is set to the RAM disk, the root file system is not moved to /initrd, but the boot procedure is simply continued by starting init on the initial RAM disk. Usage scenarios --------------- The main motivation for implementing initrd was to allow for modular kernel configuration at system installation. The procedure would work as follows: 1) systems boots from floppy or other media with a minimal kernel (e.g. support for RAM disks, initrd, a.out, and the ext2 FS) and loads initrd 2) /linuxrc determines what is needed to (1) mount the "real" root FS (i.e. device type, device drivers, file system) and (2) the distribution media (e.g. CD-ROM, network, tape, ...). This can be done by asking the user, by auto-probing, or by using a hybrid approach. 3) /linuxrc loads the necessary modules 4) /linuxrc creates and populates the root file system (this doesn't have to be a very usable system yet) 5) /linuxrc unmounts the root file system and possibly any other file systems it has mounted, sets /proc/sys/kernel/..., and terminates 6) the root file system is mounted 7) now that we're sure that the file system is accessible and intact, the boot loader can be installed 8) the boot loader is configured to load an initrd with the set of modules that was used to bring up the system (e.g. /initrd can be modified, then unmounted, and finally, the image is written from /dev/ram to a file) 9) now the system is bootable and additional installation tasks can be performed The key role of initrd here is to re-use the configuration data during normal system operation without requiring the use of a bloated "generic" kernel or re-compilation or re-linking of the kernel. A second scenario is for installations where Linux runs on systems with different hardware configurations in a single administrative domain. In such cases, it is desirable to generate only a small set of kernels (ideally only one) and to keep the system-specific part of configuration information as small as possible. In this case, a common initrd could be generated with all the necessary modules. Then, only /linuxrc or a file read by it would have to be different. A third scenario are more convenient recovery disks, because information like the location of the root FS partition doesn't have to be provided at boot time, but the system loaded from initrd can use a user-friendly dialog and it can also perform some sanity checks (or even some form of auto-detection). Last not least, CDrom distributors may use it for better installation from CD, either using a LILO boot floppy and bootstrapping a bigger ramdisk via initrd from CD, or using LOADLIN to directly load the ramdisk from CD without need of floppies. Since initrd is a fairly generic mechanism, it is likely that additional uses will be found. Resources --------- The bzImage+initrd patch (bzImage is an extension to load kernels directly above 1 MB, which allows kernels sizes of up to approximately 2 MB) can be found at http://youpibouh.thefreecat.org/loadlin/bzImage+initrd-1.3.72.patch.gz A very simple example for building an image for initrd, also including the program 'freeramdisk', can be found on http://youpibouh.thefreecat.org/loadlin/initrd-example.tgz loadlin-1.6f/doc/PaxHeaders.14419/changes0000644000175000017500000000013212025461304016276 xustar000000000000000030 mtime=1347838660.982396102 30 atime=1347838662.030370552 30 ctime=1347838660.982396102 loadlin-1.6f/doc/changes0000644000175000017500000002455012025461304015257 0ustar00samysamy00000000000000 History ======= LOADLIN-16f =========== Recent Linux kernels have grown their setup code, and thus reduced heap size, down to not being bootable at all with just 40 setup+heap sectors. I have sacrificed 1K command line out of 2K, to free some room and get 4K more for the setup+heap. Hopefully that will last some time. Otherwise we will have to reconsider the lets-fit-in-64KiB rule. Sep 17 2012, Samuel Thibault LOADLIN-16e =========== A bug in my compiler had broken VCPI support. Depending on its size, the very end of the initrd could be bogus. When using INT15, loadlin always try to load kernel+initrd below 16MB for old BIOSes, but if that does not fit, now emit a warning and load above 16MB. Loadlin does not always load setup at 0x95000, since it may not be available Linux used to always move itself there, but it doesn't do it any more. Fix Loadlin accordingly. Aug 25 2010, Samuel Thibault LOADLIN-16d =========== Support for loading very big bzImages: up to ~200MB have been tested. Fix recent linux setup (>= 2.6.23) which use BSS. Feb 8 2009, Samuel Thibault LOADLIN-16c =========== Support for loading bzImages bigger than 1MB compressed. Those images may be produced by kernels >= 2.4.5 (setup_header_version >= 0x0202). Apr 15 2002, Hans Lermen LOADLIN-16b =========== This version of LOADLIN contains a small fix to boot kernels with GDT layouts other than the standard ones (loadlin-1.6b nevertheless can boot also standard kernels). Prominent example of such a non-standard GDT kernel is Win4Lin. Thanks to Robert W. Hall for pointing this out, having made a primary fix and testing the final binary;-) Dec 6 2000, Hans Lermen LOADLIN-16a =========== Small fix to EXT_MEM_K changes in kernels > 2.1.22. We don't check < 4MB in LOADLIN any more. Jan 24 1997, Hans Lermen ----------------------------------------------------- version 1.6 April 30, '96 Release of LOADLIN-1.6 - Finaly made the setup-buffer 16 K (again), now we only have 12 K remaining on top of low mem. This doesn't hurt, because setup.S is now movable. - Fixed a mapping bug. The auxbuffer-mapping wrapped around (from e000 to 10000, were we needed at least access to the bootsector). - Removed 'root=' and ro/rw translation, now passing the string unchanged to the kernel. - New option: -dskreset after completing disk access, reset the disk subsystem -wait=nnn after completing disk access, wait nnn DOS-timer-ticks (takes place _after_ -dskreset is checked) - Definitively removed old LoadlinX support, because it becomes impossible to translate the DOSish drive letters to Linux device names. ( more the two drives, no standard to detect wether seeing SCSI or IDE drives ) April 1, '96 - Made @@...@@ parameter passing working again for below 9000 running setup.S. Now can have params behind the @-responsefile. ( such as: loadlin @linux.par image=other root=/dev/other ) - Introduced file-suffix (preparing for compound .exe + kernel + initrd ) Mars 19, '96 - Heap setting for video.S stuff (CAN_USE_HEAP,heap_end_ptr) Mars 7, '96 - Fixed bug in bzImage code. (finally found, what seemed to be vanished in 1.3.71, but fortunately came up to crash on _my_ machine). kernel/head.S does not setup %esp, it uses the one of boot/head.S, and because this is pointing above 0x100000 for high loaded kernels, part of the kernel gets destroyed on startup. Mars 6, '96 - Fix bug in LOALDIN (not recognizing 'k' or 'm' in mem=xxxK) - Some additional features and fixes in bzImage+initrd Feb. 21. '96 - Fixed bug in LOADLIN (not loading old unpatched zImages) Feb. 20. '96 - Fixed a bug in Makefiles, some as86-cleanups Feb. 19. '96 - added support for dd'ed floppy boot (for bzImages). - fixed some odd error output in loadlin.exe Feb. 17. '96 - Initial announcement of LILO+LOADLIN+bzImage+initrd by Werner Almesberger ----------------------------------------------------- version 1.5 added: Adaption to newer kernel: The setup buffer is now 16Kb. Setup size is determined by byte 497 in the boot sector. The actual size and the setup buffer size are printed by the debug output. Added kernel version control (needs patch for boot/setup.S). Changed the dev-numbers of /dev/xda, /dev/xdb to 0xD00,0xD40. (if you rely on old numbering use the -oldxd switch) The Javier method: A very clever guy in Spain, Javier Achirica invented a method to intercept the Linux setup code just before protected mode transition. I call it the "Javier method" and it is enabled whenever the -ja switch is used or neither BIOSINT nor REALBIOS are configured. All configuration steps, that where necessary for version 1.4 and below are now superfluous on allmost all machines. DBLSPACE is no more a problem and, although invented especially for V86 mode I use Javier's method also for realmode to move the image down. New option -clone: On some 486 clones we have problems with CR0 while probing for V86 mode. (as reported by Jacek Zapala zapala@if.pw.edu.pl ). It can happen that the CPU is in realmode, but PAGING is enabled ! This is possible, but neither documented nor supported by INTEL. May be the motherboard's BIOS is mapping shadow ram this way, or one of those old and strange EMM managers is used, but probably this is an indication of a not exactly compatible 486 clone. The -clone switch byepasses the CR0 check and assumes V86 if an EMM manger is found. But of course this EMM manager must not use real paging ! New option -n: You can switch off the translation of root=/dev/xxx with the -n switch The string is then put unchanged into the command_line. Actually it does both, translates and put into command_line, but Linux will overwrite the LOADLIN-translation, and LOADLIN has a chance to check for know numbers. This option is intended for future Linux devellopement, if Linus expands the root device list, you can use these new device with your then not uptodate LOADLIN. Changed ramdisk= param I got report, that the prompt for diskchange (if using ramdisk) was inconvenient when using diskless configurations (builtin ramdisk), as used by (Szemethy, what's the hell is your correct "Reply to"). With "ramdisk=1440,no" the prompt will be disabled. Using VCPI with NOEMS: As told by Jon Peatfield there is VCPI available even if using NOEMS in EMM386. The signature is not EMMXXXX0, but EMMQXXX0, which is a violation of the VCPI specification. Enhancements for loadlinX: The loadlin preprocessor LOADLINX now fully supports response files (@test.par). Additional command_line options are merged into those comeing from the response file, so you can you a "default" params file and then change some params on the actual call. With this feature LOADLINX can may be useful even if UMSDOS support is not needed. New option --version=... (e.g. --version=1.1.47#1) verifies the kernel version and aborts, if no match is found. Otion --version (without the "=") prints the version-string from a kernel image. New docs: QUICKSTA.RT, is taken from Pat Volkerding's LODLIN14.TXT bug-fix: vga=-1 did not work, e.g the sign wasn't interpreted. Minor changes on the cpu_check routine. ----------------------------------------------------- version 1.4 added: REALBIOS support (probing the BIOS via boot from floppy as proposed by Alessandro Rubini) to overcome the problem with QEMM. Alpha tested by Chuck Munro. loadlinX.exe (preprocessor for LOADLIN ("root=c:"), as proposed by Jacques Gelinas) Better documentation (author: Chuck Munro) readme --> manual.txt removed: old source DEBUGMODE switch (don't need it any more) bug-fix: None from 1.3, got no bug report till now, (but problem reports solved with introduction of REALBIOS support) ----------------------------------------------------- version 1.3 added verbose and debug (-v -d -t) options Adaptation to kernel 1.0.5 changes for init/main.c : Kernel changes (by Linus): Command_line size is now 256 by default and is checked for size, but irritating option passing to SYSVinit is not handled. LOADLIN changes: I guess it had been better to let the kernel handle ALL params, and pass the params as string (instead of writing around in the binary), so future devellopement would be much easier. It was a very good idea of Linus to introduce the "command line feature",... and if (one day) the kernel handles all things appropriate, I will change back the following changes: Got "ro,rw" flags away from command line, sets 0x1f2 of bootsector instead. Recognize all "root=..." myself, which avoids the bug in "init/main.c". Fixed bugs: vga=ask,normal,extended did not work parsing DOS-command-line terminated incorrectly Cleaned up documentation ----------------------------------------------------- version 1.2.1 never released Fixed the problem with DBLSPACE Resets interrupt vector if BIOSINTV.SYS is recognized, not only if using VCPIswitch. ----------------------------------------------------- version 1.2 first appearence on: sunsite.unc.edu:/pub/Linux/system/Linux-boot elserv.ffm.fgan.de:/pub/linux/loadlin-1.2 Added support for V86 (realmode back switch over VCPI) Added BIOSINTV.SYS driver to get a clean interrupt vector table Checked and cleaned up "sync before load" out of a LINUX.BAT file ----------------------------------------------------- version 1.1 First released version appeared on ftp.ffm.fgan.de Added response file feature resolved problem with uppercase conversion in CONFIG.SYS Cleaned up documentation. Sent my kernel patch to Linus. ----------------------------------------------------- version 1.0 (NOTE: I allways start any packet-numbering with 1.0) Private ALPHA version. Never released loadlin-1.6f/doc/PaxHeaders.14419/announce.txt0000644000175000017500000000013212025461304017312 xustar000000000000000030 mtime=1347838660.982396102 30 atime=1347838662.030370552 30 ctime=1347838660.982396102 loadlin-1.6f/doc/announce.txt0000644000175000017500000001611212025461304016266 0ustar00samysamy00000000000000NOTE: This was the annoncement on linux-kernel of bzImage+initrd Starting with kernel version 1.3.73 bzImage+initrd is part of the official kernel. YOU NEED NOT TO APPLY THE PATCH ------------------------------------------------------------------------- From lermen@elserv.ffm.fgan.deWed Mar 6 11:10:17 1996 Date: Wed, 6 Mar 1996 11:09:46 +0100 (MET) From: Hans Lermen To: linux-kernel@vger.rutgers.edu Cc: Werner Almesberger Subject: PATCH: Linux high in the sky and more Hi, this is a patch that adds direct loading of kernels above 1 MB, support for an initial RAM disk that is loaded by the boot loader and that can be mounted as root before the "real" root is mounted, plus a few minor fixes to make LOADLIN work better, particularly in W95 environments. The initial RAM disk feature (we call it simply "initrd") should help to confine the number of prebuilt kernels a distribution has to come with to something reasonable, i.e. one. All these features will be supported in the next versions of LILO and LOADLIN, which both are essentially ready to be released. The features are in detail: - kernels can be loaded directly above 1 MB, which removes the 0.5 MB compressed size restriction. This also works with dd'ed floppy boot. - a file (e.g. a RAM disk image) can be loaded by the boot loader and is then available to the kernel, e.g. for mounting - when such a RAM disk is mounted on /, a special initialization program /linuxrc is executed. When it terminates, the RAM disk can be unmounted (or "moved" to a different mount point) and the "real" root FS is mounted. The root FS device can be altered from within that environment. - no loading restrictions when using LOADLIN under Windows 95 (the 0x90000 segment is mostly occupied by W'95 ) Attached is a detailed description of what the patch does. The patch itself (for 1.3.71) can be found at ftp://lrcftp.epfl.ch/pub/people/almesber/lilo/bzImage+initrd-1.3.72.patch.gz and ftp://elserv.ffm.fgan.de/pub/linux/loadlin-1.6/bzImage+initrd-1.3.72.patch.gz Since the first announce of this patch in mid-February, some additional features have been included, bugs have been fixed and documentation has been added. We think it is stable enough to be included in the mainstream kernel. Cheers, Werner & Hans ---------------------------------- cut here ----------------------------------- Loading of big kernels (1 MB compressed) ---------------------------------------- We call the new kernel format bzImage (big-zImage), and in fact it's the the old zImage kernel with the following changes: 1. The gunzip code (arch/i386/boot/compressed/misc.c) will now be linked at 0x100000. Because it would overwrite itself while decompressing, the first part of the decompressed data is written to low mem. When low mem becomes exhausted, then the rest is put behind __end. When decompression has completed, then a small move routine is copied down to low mem, which then moves the kernel at its proper place. This technique has the advantage that it needs the fewest changes to the old zImage. 2. The arch/i386/boot/setup.S has gotten a header, which from the kernel's point of view is always located at 0x90202. This header contains information used to coordinate the operation of loaders and the kernel (e.g. to detect inconsistencies). 3. Because the kernel size is given as a 16 bit value (segment format) in the bootsector, the compressed size of the bzImage is limited to 0xffff0 Bytes (~1MB). Given a compression ratio of 1:2, which is quite realistic, the decompressed kernel can be about 2 Meg. Loading of ramdisk directly by the loaders ------------------------------------------ With the same technique used for the kernel, also a ramdisk image can be loaded high. The image is loaded directly below mem_end. The start address and the size are put into the setup.S header so the kernel can find the data. The pages used by the image are marked "in use" and are freed later, when no longer needed. We've extended the RAM disk code to allow loading of a RAM disk from that data. (Typically, the loaded data will be compressed.) Then, that initrd can be mounted as root and the executable /linuxrc will be run. /linuxrc can now access additional media and load modules. (Actually, /linuxrc can do most things init can do.) When done, /linuxrc terminates, the "real" root file system is mounted and the initrd is either unmounted or it is "moved" to the mount point /initrd. Note that, in the latter case, the initrd is not unmounted, so any open files do not need to be closed, i.e. processes can survive the root change. This avoids the need to either have a large collection of precompiled kernels, to re-compile the kernel, or to have a "kernel link set". In particular, the boot floppy could be self-contained, i.e. no additional media would be necessary to create a bootable hard disk based system. There are a few other options, like - if root=/dev/ram, we boot directly into the RAM disk, using init - from within the initrd environment, the root FS device can be changed (using /proc/sys/kernel/real-root-dev) - if root=/dev/ram _after_ initrd, we simply start init in initrd A detailed description of the initrd technique can be found within the patch in the file linux/Documentation/initrd.txt. Better support for LOADLIN -------------------------- The fact that LOADLIN operates in a DOS/Windows environment adds two complications: - the kernel cannot be loaded in physically contiguous memory. Instead, LOADLIN has to re-arrange the pages after executing setup (which may have to be done in VM86 mode), but before booting the actual kernel - segment 0x9000 may be occupied (i.e. under Windows 95), so that the setup.S code must run in a different segment For those two reasons, the code32_start has been added to the setup.S header and setup.S itself has been made position independent. Since earlier versions of LOADLIN already used a setup header similar to the one we need now anyway, we've retained compatibility by basing the new header on the old one. Final remarks ------------- Given that many distributions will be based exclusively on the next major release of Linux for the next year, we think that it is important that this patch be integrated into 1.4/2.0, although the feature freeze is already in place. The next versions of LOADLIN and LILO will support the features described above. Some preliminary test versions are available on ftp://elserv.ffm.fgan.de/pub/linux/loadlin-1.6/loadlin-1.6-pre11-bin.tgz and ftp://lrcftp.epfl.ch/pub/people/almesber/lilo/lilo.18dev3.tar.gz This patch was jointly developed by Werner Almesberger and Hans Lermen. -- _________________________________________________________________________ / Werner Almesberger, DI-LRC,EPFL,CH werner.almesberger@lrc.di.epfl.ch / /_IN_R_133__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/ -- Hans Lermen