├── LICENSE ├── boot ├── boot.asm ├── boot32.asm ├── boot32lb.asm ├── makefile └── oemboot.asm ├── build.bat ├── clean.bat ├── docs ├── sys.htm └── sys.txt ├── hdr ├── algnbyte.h ├── dcb.h ├── device.h ├── fat.h ├── kconfig.h ├── portab.h └── xstructs.h ├── mkfiles ├── generic.mak └── watcom.mak └── sys ├── bin2c.c ├── bootmgr.c ├── config.big ├── config.edr ├── config.fd ├── config.h ├── config.oem ├── config.std ├── copy.c ├── diskio.h ├── diskio_d.c ├── diskio_w.c ├── fdkrncfg.c ├── getenv.c ├── initopts.c ├── makefile ├── prf.c ├── putboot.c ├── sys.c ├── sys.h ├── talloc.c ├── usage.c └── wsys ├── wsys.dsp └── wsys.dsw /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /boot/boot32.asm: -------------------------------------------------------------------------------- 1 | ; +--------+ 2 | ; | | 3 | ; | | 4 | ; |--------| 4000:0000 5 | ; | | 6 | ; | FAT | 7 | ; | | 8 | ; |--------| 2000:0000 9 | ; |BOOT SEC| 10 | ; |RELOCATE| 11 | ; |--------| 1FE0:0000 12 | ; | | 13 | ; | | 14 | ; | | 15 | ; | | 16 | ; |--------| 17 | ; |BOOT SEC| 18 | ; |ORIGIN | 07C0:0000 19 | ; |--------| 20 | ; | | 21 | ; | | 22 | ; | | 23 | ; |--------| 24 | ; |KERNEL | 25 | ; |LOADED | 26 | ; |--------| 0060:0000 27 | ; | | 28 | ; +--------+ 29 | 30 | ;%define MULTI_SEC_READ 1 31 | 32 | 33 | segment .text 34 | 35 | %define BASE 0x7c00 36 | 37 | org BASE 38 | 39 | Entry: jmp short real_start 40 | nop 41 | 42 | ; bp is initialized to 7c00h 43 | %define bsOemName bp+0x03 ; OEM label 44 | %define bsBytesPerSec bp+0x0b ; bytes/sector 45 | %define bsSecPerClust bp+0x0d ; sectors/allocation unit 46 | %define bsResSectors bp+0x0e ; # reserved sectors 47 | %define bsFATs bp+0x10 ; # of fats 48 | %define bsRootDirEnts bp+0x11 ; # of root dir entries 49 | %define bsSectors bp+0x13 ; # sectors total in image 50 | %define bsMedia bp+0x15 ; media descrip: fd=2side9sec, etc... 51 | %define sectPerFat bp+0x16 ; # sectors in a fat 52 | %define sectPerTrack bp+0x18 ; # sectors/track 53 | %define nHeads bp+0x1a ; # heads 54 | %define nHidden bp+0x1c ; # hidden sectors 55 | %define nSectorHuge bp+0x20 ; # sectors if > 65536 56 | %define xsectPerFat bp+0x24 ; Sectors/Fat 57 | %define xrootClst bp+0x2c ; Starting cluster of root directory 58 | %define drive bp+0x40 ; Drive number 59 | 60 | times 52h - ($ - $$) db 0 61 | ; The filesystem ID is used by lDOS's instsect (by ecm) 62 | ; by default to validate that the filesystem matches. 63 | db "FAT32" 64 | times 5Ah - ($ - $$) db 32 65 | 66 | 67 | %define LOADSEG 0x0060 68 | 69 | %define FATSEG 0x2000 70 | 71 | %define fat_sector bp+0x48 ; last accessed sector of the FAT 72 | 73 | %define loadsegoff_60 bp+loadseg_off-Entry ; FAR pointer = 60:0 74 | %define loadseg_60 bp+loadseg_seg-Entry 75 | 76 | %define fat_start bp+0x5e ; first FAT sector 77 | %define data_start bp+0x62 ; first data sector 78 | %define fat_secmask bp+0x66 ; number of clusters in a FAT sector - 1 79 | %define fat_secshift bp+0x68 ; fat_secmask+1 = 2^fat_secshift 80 | 81 | ;----------------------------------------------------------------------- 82 | ; ENTRY 83 | ;----------------------------------------------------------------------- 84 | 85 | real_start: cld 86 | cli 87 | sub ax, ax 88 | mov ds, ax 89 | mov bp, 0x7c00 90 | 91 | mov ax, 0x1FE0 92 | mov es, ax 93 | mov si, bp 94 | mov di, bp 95 | mov cx, 0x0100 96 | rep movsw ; move boot code to the 0x1FE0:0x0000 97 | jmp word 0x1FE0:cont 98 | 99 | loadseg_off dw 0 100 | loadseg_seg dw LOADSEG 101 | 102 | cont: mov ds, ax 103 | mov ss, ax 104 | lea sp, [bp-0x20] 105 | sti 106 | mov [drive], dl ; BIOS passes drive number in DL 107 | 108 | ; call print 109 | ; db "Loading ",0 110 | 111 | ; Calc Params 112 | ; Fat_Start 113 | mov si, word [nHidden] 114 | mov di, word [nHidden+2] 115 | add si, word [bsResSectors] 116 | adc di, byte 0 117 | 118 | mov word [fat_start], si 119 | mov word [fat_start+2], di 120 | ; Data_Start 121 | mov al, [bsFATs] 122 | cbw 123 | push ax 124 | mul word [xsectPerFat+2] 125 | add di, ax 126 | pop ax 127 | mul word [xsectPerFat] 128 | add ax, si 129 | adc dx, di 130 | mov word[data_start], ax 131 | mov word[data_start+2], dx 132 | ; fat_secmask 133 | mov ax, word[bsBytesPerSec] 134 | shr ax, 1 135 | shr ax, 1 136 | dec ax 137 | mov word [fat_secmask], ax 138 | ; fat_secshift 139 | ; cx = temp 140 | ; ax = fat_secshift 141 | xchg ax, cx ; cx = 0 after movsw 142 | inc cx 143 | secshift: inc ax 144 | shr cx, 1 145 | cmp cx, 1 146 | jne secshift 147 | mov byte [fat_secshift], al 148 | dec cx 149 | 150 | ; FINDFILE: Searches for the file in the root directory. 151 | ; 152 | ; Returns: 153 | ; DX:AX = first cluster of file 154 | 155 | mov word [fat_sector], cx ; CX is 0 after "dec" 156 | mov word [fat_sector + 2], cx 157 | 158 | mov ax, word [xrootClst] 159 | mov dx, word [xrootClst + 2] 160 | ff_next_cluster: 161 | push dx ; save cluster 162 | push ax 163 | call convert_cluster 164 | jc boot_error ; EOC encountered 165 | 166 | ff_next_sector: 167 | push bx ; save sector count 168 | 169 | les bx, [loadsegoff_60] 170 | call readDisk 171 | push dx ; save sector 172 | push ax 173 | 174 | mov ax, [bsBytesPerSec] 175 | 176 | ; Search for KERNEL.SYS file name, and find start cluster. 177 | ff_next_entry: mov cx, 11 178 | mov si, filename 179 | mov di, ax 180 | sub di, 0x20 181 | repe cmpsb 182 | jz ff_done 183 | 184 | sub ax, 0x20 185 | jnz ff_next_entry 186 | pop ax ; restore sector 187 | pop dx 188 | pop bx ; restore sector count 189 | dec bx 190 | jnz ff_next_sector 191 | ff_find_next_cluster: 192 | pop ax ; restore current cluster 193 | pop dx 194 | call next_cluster 195 | jmp short ff_next_cluster 196 | ff_done: 197 | 198 | mov ax, [es:di+0x1A-11] ; get cluster number 199 | mov dx, [es:di+0x14-11] 200 | c4: 201 | sub bx, bx ; ES points to LOADSEG 202 | c5: push dx 203 | push ax 204 | push bx 205 | call convert_cluster 206 | jc boot_success 207 | mov di, bx 208 | pop bx 209 | c6: 210 | call readDisk 211 | dec di 212 | jnz c6 213 | pop ax 214 | pop dx 215 | call next_cluster 216 | jmp short c5 217 | 218 | boot_error: 219 | xor ah,ah 220 | int 0x16 ; wait for a key 221 | int 0x19 ; reboot the machine 222 | 223 | ; input: 224 | ; DX:AX - cluster 225 | ; output: 226 | ; DX:AX - next cluster 227 | ; CX = 0 228 | ; modify: 229 | ; DI 230 | next_cluster: 231 | push es 232 | mov di, ax 233 | and di, [fat_secmask] 234 | 235 | mov cx, [fat_secshift] 236 | cn_loop: 237 | shr dx,1 238 | rcr ax,1 239 | dec cx 240 | jnz cn_loop ; DX:AX fat sector where our 241 | ; cluster resides 242 | ; DI - cluster index in this 243 | ; sector 244 | 245 | shl di,1 ; DI - offset in the sector 246 | shl di,1 247 | add ax, [fat_start] 248 | adc dx, [fat_start+2] ; DX:AX absolute fat sector 249 | 250 | push bx 251 | mov bx, FATSEG 252 | mov es, bx 253 | sub bx, bx 254 | 255 | cmp ax, [fat_sector] 256 | jne cn1 ; if the last fat sector we 257 | ; read was this, than skip 258 | cmp dx,[fat_sector+2] 259 | je cn_exit 260 | cn1: 261 | mov [fat_sector],ax ; save the fat sector number, 262 | mov [fat_sector+2],dx ; we are going to read 263 | call readDisk 264 | cn_exit: 265 | pop bx 266 | mov ax, [es:di] ; DX:AX - next cluster 267 | mov dx, [es:di + 2] ; 268 | pop es 269 | ret 270 | 271 | 272 | boot_success: 273 | mov bl, [drive] 274 | jmp far [loadsegoff_60] 275 | 276 | ; Convert cluster to the absolute sector 277 | ;input: 278 | ; DX:AX - target cluster 279 | ;output: 280 | ; DX:AX - absoulute sector 281 | ; BX - [bsSectPerClust] 282 | ;modify: 283 | ; CX 284 | convert_cluster: 285 | cmp dx,0x0fff 286 | jne c3 287 | cmp ax,0xfff8 288 | jb c3 ; if cluster is EOC (carry is set), do ret 289 | stc 290 | ret 291 | c3: 292 | mov cx, dx ; sector = (cluster - 2)*clussize + 293 | ; + data_start 294 | sub ax, 2 295 | sbb cx, byte 0 ; CX:AX == cluster - 2 296 | mov bl, [bsSecPerClust] 297 | sub bh, bh 298 | xchg cx, ax ; AX:CX == cluster - 2 299 | mul bx ; first handle high word 300 | ; DX must be 0 here 301 | xchg ax, cx ; then low word 302 | mul bx 303 | add dx, cx ; DX:AX target sector 304 | add ax, [data_start] 305 | adc dx, [data_start + 2] 306 | ret 307 | 308 | ; prints text after call to this function. 309 | 310 | print_1char: 311 | xor bx, bx ; video page 0 312 | mov ah, 0x0E ; else print it 313 | int 0x10 ; via TTY mode 314 | print: pop si ; this is the first character 315 | print1: lodsb ; get token 316 | push si ; stack up potential return address 317 | cmp al, 0 ; end of string? 318 | jne print_1char ; until done 319 | ret ; and jump to it 320 | 321 | ;input: 322 | ; DX:AX - 32-bit DOS sector number 323 | ; ES:BX - destination buffer 324 | ;output: 325 | ; ES:BX points one byte after the last byte read. 326 | ; DX:AX - next sector 327 | ;modify: 328 | ; ES if DI * bsBytesPerSec >= 65536, CX 329 | 330 | readDisk: 331 | read_next: push dx 332 | push ax 333 | ; 334 | ; translate sector number to BIOS parameters 335 | ; 336 | 337 | ; 338 | ; abs = sector offset in track 339 | ; + head * sectPerTrack offset in cylinder 340 | ; + track * sectPerTrack * nHeads offset in platter 341 | ; 342 | xchg ax, cx 343 | mov al, [sectPerTrack] 344 | mul byte [nHeads] 345 | xchg ax, cx 346 | ; cx = nHeads * sectPerTrack <= 255*63 347 | ; dx:ax = abs 348 | div cx 349 | ; ax = track, dx = sector + head * sectPertrack 350 | xchg ax, dx 351 | ; dx = track, ax = sector + head * sectPertrack 352 | div byte [sectPerTrack] 353 | ; dx = track, al = head, ah = sector 354 | mov cx, dx 355 | ; cx = track, al = head, ah = sector 356 | 357 | ; the following manipulations are necessary in order to 358 | ; properly place parameters into registers. 359 | ; ch = cylinder number low 8 bits 360 | ; cl = 7-6: cylinder high two bits 361 | ; 5-0: sector 362 | mov dh, al ; save head into dh for bios 363 | xchg ch, cl ; set cyl no low 8 bits 364 | ror cl, 1 ; move track high bits into 365 | ror cl, 1 ; bits 7-6 (assumes top = 0) 366 | inc ah ; sector offset from 1 367 | or cl, ah ; merge sector into cylinder 368 | 369 | mov ax, 0x0201 370 | mov dl, [drive] 371 | int 0x13 372 | 373 | pop ax 374 | pop dx 375 | jnc read_ok ; jump if no error 376 | xor ah, ah ; else, reset floppy 377 | int 0x13 378 | jmp short read_next 379 | read_ok: 380 | add bx, word [bsBytesPerSec] 381 | 382 | jnc no_incr_es ; if overflow... 383 | 384 | mov cx, es 385 | add ch, 0x10 ; ...add 1000h to ES 386 | mov es, cx 387 | 388 | no_incr_es: 389 | add ax,byte 1 390 | adc dx,byte 0 391 | ret 392 | 393 | times 0x01f1-$+$$ db 0 394 | 395 | filename db "KERNEL SYS",0,0 396 | 397 | sign dw 0xAA55 398 | -------------------------------------------------------------------------------- /boot/boot32lb.asm: -------------------------------------------------------------------------------- 1 | ; This is an LBA-enabled FreeDOS FAT32 boot sector (single sector!). 2 | ; You can use and copy source code and binaries under the terms of the 3 | ; GNU Public License (GPL), version 2 or newer. See www.gnu.org for more. 4 | 5 | ; Based on earlier work by FreeDOS kernel hackers, modified heavily by 6 | ; Eric Auer and Jon Gentle in 7 / 2003. 7 | ; 8 | ; Features: Uses LBA and calculates all variables from BPB/EBPB data, 9 | ; thus making partition move / resize / image-restore easier. FreeDOS 10 | ; can boot from FAT32 partitions which start > 8 GB boundary with this 11 | ; boot sector. Disk geometry knowledge is not needed for booting. 12 | ; 13 | ; Windows uses 2-3 sectors for booting (sector stage, statistics sector, 14 | ; filesystem stage). Only using 1 sector for FreeDOS makes multi-booting 15 | ; of FreeDOS and Windows on the same filesystem easier. 16 | ; 17 | ; Requirements: LBA BIOS and 386 or better CPU. Use the older CHS-only 18 | ; boot sector if you want FAT32 on really old PCs (problems: you cannot 19 | ; boot from > 8 GB boundary, cannot move / resize / ... without applying 20 | ; SYS again if you use the CHS-only FAT32 boot sector). 21 | ; 22 | ; FAT12 / FAT16 hints: Use the older CHS-only boot sector unless you 23 | ; have to boot from > 8 GB. The LBA-and-CHS FAT12 / FAT16 boot sector 24 | ; needs applying SYS again after move / resize / ... a variant of that 25 | ; boot sector without CHS support but with better move / resize / ... 26 | ; support would be good for use on LBA harddisks. 27 | 28 | 29 | ; Memory layout for the FreeDOS FAT32 single stage boot process: 30 | 31 | ; ... 32 | ; |-------| 1FE0:7E00 33 | ; |BOOTSEC| 34 | ; |RELOC. | 35 | ; |-------| 1FE0:7C00 36 | ; ... 37 | ; |-------| 2000:0200 38 | ; | FAT | (only 1 sector buffered) 39 | ; |-------| 2000:0000 40 | ; ... 41 | ; |-------| 0000:7E00 42 | ; |BOOTSEC| overwritten by the kernel, so the 43 | ; |ORIGIN | bootsector relocates itself up... 44 | ; |-------| 0000:7C00 45 | ; ... 46 | ; |-------| 47 | ; |KERNEL | maximum size 134k (overwrites bootsec origin) 48 | ; |LOADED | (holds 1 sector directory buffer before kernel load) 49 | ; |-------| 0060:0000 50 | ; ... 51 | 52 | segment .text 53 | 54 | org 0x7c00 ; this is a boot sector 55 | 56 | Entry: jmp short real_start 57 | nop 58 | 59 | ; bp is initialized to 7c00h 60 | ; %define bsOemName bp+0x03 ; OEM label (8) 61 | %define bsBytesPerSec bp+0x0b ; bytes/sector (dw) 62 | %define bsSecPerClust bp+0x0d ; sectors/allocation unit (db) 63 | %define bsResSectors bp+0x0e ; # reserved sectors (dw) 64 | %define bsFATs bp+0x10 ; # of fats (db) 65 | ; %define bsRootDirEnts bp+0x11 ; # of root dir entries (dw, 0 for FAT32) 66 | ; (FAT32 has root dir in a cluster chain) 67 | ; %define bsSectors bp+0x13 ; # sectors total in image (dw, 0 for FAT32) 68 | ; (if 0 use nSectorHuge even if FAT16) 69 | ; %define bsMedia bp+0x15 ; media descriptor: fd=2side9sec, etc... (db) 70 | ; %define sectPerFat bp+0x16 ; # sectors in a fat (dw, 0 for FAT32) 71 | ; (FAT32 always uses xsectPerFat) 72 | %define sectPerTrack bp+0x18 ; # sectors/track 73 | ; %define nHeads bp+0x1a ; # heads (dw) 74 | %define nHidden bp+0x1c ; # hidden sectors (dd) 75 | ; %define nSectorHuge bp+0x20 ; # sectors if > 65536 (dd) 76 | %define xsectPerFat bp+0x24 ; Sectors/Fat (dd) 77 | ; +0x28 dw flags (for fat mirroring) 78 | ; +0x2a dw filesystem version (usually 0) 79 | %define xrootClst bp+0x2c ; Starting cluster of root directory (dd) 80 | ; +0x30 dw -1 or sector number of fs.-info sector 81 | ; +0x32 dw -1 or sector number of boot sector backup 82 | ; (+0x34 .. +0x3f reserved) 83 | %define drive bp+0x40 ; Drive number 84 | %define loadsegoff_60 bp+loadseg_off-Entry 85 | 86 | %define LOADSEG 0x0060 87 | 88 | %define FATSEG 0x2000 89 | 90 | %define fat_secshift fat_afterss-1 ; each fat sector describes 2^?? 91 | ; clusters (db) (selfmodifying) 92 | %define fat_sector bp+0x44 ; last accessed FAT sector (dd) 93 | ; (overwriting unused bytes) 94 | %define fat_start bp+0x48 ; first FAT sector (dd) 95 | ; (overwriting unused bytes) 96 | %define data_start bp+0x4c ; first data sector (dd) 97 | ; (overwriting unused bytes) 98 | 99 | times 52h - ($ - $$) db 0 100 | ; The filesystem ID is used by lDOS's instsect (by ecm) 101 | ; by default to validate that the filesystem matches. 102 | db "FAT32" 103 | times 5Ah - ($ - $$) db 32 104 | ; not used: [0x42] = byte 0x29 (ext boot param flag) 105 | ; [0x43] = dword serial 106 | ; [0x47] = label (padded with 00, 11 bytes) 107 | ; [0x52] = "FAT32",32,32,32 (not used by Windows) 108 | ; ([0x5a] is where FreeDOS parts start) 109 | 110 | ;----------------------------------------------------------------------- 111 | ; ENTRY 112 | ;----------------------------------------------------------------------- 113 | 114 | real_start: cld 115 | cli 116 | sub ax, ax 117 | mov ds, ax 118 | mov bp, 0x7c00 119 | 120 | mov ax, 0x1FE0 121 | mov es, ax 122 | mov si, bp 123 | mov di, bp 124 | mov cx, 0x0100 125 | rep movsw ; move boot code to the 0x1FE0:0x0000 126 | jmp word 0x1FE0:cont 127 | 128 | loadseg_off dw 0, LOADSEG 129 | 130 | ; ------------- 131 | 132 | cont: mov ds, ax 133 | mov ss, ax ; stack and BP-relative moves up, too 134 | lea sp, [bp-0x20] 135 | sti 136 | mov [drive], dl ; BIOS passes drive number in DL 137 | 138 | mov si, msg_LoadFreeDOS 139 | call print ; modifies AX BX SI 140 | 141 | 142 | ; ------------- 143 | 144 | ; CALCPARAMS: figure out where FAT and DATA area starts 145 | ; (modifies EAX EDX, sets fat_start and data_start variables) 146 | 147 | calc_params: xor eax, eax 148 | mov [fat_sector], eax ; init buffer status 149 | 150 | ; first, find fat_start: 151 | mov ax, [bsResSectors] ; no movzx eax, word... needed 152 | add eax, [nHidden] 153 | mov [fat_start], eax ; first FAT sector 154 | mov [data_start], eax ; (only first part of value) 155 | 156 | ; next, find data_start: 157 | mov eax, [bsFATs] ; no movzx ... byte needed: 158 | ; the 2 dw after the bsFATs db are 0 by FAT32 definition :-). 159 | imul dword [xsectPerFat] ; (also changes edx) 160 | add [data_start], eax ; first DATA sector 161 | ; (adding in RAM is shorter!) 162 | 163 | ; finally, find fat_secshift: 164 | mov ax, 512 ; default sector size (means default shift) 165 | ; shift = log2(secSize) - log2(fatEntrySize) 166 | ;--- mov cl, 9-2 ; shift is 7 for 512 bytes per sector 167 | fatss_scan: cmp ax, [bsBytesPerSec] 168 | jz fatss_found 169 | add ax,ax 170 | ;--- inc cx 171 | inc word [fat_secshift] ;XXX ; initially 9-2 (byte!) 172 | jmp short fatss_scan ; try other sector sizes 173 | fatss_found: 174 | ;--- mov [fat_secshift], cl 175 | 176 | ; ------------- 177 | 178 | ; FINDFILE: Searches for the file in the root directory. 179 | ; Returns: EAX = first cluster of file 180 | 181 | mov eax, [xrootClst] ; root dir cluster 182 | 183 | ff_next_clust: push eax ; save cluster 184 | call convert_cluster 185 | jc boot_error ; EOC encountered 186 | ; EDX is clust/sector, EAX is sector 187 | 188 | ff_next_sector: les bx, [loadsegoff_60] ; load to loadseg:0 189 | call readDisk 190 | ;--- push eax ; save sector 191 | 192 | ;--- xor ax, ax ; first dir. entry in this sector 193 | xor di, di ;XXX 194 | 195 | ; Search for KERNEL.SYS file name, and find start cluster. 196 | ff_next_entry: mov cx, 11 197 | mov si, filename 198 | ;--- mov di, ax 199 | repe cmpsb 200 | jz ff_done ; note that di now is at dirent+11 201 | 202 | ;--- add ax, 0x20 ; next directory entry 203 | ;--- cmp ax, [bsBytesPerSec] ; end of sector reached? 204 | add di, byte 0x20 ;XXX 205 | and di, byte -0x20 ; 0xffe0 ;XXX 206 | cmp di, [bsBytesPerSec] ;XXX 207 | jnz ff_next_entry 208 | 209 | ;--- pop eax ; restore sector 210 | dec dx ; next sector in cluster 211 | jnz ff_next_sector 212 | 213 | ff_walk_fat: pop eax ; restore current cluster 214 | call next_cluster ; find next cluster 215 | jmp ff_next_clust 216 | 217 | ff_done: push word [es:di+0x14-11] ; get cluster number HI 218 | push word [es:di+0x1A-11] ; get cluster number LO 219 | pop eax ; convert to 32bit 220 | 221 | sub bx, bx ; ES points to LOADSEG 222 | ; (kernel -> ES:BX) 223 | 224 | ; ------------- 225 | 226 | read_kernel: push eax 227 | call convert_cluster 228 | jc boot_success ; EOC encountered - done 229 | ; EDX is sectors in cluster, EAX is sector 230 | 231 | rk_in_cluster: call readDisk 232 | dec dx 233 | jnz rk_in_cluster ; loop over sect. in cluster 234 | 235 | rk_walk_fat: pop eax 236 | call next_cluster 237 | jmp read_kernel 238 | 239 | ;----------------------------------------------------------------------- 240 | 241 | boot_success: mov bl, [drive] 242 | jmp far [loadsegoff_60] 243 | 244 | ;----------------------------------------------------------------------- 245 | 246 | boot_error: mov si, msg_BootError 247 | call print ; modifies AX BX SI 248 | 249 | wait_key: xor ah,ah 250 | int 0x16 ; wait for a key 251 | reboot: int 0x19 ; reboot the machine 252 | 253 | ;----------------------------------------------------------------------- 254 | 255 | ; given a cluster number, find the number of the next cluster in 256 | ; the FAT chain. Needs fat_secshift and fat_start. 257 | ; input: EAX - cluster 258 | ; output: EAX - next cluster 259 | 260 | next_cluster: push es 261 | push di 262 | push bx 263 | 264 | mov di, ax 265 | shl di, 2 ; 32bit FAT 266 | 267 | push ax 268 | mov ax, [bsBytesPerSec] 269 | dec ax 270 | and di, ax ; mask to sector size 271 | pop ax 272 | 273 | shr eax, 7 ; e.g. 9-2 for 512 by/sect. 274 | fat_afterss: ; selfmodifying code: previous byte is patched! 275 | ; (to hold the fat_secshift value) 276 | 277 | add eax, [fat_start] ; absolute sector number now 278 | 279 | mov bx, FATSEG 280 | mov es, bx 281 | sub bx, bx 282 | 283 | cmp eax, [fat_sector] ; already buffered? 284 | jz cn_buffered 285 | mov [fat_sector],eax ; number of buffered sector 286 | call readDisk 287 | 288 | cn_buffered: and byte [es:di+3],0x0f ; mask out top 4 bits 289 | mov eax, [es:di] ; read next cluster number 290 | 291 | pop bx 292 | pop di 293 | pop es 294 | ret 295 | 296 | 297 | ;----------------------------------------------------------------------- 298 | 299 | ; Convert cluster number to the absolute sector number 300 | ; ... or return carry if EndOfChain! Needs data_start. 301 | ; input: EAX - target cluster 302 | ; output: EAX - absolute sector 303 | ; EDX - [bsSectPerClust] (byte) 304 | ; carry clear 305 | ; (if carry set, EAX/EDX unchanged, end of chain) 306 | 307 | convert_cluster: 308 | cmp eax, 0x0ffffff8 ; if end of cluster chain... 309 | jnb end_of_chain 310 | 311 | ; sector = (cluster-2) * clustersize + data_start 312 | dec eax 313 | dec eax 314 | 315 | movzx edx, byte [bsSecPerClust] 316 | push edx 317 | mul edx 318 | pop edx 319 | add eax, [data_start] 320 | ; here, carry is unset (unless parameters are wrong) 321 | ret 322 | 323 | end_of_chain: stc ; indicate EOC by carry 324 | ret 325 | 326 | ;----------------------------------------------------------------------- 327 | 328 | ; PRINT - prints string DS:SI 329 | ; modifies AX BX SI 330 | 331 | printchar: xor bx, bx ; video page 0 332 | mov ah, 0x0e ; print it 333 | int 0x10 ; via TTY mode 334 | print: lodsb ; get token 335 | cmp al, 0 ; end of string? 336 | jne printchar ; until done 337 | ret ; return to caller 338 | 339 | ;----------------------------------------------------------------------- 340 | 341 | ; Read a sector from disk, using LBA 342 | ; input: EAX - 32-bit DOS sector number 343 | ; ES:BX - destination buffer 344 | ; (will be filled with 1 sector of data) 345 | ; output: ES:BX points one byte after the last byte read. 346 | ; EAX - next sector 347 | 348 | readDisk: push dx 349 | push si 350 | push di 351 | 352 | read_next: push eax ; would ax be enough? 353 | mov di, sp ; remember parameter block end 354 | 355 | ;--- db 0x66 ; operand size override (push dword) 356 | push byte 0 ;XXX ; other half of the 32 bits at [C] 357 | ; (did not trust "o32 push byte 0" opcode) 358 | push byte 0 ; [C] sector number high 32bit 359 | push eax ; [8] sector number low 32bit 360 | push es ; [6] buffer segment 361 | push bx ; [4] buffer offset 362 | push byte 1 ; [2] 1 sector (word) 363 | push byte 16 ; [0] size of parameter block (word) 364 | mov si, sp 365 | mov dl, [drive] 366 | mov ah, 42h ; disk read 367 | int 0x13 368 | 369 | mov sp, di ; remove parameter block from stack 370 | ; (without changing flags!) 371 | pop eax ; would ax be enough? 372 | 373 | jnc read_ok ; jump if no error 374 | 375 | push ax ; !! 376 | xor ah, ah ; else, reset and retry 377 | int 0x13 378 | pop ax ; !! 379 | jmp read_next 380 | 381 | read_ok: inc eax ; next sector 382 | add bx, word [bsBytesPerSec] 383 | jnc no_incr_es ; if overflow... 384 | 385 | mov dx, es 386 | add dh, 0x10 ; ...add 1000h to ES 387 | mov es, dx 388 | 389 | no_incr_es: pop di 390 | pop si 391 | pop dx 392 | ret 393 | 394 | ;----------------------------------------------------------------------- 395 | 396 | msg_LoadFreeDOS db "Loading FreeDOS ",0 397 | 398 | times 0x01ee-$+$$ db 0 399 | 400 | msg_BootError db "No " 401 | ; currently, only "kernel.sys not found" gives a message, 402 | ; but read errors in data or root or fat sectors do not. 403 | 404 | filename db "KERNEL SYS" 405 | 406 | sign dw 0, 0xAA55 407 | ; Win9x uses all 4 bytes as magic value here. 408 | -------------------------------------------------------------------------------- /boot/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # makefile for DOS-C boot 3 | # 4 | 5 | !include "../mkfiles/generic.mak" 6 | 7 | ######################################################################## 8 | 9 | all: fat12.bin fat16.bin fat32chs.bin fat32lba.bin oemfat12.bin oemfat16.bin ntfs.bin 10 | 11 | fat12.bin: boot.asm $(DEPENDS) 12 | $(NASM) -DISFAT12 boot.asm -l$*.lst -o$*.bin 13 | 14 | fat16.bin: boot.asm $(DEPENDS) 15 | $(NASM) -DISFAT16 boot.asm -l$*.lst -o$*.bin 16 | 17 | fat32chs.bin: boot32.asm $(DEPENDS) 18 | $(NASM) boot32.asm -l$*.lst -o$*.bin 19 | 20 | fat32lba.bin: boot32lb.asm $(DEPENDS) 21 | $(NASM) boot32lb.asm -l$*.lst -o$*.bin 22 | 23 | oemfat12.bin: oemboot.asm $(DEPENDS) 24 | $(NASM) -DISFAT12 oemboot.asm -l$*.lst -o$*.bin 25 | 26 | oemfat16.bin: oemboot.asm $(DEPENDS) 27 | $(NASM) -DISFAT16 oemboot.asm -l$*.lst -o$*.bin 28 | 29 | ntfs.bin: ntfs.asm $(DEPENDS) 30 | $(NASM) ntfs.asm -l$*.lst -o$*.bin 31 | 32 | ######################################################################## 33 | 34 | clean: 35 | -$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf 36 | 37 | clobber: clean 38 | -$(RM) *.bin status.me 39 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | ECHO Building SYS 3 | MKDIR BIN 2> NUL 4 | PUSHD . 5 | IF "%COMPILER%"=="" GOTO SET_VARS 6 | 7 | :BOOTSECT 8 | ECHO building boot sectors %NASM% 9 | CD BOOT 10 | wmake -h -ms %1 11 | IF NOT %ERRORLEVEL%==0 GOTO ERROR_BS 12 | ECHO boot sectors successfully built 13 | CD .. 14 | 15 | :SYS 16 | ECHO building sys program 17 | CD SYS 18 | wmake -h -ms %1 19 | IF NOT %ERRORLEVEL%==0 GOTO ERROR_SYS 20 | ECHO sys successfully built 21 | CD .. 22 | 23 | GOTO DONE 24 | 25 | 26 | :SET_VARS 27 | SET COMPILER=WATCOM 28 | SET NASM=C:\NASM\NASM.EXE 29 | GOTO BOOTSECT 30 | 31 | :ERROR_BS 32 | ECHO Failure assembling boot sectors 33 | GOTO DONE 34 | 35 | :ERROR_SYS 36 | ECHO Failure compiling sys program 37 | GOTO DONE 38 | 39 | :DONE 40 | POPD 41 | ECHO done. 42 | 43 | :CLEAR_VARS 44 | SET COMPILER= 45 | SET NASM= 46 | -------------------------------------------------------------------------------- /clean.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | ECHO cleaning... 3 | 4 | :BOOTSECT 5 | CD BOOT 6 | wmake -h -ms clobber 7 | CD .. 8 | 9 | :SYS 10 | ECHO building sys program 11 | CD SYS 12 | wmake -h -ms clobber 13 | CD .. 14 | 15 | ECHO done 16 | -------------------------------------------------------------------------------- /docs/sys.htm: -------------------------------------------------------------------------------- 1 | 2 | sys - FreeDOS system file installer 3 | 4 |

sys

5 | Copy system files and make a floppy disk or hard disk bootable. 6 |
  7 |   sys [[d:]path] d: [bootsect] [switches]
  8 | 
9 |

Options

10 |
 11 |   [[d:]path]
 12 |   The (optional) location of the system files.
 13 |   If not given, the current directory is assumed.
 14 | 
 15 |   d:
 16 |   The drive to make bootable.
 17 | 
 18 |   bootsect
 19 |   The name of file, to which the 512-byte boot sector image
 20 |   will be written.
 21 |   (the drive's real boot sector won't be
 22 |    written to unless BOTH is used.)
 23 | 
 24 | Switches (FreeDOS specific):
 25 | 
 26 |   /BOTH
 27 |   The new boot sector will be written to the image file
 28 |   and to the actual drive boot sector.
 29 | 
 30 |   /BOOTONLY
 31 |   With this option the boot sector (or image) will be updated,
 32 |   but the kernel and command.com will
 33 |   not be copied to the destination.
 34 | 
 35 |   /UPDATE
 36 |   This option is for updating (or changing) your kernel while
 37 |   leaving your shell alone.  Updates the boot sector and copies
 38 |   the kernel file(s) to the destination.  [Allows installing
 39 |   latest kernel and boot sector without making a copy of your
 40 |   current COMMAND.COM or other shell first.]  Note: for FreeDOS
 41 |   kernel, an upgrade can also be performed by simply copying
 42 |   KERNEL.SYS over an existing bootable one (though making a 
 43 |   backup of your current kernel is encouraged).
 44 | 
 45 |   /K filename
 46 |   Gives the filename of the kernel file to be copied. This option
 47 |   is only required when the kernel is not called "kernel.sys"
 48 |   Note: when combined with the /L option, allows one to use FreeDOS
 49 |   sys to create a system to boot custom kernels (ie custom OS)
 50 | 
 51 |   /L segment
 52 |   The load segment, in hexadecimal, to use. The default is 0x60.
 53 | 
 54 |   /B btdrv
 55 |   Sets the BIOS boot drive # (in hex) stored within the boot sector.
 56 | 
 57 |   /FORCE:BSDRV
 58 |   Causes the boot sector to only use the btdrv indicated in
 59 |   boot sector.  NOPs the code that normally uses BIOS provided
 60 |   drive # passed at boot time in the DL register.
 61 | 
 62 |   /BACKUPBS [path]filename
 63 |   The original boot sector is written to [path]filename prior
 64 |   to overwriting with FreeDOS one.  The filename may refer to any
 65 |   [image or bs] file, if exists only the 1st 512 bytes will be
 66 |   overwritten.
 67 | 
 68 |   /DUMPBS [path]filename
 69 |   The original boot sector is written to [path]filename and
 70 |   then exits.  The filename may refer to any [image or bs] file,
 71 |   if exists only the 1st 512 bytes will be overwritten.
 72 |   Note: /backupbs is intended to provide a backup of existing
 73 |   boot sector in case one wishes to restore it later (see /restorbs),
 74 |   whereas /dumpbs is intended only as a convenient method to
 75 |   obtain current boot sector (such as for debugging purposes or
 76 |   alternate installation scenerios).
 77 | 
 78 |   /RESTORBS [path]filename
 79 |   Restores original boot sector ([path]filename) and exits.
 80 |   The boot sector specified is written with no modifications.
 81 |   The filename may refer to any [image or bs] file, only the 1st
 82 |   512 bytes are used.
 83 | 
 84 |   /OEM:DOS
 85 |   Where DOS is one of
 86 |     AUTO - the default, attempts to determine automatically,
 87 |                   checking for FreeDOS, DR-DOS, PC-DOS, then MS-DOS;
 88 |     FD   - FreeDOS mode, setup destination drive to boot
 89 |                   the FreeDOS kernel and copy FreeDOS system files
 90 |                   (default to KERNEL.SYS and load segment of 0x60)
 91 |     DR   - use DR DOS 7+ (including Udo Kuhnt's DR-DOS
 92 |                   Enhancement Project) compatible settings
 93 |                   (use IBMBIO.COM & IBMDOS.COM, and loadseg=0x70)
 94 |     PC   - use PC-DOS (any) compatible settings, including
 95 |                   alternate boot sector (supports FAT12/16 only)
 96 |                   Must be explicitly choosen, AUTO selects DR mode.
 97 |                   (use IBMBIO.COM & IBMDOS.COM, and loadseg=0x70)
 98 |     MS   - use MS-DOS (pre 7) compatible settings, including
 99 |                   alternate boot sector (supports FAT12/16 only)
100 |                   (use IO.SYS & MSDOS.SYS, and loadseg=0x70)
101 |     W9x  - use MS-DOS 7+, aka Windows 9x DOS compatible
102 |                   settings, Win ME unsupported ...
103 | 
104 |   Note: when attempting to boot older PC/MS DOS versions, even when
105 |   using the alternate boot sector, one may need to ensure the
106 |   system files are the 1st two filesystem entries and in consecutive
107 |   sectors at the beginning of the drive; so for best results when
108 |   creating a PC/MS DOS boot disk, format the drive first, do NOT
109 |   create a label, and then run sys on it.  You can then add a label.
110 |   Newer releases, such as PC-DOS 7.x do not have these limitations.
111 | 
112 | 
113 |
114 |
115 | Copyright © 1998 Jim Hall
116 | This file is derived from the FreeDOS Spec Command HOWTO. 117 | See the file H2Cpying.txt for copying conditions. 118 |
119 | 120 | 121 | -------------------------------------------------------------------------------- /docs/sys.txt: -------------------------------------------------------------------------------- 1 | FreeDOS System Installer v3.8 - April, 2012 2 | documentation by: 3 | Jeremy Davis 4 | Bart Oldeman 5 | 6 | SYS is the program which will prepare a disk to boot 7 | the operating system. It requires the disk already be 8 | prepared via the format program (this initializes the 9 | file system and places a valid BPB on the disk to describe 10 | the size and other necessary settings to access contents). 11 | SYS will install the code with the logic to load the operating 12 | system to run the computer. Additionally, SYS may copy over 13 | the actual files needed by the operating system to begin. 14 | For FreeDOS this will be the kernel (KERNEL.SYS) and the 15 | command shell (COMMAND.COM). 16 | 17 | FreeDOS SYS's standard behavior is very similar (though in 18 | my opinion improved) to that of other DOSes. 19 | SYS /? (or no options) should provide a general usage. 20 | SYS /? OEM provides overview of DOS versions the given 21 | build of sys will support (which boot sectors included). 22 | For options to configure FreeDOS kernel see SYS CONFIG /? 23 | Note: /? may be replaced with /HELP 24 | 25 | Please refer to the source itself for details, but this 26 | we attempt to maintain this document. 27 | 28 | 29 | Usage: SYS [source] drive [bootsect] [{option}] 30 | source = A:,B:,C:\KERNEL\BIN\,etc., or current directory if not given 31 | drive = drive letter (A:,B:,C:,... or A,B,C,...) to install system to 32 | bootsect = name of 512-byte boot sector file image for drive: 33 | to write to *instead* of real boot sector 34 | {option} is one or more of the following: 35 | /BOTH : write to *both* the real boot sector and the image file 36 | /BOOTONLY: do *not* copy kernel or shell, only update boot sector or image 37 | /UPDATE : copy kernel and update boot sector (do *not* copy shell) 38 | /OEM : indicates boot sector, filenames, and load segment to use 39 | /OEM:FD use FreeDOS compatible settings 40 | /OEM:DR use DR DOS 7+ compatible settings (same as /OEM) 41 | /OEM:PC use PC-DOS compatible settings 42 | /OEM:MS use MS-DOS compatible settings (up to 6.x) 43 | /OEM:W9x use MS Win9x DOS compatible settings (7.x+) 44 | /OEM:Rx use RxDOS compatible settings 45 | /OEM:DE use DEll Real Mode Kernel settings 46 | default is /OEM:AUTO, select DOS based on existing files 47 | /K name : name of kernel to use in boot sector instead of KERNEL.SYS 48 | /L segm : hex load segment to use in boot sector instead of 0x60 49 | /B btdrv : hex BIOS # of boot drive set in bs, 0=A:, 80=1st hd,... 50 | /FORCE : override automatic selection of BIOS related settings 51 | /FORCE:BSDRV (/FORCEDRV) use boot drive # set in bootsector 52 | /FORCE:BIOSDRV use boot drive # provided by BIOS 53 | /FORCE:AUTO select LBA or CHS depending on BIOS availability 54 | /FORCE:LBA always use LBA 55 | /FORCE:CHS always use CHS 56 | /NOBAKBS : skips copying boot sector to backup bs, FAT32 only else ignored 57 | /SKFN filename : copy from filename to kernel (e.g. default would be KERNEL.SYS) 58 | /SCFN filename : copy from filename to COMMAND.COM 59 | /BACKUPBS [path]filename : save current bs before overwriting 60 | /GETBS [path]filename : save current bs to file and exit 61 | /PUTBS [path]filename : replace current bs and exit (updates BPB 1st) 62 | /RESTORBS [path]filename : overwrite bs and exit (does not update BPB) 63 | /BSCODE [path]filename : use external bootcode 64 | /BSCOUNT # : count of sectors bootcode is 65 | /VERBOSE : display additional (debug) output 66 | 67 | SYS /HELP 68 | SYS /HELP OEM 69 | SYS CONFIG /HELP 70 | 71 | The simplest usage: 72 | 73 | SYS drive 74 | 75 | drive should be the drive (A:, B:, C:, ...) you wish 76 | to be bootable with FreeDOS (kernel & command.com) 77 | When using this form, KERNEL.SYS and COMMAND.COM 78 | must reside either in the current directory (which 79 | is searched first) or in recent revisions may also 80 | be in the root directory of the current drive. 81 | 82 | Complete form: 83 | 84 | SYS [source] drive [bootsect [/BOTH]] 85 | 86 | Here drive is the same as before, but this time 87 | you specify where KERNEL.SYS and COMMAND.COM are. 88 | Source may simply be a drive (in this case it 89 | is similar to PC & MS SYS). The current directory 90 | of the specified drive is first searched for 91 | KERNEL.SYS & COMMAND.COM and if not found then 92 | the root directory of the specified drive is tried. 93 | Alternatively, you may specify a path (either fully 94 | qualified or relative) to where KERNEL.SYS and 95 | COMMAND.COM may be found; note that this should 96 | only search this directory and will fail if they 97 | are not found, i.e. it will not check for them on 98 | the root directory of the drive specified when 99 | a path is given. It should also fail if the 100 | source and destination drive are both the same 101 | and would result in trying to SYS from the root 102 | to the root (e.g. trying to SYS from C:\ to C:\). 103 | 104 | If you specify a name for "bootsect", for instance, 105 | bootsect.fd, SYS will write to that file instead of 106 | the real boot sector. You will obtain a 512-byte file 107 | containing the boot sector, which can then be used 108 | for dual booting or diagnostic purposes. 109 | 110 | If you also specify /BOTH, sys will write to both 111 | the image file and the boot sector. 112 | Note: earlier versions of SYS used the option BOTH 113 | (without the slash /), but current versions require 114 | the forward slash for the /BOTH option. 115 | 116 | If enabled in build, the /BOOTMGR option can be 117 | used to to add FreeDOS to boot manager menu. 118 | Sys will add a simple entry to the boot manager 119 | configuration file to chain to the FreeDOS 120 | boot sector or if supported loading the kernel 121 | directly. If a "bootsect" name is provided it 122 | will be used; default name is FREEDOS.BSS. 123 | An error occurs if used with the /BOTH option. 124 | 125 | The /BOOTONLY option may be used to avoid copying 126 | any files, only the boot sector (or optional bootsect 127 | file) while be written. 128 | 129 | The /UPDATE option is used when updating the 130 | FreeDOS kernel. Both the boot sector (or bootsect 131 | file) is written and the kernel (KERNEL.SYS) is 132 | copied to the destination drive. (The default 133 | without /BOOTONLY or /UPDATE is to update the 134 | boot sector and copy both the kernel and shell 135 | to the destination drive.) 136 | 137 | The /FORCE options override the default actions 138 | to use. There are two separate groups of options. 139 | :AUTO, :LBA, or :CHS determine which method of 140 | communicating with the computer's BIOS is used to 141 | read the drive when loading the operating system. 142 | On FAT32 drives /FORCE:LBA and /FORCE:CHS 143 | will select which boot sector code is used (default 144 | same as /FORCE:AUTO will choose based on query of 145 | BIOS support for LBA extensions and use LBA if it 146 | is supported else only CHS will be used). Note that 147 | due to limited space, on FAT32 only one or the other 148 | of the access methods is supported, but for FAT12 or 149 | FAT16 both are available so support can be queried 150 | at boot time. Using CHS is supported for backward 151 | compatibility across most computers but limits the 152 | location on the disk to that supported by CHS (generally 153 | within 1st 8GB on newer computers) and has most issues 154 | if drive is used on different computer. LBA is best 155 | but not supported on all (mostly older) computers. 156 | On FAT12 and FAT16 drives specifying /FORCE:LBA will ensure 157 | even 1st floppy drive attempts to use LBA support 158 | (note that CHS may still be used if LBA check fails) 159 | and /FORCE:CHS will always bypass use of LBA extensions. 160 | :BSDRV or :BIOSDRV determines whether to use drive 161 | specified by computer's BIOS (/FORCE:BIOSDRV) to load 162 | the os from or if the value stored in the boot sector 163 | should be used (/FORCE:BSDRV). The :BSDRV option is 164 | useful if the computer's BIOS does not provide a valid 165 | drive # (0=1st floppy, 1=2nd floppy, ... 80=1st hard drive, 166 | 81=2nd hard drive, ...) or for advanced/computer specific 167 | booting (i.e. chaining to 2nd hard drive). The drive 168 | number may be set via the /B btdrv option. By default 169 | it is set to 0 for floppy and 80 if sys'ing a hard drive. 170 | 171 | *** For OEM compatible support one should format the drive 172 | and then immediately run sys before adding any other 173 | files or even volume label for maximum compatibility. 174 | A future update to sys will ensure the 1st two directory 175 | entries are the kernel files, but currently not implemented. 176 | 177 | Multiple versions of DOS are optionally supported 178 | (determined at build time) via included boot sectors. 179 | The primary usage of this feature is to allow the same drive 180 | to multiboot via simple SYS followed by reboot (e.g. 181 | for testing) and to allow creation of boot disks (where 182 | most other versions of SYS will only run if corresponding 183 | version of DOS kernel is already running - MS-DOS 5 can't 184 | be used to run sys for PC-DOS 4, etc.). The default boot 185 | sector will load the complete kernel and chain to it. 186 | This one (referred to as the standard or FreeDOS boot 187 | sector) is used to boot FreeDOS and Enhanced DR-DOS kernels. 188 | The OEM compatible boot sector (if included) is used to 189 | boot other versions of DOS including Microsoft's MS-DOS, 190 | IBM's PC-DOS, RX-DOS, Dell's Real Mode Kernel (DRMK-DOS), 191 | and other operating systems with similar requirements to 192 | traditional DOS kernels (1st few sectors of kernel only). 193 | Refer to the boot sector's code for explicit registers 194 | that parameters are passed in what is supported - where 195 | different versions of even the same vendor's DOS may 196 | require different information. 197 | 198 | The /NOBAKBS option disable the storing of a second copy 199 | of the boot sector on file systems that store multiple 200 | copies of the boot code. Currently only FAT32 is supported 201 | that uses this feature. When multi-booting it may be 202 | best to use this option so all of the original operating 203 | systems backup boot sectors are unchanged (FreeDOS uses 204 | only 1 sector even for FAT32, whereas other operating 205 | systems may use multiple sectors on FAT32 drives). 206 | Note: if writing boot sector to a file instead of disk 207 | then this option is ignored as neither primary nor backup 208 | boot sector will be written. 209 | 210 | The boot code used is fairly generic and may be used to 211 | boot other operating systems, even hobby ones. To facilitate 212 | the varied kernel names and load segments the options 213 | /K and /L may be utilized. E.g. to boot a fictional 214 | operating system MyOS which uses a kernel named MYOS.BIN 215 | and requires it to be loaded at segment 0x70 the following 216 | sys command line could be used, assuming a copy of the os 217 | files are on drive C: and we want drive A: to be bootable: 218 | SYS C: A: /UPDATE /K MYOS.BIN /L 70 219 | where /UPDATE option is used to allow copying MYOS.BIN but 220 | avoid attempting to copy COMMAND.COM. 221 | 222 | To allow keeping multiple versions of the kernel and selecting 223 | a specific one to use to make a drive bootable the /SKFN 224 | option can be used. This option Sets the Kernel FileName as 225 | the source filename used for the copy to destination. It does 226 | not effect the resulting file name nor filename indicated 227 | in the boot sector (use /K name to change the destination name). 228 | E.g. if KE2040.SYS and KE2041.SYS are in the current drive then: 229 | SYS A: /SKFN KE2041.SYS /UPDATE 230 | will set A: to boot a file named KERNEL.SYS (the default name 231 | used for FreeDOS) and copy the file named KE2041.SYS to 232 | A:\KERNEL.SYS, and since update is used leave COMMAND.COM unchanged. 233 | E.g. if FD.SYS and EDR.SYS are in current drive then: 234 | SYS A: /SKFN EDR.SYS /L 70 /K DRBIO.SYS 235 | is mostly equivalent to 236 | SYS A: /OEM:DR /SKFN EDR.SYS 237 | which copies EDR.SYS to A:DRBIO.SYS, copies COMMAND.COM to A:COMMAND.COM 238 | and places the standard boot sector on floppy loading kernel 239 | at 0x70 (instead of default 0x60 segment). 240 | 241 | The /SCFN option is similar to /SKFN except is specifies the 242 | source name of COMMAND.COM; it is always copied to destination 243 | as COMMAND.COM. E.g. to use 4DOS.COM 244 | SYS A: /SCFN 4DOS.COM 245 | will write the boot sector, copy the kernel, and then copy 246 | 4DOS.COM to A:\COMMAND.COM (instead of attempting to copy 247 | COMMAND.COM to A:\COMMAND.COM). 248 | 249 | As the boot sector is important for the proper booting of a 250 | computer there are several options to work with the boot sector. 251 | /BACKUPBS is used to during normal operations to create a copy 252 | of the current boot sector before SYS makes any changes to it. 253 | Logically using /BACKUPBS file.bs is the same as 1st running 254 | SYS with the /GETBS file.bs option then rerunning to set the 255 | boot sector and copy files. E.g. 256 | SYS C: A: /BACKUPBS orig.bs 257 | is the same as running the following two commands: 258 | SYS A: /GETBS orig.bs 259 | SYS C: A: 260 | To retrieve and set the boot sector directly then /GETBS and 261 | /PUTBS commands should be used. Note: in earlier versions 262 | /GETBS was /DUMPBS which still works as an alias to /GETBS. 263 | The /GETBS command will copy the current boot sector code 264 | to specified filename and exit. E.g. 265 | SYS C: /GETBS backup.bs 266 | will copy the current boot sector of drive C: to file named backup.bs 267 | To later fix or update the boot sector with a previously saved 268 | boot sector (or maybe one you are developing/testing) use the 269 | /PUTBS option. This will copy the settings from the drive's 270 | current BPB to the new boot sector then write it to the drive. E.g. 271 | SYS C: /PUTBS backup.bs 272 | will load backup.bs, copy the current C: drive's BPB information 273 | (which gives the # sectors, heads, etc.) to it and then overwrite 274 | drive C:'s boot sector with the new code and exit. 275 | If you are using the exact same drive and computer then the 276 | /RESTORBS (or /RESTOREBS) option may be used - it does not make 277 | any changes to the loaded BPB so should only be used on the same 278 | computer and drive from a previous /GETBS command (or other program 279 | that retrieved the boot sector). 280 | 281 | New with SYS 3.8 is the ability to set the boot sector of a drive 282 | using external (to SYS command) boot code via /BSCODE option. 283 | This can be used for development purposes or to copy the boot 284 | sector from a previous /GETBS call or disk image file and write 285 | to specified drive. Note that the BPB will be updated prior to 286 | writing to drive, so may be used from boot code for different 287 | drive or ones written from a different computer. 288 | 289 | The /VERBOSE option may be used to see additional details during 290 | the system installation process. It is useful for the curious 291 | and to help if there are issues booting/running the SYS command. 292 | 293 | 294 | 295 | FreeDOS Kernel Configuration Options: 296 | 297 | Simplest form: 298 | 299 | SYS CONFIG 300 | 301 | This will simply display the current settings 302 | for the file KERNEL.SYS in the current directory. 303 | It is useful to see what the options are currently 304 | set to, what options are supported, and should 305 | show valid values along with defaults (defaults are 306 | the valid values with a '*' next to them). 307 | 308 | Optionally specify file: 309 | 310 | SYS CONFIG [drive][path]KERNEL.SYS 311 | 312 | This form behaves as above, except will display 313 | the settings for the kernel file you specify. 314 | drive and path are optional, and generally just 315 | a \ will be used to indicate root directory of 316 | current drive. KERNEL.SYS specifies the filename 317 | of the kernel, which may not be "KERNEL.SYS", 318 | for example when testing you want to alter 319 | KERNTEST.SYS and later copy (or rename) this to 320 | KERNEL.SYS for booting. 321 | 322 | 323 | Changing options: 324 | 325 | SYS CONFIG OPTION1=value [OPTION2=value ...] 326 | 327 | This form will read the current settings from 328 | the kernel (KERNEL.SYS in the current directory) 329 | and set the options specified to the value given. 330 | If the value is potentially invalid (too large, too 331 | small, etc) then a warning will be displayed, but 332 | the change will still occur. The kernel file is 333 | only updated if at least one option is different from the 334 | current settings. If you wish to force the kernel 335 | file to be written to, then set the same option 336 | twice (OPTION1=oddvalue OPTION1=desiredvalue), with 337 | the 1st time the value being different from the 338 | current one and the rightmost one being the desired 339 | value. Currently three options are supported. 340 | Note: currently only the 1st three letters are 341 | actually checked, so they may be abreviated to 342 | DLA, SHO, and SKI and with my recent patch you may 343 | specify the value as either a decimal number 0,10,255,... 344 | or as a hexidecimal number 0x0,0xA, 0xFF... 345 | 346 | DLASORT which may be set to 0 or 1 347 | DLASORT=0 or DLASORT=1 348 | This option is for specifying whether Drive Letter 349 | Assignment should follow the normal MSDOS way of 350 | all primary partitions across drives and then 351 | extended partitions, or the more logical 352 | all partitions (primary & extended) on the 1st 353 | drive, then repeat for all following drives 354 | (all primary & extended, then try next drive). 355 | 0 corresponds to MS way and 1 corresponds to first 356 | drive completely, then next ... 357 | 358 | SHOWDRIVEASSIGNMENT which may be 0 or 1 359 | SHOWDRIVEASSIGNMENT=0 or SHOWDRIVEASSIGNMENT=1 360 | If 1 then the normal drive assignment information 361 | is displayed upon booting. If 0 then this information 362 | is supressed (not shown). 363 | 364 | SKIPCONFIGSECONDS which may be -128 to 127. 365 | A negative value ( < 0 ) indicates that F5/F8 366 | processing will be skipped (the kernel won't check 367 | if you pressed these keys, so you can't skip config 368 | file (CONFIG.SYS) processing). A 0 means you must 369 | have pressed the key precisely for when the kernel 370 | checks for it - essentially skipping, though a well 371 | timed finger will still get to use it. And any value 372 | greater than 0 is the number of seconds the kernel will 373 | display the prompt and wait for you to press the key 374 | before assuming you didn't. 375 | 376 | FORCELBA which may be 0 or 1 377 | FORCELBA=0 or FORCELBA=1 378 | If 1 then the kernel will use LBA (extended INT13) 379 | techniques to address all partitions if possible, 380 | even if these have a non-LBA partition type and 381 | are completely below cylinder 1023 (usually the 8GB 382 | boundary). This is 0 by default, for compatibility 383 | reasons. Setting this to 1 may bypass some buggy 384 | BIOSes and gives slightly better performance. 385 | 386 | GLOBALENABLELBASUPPORT which maybe 0 or 1 387 | GLOBALENABLELBASUPPORT=0 or GLOBALENABLELBASUPPORT=1 388 | If 0 then LBA will be completely disabled, irrespective 389 | of the FORCELBA setting. You need this if FreeDOS thinks 390 | you have LBA available, but in reality you do not. 391 | This setting is set to 1 by default. 392 | 393 | Example: To set the kernel in the current directory 394 | to have a timeout of 5 seconds (default is 2) run 395 | SYS CONFIG SKI=5 396 | 397 | 398 | Changing options of specified file: 399 | 400 | SYS CONFIG [drive][path]KERNEL.SYS OPTION1=value ...] 401 | 402 | This is just like previous section on setting options, 403 | except the first argument after CONFIG specifies which 404 | kernel file to use. The filename is the same form used 405 | for displaying options of specified kernel file described 406 | above. 407 | 408 | Example2: To set a kernel in the root directory to 409 | not show drive assignment and change the timeout 410 | to never check 411 | SYS CONFIG \KERNEL.SYS SKI=-1 SHOWDRIVEASSIGNMENT=0x0 412 | 413 | 414 | 415 | * All trade marks (TM) belong to respective companies and 416 | use within this document only for indicating given variant, 417 | all rights reserved respective owners, use in this document 418 | does not indicates owners knowledge or other... 419 | -------------------------------------------------------------------------------- /hdr/algnbyte.h: -------------------------------------------------------------------------------- 1 | 2 | #if defined(_MSC_VER) 3 | #if _MSC_VER >= 700 4 | #pragma warning(disable:4103) 5 | #endif 6 | #pragma pack(1) 7 | #elif defined(_QC) || defined(__WATCOMC__) || defined(__GNUC__) 8 | #pragma pack(1) 9 | #elif defined(__ZTC__) 10 | #pragma ZTC align 1 11 | #elif defined(__TURBOC__) && (__TURBOC__ > 0x202) 12 | #pragma option -a- 13 | #endif 14 | -------------------------------------------------------------------------------- /hdr/dcb.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* dcb.h */ 4 | /* */ 5 | /* DOS Device Control Block Structure */ 6 | /* */ 7 | /* November 20, 1991 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | 32 | /* Internal drive parameter block */ 33 | struct dpb { 34 | BYTE dpb_unit; /* unit for error reporting */ 35 | BYTE dpb_subunit; /* the sub-unit for driver */ 36 | UWORD dpb_secsize; /* sector size */ 37 | UBYTE dpb_clsmask; /* mask (sectors/cluster-1) */ 38 | UBYTE dpb_shftcnt; /* log base 2 of cluster size */ 39 | UWORD dpb_fatstrt; /* FAT start sector */ 40 | UBYTE dpb_fats; /* # of FAT copies */ 41 | UWORD dpb_dirents; /* # of dir entries */ 42 | UWORD dpb_data; /* start of data area */ 43 | UWORD dpb_size; /* # of clusters+1 on media */ 44 | UWORD dpb_fatsize; /* # of sectors / FAT */ 45 | UWORD dpb_dirstrt; /* start sec. of root dir */ 46 | struct dhdr FAR * /* pointer to device header */ 47 | dpb_device; 48 | UBYTE dpb_mdb; /* media descr. byte */ 49 | BYTE dpb_flags; /* -1 = force MEDIA CHK */ 50 | struct dpb FAR * /* next dpb in chain */ 51 | dpb_next; /* -1 = end */ 52 | UWORD dpb_cluster; /* cluster # of first free */ 53 | /* -1 if not known */ 54 | #ifndef WITHFAT32 55 | UWORD dpb_nfreeclst; /* number of free clusters */ 56 | /* -1 if not known */ 57 | #else 58 | union { 59 | struct { 60 | UWORD dpb_nfreeclst_lo; 61 | UWORD dpb_nfreeclst_hi; 62 | } dpb_nfreeclst_st; 63 | ULONG _dpb_xnfreeclst; /* number of free clusters */ 64 | /* -1 if not known */ 65 | } dpb_nfreeclst_un; 66 | #define dpb_nfreeclst dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_lo 67 | #define dpb_xnfreeclst dpb_nfreeclst_un._dpb_xnfreeclst 68 | 69 | UWORD dpb_xflags; /* extended flags, see bpb */ 70 | UWORD dpb_xfsinfosec; /* FS info sector number, */ 71 | /* 0xFFFF if unknown */ 72 | UWORD dpb_xbackupsec; /* backup boot sector number */ 73 | /* 0xFFFF if unknown */ 74 | ULONG dpb_xdata; 75 | ULONG dpb_xsize; /* # of clusters+1 on media */ 76 | ULONG dpb_xfatsize; /* # of sectors / FAT */ 77 | CLUSTER dpb_xrootclst; /* starting cluster of root dir */ 78 | CLUSTER dpb_xcluster; /* cluster # of first free */ 79 | /* -1 if not known */ 80 | #endif 81 | }; 82 | 83 | #define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ 84 | #define XUNKNCLSTFREE 0xffffffffl /* unknown for DOS */ 85 | #define UNKNCLSTFREE 0xffff /* unknown for DOS */ 86 | -------------------------------------------------------------------------------- /hdr/fat.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* fat.h */ 4 | /* */ 5 | /* FAT File System data structures & declarations */ 6 | /* */ 7 | /* November 26, 1991 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | 32 | /* FAT file system attribute bits */ 33 | #define D_NORMAL 0 /* normal */ 34 | #define D_RDONLY 0x01 /* read-only file */ 35 | #define D_HIDDEN 0x02 /* hidden */ 36 | #define D_SYSTEM 0x04 /* system */ 37 | #define D_VOLID 0x08 /* volume id */ 38 | #define D_DIR 0x10 /* subdir */ 39 | #define D_ARCHIVE 0x20 /* archive bit */ 40 | /* /// Added D_DEVICE bit. - Ron Cemer */ 41 | #define D_DEVICE 0x40 /* device bit */ 42 | 43 | #define D_LFN (D_RDONLY | D_HIDDEN | D_SYSTEM | D_VOLID) 44 | #define D_ALL (D_RDONLY | D_HIDDEN | D_SYSTEM | D_DIR | D_ARCHIVE) 45 | 46 | /* FAT file name constants */ 47 | #define FNAME_SIZE 8 48 | #define FEXT_SIZE 3 49 | 50 | /* FAT deleted flag */ 51 | #define DELETED '\x5' /* if first char, delete file */ 52 | #define EXT_DELETED '\xe5' /* external deleted flag */ 53 | 54 | /* Test for 16 bit or 12 bit FAT */ 55 | #define SIZEOF_CLST16 2 56 | #define SIZEOF_CLST32 4 57 | 58 | /* FAT cluster special flags */ 59 | #define FREE 0x000 60 | 61 | #ifdef WITHFAT32 62 | #define LONG_LAST_CLUSTER 0x0FFFFFFFUL 63 | #define LONG_BAD 0x0FFFFFF7UL 64 | #else 65 | #define LONG_LAST_CLUSTER 0xFFFF 66 | #define LONG_BAD 0xFFF7 67 | #endif 68 | #define MASK16 0xFFF8 69 | #define BAD16 0xFFF7 70 | #define MASK12 0xFF8 71 | #define BAD12 0xFF7 72 | 73 | /* magic constants: even though FF7 is BAD so FF6 could be a valid cluster 74 | no., MS docs specify that FF5 is the maximal possible cluster number 75 | for FAT12; similar for 16 and 32 */ 76 | 77 | #define FAT_MAGIC 4085 78 | #define FAT_MAGIC16 65525U 79 | #define FAT_MAGIC32 268435455UL 80 | 81 | /* int ISFAT32(struct dpb FAR *dpbp);*/ 82 | #define ISFAT32(x) _ISFAT32(x) 83 | 84 | /* 85 | #define _ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 && ((dpbp)->dpb_size)<=FAT_MAGIC32 ) 86 | */ 87 | #define _ISFAT32(dpbp) (((dpbp)->dpb_fatsize)==0) 88 | #define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC && ((dpbp)->dpb_size)<=FAT_MAGIC16 ) 89 | #define ISFAT12(dpbp) ((((dpbp)->dpb_size)-1)dir_start) 132 | #define setdstart(dpbp, dentry, value) \ 133 | (((dentry)->dir_start) = (UWORD)(value)) 134 | #define checkdstart(dpbp, dentry, value) \ 135 | (((dentry)->dir_start) == (UWORD)(value)) 136 | #endif 137 | 138 | #define DIR_NAME 0 139 | #define DIR_EXT FNAME_SIZE 140 | #define DIR_ATTRIB (FNAME_SIZE+FEXT_SIZE) 141 | #define DIR_RESERVED (FNAME_SIZE+FEXT_SIZE+1) 142 | #define DIR_TIME (FNAME_SIZE+FEXT_SIZE+11) 143 | #define DIR_DATE (FNAME_SIZE+FEXT_SIZE+13) 144 | #define DIR_START (FNAME_SIZE+FEXT_SIZE+15) 145 | #define DIR_SIZE (FNAME_SIZE+FEXT_SIZE+17) 146 | 147 | #define DIRENT_SIZE 32 148 | 149 | -------------------------------------------------------------------------------- /hdr/kconfig.h: -------------------------------------------------------------------------------- 1 | /* 2 | KConfig.h 3 | 4 | DLASortByDriveNo 5 | 0 : Drive Letter Assignement ike MSDOS 6 | 1 : DLA - first drive completely first, then to next drive 7 | 8 | InitDiskShowDriveAssignment 9 | 0 : don't show what drive/partition assigned to what drive letter 10 | 1 : show info 11 | 12 | SkipConfigSeconds: 13 | < 0 : not possible to skip config.sys 14 | = 0 : only possible if already pressed before, no message 15 | > 0 : wait so long for F5/F8 16 | 17 | BootHarddiskSeconds: boots by default - and without user interaction - from HD 18 | <= 0: normal 19 | > 0: 20 | display message 21 | ' hit any key to continue to boot from 'diskette or CD' 22 | wait ## seconds 23 | if no key hit, boot from HD 24 | 25 | Version_: only in kernel 2042 or higher, offline version identification 26 | OemID: 0xFD for FreeDOS kernel, 0xDC for DosC kernel 27 | Major: actual kernel version (not MS-DOS compatibility version), e.g. 2 28 | Revision: revision sequence, e.g. 42 for kernel 2042 29 | Release: 0 if released version, >0 for svn builds (e.g. svn revision #) 30 | 31 | */ 32 | typedef struct _KernelConfig { 33 | char CONFIG[6]; /* "CONFIG" */ 34 | unsigned short ConfigSize; 35 | 36 | unsigned char DLASortByDriveNo; 37 | unsigned char InitDiskShowDriveAssignment; 38 | signed char SkipConfigSeconds; 39 | unsigned char ForceLBA; 40 | unsigned char GlobalEnableLBAsupport; /* = 0 --> disable LBA support */ 41 | signed char BootHarddiskSeconds; 42 | 43 | /* for version 2042 and higher only */ 44 | unsigned char Version_OemID; 45 | unsigned char Version_Major; 46 | unsigned short Version_Revision; 47 | unsigned short Version_Release; 48 | 49 | } KernelConfig; 50 | -------------------------------------------------------------------------------- /hdr/portab.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* portab.h */ 4 | /* */ 5 | /* DOS-C portability typedefs, etc. */ 6 | /* */ 7 | /* May 1, 1995 */ 8 | /* */ 9 | /* Copyright (c) 1995 */ 10 | /* Pasquale J. Villani */ 11 | /* All Rights Reserved */ 12 | /* */ 13 | /* This file is part of DOS-C. */ 14 | /* */ 15 | /* DOS-C is free software; you can redistribute it and/or */ 16 | /* modify it under the terms of the GNU General Public License */ 17 | /* as published by the Free Software Foundation; either version */ 18 | /* 2, or (at your option) any later version. */ 19 | /* */ 20 | /* DOS-C is distributed in the hope that it will be useful, but */ 21 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 22 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 23 | /* the GNU General Public License for more details. */ 24 | /* */ 25 | /* You should have received a copy of the GNU General Public */ 26 | /* License along with DOS-C; see the file COPYING. If not, */ 27 | /* write to the Free Software Foundation, 675 Mass Ave, */ 28 | /* Cambridge, MA 02139, USA. */ 29 | /****************************************************************/ 30 | 31 | #include 32 | 33 | /****************************************************************/ 34 | /* */ 35 | /* Machine dependant portable types. Note that this section is */ 36 | /* used primarily for segmented architectures. Common types and */ 37 | /* types used relating to segmented operations are found here. */ 38 | /* */ 39 | /* Be aware that segmented architectures impose on linear */ 40 | /* architectures because they require special types to be used */ 41 | /* throught the code that must be reduced to empty preprocessor */ 42 | /* replacements in the linear machine. */ 43 | /* */ 44 | /* #ifdef */ 45 | /* # define FAR far */ 46 | /* # define NEAR near */ 47 | /* #endif */ 48 | /* */ 49 | /* #ifdef */ 50 | /* # define FAR */ 51 | /* # define NEAR */ 52 | /* #endif */ 53 | /* */ 54 | /****************************************************************/ 55 | 56 | /* commandline overflow - removing -DI86 TE */ 57 | #if defined(__TURBOC__) 58 | 59 | #define I86 60 | #define CDECL cdecl 61 | #if __TURBOC__ > 0x202 62 | #if __TURBOC__ < 0x400 /* targeted to TC++ 1.0 which is 0x297 (3.1 is 0x410) */ 63 | #pragma warn -pia /* possibly incorrect assignment */ 64 | #pragma warn -sus /* suspicious pointer conversion */ 65 | /* 66 | * NOTE: The above enable TC++ to build the kernel, but it's not recommended 67 | * for development. Use [Open]Watcom (the best!) or newer Borland compilers! 68 | */ 69 | #endif 70 | /* printf callers do the right thing for tc++ 1.01 but not tc 2.01 */ 71 | #define VA_CDECL 72 | #else 73 | #define VA_CDECL cdecl 74 | #endif 75 | #define PASCAL pascal 76 | void __int__(int); 77 | #ifndef FORSYS 78 | void __emit__(char, ...); 79 | #define disable() __emit__(0xfa) /* cli; disable interrupts */ 80 | #define enable() __emit__(0xfb) /* sti; enable interrupts */ 81 | #define halt() __emit__(0xf4) /* hlt; halt until interrupt */ 82 | #endif 83 | 84 | #elif defined (_MSC_VER) 85 | 86 | #define I86 87 | #define asm __asm 88 | #pragma warning(disable: 4761) /* "integral size mismatch in argument; 89 | 90 | conversion supplied" */ 91 | #ifndef CDECL 92 | #define CDECL _cdecl 93 | #define VA_CDECL 94 | #define PASCAL pascal 95 | #endif 96 | #define __int__(intno) asm int intno; 97 | #define disable() asm cli 98 | #define enable() asm sti 99 | #define halt() asm hlt 100 | #define _CS getCS() 101 | static unsigned short __inline getCS(void) 102 | { 103 | asm mov ax, cs; 104 | } 105 | #define _SS getSS() 106 | static unsigned short __inline getSS(void) 107 | { 108 | asm mov ax, ss; 109 | } 110 | 111 | #elif defined(__WATCOMC__) /* don't know a better way */ 112 | 113 | #ifdef __DOS__ 114 | #define I86 115 | #define __int__(intno) asm int intno; 116 | void disable(void); 117 | #pragma aux disable = "cli" modify exact []; 118 | void enable(void); 119 | #pragma aux enable = "sti" modify exact []; 120 | void halt(void); 121 | #pragma aux halt = "hlt" modify exact []; 122 | #define asm __asm 123 | #define far __far 124 | #define CDECL __cdecl 125 | #define VA_CDECL 126 | #define PASCAL pascal 127 | #define _CS getCS() 128 | unsigned short getCS(void); 129 | #pragma aux getCS = "mov dx,cs" value [dx] modify exact[dx]; 130 | #define _SS getSS() 131 | unsigned short getSS(void); 132 | #pragma aux getSS = "mov dx,ss" value [dx] modify exact[dx]; 133 | 134 | #if !defined(FORSYS) && !defined(EXEFLAT) && _M_IX86 >= 300 135 | #pragma aux default parm [ax dx cx] modify [ax dx es fs] /* min.unpacked size */ 136 | /* #pragma aux default parm [ax dx] modify [ax bx cx dx es fs]min.packed size */ 137 | #endif 138 | #endif /* DOS */ 139 | 140 | /* enable Possible loss of precision warning for compatibility with Borland */ 141 | #pragma enable_message(130) 142 | 143 | #if _M_IX86 >= 300 || defined(M_I386) 144 | #define I386 145 | #endif 146 | 147 | #elif defined (_MYMC68K_COMILER_) 148 | 149 | #define MC68K 150 | 151 | #elif defined(__GNUC__) 152 | /* for warnings only ! */ 153 | #define MC68K 154 | 155 | #else 156 | #error Unknown compiler 157 | We might even deal with a pre-ANSI compiler. This will certainly not compile. 158 | #endif 159 | 160 | #ifdef I86 161 | #if _M_IX86 >= 300 || defined(M_I386) 162 | #define I386 163 | #elif _M_IX86 >= 100 || defined(M_I286) 164 | #define I186 165 | #endif 166 | #endif 167 | 168 | #ifdef MC68K 169 | #define far /* No far type */ 170 | #define interrupt /* No interrupt type */ 171 | #define VOID void 172 | #define FAR /* linear architecture */ 173 | #define NEAR /* " " */ 174 | #define INRPT interrupt 175 | #define REG register 176 | #define API int /* linear architecture */ 177 | #define NONNATIVE 178 | #define PARASIZE 4096 /* "paragraph" size */ 179 | #define CDECL 180 | #define PASCAL 181 | #ifdef __GNUC__ 182 | #define CONST const 183 | #define PROTO 184 | typedef __SIZE_TYPE__ size_t; 185 | #else 186 | #define CONST 187 | typedef unsigned size_t; 188 | #endif 189 | #endif 190 | #ifdef I86 191 | #define VOID void 192 | #define FAR far /* segment architecture */ 193 | #define NEAR near /* " " */ 194 | #define INRPT interrupt 195 | #define CONST const 196 | #define REG register 197 | #define API int far pascal /* segment architecture */ 198 | #define NATIVE 199 | #define PARASIZE 16 /* "paragraph" size */ 200 | typedef unsigned size_t; 201 | #endif 202 | /* functions, that are shared between C and ASM _must_ 203 | have a certain calling standard. These are declared 204 | as 'ASMCFUNC', and is (and will be ?-) cdecl */ 205 | #define ASMCFUNC CDECL 206 | #define ASMPASCAL PASCAL 207 | #define ASM ASMCFUNC 208 | /* */ 209 | /* Boolean type & definitions of TRUE and FALSE boolean values */ 210 | /* */ 211 | typedef int BOOL; 212 | #ifndef FALSE 213 | #define FALSE (1==0) 214 | #define TRUE (1==1) 215 | #endif 216 | 217 | /* */ 218 | /* Common pointer types */ 219 | /* */ 220 | #ifndef NULL 221 | #define NULL 0 222 | #endif 223 | 224 | /* */ 225 | /* Convienence defines */ 226 | /* */ 227 | #define FOREVER while(TRUE) 228 | #ifndef max 229 | #define max(a,b) (((a) > (b)) ? (a) : (b)) 230 | #endif 231 | #ifndef min 232 | #define min(a,b) (((a) < (b)) ? (a) : (b)) 233 | #endif 234 | 235 | /* */ 236 | /* Common byte, 16 bit and 32 bit types */ 237 | /* */ 238 | #ifndef _WIN32 239 | typedef char BYTE; 240 | typedef short WORD; 241 | typedef long DWORD; 242 | #endif 243 | 244 | typedef unsigned char UBYTE; 245 | typedef unsigned short UWORD; 246 | typedef unsigned long UDWORD; 247 | 248 | typedef short SHORT; 249 | 250 | typedef unsigned int BITS; /* for use in bit fields(!) */ 251 | 252 | typedef int COUNT; 253 | typedef unsigned int UCOUNT; 254 | typedef unsigned long ULONG; 255 | 256 | #ifdef WITHFAT32 257 | typedef unsigned long CLUSTER; 258 | #else 259 | typedef unsigned short CLUSTER; 260 | #endif 261 | typedef unsigned short UNICODE; 262 | 263 | #if defined(STATICS) || defined(__WATCOMC__) 264 | #define STATIC static /* local calls inside module */ 265 | #else 266 | #define STATIC 267 | #endif 268 | 269 | #ifdef UNIX 270 | typedef char FAR *ADDRESS; 271 | #elif _WIN32 272 | typedef void * ADDRESS; 273 | #else 274 | typedef void FAR *ADDRESS; 275 | #endif 276 | 277 | #ifdef STRICT 278 | typedef signed long LONG; 279 | #else 280 | #define LONG long 281 | #endif 282 | 283 | typedef UWORD ofs_t; 284 | typedef UWORD seg_t; 285 | 286 | #define lonibble(v) (0x0f & (v)) 287 | #define hinibble(v) (0xf0 & (v)) 288 | 289 | #if CHAR_BIT == 8 290 | # define lobyte(v) ((UBYTE)(v)) 291 | #else 292 | # define lobyte(v) ((UBYTE)(0xff & (v))) 293 | #endif 294 | #define hibyte(v) lobyte ((UWORD)(v) >> 8u) 295 | 296 | #if USHRT_MAX == 0xFFFF 297 | # define loword(v) ((unsigned short)(v)) 298 | #else 299 | # define loword(v) (0xFFFF & (unsigned)(v)) 300 | #endif 301 | #define hiword(v) loword ((v) >> 16u) 302 | 303 | #define MK_UWORD(hib,lob) (((UWORD)(hib) << 8u) | (UBYTE)(lob)) 304 | #define MK_ULONG(hiw,low) (((ULONG)(hiw) << 16u) | (UWORD)(low)) 305 | 306 | /* General far pointer macros */ 307 | #ifdef I86 308 | #ifndef MK_FP 309 | 310 | #if defined __WATCOMC__ 311 | #define MK_FP(seg,ofs) (((UWORD)(seg)):>((VOID *)(ofs))) 312 | #elif __TURBOC__ > 0x202 313 | #define MK_FP(seg,ofs) ((void _seg *)(seg) + (void near *)(ofs)) 314 | #else 315 | #define MK_FP(seg,ofs) ((void FAR *)MK_ULONG(seg, ofs)) 316 | #endif 317 | 318 | #define pokeb(seg, ofs, b) (*(unsigned char far *)MK_FP(seg,ofs) = (b)) 319 | #define poke(seg, ofs, w) (*(unsigned far *)MK_FP(seg,ofs) = (w)) 320 | #define pokew poke 321 | #define pokel(seg, ofs, l) (*(unsigned long far *)MK_FP(seg,ofs) = (l)) 322 | #define peekb(seg, ofs) (*(unsigned char far *)MK_FP(seg,ofs)) 323 | #define peek(seg, ofs) (*(unsigned far *)MK_FP(seg,ofs)) 324 | #define peekw peek 325 | #define peekl(seg, ofs) (*(unsigned long far *)MK_FP(seg,ofs)) 326 | 327 | #if __TURBOC__ > 0x202 328 | #define FP_SEG(fp) ((unsigned)(void _seg *)(void far *)(fp)) 329 | #else 330 | #define FP_SEG(fp) hiword ((ULONG)(VOID FAR *)(fp)) 331 | #endif 332 | 333 | #define FP_OFF(fp) loword (fp) 334 | 335 | #endif 336 | #endif 337 | 338 | #ifdef MC68K 339 | #define MK_FP(seg,ofs) ((VOID *)&(((BYTE *)(size_t)(seg))[ofs])) 340 | #define FP_SEG(fp) 0 341 | #define FP_OFF(fp) ((size_t)(fp)) 342 | #endif 343 | 344 | #ifndef _WIN32 345 | typedef VOID (FAR ASMCFUNC * intvec) (void); 346 | #endif 347 | 348 | #define MK_PTR(type,seg,ofs) ((type FAR*) MK_FP (seg, ofs)) 349 | #if __TURBOC__ > 0x202 350 | # define MK_SEG_PTR(type,seg) ((type _seg*) (seg)) 351 | #else 352 | # define _seg FAR 353 | # define MK_SEG_PTR(type,seg) MK_PTR (type, seg, 0) 354 | #endif 355 | 356 | /* 357 | this suppresses the warning 358 | unreferenced parameter 'x' 359 | and (hopefully) generates no code 360 | */ 361 | #ifndef UNREFERENCED_PARAMETER 362 | #define UNREFERENCED_PARAMETER(x) (void)(x) 363 | #endif 364 | 365 | #ifdef I86 /* commandline overflow - removing /DPROTO TE */ 366 | #define PROTO 367 | #endif 368 | 369 | typedef const char CStr[], *PCStr; 370 | typedef char Str[], *PStr; 371 | typedef const void *CVP; 372 | #ifdef _WIN32 373 | typedef const void *CVFP; 374 | typedef void *VFP; 375 | #else 376 | typedef const void FAR *CVFP; 377 | typedef void FAR *VFP; 378 | #endif 379 | 380 | #define LENGTH(x) (sizeof (x)/sizeof *(x)) 381 | #define ENDOF(x) ((x) + LENGTH (x)) 382 | 383 | /* (unsigned) modulo arithmetics trick: a<=b<=c equal to b-a<=c-a */ 384 | #define inrange(type,v,lo,hi) ((type)((v) - (lo)) <= (type)((hi) - (lo))) 385 | #define _isdigit(c) inrange(UBYTE, c, '0', '9') 386 | #define _islower(c) inrange(UBYTE, c, 'a', 'z') 387 | #define _isupper(c) inrange(UBYTE, c, 'A', 'Z') 388 | 389 | /* Fast ASCII tolower/toupper */ 390 | #define _fast_lower(ch) ((ch) | 0x20) 391 | #define _fast_dolower(var) ((var) |= 0x20) 392 | #define _fast_upper(ch) ((ch) & ~0x20) 393 | #define _fast_doupper(var) ((var) &= ~0x20) 394 | -------------------------------------------------------------------------------- /hdr/xstructs.h: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* xstructs.h */ 4 | /* */ 5 | /* Extended DOS 7.0+ structures */ 6 | /* */ 7 | /****************************************************************/ 8 | 9 | 10 | struct xdpbdata { 11 | UWORD xdd_dpbsize; 12 | struct dpb xdd_dpb; 13 | }; 14 | 15 | struct xfreespace { 16 | UWORD xfs_datasize; /* size of this structure */ 17 | union { 18 | UWORD requested; /* requested structure version */ 19 | UWORD actual; /* actual structure version */ 20 | } xfs_version; 21 | ULONG xfs_clussize; /* number of sectors per cluster */ 22 | ULONG xfs_secsize; /* number of bytes per sector */ 23 | ULONG xfs_freeclusters; /* number of available clusters */ 24 | ULONG xfs_totalclusters; /* total number of clusters on the drive */ 25 | ULONG xfs_freesectors; /* number of physical sectors available */ 26 | ULONG xfs_totalsectors; /* total number of physical sectors */ 27 | ULONG xfs_freeunits; /* number of available allocation units */ 28 | ULONG xfs_totalunits; /* total allocation units */ 29 | UBYTE xfs_reserved[8]; 30 | }; 31 | 32 | struct xdpbforformat { 33 | UWORD xdff_datasize; /* size of this structure */ 34 | union { 35 | UWORD requested; /* requested structure version */ 36 | UWORD actual; /* actual structure version */ 37 | } xdff_version; 38 | UDWORD xdff_function; /* function number: 39 | 00h invalidate DPB counts 40 | 01h rebuild DPB from BPB 41 | 02h force media change 42 | 03h get/set active FAT number and mirroring 43 | 04h get/set root directory cluster number 44 | */ 45 | union { 46 | struct { 47 | DWORD nfreeclst; /* # free clusters 48 | (-1 - unknown, 0 - don't change) */ 49 | DWORD cluster; /* cluster # of first free 50 | (-1 - unknown, 0 - don't change) */ 51 | UDWORD reserved[2]; 52 | } setdpbcounts; 53 | 54 | struct { 55 | UDWORD unknown; 56 | bpb FAR *bpbp; 57 | UDWORD reserved[2]; 58 | } rebuilddpb; 59 | 60 | struct { 61 | DWORD newmirroring; /* new active FAT/mirroring state, or -1 to get 62 | bits 3-0: the 0-based FAT number of the active FAT 63 | bits 6-4: reserved (0) 64 | bit 7: do not mirror active FAT to inactive FATs 65 | */ 66 | DWORD oldmirroring; /* previous active FAT/mirroring state (as above) */ 67 | UDWORD reserved[2]; 68 | } setmirroring; 69 | 70 | struct { 71 | DWORD newrootclst; /* set new root directory cluster, -1 - get current */ 72 | DWORD oldrootclst; /* get previous root directory cluster */ 73 | UDWORD reserved[2]; 74 | } setroot; 75 | } xdff_f; 76 | }; 77 | 78 | COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp); 79 | -------------------------------------------------------------------------------- /mkfiles/generic.mak: -------------------------------------------------------------------------------- 1 | # These are generic definitions 2 | 3 | # TARGET : we create a $(TARGET).sys file 4 | 5 | BASE=C:\WATCOM 6 | COMPILER=WATCOM 7 | NASM=C:\NASM\NASM.EXE 8 | 9 | !if $(XCPU)0 == 0 10 | XCPU=86 11 | !endif 12 | CPUOPT= 13 | !if $(XCPU) == 186 14 | CPUOPT=-1 15 | !endif 16 | !if $(XCPU) == 386 17 | CPUOPT=-3 18 | !endif 19 | # extension, if compiler supports it, specify compiler switch in XCPU_EX and set XCPU to 386 20 | !if $(XCPU_EX)0 != 0 21 | XCPU=386 22 | CPUOPT=$(XCPU_EX) 23 | !endif 24 | 25 | !if $(XFAT)0 == 0 26 | XFAT=32 27 | !endif 28 | !if $(XFAT) == 32 29 | ALLCFLAGS=-DWITHFAT32 $(ALLCFLAGS) 30 | NASMFLAGS=-DWITHFAT32 $(NASMFLAGS) 31 | !endif 32 | 33 | NASMFLAGS=-fobj -i../hdr/ -D$(COMPILER) -DXCPU=$(XCPU) $(NASMFLAGS) 34 | 35 | BINPATH=$(BASE)\bin 36 | INCLUDEPATH=$(BASE)\include 37 | LIBPATH=$(BASE)\lib 38 | INITPATCH=@rem 39 | 40 | !if $(LOADSEG)0 == 0 41 | LOADSEG=0x60 42 | !endif 43 | 44 | !include "..\mkfiles\$(COMPILER).mak" 45 | 46 | TARGET=$(TARGET)$(XCPU)$(XFAT) 47 | INITCFLAGS=$(INITCFLAGS) $(ALLCFLAGS) 48 | CFLAGS=$(CFLAGS) $(ALLCFLAGS) 49 | RM=DEL 50 | DEPENDS=makefile ..\*.bat 51 | #..\mkfiles\*.* 52 | 53 | # Implicit Rules ####################################################### 54 | 55 | .asm.obj: 56 | $(NASM) $(NASMFLAGS) $< 57 | 58 | .c.obj: 59 | $(CC) $(CFLAGS) $< 60 | 61 | .cpp.obj: 62 | $(CC) $(CFLAGS) $< 63 | 64 | .c.exe: 65 | $(CL) $(CFLAGSC) $< 66 | 67 | .c.com: 68 | $(CL) $(CFLAGST) $< 69 | 70 | -------------------------------------------------------------------------------- /mkfiles/watcom.mak: -------------------------------------------------------------------------------- 1 | # 2 | # WATCOM.MAK - kernel compiler options for WATCOM C/OpenWatcom 3 | # 4 | 5 | TARGET=KWC 6 | 7 | BINPATH=$(BASE)\binnt 8 | INCLUDEPATH=$(BASE)\h 9 | LIBPATH=$(BASE)\lib286 10 | 11 | CC=$(BINPATH)\wcc 12 | CL=$(BINPATH)\wcl 13 | CLW=$(BINPATH)\wcl386 14 | 15 | # used for building the library 16 | 17 | CLIB=$(LIBPATH)\dos\clibm.lib 18 | MATH_EXTRACT=*i4m 19 | MATH_INSERT =+i4m 20 | 21 | # 22 | # Compiler options for Watcom 23 | # --------------------------- 24 | # 25 | # -e= set limit on number of error messages 26 | # -w= set warning level number 27 | # -we treat all warnings as errors 28 | # -wx set warning level to max 29 | # -zq operate quietly 30 | # 31 | # -j change char default from unsigned to signed 32 | # -ms small memory model (small code/small data) 33 | # -os -> favor code size over execution time in optimizations 34 | # -s remove stack overflow checks 35 | # -ze enable extensions (i.e., near, far, export, etc.) 36 | # -zl remove default library information 37 | # -zp pack structure members with alignment {1,2,4,8,16} 38 | # -zu SS!=DGROUP 39 | # 40 | # -3 optimization for 386 - given in $(CPUOPT) 41 | # -g= set code group name 42 | # -nc= set code class name 43 | # -nd= set data segment name 44 | # -nm= set module name 45 | # -nt= set name of text segment 46 | # 47 | # -bt=DOS force executable as DOS (prevents compile issues when building on NT) 48 | 49 | ALLCFLAGS=-I$(INCLUDEPATH) $(CPUOPT)$(ALLCFLAGS) 50 | INITCFLAGS=@wci.cfg 51 | CFLAGS =@wc.cfg 52 | 53 | CFLAGST=-I..\hdr;$(INCLUDEPATH) -e3-we-wx-zq-os-s-zp1-mt-bt=DOS 54 | CFLAGSC=-I..\hdr;$(INCLUDEPATH) -e3-we-wx-zq-os-s-zp1-mc-bt=DOS 55 | 56 | CFLAGSW=-I..\hdr;$(INCLUDEPATH) -e3-we-wx-zq-os-s-zp1-bt=NT 57 | -------------------------------------------------------------------------------- /sys/bin2c.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char **argv) 4 | { 5 | FILE *in, *out; 6 | int col; 7 | int c; 8 | 9 | if (argc < 4) 10 | { 11 | fprintf(stderr, 12 | "Usage: bin2c \n"); 13 | return 1; 14 | } 15 | 16 | if ((in = fopen(argv[1], "rb")) == NULL) 17 | { 18 | fprintf(stderr, "Cannot open input file (%s).\n", argv[1]); 19 | return 1; 20 | } 21 | 22 | if ((out = fopen(argv[2], "wt")) == NULL) 23 | { 24 | fprintf(stderr, "Cannot open output file (%s).\n", argv[2]); 25 | return 1; 26 | } 27 | 28 | col = 0; 29 | 30 | fprintf(out, "unsigned char %s[] = {\n ", argv[3]); 31 | 32 | while ((c = fgetc(in)) != EOF) 33 | { 34 | if (col) 35 | { 36 | fprintf(out, ", "); 37 | } 38 | if (col >= 8) 39 | { 40 | fprintf(out, "\n "); 41 | col = 0; 42 | } 43 | fprintf(out, "0x%02X", c); 44 | col++; 45 | } 46 | 47 | fprintf(out, "\n};\n"); 48 | fclose(in); 49 | fclose(out); 50 | 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /sys/bootmgr.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | 3 | bootmgr.c 4 | DOS-C 5 | 6 | sys utility for DOS-C 7 | 8 | Copyright (c) 1991 9 | Pasquale J. Villani 10 | All Rights Reserved 11 | 12 | This file is part of DOS-C. 13 | 14 | DOS-C is free software; you can redistribute it and/or modify it under the 15 | terms of the GNU General Public License as published by the Free Software 16 | Foundation; either version 2, or (at your option) any later version. 17 | 18 | DOS-C is distributed in the hope that it will be useful, but WITHOUT ANY 19 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 21 | details. 22 | 23 | You should have received a copy of the GNU General Public License along with 24 | DOS-C; see the file COPYING. If not, write to the Free Software Foundation, 25 | 675 Mass Ave, Cambridge, MA 02139, USA. 26 | 27 | ***************************************************************/ 28 | 29 | 30 | #include "sys.h" 31 | 32 | #ifdef USEBOOTMANAGER 33 | 34 | #include "diskio.h" 35 | 36 | #ifdef _WIN32 37 | typedef unsigned long FileAttributes; 38 | #else 39 | typedef unsigned FileAttributes; 40 | static unsigned GetFileAttributes(const char *filename) 41 | { 42 | unsigned attributes = 0; 43 | _dos_getfileattr(filename, &attributes); 44 | return attributes; 45 | } 46 | #define SetFileAttributes(fname, attr) _dos_setfileattr(fname, attr) 47 | #endif 48 | 49 | 50 | /* returns TRUE if successfully adds section, FALSE any errors */ 51 | BOOL writeConfigSection(const char *fname, const char *configText) 52 | { 53 | int fd; 54 | BOOL ret = FALSE; 55 | FileAttributes attr = GetFileAttributes(fname); 56 | SetFileAttributes(fname, 0); /* remove any readonly, system, or hidden attributes */ 57 | fd = open(fname, O_RDWR|O_TEXT); /* file must exist */ 58 | if (fd >= 0) 59 | { 60 | /* append configText to end of current file */ 61 | if (lseek(fd, 0, SEEK_END) != -1L) 62 | { 63 | register int len = strlen(configText); 64 | if (write(fd, configText, len) == len) 65 | ret = TRUE; 66 | } 67 | close(fd); 68 | } 69 | SetFileAttributes(fname, attr); /* restore original attributes */ 70 | return ret; 71 | } 72 | 73 | /* returns true if filename exists, false otherwise */ 74 | static BOOL exists(const char *fname) 75 | { 76 | struct stat statbuf; 77 | return (stat(fname, &statbuf)==0?TRUE:FALSE); 78 | } 79 | 80 | /* attempts to determine if file exists 81 | checks root directory (\basename), then a subdirectory (\name\basename) 82 | and finally a subdirectory in boot directory (\boot\name\basename) 83 | returning NULL if file not found 84 | */ 85 | static const char *getBootConfigFile(char drive, const char *basename, const char *name) 86 | { 87 | static char buffer[SYS_MAXPATH]; 88 | sprintf(buffer, "%c:\\%s", drive, basename); 89 | if (exists(buffer)) return buffer; 90 | if (name != NULL) 91 | { 92 | sprintf(buffer, "%c:\\%s\\%s", drive, name, basename); 93 | if (exists(buffer)) return buffer; 94 | sprintf(buffer, "%c:\\boot\\%s\\%s", drive, name, basename); 95 | if (exists(buffer)) return buffer; 96 | } 97 | return NULL; 98 | } 99 | 100 | 101 | const char *menuName = "\"FreeDOS (C:)\""; 102 | typedef void (* getConfigSectionTextFn)(char *buffer, const char *bsFilename, unsigned drive); 103 | 104 | /* entry for syslinux.cfg (or variants) (check /, /syslinux/, /boot/syslinux/) 105 | */ 106 | void getSyslinuxConfig(char *buffer, const char *bsFilename, unsigned drive) 107 | { 108 | sprintf(buffer, "\n" \ 109 | "LABEL %s\n" \ 110 | " BOOT %s\n" /* maybe "BSS %s\n" */ \ 111 | "\n", 112 | menuName, bsFilename); 113 | } 114 | 115 | /* entry for freeldr.ini (check /) 116 | http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/FREELDR.INI?revision=29690&view=markup 117 | */ 118 | void getFreeLdrConfig(char *buffer, const char *bsFilename, unsigned drive) 119 | { 120 | sprintf(buffer, "\n" \ 121 | "[Operating Systems]\n" \ 122 | "FreeDOS=%s\n" \ 123 | "[FreeDOS]\n" \ 124 | "BootType=BootSector\n" \ 125 | "BootSector=%s\n" \ 126 | "\n", 127 | menuName, bsFilename); 128 | } 129 | 130 | 131 | /* entry for boot.ini (check /) 132 | For Windows NT loader, provide a boot sector and name to display 133 | (note: if using MSDOS and MS Windows 95 you may need /WIN95 & /WIN95DOS) 134 | http://www.tburke.net/info/ntldr/ntldr_hacking_guide.htm 135 | */ 136 | void getNtldrConfig(char *buffer, const char *bsFilename, unsigned drive) 137 | { 138 | sprintf(buffer, "\n" \ 139 | "%s=%s\n" \ 140 | "\n", 141 | bsFilename, menuName); 142 | } 143 | 144 | static const char *grubFormatDrive(unsigned drive) 145 | { 146 | static char disk[8]; 147 | if (drive >= 'C') 148 | sprintf(disk, "hd%u", (drive-'C')); 149 | else 150 | sprintf(disk, "fd%u", (drive-'A')); 151 | return disk; 152 | } 153 | 154 | static const char *grubFormatPath(const char *bsFilename) 155 | { 156 | static char buffer[SYS_MAXPATH]; 157 | register char *p; 158 | /* skip drive */ 159 | if (bsFilename[1] == ':') 160 | strcpy(buffer, bsFilename+2); 161 | else 162 | strcpy(buffer, bsFilename); 163 | for (p = buffer; *p != '\0'; p++) 164 | { 165 | if (*p == '\\') *p = '/'; 166 | } 167 | return bsFilename; 168 | } 169 | 170 | /* entry for menu.lst (check /, /grub/, /boot/grub/) 171 | http://www.gnu.org/software/grub/manual/legacy/grub.html 172 | */ 173 | void getGrubConfig(char *buffer, const char *bsFilename, unsigned drive) 174 | { 175 | sprintf(buffer, "\n" \ 176 | "title %s\n" \ 177 | "root (%s,0)\n" /* or possibly "rootnoverify (hd0,0)\n", use fd0 for floppy, note 0 based partitions */ \ 178 | "chainloader %s\n" /* or chainloader +1 to read from drive or even better chainloader /kernel.sys */ \ 179 | /* "makeactive\n" */ \ 180 | "\n", 181 | menuName, grubFormatDrive(drive), grubFormatPath(bsFilename)); 182 | } 183 | 184 | /* entry for grub.cfg (burg.cfg also?) (check /, /grub/, /boot/grub/, /boot/grub2/, /grub2/) 185 | http://www.gnu.org/software/grub/manual/grub.html 186 | */ 187 | void getGrub2Config(char *buffer, const char *bsFilename, unsigned drive) 188 | { 189 | sprintf(buffer, "\n" \ 190 | "menuentry %s {\n" \ 191 | "insmod chain\n" \ 192 | "set root=(%s,1)\n" /* can leave out so uses default (where grub installed), also supports hd0=0x80, note 1 based partitions */ \ 193 | "chainloader %s\n" /* or chainloader +1 to read from drive */ \ 194 | /* "parttool ${root} boot+\n" */ \ 195 | "}\n" \ 196 | "\n", 197 | menuName, grubFormatDrive(drive), grubFormatPath(bsFilename)); 198 | } 199 | 200 | 201 | BOOL writeBootLoaderEntry(SYSOptions *opts) 202 | { 203 | getConfigSectionTextFn fn = NULL; 204 | const char *cfgFilename; 205 | static char buffer[4*SYS_MAXPATH]; 206 | char drive = 'A' + opts->dstDrive; 207 | 208 | if (opts->verbose) 209 | printf("Adding entry to boot manager.\n"); 210 | 211 | memset(buffer, 0, sizeof(buffer)); 212 | switch(opts->addToBtMgr) 213 | { 214 | case USEBTMGR: 215 | /* fall through testing each in order they appear here */ 216 | case SYSLINUX: 217 | if ((cfgFilename = getBootConfigFile(drive, "syslinux.cfg", "syslinux")) != NULL) 218 | { 219 | #ifdef DEBUG 220 | printf("SysLinux\n"); 221 | #endif 222 | opts->addToBtMgr = SYSLINUX; 223 | fn = getSyslinuxConfig; 224 | break; 225 | } 226 | case FREELDR: 227 | if ((cfgFilename = getBootConfigFile(drive, "freeldr.ini", NULL)) != NULL) 228 | { 229 | #ifdef DEBUG 230 | printf("FreeLdr\n"); 231 | #endif 232 | opts->addToBtMgr = FREELDR; 233 | fn = getFreeLdrConfig; 234 | break; 235 | } 236 | case NTLDR: 237 | if ((cfgFilename = getBootConfigFile(drive, "boot.ini", NULL)) != NULL) 238 | { 239 | #ifdef DEBUG 240 | printf("Ntldr\n"); 241 | #endif 242 | opts->addToBtMgr = NTLDR; 243 | fn = getNtldrConfig; 244 | break; 245 | } 246 | case GRUB: 247 | if ((cfgFilename = getBootConfigFile(drive, "menu.lst", "grub")) != NULL) 248 | { 249 | #ifdef DEBUG 250 | printf("Grub Legacy\n"); 251 | #endif 252 | opts->addToBtMgr = GRUB; 253 | fn = getGrubConfig; 254 | break; 255 | } 256 | case GRUB2: 257 | if ( ((cfgFilename = getBootConfigFile(drive, "grub.cfg", "grub2")) != NULL) || 258 | ((cfgFilename = getBootConfigFile(drive, "grub.cfg", "grub")) != NULL) ) 259 | { 260 | #ifdef DEBUG 261 | printf("Grub2\n"); 262 | #endif 263 | opts->addToBtMgr = GRUB2; 264 | fn = getGrub2Config; 265 | break; 266 | } 267 | } 268 | if (fn != NULL) 269 | { 270 | char bsf[SYS_MAXPATH]; 271 | truename(bsf, opts->bsFile); 272 | fn(buffer, bsf, opts->defBootDrive); 273 | #ifdef DEBUG 274 | if (opts->verbose) 275 | printf("Updating %s with:\n%s", cfgFilename, buffer); 276 | #endif 277 | return writeConfigSection(cfgFilename, buffer); 278 | } 279 | return FALSE; 280 | } 281 | 282 | #endif /* USEBOOTMANAGER */ 283 | -------------------------------------------------------------------------------- /sys/config.big: -------------------------------------------------------------------------------- 1 | /* to display extra information */ 2 | #define DEBUG 3 | /* to enable display of sector dumps */ 4 | // #define DDEBUG */ 5 | /* include support for FAT32 file system */ 6 | #define WITHFAT32 7 | /* include support for NTFS file system */ 8 | #define WITHNTFS 9 | /* include support to configure FD kernel */ 10 | #define FDCONFIG 11 | /* supported embedded core files */ 12 | #define EMBEDDEDVFS 13 | /* include support for OEM MS/PC DOS 3.??-6.x */ 14 | #define WITHOEMCOMPATBS 15 | /* include support to add entry to existing boot manager */ 16 | #define USEBOOTMANAGER 17 | /* include support for Windows/ReactOS */ 18 | #define FREELDR 19 | /* build Enhanced DR-DOS variant instead of default FreeDOS build */ 20 | // #define DRSYS */ 21 | /* OEM branded version */ 22 | #define SYS_NAME "FreeDOS (Extended)" 23 | /* Optional, files and settings for default kernel */ 24 | // #define OEM_FILES { "KERNEL.SYS", NULL, 0x60/*:0*/, 1, 0 }, 25 | -------------------------------------------------------------------------------- /sys/config.edr: -------------------------------------------------------------------------------- 1 | /* build Enhanced DR-DOS variant instead of default FreeDOS build */ 2 | #define DRSYS */ 3 | /* include support for FAT32 file system */ 4 | #define WITHFAT32 5 | /* include support for OEM MS/PC DOS 3.??-6.x */ 6 | #define WITHOEMCOMPATBS 7 | -------------------------------------------------------------------------------- /sys/config.fd: -------------------------------------------------------------------------------- 1 | /* include support for FAT32 file system */ 2 | #define WITHFAT32 3 | /* include support to configure FD kernel */ 4 | #define FDCONFIG 5 | -------------------------------------------------------------------------------- /sys/config.h: -------------------------------------------------------------------------------- 1 | /* to display extra information */ 2 | // #define DEBUG 3 | /* to enable display of sector dumps */ 4 | // #define DDEBUG */ 5 | /* include support for FAT32 file system */ 6 | #define WITHFAT32 7 | /* include support for NTFS file system */ 8 | //#define WITHNTFS 9 | /* include support to configure FD kernel */ 10 | #define FDCONFIG 11 | /* include support for OEM MS/PC DOS 3.??-6.x */ 12 | #define WITHOEMCOMPATBS 13 | /* include support to add entry to existing boot manager */ 14 | #define USEBOOTMANAGER 15 | -------------------------------------------------------------------------------- /sys/config.oem: -------------------------------------------------------------------------------- 1 | /* Custom OEM branded version */ 2 | #define SYS_NAME "OEM-DOS" 3 | /* Optional, files and settings for default kernel */ 4 | #define OEM_FILES { "KERNEL.SYS", NULL, 0x60/*:0*/, 1, 0 }, 5 | /* include support for FAT32 file system */ 6 | #define WITHFAT32 7 | /* include support for OEM MS/PC DOS 3.??-6.x */ 8 | #define WITHOEMCOMPATBS 9 | -------------------------------------------------------------------------------- /sys/config.std: -------------------------------------------------------------------------------- 1 | /* to display extra information */ 2 | // #define DEBUG 3 | /* to enable display of sector dumps */ 4 | // #define DDEBUG */ 5 | /* include support for FAT32 file system */ 6 | #define WITHFAT32 7 | /* include support for NTFS file system */ 8 | #define WITHNTFS 9 | /* include support to configure FD kernel */ 10 | #define FDCONFIG 11 | /* include support for OEM MS/PC DOS 3.??-6.x */ 12 | #define WITHOEMCOMPATBS 13 | /* include support to add entry to existing boot manager */ 14 | #define USEBOOTMANAGER 15 | -------------------------------------------------------------------------------- /sys/copy.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | 3 | copy.c 4 | DOS-C 5 | 6 | sys utility for DOS-C 7 | 8 | Copyright (c) 1991 9 | Pasquale J. Villani 10 | All Rights Reserved 11 | 12 | This file is part of DOS-C. 13 | 14 | DOS-C is free software; you can redistribute it and/or modify it under the 15 | terms of the GNU General Public License as published by the Free Software 16 | Foundation; either version 2, or (at your option) any later version. 17 | 18 | DOS-C is distributed in the hope that it will be useful, but WITHOUT ANY 19 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 21 | details. 22 | 23 | You should have received a copy of the GNU General Public License along with 24 | DOS-C; see the file COPYING. If not, write to the Free Software Foundation, 25 | 675 Mass Ave, Cambridge, MA 02139, USA. 26 | 27 | ***************************************************************/ 28 | 29 | #include "sys.h" 30 | #include "xstructs.h" 31 | #include "diskio.h" 32 | 33 | #ifdef __TURBOC__ 34 | #include 35 | #include 36 | #else 37 | #include 38 | #endif 39 | 40 | #define COPY_SIZE 0x4000 41 | 42 | 43 | #ifdef _WIN32 44 | 45 | void truename(char *dest, const char *src) 46 | { 47 | if (_fullpath(dest, src, SYS_MAXPATH) == NULL) 48 | strcpy(dest, src); /* oops! fallback to what user specified */ 49 | } 50 | 51 | /* 52 | * Returns TRUE if `drive` has at least `bytes` free space, FALSE otherwise. 53 | */ 54 | BOOL check_space(COUNT drive, ULONG bytes) 55 | { 56 | ULARGE_INTEGER freeBytes; 57 | char *drivename = "A:\\"; 58 | drivename[0] = 'A' + drive; 59 | if (GetDiskFreeSpaceExA(drivename, &freeBytes, NULL, NULL)) 60 | { 61 | if (freeBytes.QuadPart >= bytes) 62 | return TRUE; 63 | } 64 | return FALSE; 65 | } /* check_space */ 66 | 67 | 68 | #define allocBlock(blksize) (BYTE *)malloc((unsigned)(blksize)) 69 | #define freeBlock(ptr) free((void *)(ptr)) 70 | 71 | #define normalizePtr(ptr) 72 | 73 | 74 | typedef struct _utimbuf filetime_t; 75 | 76 | /* get original file date and time */ 77 | void getFileTime(int fdin, filetime_t *filetime) 78 | { 79 | struct stat fstatbuf; 80 | if (fstat(fdin, &fstatbuf)) 81 | memset(&fstatbuf, 0, sizeof(fstatbuf)); 82 | filetime->actime = /* access time */ 83 | filetime->modtime = fstatbuf.st_mtime; /* modification time */ 84 | } 85 | 86 | /* set copied files time to match original */ 87 | #ifdef _MSC_VER 88 | #define setFileTimeAndClose(fname, fd, filetime) _futime(fd, (struct _utimbuf *)filetime); close(fd) 89 | #else 90 | #define setFileTimeAndClose(fname, fd, filetime) close(fdout); _utime(fname, (struct _utimbuf *)filetime) 91 | #endif 92 | 93 | #else 94 | 95 | #ifdef __WATCOMC__ 96 | 97 | long filelength(int __handle); 98 | #pragma aux filelength = \ 99 | "mov ax, 0x4202" \ 100 | "xor cx, cx" \ 101 | "xor dx, dx" \ 102 | "int 0x21" \ 103 | "push ax" \ 104 | "push dx" \ 105 | "mov ax, 0x4200" \ 106 | "xor cx, cx" \ 107 | "xor dx, dx" \ 108 | "int 0x21" \ 109 | "pop dx" \ 110 | "pop ax" \ 111 | parm [bx] \ 112 | modify [cx] \ 113 | value [dx ax]; 114 | 115 | unsigned getextdrivespace(void far *drivename, void *buf, unsigned buf_size); 116 | #pragma aux getextdrivespace = \ 117 | "mov ax, 0x7303" \ 118 | "stc" \ 119 | "int 0x21" \ 120 | "sbb ax, ax" \ 121 | parm [es dx] [di] [cx] \ 122 | value [ax]; 123 | 124 | #else 125 | 126 | void truename(char *dest, const char *src) 127 | { 128 | union REGS regs; 129 | struct SREGS sregs; 130 | 131 | regs.h.ah = 0x60; 132 | sregs.es = FP_SEG(dest); 133 | regs.x.di = FP_OFF(dest); 134 | sregs.ds = FP_SEG(src); 135 | regs.x.si = FP_OFF(src); 136 | intdosx(®s, ®s, &sregs); 137 | } /* truename */ 138 | 139 | unsigned getextdrivespace(void far *drivename, void *buf, unsigned buf_size) 140 | { 141 | union REGS regs; 142 | struct SREGS sregs; 143 | 144 | regs.x.ax = 0x7303; /* get extended drive free space */ 145 | 146 | sregs.es = FP_SEG(buf); 147 | regs.x.di = FP_OFF(buf); 148 | sregs.ds = FP_SEG(drivename); 149 | regs.x.dx = FP_OFF(drivename); 150 | 151 | regs.x.cx = buf_size; 152 | 153 | intdosx(®s, ®s, &sregs); 154 | return regs.x.ax == 0x7300 || regs.x.cflag; 155 | } /* getextdrivespace */ 156 | 157 | #endif /* __WATCOMC__ */ 158 | 159 | /* static */ struct xfreespace x; /* we make this static to be 0 by default - 160 | this avoids FAT misdetections */ 161 | /* 162 | * Returns TRUE if `drive` has at least `bytes` free space, FALSE otherwise. 163 | */ 164 | BOOL check_space(COUNT drive, ULONG bytes) 165 | { 166 | /* try extended drive space check 1st, if unsupported or other error fallback to standard check */ 167 | char *drivename = "A:\\"; 168 | drivename[0] = 'A' + drive; 169 | if (getextdrivespace(drivename, &x, sizeof(x))) 170 | { 171 | #ifdef __TURBOC__ 172 | struct dfree df; 173 | getdfree(drive + 1, &df); 174 | return (ULONG)df.df_avail * df.df_sclus * df.df_bsec >= bytes; 175 | #else 176 | struct _diskfree_t df; 177 | _dos_getdiskfree(drive + 1, &df); 178 | return (ULONG)df.avail_clusters * df.sectors_per_cluster 179 | * df.bytes_per_sector >= bytes; 180 | #endif 181 | } 182 | else 183 | return x.xfs_freeclusters > (bytes / (x.xfs_clussize * x.xfs_secsize)); 184 | } /* check_space */ 185 | 186 | 187 | /* allocate memory from DOS, return NULL on error, pointer to buffer otherwise */ 188 | BYTE FAR* allocBlock(ULONG memsize) 189 | { 190 | unsigned dseg; 191 | #ifdef __TURBOC__ 192 | if (allocmem((unsigned)((memsize+15)>>4), &dseg)!=-1) 193 | #else 194 | if (_dos_allocmem((unsigned)((memsize+15)>>4), &dseg)!=0) 195 | #endif 196 | return NULL; /* failed to allocate memory */ 197 | 198 | return MK_FP(dseg, 0); /* success */ 199 | } 200 | 201 | #ifdef __TURBOC__ 202 | #define freeBlock(ptr) freemem(FP_SEG(ptr)) 203 | #else 204 | #define freeBlock(ptr) _dos_freemem(FP_SEG(ptr)) 205 | #endif 206 | 207 | /* adjust segment:offset to maintain valid, takes a pointer to a far pointer to updated */ 208 | void normalizePtr(BYTE FAR **ptr) 209 | { 210 | register BYTE FAR *bufptr = *ptr; 211 | if (FP_OFF(bufptr) > 0x7777) /* watcom needs this in tiny model */ 212 | { 213 | bufptr = MK_FP(FP_SEG(bufptr)+0x700, FP_OFF(bufptr)-0x7000); 214 | } 215 | *ptr = bufptr; 216 | } 217 | 218 | 219 | #if defined __WATCOMC__ || defined _MSC_VER /* || defined __BORLANDC__ */ 220 | typedef struct { 221 | #if defined(__WATCOMC__) && __WATCOMC__ < 1280 222 | unsigned short date, time; 223 | #else 224 | unsigned date, time; 225 | #endif 226 | } filetime_t; 227 | #elif defined __TURBOC__ 228 | typedef struct ftime filetime_t; 229 | #endif 230 | 231 | /* get original file date and time */ 232 | #if defined __WATCOMC__ || defined _MSC_VER /* || defined __BORLANDC__ */ 233 | #define getFileTime(fdin, filetime) _dos_getftime(fdin, &((filetime)->date), &((filetime)->time)); 234 | #elif defined __TURBOC__ 235 | #define getFileTime(fdin, filetime) getftime(fdin, filetime); 236 | #endif 237 | 238 | /* set copied files time to match original */ 239 | #if defined __WATCOMC__ || defined _MSC_VER /* || defined __BORLANDC__ */ 240 | #define setFileTimeAndClose(fname, fd, filetime) _dos_setftime(fd, (filetime)->date, (filetime)->time); close(fd) 241 | #elif defined __TURBOC__ 242 | #define setFileTimeAndClose(fname, fd, filetime) setftime(fd, ftime); close(fd) 243 | #endif 244 | 245 | 246 | #endif /* _WIN32 */ 247 | 248 | 249 | 250 | 251 | BYTE copybuffer[COPY_SIZE]; 252 | 253 | 254 | /* copies file (path+filename specified by srcFile) to drive:\filename */ 255 | BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename) 256 | { 257 | static BYTE src[SYS_MAXPATH]; 258 | static BYTE dest[SYS_MAXPATH]; 259 | unsigned ret; 260 | int fdin, fdout; 261 | ULONG copied = 0; 262 | filetime_t filetime; 263 | 264 | printf("Copying %s...\n", source); 265 | 266 | truename(src, source); 267 | sprintf(dest, "%c:\\%s", 'A' + drive, filename); 268 | if (stricmp(src, dest) == 0) 269 | { 270 | printf("%s: source and destination are identical: skipping \"%s\"\n", 271 | pgm, source); 272 | return TRUE; 273 | } 274 | 275 | if ((fdin = open(source, O_RDONLY | O_BINARY)) < 0) 276 | { 277 | printf("%s: failed to open \"%s\"\n", pgm, source); 278 | return FALSE; 279 | } 280 | 281 | /* get original creation file date & time */ 282 | getFileTime(fdin, &filetime); 283 | 284 | if (!check_space(drive, filelength(fdin))) 285 | { 286 | printf("%s: Not enough space to transfer %s\n", pgm, filename); 287 | close(fdin); 288 | return FALSE; 289 | } 290 | 291 | if ((fdout = 292 | open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, 293 | S_IREAD | S_IWRITE)) < 0) 294 | { 295 | printf(" %s: can't create\"%s\"\nDOS errnum %d\n", pgm, dest, errno); 296 | close(fdin); 297 | return FALSE; 298 | } 299 | 300 | #if 0 /* simple copy loop, read chunk then write chunk, repeat until all data copied */ 301 | while ((ret = read(fdin, copybuffer, COPY_SIZE)) > 0) 302 | { 303 | if (write(fdout, copybuffer, ret) != ret) 304 | { 305 | printf("Can't write %u bytes to %s\n", ret, dest); 306 | close(fdout); 307 | unlink(dest); 308 | return FALSE; 309 | } 310 | copied += ret; 311 | } 312 | #else /* read in whole file, then write out whole file */ 313 | { 314 | ULONG filesize; 315 | BYTE far *buffer, far *bufptr; 316 | UWORD offs; 317 | unsigned chunk_size; 318 | 319 | /* get length of file to copy, then allocate enough memory for whole file */ 320 | filesize = filelength(fdin); 321 | buffer = allocBlock(filesize); 322 | if (buffer == NULL) 323 | { 324 | printf("Not enough memory to buffer %lu bytes for %s\n", filesize, source); 325 | return FALSE; 326 | } 327 | bufptr = buffer; 328 | 329 | /* read in whole file, a chunk at a time; adjust size of last chunk to match remaining bytes */ 330 | chunk_size = (COPY_SIZE < filesize)?COPY_SIZE:(unsigned)filesize; 331 | while ((ret = read(fdin, copybuffer, chunk_size)) > 0) 332 | { 333 | for (offs = 0; offs < ret; offs++) 334 | { 335 | *bufptr = copybuffer[offs]; 336 | bufptr++; 337 | normalizePtr(&bufptr); 338 | } 339 | /* keep track of how much read in, and only read in filesize bytes */ 340 | copied += ret; 341 | chunk_size = (COPY_SIZE < (filesize-copied))?COPY_SIZE:(unsigned)(filesize-copied); 342 | } 343 | 344 | /* write out file, a chunk at a time; adjust size of last chunk to match remaining bytes */ 345 | bufptr = buffer; 346 | copied = 0; 347 | do 348 | { 349 | /* keep track of how much read in, and only read in filesize bytes */ 350 | chunk_size = (COPY_SIZE < (filesize-copied))?COPY_SIZE:(unsigned)(filesize-copied); 351 | copied += chunk_size; 352 | 353 | /* setup chunk of data to be written out */ 354 | for (offs = 0; offs < chunk_size; offs++) 355 | { 356 | copybuffer[offs] = *bufptr; 357 | bufptr++; 358 | normalizePtr(&bufptr); 359 | } 360 | 361 | /* write the data to disk, abort on any error */ 362 | if ((unsigned)write(fdout, copybuffer, chunk_size) != chunk_size) 363 | { 364 | printf("Can't write %u bytes to %s\n", ret, dest); 365 | close(fdout); 366 | unlink(dest); 367 | return FALSE; 368 | } 369 | } while (copied < filesize); 370 | 371 | freeBlock(buffer); 372 | } 373 | #endif /* simple copy loop */ 374 | 375 | /* reduce disk swap on single drives, close file on drive last accessed 1st */ 376 | 377 | /* set copied files time to match original and close file */ 378 | setFileTimeAndClose(dest, fdout, &filetime); 379 | 380 | /* close input file, usually same drive as next action will access */ 381 | close(fdin); 382 | 383 | 384 | printf("%lu Bytes transferred\n", copied); 385 | 386 | return TRUE; 387 | } /* copy */ 388 | 389 | -------------------------------------------------------------------------------- /sys/diskio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | 3 | diskio.h 4 | DOS-C 5 | 6 | sys utility for DOS-C 7 | 8 | Copyright (c) 1991 9 | Pasquale J. Villani 10 | All Rights Reserved 11 | 12 | This file is part of DOS-C. 13 | 14 | DOS-C is free software; you can redistribute it and/or modify it under the 15 | terms of the GNU General Public License as published by the Free Software 16 | Foundation; either version 2, or (at your option) any later version. 17 | 18 | DOS-C is distributed in the hope that it will be useful, but WITHOUT ANY 19 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 21 | details. 22 | 23 | You should have received a copy of the GNU General Public License along with 24 | DOS-C; see the file COPYING. If not, write to the Free Software Foundation, 25 | 675 Mass Ave, Cambridge, MA 02139, USA. 26 | 27 | ***************************************************************/ 28 | 29 | /* assumes sys.h already included */ 30 | 31 | #ifdef __WATCOMC__ 32 | /* some non-conforming functions to make the executable smaller */ 33 | int open(const char *pathname, int flags, ...); 34 | int read(int fd, void *buf, unsigned count); 35 | int write(int fd, const void *buf, unsigned count); 36 | #define close _dos_close 37 | int unlink(const char *pathname); 38 | long lseek(int handle, long offset, int origin ); 39 | #ifndef SEEK_END 40 | #define SEEK_END 2 41 | #endif 42 | #endif 43 | 44 | 45 | int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, int write); 46 | 47 | void lockDrive(unsigned drive); 48 | void unLockDrive(unsigned drive); 49 | 50 | /* returns default BPB (and other device parameters) */ 51 | int getDeviceParms(unsigned drive, FileSystem fs, unsigned char *buffer); 52 | 53 | /* 54 | * If BIOS has got LBA extensions, after the Int 13h call BX will be 0xAA55. 55 | * If extended disk access functions are supported, bit 0 of CX will be set. 56 | */ 57 | BOOL haveLBA(void); /* return TRUE if we have LBA BIOS, FALSE otherwise */ 58 | 59 | /* return canonical (full) name */ 60 | void truename(char *dest, const char *src); 61 | 62 | #if defined __WATCOMC__ && defined __DOS__ 63 | #pragma aux haveLBA = \ 64 | "mov ax, 0x4100" /* IBM/MS Int 13h Extensions - installation check */ \ 65 | "mov bx, 0x55AA" \ 66 | "mov dl, 0x80" \ 67 | "int 0x13" \ 68 | "xor ax, ax" \ 69 | "cmp bx, 0xAA55" \ 70 | "jne quit" \ 71 | "and cx, 1" \ 72 | "xchg cx, ax" \ 73 | "quit:" \ 74 | modify [bx cx dx] \ 75 | value [ax]; 76 | 77 | #pragma aux lseek = \ 78 | "mov ah, 0x42" /* DOS set current file position */ \ 79 | "int 0x21" \ 80 | "jnc ok" \ 81 | "mov ax, -1" \ 82 | "cwd" \ 83 | "ok:" \ 84 | parm [bx] [cx dx] [al] \ 85 | modify [ax bx cx dx] \ 86 | value [dx ax]; 87 | 88 | /* return canonical (full) name */ 89 | void truename(char *dest, const char *src); 90 | #pragma aux truename = \ 91 | "push ds" \ 92 | "pop es" \ 93 | "mov ah,0x60" \ 94 | "int 0x21" \ 95 | parm [di] [si] \ 96 | modify [ax di si es]; 97 | #endif 98 | -------------------------------------------------------------------------------- /sys/diskio_d.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | 3 | diskio_d.c 4 | DOS-C 5 | 6 | sys utility for DOS-C 7 | 8 | Copyright (c) 1991 9 | Pasquale J. Villani 10 | All Rights Reserved 11 | 12 | This file is part of DOS-C. 13 | 14 | DOS-C is free software; you can redistribute it and/or modify it under the 15 | terms of the GNU General Public License as published by the Free Software 16 | Foundation; either version 2, or (at your option) any later version. 17 | 18 | DOS-C is distributed in the hope that it will be useful, but WITHOUT ANY 19 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 21 | details. 22 | 23 | You should have received a copy of the GNU General Public License along with 24 | DOS-C; see the file COPYING. If not, write to the Free Software Foundation, 25 | 675 Mass Ave, Cambridge, MA 02139, USA. 26 | 27 | ***************************************************************/ 28 | 29 | #include "sys.h" 30 | #include "diskio.h" 31 | 32 | void reset_drive(int DosDrive); 33 | int generic_block_ioctl(unsigned drive, unsigned cx, unsigned char *par); 34 | 35 | 36 | #ifdef __WATCOMC__ 37 | #pragma aux reset_drive "*_" = \ 38 | "push ds" \ 39 | "inc dx" \ 40 | "mov ah, 0xd" \ 41 | "int 0x21" \ 42 | "mov ah,0x32" \ 43 | "int 0x21" \ 44 | "pop ds" \ 45 | parm [dx] \ 46 | modify [ax bx]; 47 | 48 | #pragma aux generic_block_ioctl = \ 49 | "mov ax, 0x440d" \ 50 | "int 0x21" \ 51 | "sbb ax, ax" \ 52 | value [ax] \ 53 | parm [bx] [cx] [dx]; /* BH must be 0 for lock! */ 54 | 55 | 56 | int absread(int DosDrive, int nsects, int foo, void *diskReadPacket); 57 | #pragma aux absread = \ 58 | "push bp" \ 59 | "int 0x25" \ 60 | "sbb ax, ax" \ 61 | "popf" \ 62 | "pop bp" \ 63 | parm [ax] [cx] [dx] [bx] \ 64 | modify [si di] \ 65 | value [ax]; 66 | 67 | int abswrite(int DosDrive, int nsects, int foo, void *diskReadPacket); 68 | #pragma aux abswrite = \ 69 | "push bp" \ 70 | "int 0x26" \ 71 | "sbb ax, ax" \ 72 | "popf" \ 73 | "pop bp" \ 74 | parm [ax] [cx] [dx] [bx] \ 75 | modify [si di] \ 76 | value [ax]; 77 | 78 | int fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno); 79 | #pragma aux fat32readwrite = \ 80 | "mov ax, 0x7305" \ 81 | "mov cx, 0xffff" \ 82 | "int 0x21" \ 83 | "sbb ax, ax" \ 84 | parm [dx] [bx] [si] \ 85 | modify [cx dx si] \ 86 | value [ax]; 87 | 88 | #else 89 | 90 | #ifndef __TURBOC__ 91 | 92 | int int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno) 93 | { 94 | union REGS regs; 95 | 96 | regs.h.al = (BYTE) DosDrive; 97 | regs.x.bx = (short)diskReadPacket; 98 | regs.x.cx = 0xffff; 99 | 100 | int86(intno, ®s, ®s); 101 | 102 | return regs.x.cflag; 103 | } 104 | 105 | #define absread(DosDrive, foo, cx, diskReadPacket) \ 106 | int2526readwrite(DosDrive, diskReadPacket, 0x25) 107 | 108 | #define abswrite(DosDrive, foo, cx, diskReadPacket) \ 109 | int2526readwrite(DosDrive, diskReadPacket, 0x26) 110 | 111 | #endif 112 | 113 | int fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno) 114 | { 115 | union REGS regs; 116 | 117 | regs.x.ax = 0x7305; 118 | regs.h.dl = DosDrive; 119 | regs.x.bx = (short)diskReadPacket; 120 | regs.x.cx = 0xffff; 121 | regs.x.si = intno; 122 | intdos(®s, ®s); 123 | 124 | return regs.x.cflag; 125 | } /* fat32readwrite */ 126 | 127 | #endif 128 | 129 | int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, 130 | int write) 131 | { 132 | struct { 133 | unsigned long sectorNumber; 134 | unsigned short count; 135 | void far *address; 136 | } diskReadPacket; 137 | 138 | diskReadPacket.sectorNumber = sector; 139 | diskReadPacket.count = count; 140 | diskReadPacket.address = buffer; 141 | 142 | if ((!write && absread(DosDrive, -1, -1, &diskReadPacket) == -1) 143 | || (write && abswrite(DosDrive, -1, -1, &diskReadPacket) == -1)) 144 | { 145 | #ifdef WITHFAT32 146 | return fat32readwrite(DosDrive + 1, &diskReadPacket, write); 147 | #else 148 | return 0xff; 149 | #endif 150 | } 151 | return 0; 152 | } /* MyAbsReadWrite */ 153 | 154 | 155 | #ifdef __WATCOMC__ 156 | 157 | /* some non-conforming functions to make the executable smaller */ 158 | int open(const char *pathname, int flags, ...) 159 | { 160 | int handle; 161 | int result = (flags & O_CREAT ? 162 | _dos_creat(pathname, _A_NORMAL, &handle) : 163 | _dos_open(pathname, flags & (O_RDONLY | O_WRONLY | O_RDWR), 164 | &handle)); 165 | 166 | return (result == 0 ? handle : -1); 167 | } 168 | 169 | int read(int fd, void *buf, unsigned count) 170 | { 171 | unsigned bytes; 172 | int result = _dos_read(fd, buf, count, &bytes); 173 | 174 | return (result == 0 ? bytes : -1); 175 | } 176 | 177 | int write(int fd, const void *buf, unsigned count) 178 | { 179 | unsigned bytes; 180 | int result = _dos_write(fd, buf, count, &bytes); 181 | 182 | return (result == 0 ? bytes : -1); 183 | } 184 | 185 | int stat(const char *file_name, struct stat *statbuf) 186 | { 187 | struct find_t find_tbuf; 188 | 189 | int ret = _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf); 190 | statbuf->st_size = (off_t)find_tbuf.size; 191 | /* statbuf->st_attr = (ULONG)find_tbuf.attrib; */ 192 | return ret; 193 | } 194 | 195 | 196 | #else 197 | 198 | BOOL haveLBA(void) 199 | { 200 | union REGS r; 201 | r.x.ax = 0x4100; 202 | r.x.bx = 0x55AA; 203 | r.h.dl = 0x80; 204 | int86(0x13, &r, &r); 205 | return r.x.bx == 0xAA55 && r.x.cx & 1; 206 | } 207 | 208 | void reset_drive(int DosDrive) 209 | { 210 | union REGS regs; 211 | 212 | regs.h.ah = 0xd; 213 | intdos(®s, ®s); 214 | regs.h.ah = 0x32; 215 | regs.h.dl = DosDrive + 1; 216 | intdos(®s, ®s); 217 | } /* reset_drive */ 218 | 219 | int generic_block_ioctl(unsigned drive, unsigned cx, unsigned char *par) 220 | { 221 | union REGS regs; 222 | 223 | regs.x.ax = 0x440d; 224 | regs.x.cx = cx; 225 | regs.x.dx = (unsigned)par; 226 | regs.x.bx = drive; /* BH must be 0 for lock! */ 227 | intdos(®s, ®s); 228 | return regs.x.cflag; 229 | } /* generic_block_ioctl */ 230 | 231 | #endif 232 | 233 | 234 | void lockDrive(unsigned drive) 235 | { 236 | generic_block_ioctl(drive + 1, 0x84a, NULL); 237 | reset_drive(drive); 238 | } 239 | 240 | void unLockDrive(unsigned drive) 241 | { 242 | reset_drive(drive); 243 | generic_block_ioctl(drive + 1, 0x86a, NULL); 244 | } 245 | 246 | int getDeviceParms(unsigned drive, FileSystem fs, unsigned char *buffer) 247 | { 248 | return generic_block_ioctl(drive + 1, (fs==FAT32)?0x4860:0x860, buffer); 249 | } 250 | -------------------------------------------------------------------------------- /sys/diskio_w.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | 3 | diskio_w.c 4 | DOS-C 5 | 6 | sys utility for DOS-C 7 | 8 | Copyright (c) 1991 9 | Pasquale J. Villani 10 | All Rights Reserved 11 | 12 | This file is part of DOS-C. 13 | 14 | DOS-C is free software; you can redistribute it and/or modify it under the 15 | terms of the GNU General Public License as published by the Free Software 16 | Foundation; either version 2, or (at your option) any later version. 17 | 18 | DOS-C is distributed in the hope that it will be useful, but WITHOUT ANY 19 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 21 | details. 22 | 23 | You should have received a copy of the GNU General Public License along with 24 | DOS-C; see the file COPYING. If not, write to the Free Software Foundation, 25 | 675 Mass Ave, Cambridge, MA 02139, USA. 26 | 27 | ***************************************************************/ 28 | 29 | #include "sys.h" 30 | #include "diskio.h" 31 | #include 32 | 33 | void ShowErrorMsg(void) 34 | { 35 | LPVOID lpMsgBuf; 36 | FormatMessage( 37 | FORMAT_MESSAGE_ALLOCATE_BUFFER | 38 | FORMAT_MESSAGE_FROM_SYSTEM | 39 | FORMAT_MESSAGE_IGNORE_INSERTS, 40 | NULL, 41 | GetLastError(), 42 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language 43 | (LPTSTR) &lpMsgBuf, 44 | 0, 45 | NULL 46 | ); 47 | // Process any inserts in lpMsgBuf. 48 | // ... 49 | // Display the string. 50 | MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION ); 51 | // Free the buffer. 52 | LocalFree( lpMsgBuf ); 53 | } 54 | 55 | /* NT 5+ only, floppies only */ 56 | /* See http://www.codeguru.com/system/ReadSector.html by Sreejith S 57 | to add Win9x support 58 | */ 59 | int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, int write) 60 | //int MyAbsReadWrite(int DosDrive, UWORD count, ULONG sector, char *buffer, int write) 61 | { 62 | char devName[] = "\\\\.\\X:"; 63 | HANDLE hFloppy; 64 | ULONG bytesTransferred; 65 | 66 | /* get handle to floppy */ 67 | devName[4] = 'A' + DosDrive; 68 | if ((hFloppy = CreateFile(devName, write?GENERIC_WRITE:GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 69 | NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) return 0xFF; 70 | 71 | /* seek to desired sector */ 72 | SetFilePointer(hFloppy, sector*SEC_SIZE, NULL, FILE_BEGIN); 73 | 74 | /* actually perform the read or write */ 75 | if (write) 76 | WriteFile(hFloppy, buffer, count*SEC_SIZE, &bytesTransferred, NULL); 77 | else 78 | ReadFile(hFloppy, buffer, count*SEC_SIZE, &bytesTransferred, NULL); 79 | 80 | /* free handle */ 81 | CloseHandle(hFloppy); 82 | 83 | if (bytesTransferred != (ULONG)(count*SEC_SIZE)) 84 | { 85 | printf("Not all bytes read/written, transferred %Lu bytes\n", bytesTransferred); 86 | ShowErrorMsg(); 87 | } 88 | 89 | /* return success or failure depending on if all data transferred or not */ 90 | if (bytesTransferred == (ULONG)(count*SEC_SIZE)) 91 | return 0; 92 | else 93 | return 0xFF; 94 | } 95 | 96 | 97 | void reset_drive(int DosDrive) {} 98 | 99 | int generic_block_ioctl(unsigned drive, unsigned cx, unsigned char *par); 100 | 101 | /* 102 | * If BIOS has got LBA extensions, after the Int 13h call BX will be 0xAA55. 103 | * If extended disk access functions are supported, bit 0 of CX will be set. 104 | */ 105 | BOOL haveLBA(void) /* return TRUE if we have LBA BIOS, FALSE otherwise */ 106 | { 107 | return TRUE; 108 | } 109 | 110 | void lockDrive(unsigned drive) {} 111 | void unLockDrive(unsigned drive) {} 112 | 113 | /* returns default BPB (and other device parameters) */ 114 | int getDeviceParms(unsigned drive, FileSystem fs, unsigned char *buffer) 115 | { 116 | struct { 117 | UBYTE filler1[11]; 118 | UWORD bsBytesPerSec; 119 | UBYTE filler2[11]; 120 | UWORD bsSecPerTrack; 121 | UWORD bsHeads; 122 | ULONG bsHiddenSecs; 123 | } fakeBPB = { 0 }; 124 | HANDLE hnd; 125 | DWORD result; 126 | DISK_GEOMETRY dskGeom; 127 | PARTITION_INFORMATION partInfo; 128 | 129 | char *drivename = "A:\\"; 130 | drivename[0] = 'A' + drive; 131 | hnd = CreateFileA(drivename, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); 132 | if (hnd == INVALID_HANDLE_VALUE) 133 | { 134 | printf("Unable to get handle to drive %s (%i)\n", drivename, GetLastError()); 135 | return -1; 136 | } 137 | 138 | result = DeviceIoControl(hnd, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &dskGeom, sizeof(dskGeom), &result/*unused*/, NULL); 139 | if (result) 140 | result = DeviceIoControl(hnd, IOCTL_DISK_GET_PARTITION_INFO, NULL, 0, &partInfo, sizeof(partInfo), &result/*unused*/, NULL); 141 | CloseHandle(hnd); 142 | 143 | if (result) 144 | { 145 | /* truncation of types ok, values should not exceed max values of BPB types */ 146 | fakeBPB.bsBytesPerSec = (UWORD)dskGeom.BytesPerSector; 147 | fakeBPB.bsSecPerTrack = (UWORD)dskGeom.SectorsPerTrack; 148 | fakeBPB.bsHeads = (UWORD)dskGeom.TracksPerCylinder; 149 | fakeBPB.bsHiddenSecs = partInfo.HiddenSectors; 150 | return 0; 151 | } 152 | 153 | printf("Error obtaining drive %s geometry\n", drivename); 154 | return -1; 155 | } 156 | -------------------------------------------------------------------------------- /sys/fdkrncfg.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * * 3 | * FDKRNCFG.C - FreeDOS Kernel Configuration * 4 | * This is a simple little program that merely displays and/or changes * 5 | * the configuration options specified within the CONFIG section of * 6 | * the FreeDOS Kernel (if supported) * 7 | * * 8 | * Initially Written by Kenneth J. Davis Oct 11, 2001 (public domain) * 9 | * Future versions may contain copyrighted portions, if so the * 10 | * copyright holders should be listed after this line. * 11 | * Initial release - public domain * 12 | * * 13 | * merged into SYS by tom ehlert * 14 | ***************************************************************************/ 15 | 16 | char VERSION[] = "v1.02"; 17 | char PROGRAM[] = "SYS CONFIG"; 18 | char KERNEL[] = "KERNEL.SYS"; 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include "portab.h" 25 | /* These definitions deliberately put here instead of 26 | * #including to make executable MUCH smaller 27 | * using [s]printf from prf.c! 28 | */ 29 | #ifdef _WIN32 30 | #include 31 | #else 32 | extern int VA_CDECL printf(CONST char FAR * fmt, ...); 33 | extern int VA_CDECL sprintf(char FAR * buff, CONST char FAR * fmt, ...); 34 | #endif 35 | 36 | #if defined __WATCOMC__ && !defined(_WIN32) 37 | unsigned _dos_close(int handle); 38 | #define close _dos_close 39 | #define SEEK_SET 0 40 | int open(const char *pathname, int flags, ...); 41 | int read(int fd, void *buf, unsigned count); 42 | int write(int fd, const void *buf, unsigned count); 43 | int stat(const char *file_name, struct stat *buf); 44 | unsigned long lseek(int fildes, unsigned long offset, int whence); 45 | #pragma aux lseek = \ 46 | "mov ah, 0x42" \ 47 | "int 0x21" \ 48 | parm [bx] [dx cx] [ax] \ 49 | value [dx ax]; 50 | 51 | #else 52 | #include 53 | /* #include */ 54 | #endif 55 | 56 | #define FAR far 57 | #include "kconfig.h" 58 | 59 | KernelConfig cfg; /* static memory zeroed automatically */ 60 | 61 | typedef unsigned char byte; 62 | typedef signed char sbyte; 63 | typedef unsigned short word; 64 | typedef signed short sword; 65 | typedef unsigned long dword; 66 | typedef signed long sdword; 67 | 68 | 69 | /* Displays command line syntax */ 70 | void showUsage(void) 71 | { 72 | printf("Usage: \n" 73 | " %s \n" 74 | " %s [/help | /?]\n" 75 | " %s [ [drive:][path]%s] [option=value ...] \n", 76 | PROGRAM, PROGRAM, PROGRAM, KERNEL); 77 | printf("\n"); 78 | printf(" If no options are given, the current values are shown.\n"); 79 | printf(" /help or /? displays this usage information.\n" 80 | " [drive:][path]KERNEL.SYS specifies the kernel file to\n" 81 | " modify, if not given defaults to %s\n", KERNEL); 82 | printf("\n"); 83 | printf 84 | (" option=value ... specifies one or more options and the values\n" 85 | " to set each to. If an option is given multiple times,\n" 86 | " the value set will be the rightmost one.\n"); 87 | printf(" Current Options are: DLASORT=0|1, SHOWDRIVEASSIGNMENT=0|1\n" 88 | " SKIPCONFIGSECONDS=#, FORCELBA=0|1\n" 89 | " GLOBALENABLELBASUPPORT=0|1\n" 90 | " BootHarddiskSeconds=0|seconds to wait\n"); 91 | } 92 | 93 | /* simply reads in current configuration values, exiting program 94 | with an error message and error code unable to, otherwise 95 | cfg & kfile are valid on return. 96 | */ 97 | 98 | /* Reads in the current kernel configuration settings, 99 | return 0 on success, nonzero on error. If there was 100 | an actual error the return value is positive, if there 101 | were no errors, but the CONFIG section was not found 102 | then a negative value is returned. cfg is only altered 103 | if the return value is 0 (ie successfully found and 104 | read in the config section). The position of the file 105 | pointer on input does not matter, the file position 106 | upon return may be anywhere. The memory allocated for 107 | cfg should be freed to prevent memory leakage (it should 108 | not point to allocated memory on entry, as that memory 109 | will not be used, and will likely not be freed as a result). 110 | */ 111 | int readConfigSettings(int kfile, char *kfilename, KernelConfig * cfg) 112 | { 113 | /* Seek to start of kernel file */ 114 | if (lseek(kfile, 2, SEEK_SET) != 2) 115 | printf("can't seek to offset 2\n"), exit(1); 116 | 117 | if (read(kfile, cfg, sizeof(KernelConfig)) != sizeof(KernelConfig)) 118 | printf("can't read %u bytes\n", sizeof(KernelConfig)), exit(1); 119 | 120 | if (memcmp(cfg->CONFIG, "CONFIG", 6) != 0) 121 | { 122 | printf("Error: no CONFIG section found in kernel file <%s>\n", 123 | kfilename); 124 | printf("Only FreeDOS kernels after 2025 contain a CONFIG section!\n"); 125 | exit(1); 126 | } 127 | 128 | /* check if config settings old UPX header and adjust */ 129 | if (cfg->ConfigSize == 19) 130 | cfg->ConfigSize = 6; /* ignore 'nused87654321' */ 131 | 132 | return 1; 133 | } 134 | 135 | /* Writes config values out to file. 136 | Returns 0 on success, nonzero on error. 137 | */ 138 | int writeConfigSettings(int kfile, KernelConfig * cfg) 139 | { 140 | /* Seek to CONFIG section at start of options of kernel file */ 141 | if (lseek(kfile, 2, SEEK_SET) != 2) 142 | return 1; 143 | 144 | /* Write just the config option information out */ 145 | if (write(kfile, cfg, sizeof(KernelConfig)) != sizeof(KernelConfig)) 146 | return 1; 147 | 148 | /* successfully wrote out kernel config data */ 149 | return 0; 150 | } 151 | 152 | /* Displays kernel configuration information */ 153 | void displayConfigSettings(KernelConfig * cfg) 154 | { 155 | /* print known options and current value - only if available */ 156 | 157 | /* show kernel version if available, read only, no option to modify */ 158 | if (cfg->ConfigSize >= 12) 159 | { 160 | printf 161 | ("%s kernel %s (build %d.%d OEM:%02X)\n", 162 | (cfg->Version_OemID == 0xFD)?"FreeDOS":"DOS-C", 163 | cfg->Version_Release?"SVN":"Release", 164 | cfg->Version_Major, 165 | cfg->Version_Revision, 166 | cfg->Version_OemID 167 | ); 168 | } 169 | printf("Config Size is %u\n", cfg->ConfigSize); 170 | 171 | if (cfg->ConfigSize >= 1) 172 | { 173 | printf 174 | ("DLASORT=0x%02X Sort disks by drive order: *0=no, 1=yes\n", 175 | cfg->DLASortByDriveNo); 176 | } 177 | 178 | if (cfg->ConfigSize >= 2) 179 | { 180 | printf 181 | ("SHOWDRIVEASSIGNMENT=0x%02X Show how drives assigned: *1=yes 0=no\n", 182 | cfg->InitDiskShowDriveAssignment); 183 | } 184 | 185 | if (cfg->ConfigSize >= 3) 186 | { 187 | printf 188 | ("SKIPCONFIGSECONDS=%-3d time to wait for F5/F8: *2 sec (skip < 0)\n", 189 | cfg->SkipConfigSeconds); 190 | } 191 | 192 | if (cfg->ConfigSize >= 4) 193 | { 194 | printf 195 | ("FORCELBA=0x%02X Always use LBA if possible: *0=no, 1=yes\n", 196 | cfg->ForceLBA); 197 | } 198 | 199 | if (cfg->ConfigSize >= 5) 200 | { 201 | printf 202 | ("GLOBALENABLELBASUPPORT=0x%02X Enable LBA support: *1=yes, 0=no\n", 203 | cfg->GlobalEnableLBAsupport); 204 | } 205 | 206 | if (cfg->ConfigSize >= 6) 207 | { 208 | printf 209 | ("BootHarddiskSeconds=%d : *0=no else seconds to wait for key\n", 210 | cfg->BootHarddiskSeconds); 211 | } 212 | 213 | #if 0 /* we assume that SYS is as current as the kernel */ 214 | 215 | /* Print value any options added that are unknown as hex dump */ 216 | if (cfg->configHdr.configSize > sizeof(ConfigData)) 217 | { 218 | printf("Additional options are available, they are not currently\n" 219 | "supported by this tool. The current extra values are (in Hex):\n"); 220 | for (i = 0; i < (cfg->configSize - sizeof(ConfigData)); i++) 221 | { 222 | if ((i % 32) == 0) 223 | printf("\n"); 224 | else if ((i % 4) == 0) 225 | printf(" "); 226 | printf("%02X", (unsigned int)cfg->extra[i]); 227 | } 228 | printf("\n"); 229 | } 230 | #endif 231 | printf("\n"); 232 | } 233 | 234 | /* Note: The setXXXOption functions will set the config option of 235 | type XXX to the value given. It will display a warning, but 236 | allow probably invalid values to be used (cause I believe in 237 | letting the user do what they want, not what we guess they mean). 238 | Additionally, we only indicate a change if a new value is used, 239 | to force changes written even if same value is used, use same 240 | option twice, first with a different value & second time with 241 | (same) value desired. kjd 242 | */ 243 | 244 | /* Sets the given location to an unsigned byte value if different, 245 | displays warning if values exceeds max 246 | */ 247 | void setByteOption(byte * option, char *value, word max, int *updated, 248 | char *name) 249 | { 250 | unsigned long optionValue; 251 | 252 | /* optionValue = atoi(value); Use strtoul instead of atoi/atol as it detect base (0xFF & 255) */ 253 | optionValue = strtoul(value, NULL, 0); 254 | 255 | if (optionValue > 255) 256 | { 257 | printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", 258 | name, optionValue); 259 | } 260 | if ((byte) optionValue > max) 261 | { 262 | printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", 263 | name, (unsigned int)((byte) optionValue)); 264 | } 265 | /* Don't bother updating if same value */ 266 | if ((byte) optionValue != *option) 267 | { 268 | *option = (byte) optionValue; 269 | *updated = 1; 270 | } 271 | } 272 | 273 | /* Sets the given location to a signed byte value if different, 274 | displays warning if values exceeds max or is less than min 275 | */ 276 | void setSByteOption(sbyte * option, char *value, sword min, sword max, 277 | int *updated, char *name) 278 | { 279 | signed long optionValue; 280 | 281 | /* optionValue = atoi(value); Use strtol instead of atoi/atol as it detects base */ 282 | optionValue = strtol(value, NULL, 0); 283 | 284 | if ((optionValue < -128) || (optionValue > 127)) 285 | { 286 | printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", 287 | name, optionValue); 288 | } 289 | if (((sbyte) optionValue > max) || ((sbyte) optionValue < min)) 290 | { 291 | printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", 292 | name, (signed int)((byte) optionValue)); 293 | } 294 | /* Don't bother updating if same value */ 295 | if ((sbyte) optionValue != *option) 296 | { 297 | *option = (sbyte) optionValue; 298 | *updated = 1; 299 | } 300 | } 301 | 302 | #if 0 /* disable until there are (un)signed word configuration values */ 303 | /* Sets the given location to an unsigned word value if different, 304 | displays warning if values exceeds max 305 | */ 306 | void setWordOption(word * option, char *value, dword max, int *updated, 307 | char *name) 308 | { 309 | unsigned long optionValue; 310 | 311 | /* optionValue = atol(value); Use strtoul instead of atoi/atol as it allows 0xFF and 255 */ 312 | optionValue = strtoul(value, NULL, 0); 313 | 314 | if (optionValue > 65535) 315 | { 316 | printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", 317 | name, optionValue); 318 | } 319 | if ((word) optionValue > max) 320 | { 321 | printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", 322 | name, (unsigned int)optionValue); 323 | } 324 | /* Don't bother updating if same value */ 325 | if ((word) optionValue != *option) 326 | { 327 | *option = (word) optionValue; 328 | *updated = 1; 329 | } 330 | } 331 | 332 | /* Sets the given location to a signed byte value if different, 333 | displays warning if values exceeds max or is less than min 334 | */ 335 | void setSWordOption(sword * option, char *value, sdword min, sdword max, 336 | int *updated, char *name) 337 | { 338 | signed long optionValue; 339 | 340 | /* optionValue = atol(value); Use strtol instead of atoi/atol as it allows 0xFF and 255 */ 341 | optionValue = strtol(value, NULL, 0); 342 | 343 | if ((optionValue < -32768) || (optionValue > 32767)) 344 | { 345 | printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", 346 | name, optionValue); 347 | } 348 | 349 | if (((sword) optionValue > max) || ((sword) optionValue < min)) 350 | { 351 | printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", 352 | name, (signed int)optionValue); 353 | } 354 | /* Don't bother updating if same value */ 355 | if ((sword) optionValue != *option) 356 | { 357 | *option = (sword) optionValue; 358 | *updated = 1; 359 | } 360 | } 361 | #endif 362 | 363 | /* Main, processes command line options and calls above 364 | functions as required. 365 | */ 366 | int FDKrnConfigMain(int argc, char **argv) 367 | { 368 | char *kfilename = KERNEL; 369 | int kfile; 370 | int updates = 0; /* flag used to indicate if we need to update kernel */ 371 | int readonly = 0; /* flag indicates kernel was opened read-only */ 372 | int argstart, i; 373 | char *cptr; 374 | char *argptr; 375 | 376 | printf("FreeDOS Kernel Configuration %s\n", VERSION); 377 | 378 | /* 1st go through and just process arguments (help/filename/etc) */ 379 | for (i = 1; i < argc; i++) 380 | { 381 | argptr = argv[i]; 382 | 383 | /* is it an argument or an option specifier */ 384 | if (argptr[0] == '-' || argptr[0] == '/') 385 | { 386 | switch (argptr[1]) 387 | { 388 | case 'H': 389 | case 'h': 390 | case '?': 391 | showUsage(); 392 | exit(0); 393 | 394 | default: 395 | printf("Invalid argument found <%s>.\nUse %s /help for usage.\n", 396 | argptr, PROGRAM); 397 | exit(1); 398 | } 399 | } 400 | else if (memicmp(argptr, "CONFIG", 6) == 0) 401 | { 402 | /* ignore */ 403 | } 404 | } 405 | 406 | argstart = 2; 407 | 408 | argptr = argv[argstart]; 409 | 410 | #if 0 /* No arguments is acceptable, just displays current settings using default kernel file */ 411 | if (argptr == 0) 412 | { 413 | showUsage(); 414 | exit(1); 415 | } 416 | #endif 417 | 418 | /* the first argument may be the kernel name */ 419 | if ((argstart < argc) && (strchr(argptr, '=') == NULL)) 420 | { 421 | kfilename = argptr; 422 | argstart++; 423 | } 424 | 425 | kfile = open(kfilename, O_RDWR | O_BINARY); 426 | 427 | if (kfile < 0) 428 | { 429 | /* attempt to open read only to allow viewing options */ 430 | kfile = open(kfilename, O_RDONLY | O_BINARY); 431 | readonly = 1; 432 | 433 | if (kfile < 0) 434 | printf("Error: unable to open kernel file <%s>\n", kfilename), exit(1); 435 | } 436 | 437 | /* now that we know the filename (default or given) get config info */ 438 | readConfigSettings(kfile, kfilename, &cfg); 439 | 440 | for (i = argstart; i < argc; i++) 441 | { 442 | argptr = argv[i]; 443 | 444 | if ((cptr = strchr(argptr, '=')) == NULL) 445 | goto illegal_arg; 446 | 447 | /* split argptr into 2 pieces and make cptr point to 2nd one */ 448 | *cptr = '\0'; 449 | cptr++; 450 | 451 | /* allow 3 valid characters */ 452 | if (memicmp(argptr, "DLASORT", 3) == 0) 453 | { 454 | setByteOption(&(cfg.DLASortByDriveNo), cptr, 1, &updates, "DLASORT"); 455 | } 456 | else if (memicmp(argptr, "SHOWDRIVEASSIGNMENT", 3) == 0) 457 | { 458 | setByteOption(&(cfg.InitDiskShowDriveAssignment), 459 | cptr, 1, &updates, "SHOWDRIVEASSIGNMENT"); 460 | } 461 | else if (memicmp(argptr, "SKIPCONFIGSECONDS", 3) == 0) 462 | { 463 | setSByteOption(&(cfg.SkipConfigSeconds), 464 | cptr, -128, 127, &updates, "SKIPCONFIGSECONDS"); 465 | } 466 | else if (memicmp(argptr, "FORCELBA", 3) == 0) 467 | { 468 | setByteOption(&(cfg.ForceLBA), cptr, 1, &updates, "FORCELBA"); 469 | } 470 | else if (memicmp(argptr, "GLOBALENABLELBASUPPORT", 3) == 0) 471 | { 472 | setByteOption(&(cfg.GlobalEnableLBAsupport), 473 | cptr, 1, &updates, "GLOBALENABLELBASUPPORT"); 474 | } 475 | else if (memicmp(argptr, "BootHarddiskSeconds", 3) == 0) 476 | { 477 | setSByteOption(&(cfg.BootHarddiskSeconds), 478 | cptr, 0, 127, &updates, "BootHarddiskSeconds"); 479 | } 480 | else 481 | { 482 | illegal_arg: 483 | printf("Unknown option found <%s>.\nUse %s /help for usage.\n", 484 | argptr, PROGRAM); 485 | exit(1); 486 | } 487 | } 488 | 489 | /* warn user if attempt to modify read-only file */ 490 | if (updates && readonly) 491 | { 492 | printf("Kernel %s opened read-only, changes ignored!\n", kfilename); 493 | /* reload current settings, ignore newly requested ones */ 494 | readConfigSettings(kfile, kfilename, &cfg); 495 | } 496 | 497 | /* write out new config values if modified */ 498 | if (updates && !readonly) 499 | { 500 | /* update it */ 501 | if (writeConfigSettings(kfile, &cfg)) 502 | { 503 | printf("Error: Unable to write configuration changes to kernel!\n"); 504 | printf(" <%s>\n", kfilename); 505 | close(kfile); 506 | exit(1); 507 | } 508 | 509 | /* display new settings */ 510 | printf("\nUpdated Kernel settings.\n"); 511 | } 512 | else 513 | printf("\nCurrent Kernel settings.\n"); 514 | 515 | /* display current settings */ 516 | displayConfigSettings(&cfg); 517 | 518 | /* and done */ 519 | close(kfile); 520 | 521 | return 0; 522 | } 523 | -------------------------------------------------------------------------------- /sys/getenv.c: -------------------------------------------------------------------------------- 1 | #ifdef __WATCOMC__ 2 | 3 | #include 4 | 5 | /* WATCOM's getenv is case-insensitive which wastes a lot of space 6 | for our purposes. So here's a simple case-sensitive one */ 7 | char *getenv(const char *name) 8 | { 9 | char **envp, *ep; 10 | const char *np; 11 | char ec, nc; 12 | 13 | for (envp = environ; (ep = *envp) != NULL; envp++) { 14 | np = name; 15 | do { 16 | ec = *ep++; 17 | nc = *np++; 18 | if (nc == 0) { 19 | if (ec == '=') 20 | return ep; 21 | break; 22 | } 23 | } while (ec == nc); 24 | } 25 | return NULL; 26 | } 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /sys/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # makefile for bin2c.com and sys.com 3 | # 4 | # $Id: makefile,v 1.1 2009-07-10 14:59:02 perditionc Exp $ 5 | # 6 | 7 | !include "../mkfiles/generic.mak" 8 | 9 | DOS_FILES=diskio_d.c prf.c getenv.c talloc.c 10 | 11 | WIN_FILES=diskio_w.c 12 | 13 | SYS_C=sys.c usage.c initopts.c fdkrncfg.c putboot.c copy.c bootmgr.c 14 | 15 | ######################################################################## 16 | 17 | all: bin2c.com ..\bin\sys.com 18 | 19 | win: bin2c.com ..\bin\sys.exe 20 | 21 | bin2c.com: bin2c.c $(DEPENDS) 22 | 23 | fat12com.h: ..\boot\fat12.bin bin2c.com 24 | bin2c ..\boot\fat12.bin $*.h $* 25 | 26 | fat16com.h: ..\boot\fat16.bin bin2c.com 27 | bin2c ..\boot\fat16.bin $*.h $* 28 | 29 | fat32chs.h: ..\boot\fat32chs.bin bin2c.com 30 | bin2c ..\boot\$*.bin $*.h $* 31 | 32 | fat32lba.h: ..\boot\fat32lba.bin bin2c.com 33 | bin2c ..\boot\$*.bin $*.h $* 34 | 35 | oemfat12.h: ..\boot\oemfat12.bin bin2c.com 36 | bin2c ..\boot\$*.bin $*.h $* 37 | 38 | oemfat16.h: ..\boot\oemfat16.bin bin2c.com 39 | bin2c ..\boot\$*.bin $*.h $* 40 | 41 | ntfs.h: ..\boot\ntfs.bin bin2c.com 42 | bin2c ..\boot\$*.bin $*.h $* 43 | 44 | ..\bin\sys.com: $(SYS_C) $(DOS_FILES) sys.h ..\hdr\*.h fat12com.h fat16com.h fat32chs.h fat32lba.h oemfat12.h oemfat16.h config.h 45 | $(CL) $(CFLAGST) $(SYS_C) $(DOS_FILES) 46 | copy sys.com ..\bin 47 | del sys.com 48 | 49 | ..\bin\sys.exe: $(SYS_C) $(WIN_FILES) $(DOS_FILES) sys.h ..\hdr\*.h fat12com.h fat16com.h fat32chs.h fat32lba.h oemfat12.h oemfat16.h config.h 50 | $(CL) $(CFLAGSC) $(SYS_C) $(DOS_FILES) 51 | ECHO $(CL) $(CFLAGSW) $(SYS_C) $(WIN_FILES) 52 | upx --8086 --best --ultra-brute sys.exe 53 | ..\..\..\TOOLS\FIXHDR\fixstub sys.exe ..\bin\sysstub.exe 54 | $(CLW) $(CFLAGSW) -D_WIN32 $(SYS_C) $(WIN_FILES) -"OP STUB=..\bin\sysstub.exe" 55 | copy sys.exe ..\bin 56 | del sys.exe 57 | 58 | ######################################################################## 59 | 60 | clean: 61 | -$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf 62 | 63 | clobber: clean 64 | -$(RM) bin2c.com ..\bin\sys.com ..\bin\sysstub.exe ..\bin\sys.exe fat*.h oem*.h status.me *.exe 65 | -------------------------------------------------------------------------------- /sys/prf.c: -------------------------------------------------------------------------------- 1 | /****************************************************************/ 2 | /* */ 3 | /* prf.c */ 4 | /* */ 5 | /* Abbreviated printf Function */ 6 | /* */ 7 | /* Copyright (c) 1995 */ 8 | /* Pasquale J. Villani */ 9 | /* All Rights Reserved */ 10 | /* */ 11 | /* This file is part of DOS-C. */ 12 | /* */ 13 | /* DOS-C is free software; you can redistribute it and/or */ 14 | /* modify it under the terms of the GNU General Public License */ 15 | /* as published by the Free Software Foundation; either version */ 16 | /* 2, or (at your option) any later version. */ 17 | /* */ 18 | /* DOS-C is distributed in the hope that it will be useful, but */ 19 | /* WITHOUT ANY WARRANTY; without even the implied warranty of */ 20 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 21 | /* the GNU General Public License for more details. */ 22 | /* */ 23 | /* You should have received a copy of the GNU General Public */ 24 | /* License along with DOS-C; see the file COPYING. If not, */ 25 | /* write to the Free Software Foundation, 675 Mass Ave, */ 26 | /* Cambridge, MA 02139, USA. */ 27 | /****************************************************************/ 28 | 29 | #include "portab.h" 30 | 31 | #include 32 | #include 33 | 34 | 35 | /* special console output routine */ 36 | /*#define DOSEMU */ 37 | #ifdef DOSEMU 38 | 39 | #define MAX_BUFSIZE 80 /* adjust if necessary */ 40 | static int buff_offset = 0; 41 | static char buff[MAX_BUFSIZE]; 42 | 43 | void put_console(int c) 44 | { 45 | if (buff_offset >= MAX_BUFSIZE) 46 | { 47 | buff_offset = 0; 48 | printf("Printf buffer overflow!\n"); 49 | } 50 | if (c == '\n') 51 | { 52 | buff[buff_offset] = 0; 53 | buff_offset = 0; 54 | #ifdef __TURBOC__ 55 | _ES = FP_SEG(buff); 56 | _DX = FP_OFF(buff); 57 | _AX = 0x13; 58 | __int__(0xe6); 59 | #elif defined(I86) 60 | asm 61 | { 62 | push ds; 63 | pop es; 64 | mov dx, offset buff; 65 | mov ax, 0x13; 66 | int 0xe6; 67 | } 68 | #endif 69 | } 70 | else 71 | { 72 | buff[buff_offset] = c; 73 | buff_offset++; 74 | } 75 | } 76 | #else 77 | #ifdef __WATCOMC__ 78 | void int29(char c); 79 | #pragma aux int29 = "int 0x29" parm [al] modify exact [bx]; 80 | 81 | #ifdef DEBUG_PRINT_COMPORT 82 | void fastComPrint(char c); 83 | #pragma aux fastComPrint = \ 84 | "mov bx, 0xFD05" \ 85 | "int 0x29" parm [al] modify exact [bx]; 86 | #endif 87 | #endif 88 | 89 | void put_console(int c) 90 | { 91 | if (c == '\n') 92 | put_console('\r'); 93 | 94 | write(1, &c, 1); /* write character to stdout */ 95 | } 96 | #endif /* DOSEMU */ 97 | 98 | static BYTE FAR *charp = 0; 99 | 100 | STATIC VOID handle_char(COUNT); 101 | STATIC void do_printf(const char FAR *, va_list); 102 | VOID VA_CDECL printf(const char FAR * fmt, ...); 103 | 104 | /* special handler to switch between sprintf and printf */ 105 | STATIC VOID handle_char(COUNT c) 106 | { 107 | if (charp == 0) 108 | put_console(c); 109 | else 110 | #ifdef DEBUG_PRINT_COMPORT 111 | if (charp == (BYTE FAR *)-1) 112 | fastComPrint(c); 113 | else 114 | #endif 115 | *charp++ = c; 116 | } 117 | 118 | #define LEFT 0 119 | #define RIGHT 1 120 | #define ZEROSFILL 2 121 | #define LONGARG 4 122 | 123 | /* printf -- short version of printf to conserve space */ 124 | VOID VA_CDECL printf(CONST BYTE FAR *fmt, ...) 125 | { 126 | va_list arg; 127 | va_start(arg, fmt); 128 | charp = 0; 129 | do_printf(fmt, arg); 130 | } 131 | 132 | VOID VA_CDECL sprintf(char FAR * buff, CONST BYTE FAR * fmt, ...) 133 | { 134 | va_list arg; 135 | 136 | va_start(arg, fmt); 137 | charp = buff; 138 | do_printf(fmt, arg); 139 | handle_char('\0'); 140 | } 141 | 142 | #ifdef DEBUG_PRINT_COMPORT 143 | VOID dbgc_printf(CONST BYTE FAR * fmt, ...) 144 | { 145 | va_list arg; 146 | va_start(arg, fmt); 147 | charp = (BYTE FAR *)-1; 148 | do_printf(fmt, arg); 149 | } 150 | #endif 151 | 152 | STATIC void do_printf(CONST BYTE FAR * fmt, va_list arg) 153 | { 154 | int base, size; 155 | char s[13]; /* long enough for a 32-bit octal number string with sign */ 156 | char flags, FAR *p; 157 | 158 | for (;*fmt != '\0'; fmt++) 159 | { 160 | if (*fmt != '%') 161 | { 162 | handle_char(*fmt); 163 | continue; 164 | } 165 | 166 | fmt++; 167 | flags = RIGHT; 168 | 169 | if (*fmt == '-') 170 | { 171 | flags = LEFT; 172 | fmt++; 173 | } 174 | 175 | if (*fmt == '0') 176 | { 177 | flags |= ZEROSFILL; 178 | fmt++; 179 | } 180 | 181 | size = 0; 182 | while (1) 183 | { 184 | unsigned c = (unsigned char)(*fmt - '0'); 185 | if (c > 9) 186 | break; 187 | fmt++; 188 | size = size * 10 + c; 189 | } 190 | 191 | if (*fmt == 'l') 192 | { 193 | flags |= LONGARG; 194 | fmt++; 195 | } 196 | 197 | switch (*fmt) 198 | { 199 | case '\0': 200 | va_end(arg); 201 | return; 202 | 203 | case 'c': 204 | handle_char(va_arg(arg, int)); 205 | continue; 206 | 207 | case 'p': 208 | { 209 | UWORD w0 = va_arg(arg, unsigned); 210 | char FAR *tmp = charp; 211 | sprintf(s, "%04x:%04x", va_arg(arg, unsigned), w0); 212 | p = s; 213 | charp = tmp; 214 | break; 215 | } 216 | 217 | case 's': 218 | p = va_arg(arg, char *); 219 | break; 220 | 221 | case 'F': 222 | fmt++; 223 | /* we assume %Fs here */ 224 | case 'S': 225 | p = va_arg(arg, char FAR *); 226 | break; 227 | 228 | case 'i': 229 | case 'd': 230 | base = -10; 231 | goto lprt; 232 | 233 | case 'o': 234 | base = 8; 235 | goto lprt; 236 | 237 | case 'u': 238 | base = 10; 239 | goto lprt; 240 | 241 | case 'X': 242 | case 'x': 243 | base = 16; 244 | 245 | lprt: 246 | { 247 | long n; 248 | ULONG u; 249 | BOOL minus = FALSE; 250 | BYTE FAR *t = s + sizeof(s) - 1; 251 | 252 | if (flags & LONGARG) 253 | n = va_arg(arg, long); 254 | else 255 | { 256 | n = va_arg(arg, int); 257 | if (base >= 0) 258 | n = (long)(unsigned)n; 259 | } 260 | /* convert a long integer to a string in any base (2-16) */ 261 | u = n; 262 | if (base < 0) /* signals signed conversion */ 263 | { 264 | base = -base; 265 | if (n < 0) 266 | { 267 | u = -n; 268 | minus++; 269 | } 270 | } 271 | *t = '\0'; /* terminate the number string */ 272 | do /* generate digits in reverse order */ 273 | *--t = "0123456789ABCDEF"[(UWORD)(u % base)]; 274 | while ((u /= base) > 0); 275 | if (minus) 276 | *--t = '-'; 277 | p = t; 278 | } 279 | break; 280 | 281 | default: 282 | handle_char('?'); 283 | 284 | handle_char(*fmt); 285 | continue; 286 | 287 | } 288 | { 289 | size_t i = 0; 290 | while(p[i]) i++; 291 | size -= i; 292 | } 293 | 294 | if (flags & RIGHT) 295 | { 296 | int ch = ' '; 297 | if (flags & ZEROSFILL) ch = '0'; 298 | for (; size > 0; size--) 299 | handle_char(ch); 300 | } 301 | for (; *p != '\0'; p++) 302 | handle_char(*p); 303 | 304 | for (; size > 0; size--) 305 | handle_char(' '); 306 | } 307 | va_end(arg); 308 | } 309 | 310 | 311 | #ifdef TEST 312 | /* 313 | this testprogram verifies that the strings are printed correctly 314 | ( or the way, I expect them to print) 315 | 316 | compile like (note -DTEST !) 317 | 318 | c:\tc\tcc -DTEST -Ihdr kernel\prf.c 319 | 320 | and run. If strings are wrong, the program will wait for a key 321 | 322 | */ 323 | #include 324 | #include 325 | 326 | struct { 327 | char *should; 328 | char *format; 329 | unsigned lowint; 330 | unsigned highint; 331 | 332 | } testarray[] = { 333 | { 334 | "hello world", "%s %s", (unsigned)"hello", (unsigned)"world"}, 335 | { 336 | "hello", "%3s", (unsigned)"hello", 0}, 337 | { 338 | " hello", "%7s", (unsigned)"hello", 0}, 339 | { 340 | "hello ", "%-7s", (unsigned)"hello", 0}, 341 | { 342 | "hello", "%s", (unsigned)"hello", 0}, 343 | { 344 | "1", "%d", 1, 0}, 345 | { 346 | "-1", "%d", -1, 0}, 347 | { 348 | "65535", "%u", -1, 0}, 349 | { 350 | "-32768", "%d", 0x8000, 0}, 351 | { 352 | "32767", "%d", 0x7fff, 0}, 353 | { 354 | "-32767", "%d", 0x8001, 0}, 355 | { 356 | "8000", "%x", 0x8000, 0}, 357 | { 358 | " 1", "%4x", 1, 0}, 359 | { 360 | "0001", "%04x", 1, 0}, 361 | { 362 | "1 ", "%-4x", 1, 0}, 363 | { 364 | "1 ", "%-04x", 1, 0}, 365 | { 366 | "1", "%ld", 1, 0}, 367 | { 368 | "-1", "%ld", -1, -1}, 369 | { 370 | "65535", "%ld", -1, 0}, 371 | { 372 | "65535", "%u", -1, 0}, 373 | { 374 | "8000", "%lx", 0x8000, 0}, 375 | { 376 | "80000000", "%lx", 0, 0x8000}, 377 | { 378 | " 1", "%4lx", 1, 0}, 379 | { 380 | "0001", "%04lx", 1, 0}, 381 | { 382 | "1 ", "%-4lx", 1, 0}, 383 | { 384 | "1 ", "%-04lx", 1, 0}, 385 | { 386 | "-2147483648", "%ld", 0, 0x8000}, 387 | { 388 | "2147483648", "%lu", 0, 0x8000}, 389 | { 390 | "2147483649", "%lu", 1, 0x8000}, 391 | { 392 | "-2147483647", "%ld", 1, 0x8000}, 393 | { 394 | "32767", "%ld", 0x7fff, 0}, 395 | { 396 | "ptr 1234:5678", "ptr %p", 0x5678, 0x1234}, {0}}; 397 | 398 | void test(char *should, char *format, unsigned lowint, unsigned highint) 399 | { 400 | char b[100]; 401 | 402 | sprintf(b, format, lowint, highint); 403 | 404 | printf("'%s' = '%s'\n", should, b); 405 | 406 | if (strcmp(b, should)) 407 | { 408 | printf("\nhit a key\n"); 409 | getch(); 410 | } 411 | } 412 | 413 | int main(void) 414 | { 415 | int i; 416 | printf("hello world\n"); 417 | 418 | for (i = 0; testarray[i].should; i++) 419 | { 420 | test(testarray[i].should, testarray[i].format, testarray[i].lowint, 421 | testarray[i].highint); 422 | } 423 | return 0; 424 | } 425 | #endif 426 | 427 | -------------------------------------------------------------------------------- /sys/sys.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | 3 | sys.c 4 | DOS-C 5 | 6 | sys utility for DOS-C 7 | 8 | Copyright (c) 1991 9 | Pasquale J. Villani 10 | All Rights Reserved 11 | 12 | This file is part of DOS-C. 13 | 14 | DOS-C is free software; you can redistribute it and/or modify it under the 15 | terms of the GNU General Public License as published by the Free Software 16 | Foundation; either version 2, or (at your option) any later version. 17 | 18 | DOS-C is distributed in the hope that it will be useful, but WITHOUT ANY 19 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 21 | details. 22 | 23 | You should have received a copy of the GNU General Public License along with 24 | DOS-C; see the file COPYING. If not, write to the Free Software Foundation, 25 | 675 Mass Ave, Cambridge, MA 02139, USA. 26 | 27 | ***************************************************************/ 28 | 29 | #include "sys.h" 30 | 31 | BYTE pgm[] = "SYS"; 32 | 33 | 34 | int main(int argc, char **argv) 35 | { 36 | SYSOptions opts; /* boot options and other flags */ 37 | BYTE srcFile[SYS_MAXPATH]; /* full path+name of [kernel] file [to copy] */ 38 | 39 | printf(SYS_NAME " System Installer " SYS_VERSION ", " __DATE__ "\n"); 40 | 41 | #ifdef FDCONFIG 42 | if (argc > 1 && memicmp(argv[1], "CONFIG", 6) == 0) 43 | { 44 | exit(FDKrnConfigMain(argc, argv)); 45 | } 46 | #endif 47 | 48 | initOptions(argc, argv, &opts); 49 | 50 | printf("Processing boot sector...\n"); 51 | put_boot(&opts); 52 | 53 | if (opts.copyKernel) 54 | { 55 | printf("Now copying system files...\n"); 56 | 57 | sprintf(srcFile, "%s%s", opts.srcDrive, (opts.fnKernel)?opts.fnKernel:opts.kernel.kernel); 58 | if (!copy(srcFile, opts.dstDrive, opts.kernel.kernel)) 59 | { 60 | printf("%s: cannot copy \"%s\"\n", pgm, srcFile); 61 | exit(1); 62 | } /* copy kernel */ 63 | 64 | if (opts.kernel.dos) 65 | { 66 | sprintf(srcFile, "%s%s", opts.srcDrive, opts.kernel.dos); 67 | if (!copy(srcFile, opts.dstDrive, opts.kernel.dos) && opts.kernel.minsize) 68 | { 69 | printf("%s: cannot copy \"%s\"\n", pgm, srcFile); 70 | exit(1); 71 | } /* copy secondary file (DOS) */ 72 | } 73 | } 74 | 75 | if (opts.copyShell) 76 | { 77 | printf("Copying shell (command interpreter)...\n"); 78 | 79 | /* full source path+name including possible use of COMSPEC determined during initOptions processing */ 80 | if (!copy(opts.fnCmd, opts.dstDrive, "COMMAND.COM")) 81 | { 82 | printf("\n%s: failed to copy command interpreter (shell) file %s\n", pgm, opts.fnCmd); 83 | exit(1); 84 | } /* copy shell */ 85 | } 86 | 87 | #ifdef USEBOOTMANAGER 88 | if (opts.addToBtMgr != NONE) 89 | { 90 | if (!writeBootLoaderEntry(&opts)) 91 | printf("\n%s: failed to update boot manager\n", pgm); 92 | } 93 | #endif 94 | 95 | printf("\nSystem transferred.\n"); 96 | return 0; 97 | } 98 | -------------------------------------------------------------------------------- /sys/sys.h: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | 3 | sys.h 4 | DOS-C 5 | 6 | sys utility for DOS-C 7 | 8 | Copyright (c) 1991 9 | Pasquale J. Villani 10 | All Rights Reserved 11 | 12 | This file is part of DOS-C. 13 | 14 | DOS-C is free software; you can redistribute it and/or modify it under the 15 | terms of the GNU General Public License as published by the Free Software 16 | Foundation; either version 2, or (at your option) any later version. 17 | 18 | DOS-C is distributed in the hope that it will be useful, but WITHOUT ANY 19 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 21 | details. 22 | 23 | You should have received a copy of the GNU General Public License along with 24 | DOS-C; see the file COPYING. If not, write to the Free Software Foundation, 25 | 675 Mass Ave, Cambridge, MA 02139, USA. 26 | 27 | ***************************************************************/ 28 | #ifndef _SYS_H_ 29 | #define _SYS_H_ 30 | 31 | #define SYS_VERSION "v3.8" 32 | #include "config.h" 33 | 34 | #ifndef SYS_NAME 35 | #ifndef DRSYS 36 | #define SYS_NAME "FreeDOS" 37 | #else 38 | #define SYS_NAME "Enhanced DR-DOS" 39 | #endif 40 | #endif 41 | 42 | 43 | #ifdef _WIN32 44 | #include 45 | #endif 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | #include 54 | #define SYS_MAXPATH 260 55 | #include "portab.h" 56 | #include "algnbyte.h" 57 | #include "device.h" 58 | #include "dcb.h" 59 | #include "fat.h" 60 | 61 | #ifdef _WIN32 62 | #include 63 | #include 64 | #ifndef __WATCOMC__ 65 | #include 66 | #endif 67 | #else 68 | /* These definitions deliberately put here instead of 69 | * #including to make executable MUCH smaller 70 | * using [s]printf from prf.c! 71 | */ 72 | extern int VA_CDECL printf(CONST char FAR * fmt, ...); 73 | extern int VA_CDECL sprintf(char FAR * buff, CONST char FAR * fmt, ...); 74 | 75 | int stat(const char *file_name, struct stat *statbuf); 76 | #endif 77 | 78 | 79 | extern BYTE pgm[]; // = "SYS"; 80 | 81 | 82 | #ifdef FDCONFIG 83 | int FDKrnConfigMain(int argc, char **argv); 84 | #endif 85 | 86 | /* Indicates file system destination currently formatted as */ 87 | typedef enum {UNKNOWN=0, FAT12 = 12, FAT16 = 16, FAT32 = 32} FileSystem; 88 | 89 | /* Indicates boot managers to add to */ 90 | typedef enum {NONE=0, USEBTMGR=1, SYSLINUX=2, FREELDR=3, NTLDR=4, GRUB=5, GRUB2=6} BtMgr; 91 | 92 | /* FreeDOS sys, we default to our kernel and load segment, but 93 | if not found (or explicitly given) support OEM DOS variants 94 | (such as DR-DOS or a FreeDOS kernel mimicing other DOSes). 95 | Note: other (especially older) DOS versions expect the boot 96 | loader to perform particular steps, which we may not do; 97 | older PC/MS DOS variants may work with the OEM compatible 98 | boot sector (optionally included). 99 | */ 100 | typedef struct DOSBootFiles { 101 | const char * kernel; /* filename boot sector loads and chains to */ 102 | const char * dos; /* optional secondary file for OS */ 103 | WORD loadaddr; /* segment kernel file expects to start at for stdbs */ 104 | /* or offset to jump into kernel for oem compat bs */ 105 | BOOL stdbs; /* use FD boot sector (T) or oem compat one (F) */ 106 | LONG minsize; /* smallest dos file can be and be valid, 0=existance optional */ 107 | } DOSBootFiles; 108 | extern DOSBootFiles bootFiles[]; 109 | 110 | typedef struct SYSOptions { 111 | BYTE srcDrive[SYS_MAXPATH]; /* source drive:[path], root assumed if no path */ 112 | BYTE dstDrive; /* destination drive [STD SYS option] */ 113 | int flavor; /* DOS variant we want to boot, default is AUTO/FD */ 114 | DOSBootFiles kernel; /* file name(s) and relevant data for kernel */ 115 | BYTE defBootDrive; /* value stored in boot sector for drive, eg 0x0=A, 0x80=C */ 116 | BOOL ignoreBIOS; /* true to NOP out boot sector code to get drive# from BIOS */ 117 | BOOL skipBakBSCopy; /* true to not copy boot sector to backup boot sector */ 118 | BOOL copyKernel; /* true to copy kernel files */ 119 | BOOL copyShell; /* true to copy command interpreter */ 120 | BOOL writeBS; /* true to write boot sector to drive/partition LBA 0 */ 121 | BtMgr addToBtMgr; /* add entry to existing boot manager */ 122 | BYTE *bsFile; /* file name & path to save bs to when saving to file */ 123 | BYTE *bsFileOrig; /* file name & path to save original bs when backing up */ 124 | BYTE *altBSCode; /* file name & path for external boot code file */ 125 | BYTE *fnKernel; /* optional override to source kernel filename (src only) */ 126 | BYTE *fnCmd; /* optional override to cmd interpreter filename (src & dest) */ 127 | enum {AUTO=0,LBA,CHS} force; /* optional force boot sector to only use LBA or CHS */ 128 | BOOL verbose; /* show extra (DEBUG) output */ 129 | int bsCount; /* how many sectors to read/write */ 130 | 131 | FileSystem fs; /* current file system, set based on existing BPB not user option */ 132 | ULONG rootSector; /* obtained from existing BPB, used for updating root directory */ 133 | UCOUNT rootDirSectors; /* when booting with OEM boot logic with boot files in 1st entries */ 134 | } SYSOptions; 135 | 136 | /* display how to use and basic help information */ 137 | void showHelpAndExit(void); 138 | /* List OEM options supported, I.e. known DOS flavors supported */ 139 | void showOemHelpAndExit(void); 140 | 141 | /* get and validate arguments */ 142 | void initOptions(int argc, char *argv[], SYSOptions *opts); 143 | 144 | 145 | /* installs boot sector */ 146 | void put_boot(SYSOptions *opts); 147 | 148 | /* write bs in bsFile to drive's boot record unmodified */ 149 | void restoreBS(SYSOptions *opts); 150 | /* write bs in bsFile to drive's boot record updating BPB */ 151 | void putBS(SYSOptions *opts); 152 | /* write drive's boot record unmodified to bsFile */ 153 | void dumpBS(SYSOptions *opts); 154 | 155 | /* copies file (path+filename specified by srcFile) to drive:\filename */ 156 | BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename); 157 | 158 | /* adds basic entry to boot manager configuration file */ 159 | BOOL writeBootLoaderEntry(SYSOptions *opts); 160 | 161 | #endif /* _SYS_H_ */ 162 | -------------------------------------------------------------------------------- /sys/talloc.c: -------------------------------------------------------------------------------- 1 | /** 2 | ** TALLOC.C 3 | ** 4 | ** lean_and_mean malloc()/free implementation 5 | ** by tom ehlert, te@drivesnapshot.de 6 | ** 7 | ** please be careful: 8 | ** 9 | ** this is only slightly tested and has NO ERRORCHECCKING AT ALL 10 | ** no internal checking. no stack checking. nothing !! 11 | ** 12 | ** use it only, if your programs are already debugged !! 13 | **/ 14 | 15 | #ifndef _MSC_VER /* MSC has no brk/sbrk */ 16 | 17 | #include 18 | #include 19 | 20 | #ifdef __TURBOC__ 21 | extern unsigned __brklvl; 22 | #define sbrk(x) ((void *)__brklvl) 23 | #define brk(newbrk) \ 24 | (((char *)(newbrk) > (char *)(&length) - 0x200) ? \ 25 | -1 : \ 26 | (__brklvl = (unsigned)(newbrk), 0)) 27 | #endif 28 | 29 | #ifdef __WATCOMC__ 30 | #include 31 | #define brk(newbrk) ((int)__brk((unsigned)(newbrk))) 32 | #endif 33 | 34 | #ifdef __GNUC__ 35 | #include 36 | #endif 37 | 38 | #define BUSY (sizeof(size_t)-1) /* Bit set if memory block in use*/ 39 | #define isbusy(x) ((x->length)&BUSY) 40 | 41 | 42 | /** 43 | *** _memavl() 44 | *** return max. memory available 45 | *** Q & D 46 | **/ 47 | 48 | #ifdef DEBUG 49 | extern int printf(const char *x, ...); 50 | #define dbprintf(x) printf x 51 | #else 52 | #define dbprintf(x) 53 | #endif 54 | /*#define printf getch() != ' ' ? exit(0) : printf*/ 55 | 56 | typedef union { 57 | size_t length; 58 | char data[1]; 59 | } block; 60 | 61 | void *malloc(size_t length) 62 | { 63 | static block *alloc_bottom = NULL; 64 | 65 | block *akt, *next; 66 | block *ltop = sbrk(0); 67 | 68 | if (alloc_bottom == NULL) 69 | alloc_bottom = ltop; 70 | 71 | length = (length + sizeof(size_t) + BUSY) & ~BUSY; 72 | 73 | akt = alloc_bottom; 74 | for (;;) 75 | { 76 | if (akt == ltop) 77 | { 78 | /* end of initialized memory */ 79 | next = (block *)&akt->data[length]; 80 | if (next < akt || brk(next) == -1) 81 | return NULL; 82 | break; 83 | } 84 | dbprintf(("follow [%x] = %x\n",akt, akt->length)); 85 | next = (block *)(&akt->data[akt->length & ~BUSY]); 86 | if (isbusy(akt)) 87 | { 88 | akt = next; /* next block */ 89 | } 90 | else if (next == ltop || isbusy(next)) 91 | { 92 | size_t size = akt->length; 93 | if (size >= length) /* try to split */ 94 | { 95 | if (size > length) /* split */ 96 | { 97 | ((block *)&akt->data[length])->length = 98 | size - length; 99 | } 100 | break; 101 | } 102 | akt = next; /* next block */ 103 | } 104 | else 105 | { 106 | /* merge 2 blocks */ 107 | akt->length += next->length; 108 | } 109 | } 110 | akt->length = length | BUSY; 111 | dbprintf(("set [%x] = %x\n",akt,akt->length)); 112 | return &akt->data[sizeof(size_t)]; 113 | } 114 | 115 | #ifdef __WATCOMC__ 116 | void *_nmalloc(unsigned length) 117 | { 118 | return malloc(length); 119 | } 120 | #endif 121 | 122 | /** 123 | ** reset busy-bit 124 | **/ 125 | 126 | void free(void *ptr) 127 | { 128 | if (ptr) 129 | ((char *) ptr)[-sizeof(size_t)] &= ~BUSY; 130 | } 131 | 132 | #ifdef TALLOC_NEED_REALLOC 133 | 134 | /* there isn't often need for realloc ;) 135 | */ 136 | 137 | void* realloc(void *ptr,size_t newlength) 138 | { 139 | size_t oldlength = ((size_t*)ptr)[-1] & ~BUSY; 140 | void *newptr; 141 | 142 | newptr = malloc(newlength); 143 | 144 | if (newptr == NULL) 145 | { 146 | if (newlength <= oldlength) 147 | return ptr; 148 | } 149 | else 150 | { 151 | memcpy(newptr,ptr,oldlength); 152 | } 153 | 154 | free(ptr); 155 | return newptr; 156 | } 157 | #endif 158 | 159 | #ifdef TEST 160 | #include 161 | 162 | int gallocated = 0; 163 | 164 | void *testalloc(size_t length) 165 | { 166 | void *p; 167 | 168 | printf("alloc %x bytes - ",length); 169 | 170 | p = malloc(length); 171 | 172 | if (p) gallocated += length,printf("at %x - sum=%x\n",p,gallocated); 173 | else printf("failed\n"); 174 | return p; 175 | } 176 | void testfree(void* p) 177 | { 178 | gallocated -= ((size_t*)p)[-1] & ~BUSY; 179 | printf("free %x \n",p); 180 | 181 | free(p); 182 | } 183 | 184 | 185 | 186 | main() 187 | { 188 | char *s1,*s2,*s3,*s4,*s5,*s6; 189 | unsigned size; 190 | 191 | s1 = testalloc(1); 192 | s2 = testalloc(2); 193 | s3 = testalloc(0x10); 194 | s4 = testalloc(0x100); 195 | s5 = testalloc(0x1000); 196 | s6 = testalloc(0xfff0); 197 | 198 | testfree(s3); 199 | s3 = testalloc(6); 200 | testfree(s2); 201 | testalloc(8); 202 | 203 | #ifdef __GNUC__ 204 | for(size = 0xe0000000; size;) 205 | #else 206 | for(size = 0xe000; size;) 207 | #endif 208 | { 209 | if (testalloc(size)) 210 | ; 211 | else 212 | size >>= 1; 213 | } 214 | 215 | 216 | testfree(s1); 217 | testfree(s5); 218 | testfree(s4); 219 | testfree(s6); 220 | 221 | return 1; 222 | } 223 | #endif 224 | 225 | #endif 226 | -------------------------------------------------------------------------------- /sys/usage.c: -------------------------------------------------------------------------------- 1 | /*************************************************************** 2 | 3 | usage.c 4 | DOS-C 5 | 6 | sys utility for DOS-C 7 | 8 | Copyright (c) 1991 9 | Pasquale J. Villani 10 | All Rights Reserved 11 | 12 | This file is part of DOS-C. 13 | 14 | DOS-C is free software; you can redistribute it and/or modify it under the 15 | terms of the GNU General Public License as published by the Free Software 16 | Foundation; either version 2, or (at your option) any later version. 17 | 18 | DOS-C is distributed in the hope that it will be useful, but WITHOUT ANY 19 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 20 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 21 | details. 22 | 23 | You should have received a copy of the GNU General Public License along with 24 | DOS-C; see the file COPYING. If not, write to the Free Software Foundation, 25 | 675 Mass Ave, Cambridge, MA 02139, USA. 26 | 27 | ***************************************************************/ 28 | 29 | #include "sys.h" 30 | 31 | 32 | /* display how to use and basic help information */ 33 | void showHelpAndExit(void) 34 | { 35 | printf( 36 | "Usage: %s [source] drive: [bootsect] [{option}]\n" 37 | " source = A:,B:,C:\\DOS\\,etc., or current directory if not given\n" 38 | " drive = A,B,etc.\n" 39 | " bootsect = name of 512-byte boot sector file image for drive:\n" 40 | " to write to *instead* of real boot sector\n" 41 | " {option} is one or more of the following:\n" 42 | " /BOTH : write to *both* the real boot sector and the image file\n" 43 | #ifdef USEBOOTMANAGER 44 | " /BOOTMGR : add to boot manager menu (can't be used with /BOTH)\n" 45 | #endif 46 | " /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n" 47 | " /UPDATE : copy kernel and update boot sector (do *not* copy shell)\n" 48 | " /OEM : indicates boot sector, filenames, and load segment to use\n" 49 | " default is /OEM[:AUTO], select DOS based on existing files\n" 50 | " see %s /HELP OEM\n" 51 | " /K name : name of kernel to use in boot sector instead of %s\n" 52 | " /L segm : hex load segment to use in boot sector instead of %02x\n" 53 | " /B btdrv : hex BIOS # of boot drive set in bs, 0=A:, 80=1st hd,...\n" 54 | " /FORCE : override automatic selection of BIOS related settings\n" 55 | " /FORCE:BSDRV use boot drive # set in bootsector\n" 56 | " /FORCE:BIOSDRV use boot drive # provided by BIOS\n" 57 | " /NOBAKBS : skips copying boot sector to backup bs, FAT32 only else ignored\n" 58 | " /HELP : display this usage screen and exit\n" 59 | #ifdef FDCONFIG 60 | "Usage: %s CONFIG /HELP\n" 61 | #endif 62 | /*SYS, KERNEL.SYS/DRBIO.SYS 0x60/0x70*/ 63 | , pgm, pgm, bootFiles[0].kernel, bootFiles[0].loadaddr 64 | #ifdef FDCONFIG 65 | , pgm 66 | #endif 67 | ); 68 | exit(1); 69 | } 70 | 71 | 72 | /* List OEM options supported, I.e. known DOS flavors supported */ 73 | void showOemHelpAndExit(void) 74 | { 75 | printf( 76 | "Usage: %s [source] drive: [bootsect] [{option}]\n" 77 | " /OEM : indicates boot sector, filenames, and load segment to use\n" 78 | " /OEM:FD use FreeDOS compatible settings\n" 79 | " /OEM:EDR use Enhanced DR DOS 7+ compatible settings\n" 80 | " /OEM:DR use DR DOS 7+ compatible settings\n" 81 | #ifdef WITHOEMCOMPATBS 82 | " /OEM:PC use PC-DOS compatible settings\n" 83 | " /OEM:MS use MS-DOS compatible settings\n" 84 | " /OEM:W9x use MS Win9x DOS compatible settings\n" 85 | " /OEM:Rx use RxDOS compatible settings\n" 86 | " /OEM:DELL use Dell Real Mode Kernel (DRMK) settings\n" 87 | #else 88 | " Note that PC/MS/... compatible settings not compiled in\n" 89 | #endif 90 | "\n Default is /OEM[:AUTO], select DOS based on existing files\n" 91 | , pgm 92 | ); 93 | exit(1); 94 | } 95 | -------------------------------------------------------------------------------- /sys/wsys/wsys.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="wsys" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=wsys - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "wsys.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "wsys.mak" CFG="wsys - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "wsys - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "wsys - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "wsys - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Ignore_Export_Lib 0 43 | # PROP Target_Dir "" 44 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c 45 | # ADD CPP /nologo /W3 /GX /O2 /I "..\..\hdr" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_WIN32" /FD /c 46 | # SUBTRACT CPP /YX /Yc /Yu 47 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 48 | # ADD RSC /l 0x409 /d "NDEBUG" 49 | BSC32=bscmake.exe 50 | # ADD BASE BSC32 /nologo 51 | # ADD BSC32 /nologo 52 | LINK32=link.exe 53 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 54 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /STUB:..\..\BIN\SYSSTUB.EXE 55 | # SUBTRACT LINK32 /pdb:none 56 | 57 | !ELSEIF "$(CFG)" == "wsys - Win32 Debug" 58 | 59 | # PROP BASE Use_MFC 0 60 | # PROP BASE Use_Debug_Libraries 1 61 | # PROP BASE Output_Dir "Debug" 62 | # PROP BASE Intermediate_Dir "Debug" 63 | # PROP BASE Target_Dir "" 64 | # PROP Use_MFC 0 65 | # PROP Use_Debug_Libraries 1 66 | # PROP Output_Dir "Debug" 67 | # PROP Intermediate_Dir "Debug" 68 | # PROP Ignore_Export_Lib 0 69 | # PROP Target_Dir "" 70 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c 71 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_WIN32" /FD /GZ /c 72 | # SUBTRACT CPP /YX /Yc /Yu 73 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 74 | # ADD RSC /l 0x409 /d "_DEBUG" 75 | BSC32=bscmake.exe 76 | # ADD BASE BSC32 /nologo 77 | # ADD BSC32 /nologo 78 | LINK32=link.exe 79 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 80 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept /STUB:..\..\BIN\SYSSTUB.EXE 81 | # SUBTRACT LINK32 /pdb:none 82 | 83 | !ENDIF 84 | 85 | # Begin Target 86 | 87 | # Name "wsys - Win32 Release" 88 | # Name "wsys - Win32 Debug" 89 | # Begin Group "Source Files" 90 | 91 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 92 | # Begin Source File 93 | 94 | SOURCE=..\copy.c 95 | # End Source File 96 | # Begin Source File 97 | 98 | SOURCE=..\diskio_w.c 99 | # End Source File 100 | # Begin Source File 101 | 102 | SOURCE=..\fdkrncfg.c 103 | # End Source File 104 | # Begin Source File 105 | 106 | SOURCE=..\initopts.c 107 | # End Source File 108 | # Begin Source File 109 | 110 | SOURCE=..\putboot.c 111 | # End Source File 112 | # Begin Source File 113 | 114 | SOURCE=..\sys.c 115 | # End Source File 116 | # Begin Source File 117 | 118 | SOURCE=..\usage.c 119 | # End Source File 120 | # End Group 121 | # Begin Group "Header Files" 122 | 123 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 124 | # Begin Source File 125 | 126 | SOURCE=..\config.h 127 | # End Source File 128 | # Begin Source File 129 | 130 | SOURCE=..\diskio.h 131 | # End Source File 132 | # Begin Source File 133 | 134 | SOURCE=..\FAT12COM.H 135 | # End Source File 136 | # Begin Source File 137 | 138 | SOURCE=..\FAT16COM.H 139 | # End Source File 140 | # Begin Source File 141 | 142 | SOURCE=..\FAT32CHS.H 143 | # End Source File 144 | # Begin Source File 145 | 146 | SOURCE=..\FAT32LBA.H 147 | # End Source File 148 | # Begin Source File 149 | 150 | SOURCE=..\OEMFAT12.H 151 | # End Source File 152 | # Begin Source File 153 | 154 | SOURCE=..\OEMFAT16.H 155 | # End Source File 156 | # Begin Source File 157 | 158 | SOURCE=..\..\hdr\portab.h 159 | # End Source File 160 | # Begin Source File 161 | 162 | SOURCE=..\sys.h 163 | # End Source File 164 | # End Group 165 | # Begin Group "Resource Files" 166 | 167 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 168 | # End Group 169 | # End Target 170 | # End Project 171 | -------------------------------------------------------------------------------- /sys/wsys/wsys.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "wsys"=.\wsys.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | --------------------------------------------------------------------------------